[ Index ]

PHP Cross Reference of PageLines Framework

title

Body

[close]

/admin/ -> class.ui.typography.php (source)

   1  <?php
   2  /**
   3   *
   4   *
   5   *  Typography Control
   6   *
   7   *
   8   *  @package PageLines DMS
   9   *  @subpackage OptionsUI
  10   *  @since 2.0.b3
  11   *
  12   */
  13  
  14  class PageLinesTypeUI {
  15  
  16  
  17      /**
  18       * Construct
  19       */
  20  	function __construct() {
  21  
  22          global $pl_foundry;
  23  
  24          $this->foundry = $pl_foundry;
  25          $this->fonts = $pl_foundry->foundry;
  26  
  27      }
  28  
  29      /**
  30       *
  31       *  Main Layout Drag and Drop
  32       *
  33       */
  34  	function build_typography_control($oid, $o){
  35  
  36  
  37          $preview_styles = '';
  38  
  39          $preview_styles = $this->foundry->get_type_css( ploption($oid) );
  40  
  41          echo OptEngine::input_label( get_pagelines_option_id($oid, 'font'), __('Select Font', 'pagelines'));
  42  
  43          $opts = $this->get_opts($oid, $o, pagelines_sub_option($oid, 'font'));
  44  
  45          $extra = 'onChange="PageLinesStyleFont(this, \'font-family\')" size="1"';
  46  
  47          echo OptEngine::input_select( get_pagelines_option_id($oid, 'font'), get_pagelines_option_name($oid, 'font'), $opts, 'fontselector', $extra);
  48  
  49          ?>
  50          <div class="font_preview_wrap">
  51              <?php echo OptEngine::input_label( '', __('Preview', 'pagelines')); ?>
  52              <div class="font_preview" >
  53                  <div class="font_preview_pad" style='<?php echo $preview_styles;?>' >
  54                      The quick brown fox jumps over the lazy dog.
  55                  </div>
  56              </div>
  57          </div>
  58          <span id="<?php pagelines_option_id($oid, '_set_styling_button'); ?>" class="button" onClick="PageLinesSimpleToggle('#<?php pagelines_option_id($oid, '_set_styling'); ?>', '#<?php pagelines_option_id($oid, '_set_advanced'); ?>')">Edit Font Styling</span>
  59  
  60          <span id="<?php pagelines_option_id($oid, '_set_advanced_button'); ?>" class="button" onClick="PageLinesSimpleToggle('#<?php pagelines_option_id($oid, '_set_advanced'); ?>', '#<?php pagelines_option_id($oid, '_set_styling'); ?>')">Advanced</span>
  61  
  62          <div id="<?php pagelines_option_id($oid, '_set_styling'); ?>" class="font_styling type_inputs">
  63              <?php $this->get_type_styles($oid, $o); ?>
  64              <div class="clear"></div>
  65          </div>
  66  
  67          <div id="<?php pagelines_option_id($oid, '_set_advanced'); ?>" class="advanced_type type_inputs">
  68              <?php $this->get_type_advanced($oid, $o); ?>
  69              <div class="clear"></div>
  70          </div>
  71  
  72  
  73      <?php
  74  
  75  
  76      }
  77  
  78  
  79      /**
  80      *
  81      * @TODO document
  82      *
  83      */
  84  	function fonts_option($oid, $o){
  85  
  86  
  87          echo OptEngine::input_label($o['input_id'], $o['inputlabel']);
  88          echo OptEngine::input_select($o['input_id'], $o['input_name'], $this->get_opts($oid, $o, $o['val']), 'fontselector');
  89  
  90  
  91      }
  92  
  93  
  94      /**
  95      *
  96      * @TODO document
  97      *
  98      */
  99  	function get_opts($oid, $o, $val){
 100  
 101          $opts = '';
 102          foreach($this->fonts as $fid => $f){
 103              $free = (isset($f['free']) && $f['free']) ? true : false;
 104  
 105              if(!VPRO && !$free){
 106              }else{
 107                  $font_name = $f['name'];
 108  
 109                  if($f['web_safe']) $font_name .= ' *';
 110                  if($f['google']) $font_name .= ' G';
 111  
 112                  $title = sprintf('title="%s"', $this->foundry->gfont_key($fid));
 113  
 114                  $opts .= OptEngine::input_option( $fid, selected( $fid, $val, false), $font_name, $f['family'], $title);
 115              }
 116  
 117          }
 118  
 119          return $opts;
 120  
 121      }
 122  
 123  
 124      /**
 125      *
 126      * @TODO document
 127      *
 128      */
 129  	function get_type_styles($oid, $o){
 130  
 131          // Set Letter Spacing (em)
 132          $this->_get_type_em_select($oid, array());
 133  
 134          // Convert to caps, small-caps?
 135          $this->_get_type_select($oid, array('id' => 'transform', 'inputlabel' => 'Text Transform', 'prop' => 'text-transform',  'selectvalues' => array('none' => 'None', 'uppercase' => 'Uppercase', 'capitalize' => 'Capitalize', 'lowercase' => 'lowercase'), 'default' => 'none'));
 136  
 137          // Small Caps?
 138          $this->_get_type_select($oid, array('id' => 'variant', 'inputlabel' => 'Variant', 'prop' => 'font-variant',  'selectvalues' => array('normal' => 'Normal', 'small-caps' => 'Small-Caps'), 'default' => 'normal'));
 139  
 140          // Bold?
 141          $this->_get_type_select($oid, array('id' => 'weight', 'inputlabel' => 'Weight', 'prop' => 'font-weight', 'selectvalues' => array('normal' => 'Normal', 'bold' => 'Bold', 'lighter' => 'Light'), 'default' => 'normal'));
 142  
 143          // Italic?
 144          $this->_get_type_select($oid, array('id' => 'style', 'inputlabel' => 'Style', 'prop' => 'font-style',  'selectvalues' => array('normal' => 'Normal', 'italic' => 'Italic'), 'default' => 'normal'));
 145      }
 146  
 147  
 148      /**
 149      *
 150      * @TODO document
 151      *
 152      */
 153  	function get_type_advanced($oid, $o){ ?>
 154          <div class="type_advanced">
 155              <?php echo OptEngine::input_label( get_pagelines_option_id($oid, 'selectors'), __('Additional Selectors', 'pagelines')); ?>
 156              <textarea class=""  name="<?php pagelines_option_name($oid, 'selectors'); ?>" id="<?php pagelines_option_id($oid, 'selectors'); ?>" rows="3"><?php esc_attr_e( pagelines_sub_option($oid, 'selectors'), 'pagelines' ); ?></textarea>
 157          </div>
 158      <?php }
 159  
 160  
 161      /**
 162      *
 163      * @TODO document
 164      *
 165      */
 166  	function _get_type_em_select($oid, $o){
 167  
 168          $option_value = ( pagelines_sub_option($oid, 'kern') ) ? pagelines_sub_option($oid, 'kern') : '0.00em';
 169          ?>
 170          <div class="type_select">
 171              <?php echo OptEngine::input_label( get_pagelines_option_id($oid, 'kern'), __('Letter Spacing', 'pagelines')); ?>
 172              <select id="<?php pagelines_option_id($oid, 'kern'); ?>" name="<?php pagelines_option_name($oid, 'kern'); ?>" onChange="PageLinesStyleFont(this, 'letter-spacing')">
 173                  <option value="">&mdash;SELECT&mdash;</option>
 174                  <?php
 175                      $count_start = -.3;
 176                      for($i = $count_start; $i <= 1; $i += 0.05){
 177  
 178                          $em = number_format(round($i, 2), 2).'em';
 179  
 180                          printf('<option value="%1$s" %2$s>%1$s</option>', $em, selected($em, $option_value, false));
 181                      }
 182                  ?>
 183              </select>
 184          </div>
 185      <?php }
 186  
 187  
 188      /**
 189      *
 190      * @TODO document
 191      *
 192      */
 193  	function _get_type_select($oid, $o){
 194  
 195          $option_value = ( pagelines_sub_option($oid, $o['id']) ) ? pagelines_sub_option($oid, $o['id']) : $o['default'];
 196          ?>
 197          <div class="type_select">
 198              <?php echo OptEngine::input_label( get_pagelines_option_id($oid, $o['id']), $o['inputlabel']); ?>
 199              <select id="<?php pagelines_option_id($oid, $o['id']); ?>" name="<?php pagelines_option_name($oid, $o['id']); ?>" onChange="PageLinesStyleFont(this, '<?php echo $o['prop'];?>')">
 200                  <option value="">&mdash;SELECT&mdash;</option>
 201                  <?php foreach($o['selectvalues'] as $sid => $s):?>
 202                          <option value="<?php echo $sid;?>" <?php selected($sid, $option_value); ?>><?php echo $s;?></option>
 203                  <?php endforeach;?>
 204              </select>
 205          </div>
 206      <?php }
 207  }


Generated: Fri Aug 30 18:26:24 2013 Cross-referenced by PHPXref 0.7.1