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; } }
/** * @param org_glizy_application_Application $application * @param string $pageType * @param string $path * @param array $options * * @return mixed */ static function &createPage(&$application, $pageType, $path = NULL, $options = NULL) { $pageType = org_glizy_ObjectFactory::resolvePageType($pageType); $options['pageType'] = $pageType . '.xml'; $options['path'] = is_null($path) ? org_glizy_Paths::getRealPath('APPLICATION_PAGE_TYPE') : $path; $fileName = $options['path'] . $options['pageType']; if (isset($options['pathTemplate']) && isset($options['mode'])) { $verifyFileName = $options['pathTemplate'] . '/pageTypes/' . $options['pageType']; if (file_exists($verifyFileName)) { $options['verifyFileName'] = $verifyFileName; } } if (!file_exists($fileName)) { $fileName = glz_findClassPath($pageType); if (is_null($fileName)) { // TODO: file non trovato visualizzare errore } } // TODO // controllare l'esistenza del file $compiler = org_glizy_ObjectFactory::createObject('org.glizy.compilers.PageType'); $compiledFileName = $compiler->verify($fileName, $options); // TODO verificare se la pagina è stata compilata require_once $compiledFileName; $idPrefix = isset($options['idPrefix']) ? $options['idPrefix'] : ''; $className = glz_basename($compiledFileName); $newObj = new $className($application, isset($options['skipImport']) ? $options['skipImport'] : false, $idPrefix); return $newObj; }