Example #1
0
 /**
  * Construct the HTML view
  *
  * @param string $a_title
  * @param string $a_view
  * @param string $a_layout
  */
 public function __construct($a_title = "", $a_view, $a_layout)
 {
     parent::__construct();
     $this->_scripts = array();
     $this->_title = $a_title;
     $this->_view = $a_view;
     $this->_layout = $a_layout;
     $this->rules[] = new Rule('php_exclude', '~(<\\?)~', '<?php echo \'<?\'; ?>');
     // If conditionning
     $this->rules[] = new Rule('if_boolean', '~\\{if:(\\w+)\\}~', '<?php if (isset($this->data[\'$1\']) && $this->data[\'$1\']): ?>');
     $this->rules[] = new Rule('if_condition', '~\\{if:(\\w+)([!<>=]+)(\\w+)\\}~', '<?php if (isset($this->data[\'$1\'])) {$base = $this->data[\'$1\'];}else{$base = \'$1\';};
     		if (isset($this->data[\'$3\'])) {$value = $this->data[\'$3\'];}else{$value = \'$3\';}?>
     		<?php if ($base $2 $value) : ?>');
     $this->rules[] = new Rule('ifnot', '~\\{ifnot:(\\w+)\\}~', '<?php if (!$this->data[\'$1\']): ?>');
     $this->rules[] = new Rule('else', '~\\{else\\}~', '<?php else: ?>');
     $this->rules[] = new Rule('elseif_boolean', '~\\{else:(\\w+)\\}~', '<?php elseif (isset($this->data[\'$1\']) && $this->data[\'$1\']): ?>');
     $this->rules[] = new Rule('elseif_condition', '~\\{else:(\\w+)([!<>=]+)(\\w+)\\}~', '<?php elseif (((isset($this->data[\'$1\']) && isset($this->data[\'$3\'])) && $this->data[\'$1\'] $2 $this->data[\'$3\']) ||
     		((isset($this->data[\'$1\']) && !isset($this->data[\'$3\'])) && $this->data[\'$1\'] $2 \'$3\') ||
     		((!isset($this->data[\'$1\']) && isset($this->data[\'$3\'])) && \'$1\' $2 $this->data[\'$3\']) ||
     		((!isset($this->data[\'$1\']) && !isset($this->data[\'$3\'])) && \'$1\' $2 \'$3\')): ?>');
     $this->rules[] = new Rule('endif', '~\\{endif\\}~', '<?php endif; ?>');
     // Loops
     $this->rules[] = new Rule('loop', '~\\{loop:(\\w+)\\}~', '<?php foreach ($this->data[\'$1\'] as $element): $this->wrap($element); ?>');
     $this->rules[] = new Rule('endloop', '~\\{endloop\\}~', '<?php $this->unwrap(); endforeach; ?>');
     // Importing
     $this->rules[] = new Rule('import_view', '~\\{import:(([^\\/\\s]+\\/)?(.*))\\}~', '<?php echo $this->importFile(\'$1\'); ?>');
     $this->rules[] = new Rule('yield', '~\\{yield\\}~', '<?php $end = end($this->data); echo $end; ?>');
     // Clean variables
     $this->rules[] = new Rule('escape_var', '~\\{escape:(\\w+)\\}~', '<?php $this->showVariable(\'$1\', true); ?>');
     // Variables
     $this->rules[] = new Rule('variable', '~\\{(\\w+)\\}~', '<?php $this->showVariable(\'$1\'); ?>');
     // Arrays
     $this->rules[] = new Rule('variable_array', '~\\{(\\w+)\\[(\\w+)\\]\\}~', '<?php echo (isset($this->data[\'$1\'][\'$2\'])) ? $this->data[\'$1\'][\'$2\'] : "{$1[$2]}"; ?>');
     $this->rules[] = new Rule('variable_array_escape', '~\\{escape:(\\w+)\\[(\\w+)\\]\\}~', '<?php echo htmlentities($this->showVariable(\'$1\')[\'$2\']); ?>');
 }
Example #2
0
 /**
  * Construct the HTML view
  *
  * @param string $a_title
  * @param string $a_view
  * @param string $a_layout
  */
 public function __construct($a_title = "", $a_view = "view", $a_layout = "layout")
 {
     parent::__construct();
     $this->_scripts = array();
     $this->_title = $a_title;
     $this->set_view($a_view);
     $config = Application\Application::get_instance()->get_config();
     if (!is_null($config)) {
         if ($a_layout == "layout" && !is_null($config->get('runtime', 'default_layout'))) {
             $a_layout = $config->get('runtime', 'default_layout');
         }
     }
     $this->set_layout($a_layout);
 }
Example #3
0
 /**
  * Construct File View
  *
  * @param File $a_file
  */
 public function __construct(File $a_file = null)
 {
     parent::__construct();
     $this->set_file($a_file);
 }