Ejemplo n.º 1
0
 public static function tokenDefault(&$token, &$text)
 {
     if ($token['type'] == 'text') {
         $text .= $token['data'];
     } else {
         if ($token['type'] == 'tag' && strtoupper($token['name']) == 'COMPONENT') {
             $name = $token['data']['name'];
             $component = SystemComponent::getComponentByName($name);
             if ($component !== null) {
                 $text .= '<?php $data = ' . var_export($token['data'], true) . '; $flags = ' . var_export($token['flags'], true) . '; ?>';
                 // Sustituyo esto:
                 //$text .= $component->getPHP();
                 // Por esto otro:
                 $html = $component->getPHP();
                 $ctokens = TreeScript::getParse($html);
                 $ctext = '';
                 foreach ($ctokens as $ctoken) {
                     RenderToken::tokenDefault($ctoken, $ctext);
                 }
                 $text .= $ctext;
                 // FIN
                 ControllerPage::requireComponent($name);
             }
         } else {
             if ($token['type'] == 'tag' && $token['name'] == '') {
                 $text .= '';
             } else {
                 //$text .= '';
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function setJS($js)
 {
     //Procesar antes el js
     $tokens = TreeScript::getParse($js);
     $code = '';
     foreach ($tokens as $token) {
         if ($token['type'] == 'text') {
             $code .= $token['data'];
         } else {
             if (strtoupper($token['name']) == 'AJAX') {
                 $name = $token['data']['name'];
                 $autogenerate_list_ajax[$name] = '';
                 if (strlen($name)) {
                     if (!in_array($name, $this->getAjaxNames())) {
                         $this->setAjax($name, '<?php print_r($_POST); ?>');
                     }
                 } else {
                     $token['data']['warning'] = 'Missing attribute "name"';
                 }
             }
             $code .= RenderToken::tokenToString($token);
         }
     }
     $this->js = $code;
     return file_put_contents(self::$dir_base . '/' . $this->name . '/index.js', $code);
 }