示例#1
0
 public static function compile($compiler, &$node, &$registredNameSpaces, &$counter, $parent = 'NULL')
 {
     if ($node->hasAttribute('src')) {
         $src = $node->getAttribute('src');
         if (strpos($src, '.xml') === strlen($src) - 4) {
             $src = substr($src, 0, -4);
         }
         $pageType = org_glizy_ObjectFactory::resolvePageType($src) . '.xml';
         $path = $compiler->getPath();
         $fileName = $path . $pageType;
         if (!file_exists($fileName)) {
             $fileName = glz_findClassPath($src);
             if (is_null($fileName)) {
                 // TODO: file non trovato visualizzare errore
             }
         }
         $compiler2 = org_glizy_ObjectFactory::createObject('org.glizy.compilers.Component');
         $compiledFileName = $compiler2->verify($fileName);
         $className = GLZ_basename($compiledFileName);
         $componentId = $node->hasAttribute('id') ? $node->getAttribute('id') : '';
         $compiler->_classSource .= '// TAG: ' . $node->nodeName . ' ' . $node->getAttribute('src') . GLZ_COMPILER_NEWLINE2;
         $compiler->_classSource .= 'if (!$skipImport) {' . GLZ_COMPILER_NEWLINE2;
         $compiler->_classSource .= 'org_glizy_ObjectFactory::requireComponent(\'' . $compiledFileName . '\', \'' . addslashes($fileName) . '\')' . GLZ_COMPILER_NEWLINE;
         $compiler->_classSource .= '$n' . $counter . ' = new ' . $className . '($application, ' . $parent . ')' . GLZ_COMPILER_NEWLINE;
         $compiler->_classSource .= $parent . '->addChild($n' . $counter . ')' . GLZ_COMPILER_NEWLINE;
         $compiler->_classSource .= '}' . GLZ_COMPILER_NEWLINE;
     }
 }
示例#2
0
 /**
  *
  */
 function compile($options)
 {
     $this->addEventListener(GLZ_EVT_LISTENER_COMPILE_ROUTING, $this);
     $this->initOutput();
     if (__Config::get('MULTILANGUAGE_ENABLED')) {
         $this->language = '{language}/';
     }
     $evt = array('type' => GLZ_EVT_START_COMPILE_ROUTING);
     $this->dispatchEvent($evt);
     if (strpos($this->_fileName, 'routing.xml') !== false) {
         $modules = org_glizy_Modules::getModules();
         foreach ($modules as $m) {
             $path = glz_findClassPath($m->classPath);
             if (!is_null($path) && file_exists($path . '/config/routing.xml')) {
                 $this->compileFile($path . '/config/routing.xml');
             }
         }
     }
     $this->compileFile($this->_fileName);
     return $this->save();
 }
示例#3
0
 private function includeFolder($folder)
 {
     // controlla se il file in cache è valido
     $options = array('cacheDir' => org_glizy_Paths::get('CACHE_JS'), 'lifeTime' => org_glizy_Config::get('CACHE_CODE'), 'readControlType' => '', 'fileExtension' => '.js');
     $cacheSignature = get_class($this) . $folder;
     $cacheObj = org_glizy_ObjectFactory::createObject('org.glizy.cache.CacheFile', $options);
     $jsFileName = $cacheObj->verify($cacheSignature);
     if ($jsFileName === false) {
         $jsFile = '';
         $folder = glz_findClassPath($folder);
         $extension = $this->getAttribute('extension');
         foreach (glob($folder . '/*' . $extension) as $file) {
             // $file = pathinfo($file);
             // $file = str_replace('_', '.', $file['filename']);
             // $availableModules[] = $file;
             // $f[] = $file;
             $jsCode = file_get_contents($file);
             $jsCode = $this->replaceLocale($jsCode);
             $jsFile .= $jsCode . "\n";
         }
         if (__Config::get('DEBUG') || $this->getAttribute('inline')) {
             $cacheObj->save($jsFile, NULL, get_class($this));
         } else {
             require_once org_glizy_Paths::get('CORE_LIBS') . '/jsmin/jsmin.php';
             $cacheObj->save(JSMin::minify($jsFile), NULL, $cacheSignature);
         }
         $jsFileName = $cacheObj->getFileName();
     }
     return $jsFileName;
 }
示例#4
0
 /**
  * @param string $classPath
  *
  * @return array
  */
 function resolveClassNew($classPath)
 {
     $classMap =& org_glizy_ObjectValues::get('org.glizy.ObjectFactory', 'ClassMap', array());
     $newClassPath = isset($classMap[$classPath]) ? $classMap[$classPath] : $classPath;
     $className = str_replace('.', '_', $newClassPath);
     if (!class_exists($className)) {
         return array('originalClassName' => $classPath, 'path' => glz_findClassPath($newClassPath));
     } else {
         return array('originalClassName' => $classPath, 'class' => $className);
     }
 }
