Beispiel #1
0
 /**
  * Module Logic
  *
  * @return void
  */
 public function execute()
 {
     if (!empty($this->args[1])) {
         $this->args[0] .= "', '" . str_replace('\'', '"', $this->args[1]);
     }
     HTML\Generator::call('script', array(str_replace(':UA:', $this->args[0], self::JS)), array('compress', 'inlineInner', 'noCache'));
 }
Beispiel #2
0
 /**
  * Generate a HTML5 header.
  *
  * @return void
  */
 public function html5()
 {
     echo '<!DOCTYPE HTML>' . "\n";
     Core\Generator::lineBreak();
     echo $this->getHtml();
     echo $this->getHead();
     \Xiphe\HTML::get()->utf8()->meta('http-equiv=X-UA-Compatible|content=IE\\=edge,chrome\\=1');
 }
Beispiel #3
0
 /**
  * Module Logic
  *
  * @return void
  */
 public function execute()
 {
     $ckbxs = $this->args[0];
     $checked = $this->args[1];
     $i = 1;
     foreach ($ckbxs as $name => $label) {
         $ckd = false;
         if (in_array($i, $checked, true) || in_array($name, $checked)) {
             $ckd = true;
         }
         HTML\Generator::call('checkbox', array($name, $label, $ckd));
         $i++;
     }
 }
Beispiel #4
0
 /**
  * Module Logic
  *
  * @return void
  */
 public function execute()
 {
     switch ($this->called) {
         case 'n':
         case 'r':
             HTML\Generator::lineBreak();
             break;
         case 't':
             HTML\Generator::tabs();
             break;
         default:
             break;
     }
 }
Beispiel #5
0
 /**
  * Module Logic
  *
  * @return void
  */
 public function execute()
 {
     switch ($this->called) {
         case 'textarea':
             $Tag = new HTML\Tag($this->called, array($this->args[0], $this->args[1]), array('generate', 'inlineInner'));
             break;
         default:
             $Tag = new HTML\Tag($this->called, array($this->args[0]), array('generate'));
             break;
     }
     if ($this->called == 'checkbox' && isset($this->args[2]) && ($this->args[2] === true || $this->args[2] === 'on' || $this->args[2] === 1 || $this->args[2] === $Tag->attributes['id'] || is_array($this->args[2]) && in_array($Tag->attributes['id'], $this->args[2]))) {
         $Tag->setAttrs(array('checked' => null));
     }
     if ($this->_label !== false) {
         $Label = HTML\Generator::getLabel($this->_label, $Tag);
         HTML\Generator::appendLabel($Label, $Tag, $this->_label);
     } else {
         echo $Tag;
     }
 }
Beispiel #6
0
 /**
  * This is where the magic happens.
  *
  * Catch all method calls to unknown methods and pass them
  * to the Generator.
  * 
  * @param string $name      the called method
  * @param array  $arguments passed arguments
  * 
  * @return mixed             Xiphe\HTML or whatever the generator returns.
  */
 public function __call($name, $arguments)
 {
     Core\Config::setHTMLInstance($this);
     $r = Core\Generator::call($name, $arguments);
     if (!empty($r)) {
         return $r;
     }
     return $this;
 }
Beispiel #7
0
 /**
  * One-time-initiation for this Class.
  *
  * Checks the config.php file and builds the global config.
  * 
  * @param array $initArgs additional configuration
  * 
  * @return void
  */
 public static function init(array $initArgs = array())
 {
     if (!self::$_initiated) {
         if (!defined('XIPHE_HTML_BASE_FOLDER')) {
             define('XIPHE_HTML_BASE_FOLDER', dirname(__DIR__) . DIRECTORY_SEPARATOR);
         }
         foreach (self::getThemasterSettings() as $key => $s) {
             if (is_array($s) && isset($s['default'])) {
                 self::$_defaults[$key] = $s['default'];
             }
         }
         /*
          * Get the config array from config.php
          */
         $config = array();
         if (file_exists(XIPHE_HTML_BASE_FOLDER . 'config.php')) {
             call_user_func(function () use(&$config) {
                 include XIPHE_HTML_BASE_FOLDER . 'config.php';
             });
         } elseif (!file_exists(XIPHE_HTML_BASE_FOLDER . 'config-sample.php')) {
             self::_createSampleConfig();
         }
         /*
          * Make sure config is an array.
          */
         if (!is_array($config)) {
             Generator::debug('$config is not an array.', 3, 7);
             $config = array();
         }
         /*
          * Merge it into the defaults
          */
         $defaults = array_merge(self::$_defaults, $config);
         /*
          * Remove invalid keys and merge the initArgs.
          */
         foreach (self::$_defaults as $k => $v) {
             self::$_config[$k] = isset($initArgs[$k]) ? $initArgs[$k] : $defaults[$k];
         }
         self::$_initiated = true;
     }
 }
Beispiel #8
0
 /**
  * Module Logic
  *
  * @return void
  */
 public function execute()
 {
     /*
      * Generate the Basic Tag.
      */
     $Select = new HTML\Tag('select', array($this->args[0]), array('generate', 'start'));
     /*
      * Set the multiple attribute if multiple selections are active
      */
     if (isset($this->args[2]) && is_array($this->args[2]) && !isset($Select->attributes['multiple'])) {
         $Select->attributes['multiple'] = '';
         $Select->update('attributes');
     }
     /*
      * Open the Select Tag.
      */
     $r = '' . $Select;
     if (is_array($this->args[1])) {
         $i = 1;
         foreach ($this->args[1] as $k => $v) {
             if (is_string($v)) {
                 $args = array();
                 if (!is_int($k)) {
                     $args['value'] = $k;
                 }
                 if (isset($this->args[2]) && $this->isSelected($this->args[2], !is_int($k) ? $k : $v, $i)) {
                     $args['selected'] = '';
                 }
                 $r .= new HTML\Tag('option', array($v, $args));
             } elseif (is_array($v)) {
                 $opts = array('', array());
                 if (isset($v['inner'])) {
                     $opts[0] = $v['inner'];
                     unset($v['inner']);
                 }
                 if (isset($v['attrs'])) {
                     $opts[1] = HTML\Generator::parseAtts($v['attrs']);
                     unset($v['attrs']);
                 }
                 $opts = array_merge($opts, $v);
                 if (!in_array('selected', $opts[1]) && ($this->isSelected($this->args[2], $opts[0], $i) || $this->isSelected($this->args[2], $k, $i))) {
                     $opts[1]['selected'] = '';
                 }
                 if (!in_array('value', $opts[1])) {
                     $opts[1]['value'] = $k;
                 }
                 $r .= new HTML\Tag('option', $opts);
             } elseif (is_object($v) && get_class($v) == 'Xiphe\\HTML\\core\\Tag') {
                 if (isset($this->args[2])) {
                     if (isset($v->attributes['value'])) {
                         $k = $v->attributes['value'];
                     } else {
                         $k = $v->content;
                     }
                     if ($this->isSelected($this->args[2], $k, $i)) {
                         $v->attributes['selected'] = '';
                         $v->update('attributes');
                     }
                 }
                 $r .= $v;
             }
             $i++;
         }
     }
     $r .= $Select;
     if (!isset($this->args[3]) || $this->args[3] !== false) {
         $labelArgs = array();
         if (isset($this->args[3])) {
             $labelArgs = $this->args[3];
         }
         $Label = HTML\Generator::getLabel($labelArgs, $Select);
         HTML\Generator::appendLabel($Label, $r, $labelArgs);
     } else {
         echo $r;
     }
 }