示例#5
0
 /**
  * @param org_glizy_ModuleVO $moduleVO
  */
 function __construct(org_glizy_ModuleVO $moduleVO)
 {
     $this->moduleVO = $moduleVO;
     $this->name = $moduleVO->name;
     $path = glz_findClassPath($moduleVO->classPath);
     if (!is_null($path) && file_exists($path . '/info.xml')) {
         /** @var org_glizy_parser_XML $xml */
         $xml = org_glizy_ObjectFactory::createObject('org.glizy.parser.XML');
         $xml->loadAndParseNS($path . '/info.xml');
         foreach ($xml->documentElement->childNodes as $n) {
             if (property_exists($this, $n->tagName)) {
                 $this->{$n->tagName} = utf8_decode($n->nodeValue);
             }
         }
     }
 }
示例#6
0
 function compile_glzinclude(&$node, &$registredNameSpaces, &$counter, $parent = 'NULL', $idPrefix = '')
 {
     $origSrc = is_object($node) ? $node->getAttribute('src') : $node;
     $src = $origSrc;
     if (strpos($src, '.xml') === false) {
         $src .= '.xml';
     }
     if (file_exists(dirname($this->_fileName) . '/' . $src)) {
         $src = dirname($this->_fileName) . '/' . $src;
     } else {
         $src = glz_findClassPath($origSrc);
     }
     if (is_null($src)) {
         die('[ERROR] glz:include file not found: ' . $node->getAttribute('src'));
     }
     $this->_classSource .= '// include: ' . $src . GLZ_COMPILER_NEWLINE2;
     $srcXml = file_get_contents($src);
     // esegue il parsing per sapere quale sono i parametri del template e ricavare quelli di default
     $templateParams = array();
     $includeXML = org_glizy_ObjectFactory::createObject('org.glizy.parser.XML');
     $includeXML->loadXmlAndParseNS($srcXml);
     $templateDefineNodes = $includeXML->getElementsByTagName('templateDefine');
     foreach ($templateDefineNodes as $templateDefine) {
         if (!$templateDefine->hasAttribute('name')) {
             throw org_glizy_compilers_PageTypeException::templateDefineNotValid($src);
         }
         $templateParams[$templateDefine->getAttribute('name')] = $templateDefine->hasAttribute('required') && $templateDefine->getAttribute('required') == 'true' ? null : ($templateDefine->hasAttribute('defaultValue') ? $templateDefine->getAttribute('defaultValue') : '');
     }
     if (count($templateParams)) {
         $templateParamsKeys = array_keys($templateParams);
         foreach ($node->childNodes as $nc) {
             if ($nc->tagName == 'glz:template' && $nc->hasAttribute('name')) {
                 $name = $nc->getAttribute('name');
                 if (!in_array($name, $templateParamsKeys)) {
                     throw org_glizy_compilers_PageTypeException::templateDefinitionDontExixts($name);
                 }
                 $value = '';
                 if ($nc->hasAttribute('value')) {
                     $value = $nc->getAttribute('value');
                 } else {
                     $tempDom = new DOMDocument();
                     foreach ($nc->childNodes as $ncc) {
                         $tempDom->appendChild($tempDom->importNode($ncc, true));
                     }
                     $value = $tempDom->saveXML();
                     $value = str_replace('<?xml version="1.0"?>', '', $value);
                 }
                 $templateParams[$name] = $value;
             }
         }
         foreach ($templateParams as $k => $v) {
             if (is_null($v)) {
                 throw org_glizy_compilers_PageTypeException::templateDefinitionRequired($k, $src);
             }
             $srcXml = str_replace('##' . $k . '##', $v, $srcXml);
         }
     }
     $includeXML = org_glizy_ObjectFactory::createObject('org.glizy.parser.XML');
     $includeXML->loadXmlAndParseNS($srcXml);
     $newNameSpaces = $includeXML->namespaces;
     $this->addNamespace($newNameSpaces, $registredNameSpaces);
     if ($includeXML->documentElement->hasAttribute('adm:editComponents')) {
         $this->_classSource .= '$n0->setAttribute( "adm:editComponents", "' . $includeXML->documentElement->getAttribute('adm:editComponents') . '" )' . GLZ_COMPILER_NEWLINE;
     }
     $this->_compileXml($includeXML->documentElement, $registredNameSpaces, $counter, $parent, $idPrefix);
 }