Example #1
0
 function createChildComponents()
 {
     $entityTypeService = $this->_application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService');
     $properties = $entityTypeService->getEntityTypeAttributeProperties(__Request::get('entityTypeId'), $this->_parent->getId());
     $moduleId = $properties['entity_properties_params'];
     $this->_content['title'] = $this->data->text;
     $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'title', 'title');
     $this->addChild($c);
     $this->_content['url'] = __Routing::makeUrl($moduleId, array('document_id' => $this->data->id, 'title' => $this->data->text));
     $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Text', $this->_application, $this, 'glz:Text', 'url', 'url');
     $this->addChild($c);
     $module = org_glizy_Modules::getModule($moduleId);
     $ar = org_glizy_ObjectFactory::createModel($module->classPath . '.models.Model');
     $ar->load($this->data->id);
     if ($ar->fieldExists('image')) {
         $this->_content['__image'] = $ar->image;
         $c =& org_glizy_ObjectFactory::createComponent('org.glizy.components.Image', $this->_application, $this, 'glz:Image', '__image', '__image');
         $c->setAttribute('width', __Config::get('THUMB_WIDTH'));
         $c->setAttribute('height', __Config::get('THUMB_HEIGHT'));
         $c->setAttribute('crop', true);
         $this->addChild($c);
     } else {
         $c =& org_glizy_ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.NoImage', $this->_application, $this, 'glz:Image', '__image', '__image');
         $c->setAttribute('width', __Config::get('THUMB_SMALL_WIDTH'));
         $c->setAttribute('height', __Config::get('THUMB_SMALL_HEIGHT'));
         $this->addChild($c);
     }
 }
Example #2
0
 function execute()
 {
     $id = __Request::get('id');
     $modulesState = org_glizy_Modules::getModulesState();
     $modulesState[$id] = __Request::get('action') == 'enable';
     org_glizy_Modules::setModulesState($modulesState);
     return true;
 }
Example #3
0
 public function findTerm($fieldName, $model, $query, $term, $proxyParams = null)
 {
     $model = org_glizy_Modules::getModule($proxyParams->moduleId);
     $it = org_glizy_ObjectFactory::createModelIterator($model->classPath . '.models.Model')->where('title', '%' . $term . '%', 'ILIKE')->orderBy('title');
     $result = array();
     foreach ($it as $ar) {
         $result[] = array('id' => $ar->getId(), 'text' => $ar->title);
     }
     return $result;
 }
Example #4
0
 function execute()
 {
     $modules = org_glizy_Modules::getModules();
     $result = array();
     foreach ($modules as $module) {
         if ($module->showInOntologyBuilder) {
             $result[] = array('id' => $module->id, 'name' => $module->name);
         }
     }
     return $result;
 }
Example #5
0
 static function registerModule()
 {
     $moduleVO = org_glizy_Modules::getModuleVO();
     $moduleVO->id = 'glizycms.userManager.fe';
     $moduleVO->name = __T('User Manager');
     $moduleVO->description = '';
     $moduleVO->version = '1.0.0';
     $moduleVO->classPath = 'org.glizycms.userManager.fe';
     $moduleVO->author = 'META srl';
     $moduleVO->authorUrl = 'http://www.gruppometa.it';
     org_glizy_Modules::addModule($moduleVO);
 }
Example #6
0
 function execute()
 {
     $tableName = $this->parent->getTableName();
     $siteMap =& org_glizy_ObjectFactory::createObject('org.glizycms.core.application.SiteMapDB');
     $siteMap->getSiteArray();
     $menuNode = $siteMap->getMenuByPageType($tableName . '.views.FrontEnd');
     if ($menuNode) {
         $menuProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.MenuProxy');
         $pageId = $menuProxy->deleteMenu($menuNode->id);
     }
     org_glizy_Modules::deleteCache();
     return true;
 }
Example #7
0
 static function registerModule()
 {
     glz_loadLocale('movio.modules.thesaurus');
     $moduleVO = org_glizy_Modules::getModuleVO();
     $moduleVO->id = 'movio_thesaurus';
     $moduleVO->name = __T('movio_thesaurus');
     $moduleVO->description = '';
     $moduleVO->version = '1.0.0';
     $moduleVO->classPath = 'movio.modules.thesaurus';
     $moduleVO->author = 'META srl';
     $moduleVO->authorUrl = 'http://www.gruppometa.it';
     $moduleVO->pluginUrl = 'http://movio.beniculturali.it/';
     $moduleVO->siteMapAdmin = '<glz:Page pageType="movio.modules.thesaurus.views.Admin" id="movio_thesaurus" value="{i18n:' . $moduleVO->name . '}" icon="icon-circle-blank" adm:acl="*" />';
     org_glizy_Modules::addModule($moduleVO);
 }
Example #8
0
 static function registerModule()
 {
     $moduleVO = org_glizy_Modules::getModuleVO();
     $moduleVO->id = 'movio_touristoperators';
     $moduleVO->name = __T('Tourist Operators');
     $moduleVO->description = '';
     $moduleVO->version = '1.0.0';
     $moduleVO->classPath = 'movio.modules.touristoperators';
     $moduleVO->pageType = 'movio.modules.touristoperators.views.FrontEnd';
     $moduleVO->author = 'META srl';
     $moduleVO->authorUrl = 'http://www.gruppometa.it';
     $moduleVO->pluginUrl = 'http://movio.beniculturali.it';
     $moduleVO->siteMapAdmin = '<glz:Page pageType="movio.modules.touristoperators.views.Admin" id="movio_touristoperators" value="{i18n:Tourist Operators}" icon="icon-circle-blank" />';
     $moduleVO->showInOntologyBuilder = true;
     org_glizy_Modules::addModule($moduleVO);
 }
Example #9
0
    /**
     * Render
     *
     * @return	void
     * @access	public
     */
    function render()
    {
        // TODO tradurre le label
        $output = '';
        $output .= '<table id="' . $this->getId() . '" class="js-modulesManager ' . $this->getAttribute('cssClass') . '">';
        if ($this->getAttribute('label') != '') {
            $output .= '<caption>' . $this->getAttribute('label') . '</caption>';
        }
        // disegna le colonne
        $output .= '<thead>';
        $output .= '<tr>';
        $output .= '<th class="name">Plugin</th>';
        $output .= '<th>Descrizione</th>';
        $output .= '<th class="actions"></th>';
        $output .= '</tr>';
        $output .= '<tfoot><tr><td colspan="3"></td></tr></tfoot>';
        $output .= '<tbody>';
        $origCssClass = explode(',', $this->getAttribute('cssClass'));
        $tempCssClass = array();
        $modulesState = org_glizy_Modules::getModulesState();
        $modules = org_glizy_Modules::getModules();
        $this->sort($modules);
        foreach ($modules as $m) {
            // $moduleDescription = org_glizy_ObjectFactory::createObject( 'org.glizy.ModuleDescription', $m );
            // if ( !empty( $m->pageType ) ) continue;
            $isEnabled = !isset($modulesState[$m->id]) || $modulesState[$m->id];
            if (!count($tempCssClass)) {
                $tempCssClass = $origCssClass;
            }
            $cssClass = array_shift($tempCssClass);
            $cssClass .= ' ' . ($isEnabled ? 'enabled' : 'disabled');
            $output .= '<tr class="' . $cssClass . '">' . '<td class="name">' . __T($m->name) . '</td>' . '<td>' . '<p class="description">' . $m->description . '</p>' . '<p class="info">Versione ' . $m->version . ' | ' . __Link::makeLink2(null, array('label' => $m->author, 'title' => 'Visita il sito dell\'autore', 'url' => $m->authorUrl, 'rel' => 'external')) . ' | ' . __Link::makeLink2(null, array('label' => 'Visita il sito del plugin', 'url' => $m->pluginUrl, 'rel' => 'external')) . '</p>' . '</td>' . '<td class="actions">' . (!$isEnabled ? '<a href="" data-action="enable" data-id="' . $m->id . '" class="js-modulesManagerAction action">abilita</a>' : '') . ($isEnabled ? '<a href="" data-action="disable" data-id="' . $m->id . '" class="js-modulesManagerAction action">disabilita</a>' : '') . ' ' . ($m->canDuplicated ? '<a href="' . __Routing::makeUrl('glizycmsModuleManagerDuplicate', array('pageId' => $this->pageId, 'id' => $m->id)) . '" class="action">duplica</a>' : '') . '</td>' . '</tr>';
        }
        $output .= '</tbody>';
        $output .= '</table>';
        $output .= <<<EOD
<script type="text/javascript">
jQuery(document).ready(function() {

\t\$("table.js-modulesManager a.js-modulesManagerAction ").click( function( e ){
\t\te.stopPropagation();
\t\tif ( jQuery( this ).data( "action" ) == "uninstall" )
\t\t{
\t\t\tif ( !confirm( "Sei sicuro di voler rimuovere il plugin?") )
\t\t\t{
\t\t\t\treturn false;
\t\t\t}
\t\t}

\t\t// jQuery.modal('<div></div>', {
\t\t// \tclose: false,
\t\t// \toverlayCss:{
\t\t// \t\tbackgroundColor:"#000"
\t\t// \t},
\t\t// \toverlayClose: false
\t\t// });

\t\tjQuery.ajax( { url: Glizy.ajaxUrl+jQuery( this ).data( "action" ),
\t\t\t\t\ttype: 'POST',
\t\t\t\t\tdata: { id: jQuery( this ).data( "id" ) },
\t\t\t\t\tsuccess: function( response, r, a ) {
\t\t\t\t\t\tlocation.reload();
\t\t\t\t\t}});
\t\treturn false;
\t});

});
</script>
EOD;
        $this->addOutputCode($output);
    }
Example #10
0
 function execute()
 {
     org_glizy_Modules::deleteCache();
     org_glizy_cache_CacheFile::cleanPHP(__Paths::get('APPLICATION_TO_ADMIN_CACHE'));
     return true;
 }
Example #11
0
 function _processSiteMapXML($fileName, $parentId = '')
 {
     $application =& org_glizy_ObjectValues::get('org.glizy', 'application');
     $lang = $application->getLanguage();
     $modulesState = org_glizy_Modules::getModulesState();
     $xmlString = file_get_contents($fileName);
     if (strpos($xmlString, '<glz:modulesAdmin />')) {
         $modulesSiteMap = '';
         $modules = org_glizy_Modules::getModules();
         foreach ($modules as $m) {
             if ($m->enabled && $m->siteMapAdmin) {
                 $modulesSiteMap .= $m->siteMapAdmin;
             }
         }
         $xmlString = str_replace('<glz:modulesAdmin />', $modulesSiteMap, $xmlString);
     }
     $xml = org_glizy_ObjectFactory::createObject('org.glizy.parser.XML');
     $xml->loadXmlAndParseNS($xmlString);
     $pages = $xml->getElementsByTagName('Page');
     $total = $pages->length;
     $pagesAcl = array();
     for ($i = 0; $i < $total; $i++) {
         $currNode = $pages->item($i);
         $nodeTitle = '';
         $this->_searchNodeDetails($currNode, $nodeTitle, $lang);
         $id = $currNode->getAttribute('id');
         if (isset($modulesState[$id]) && !$modulesState[$id]) {
             continue;
         }
         $menu = $this->getEmptyMenu();
         $menu['id'] = strtolower($id);
         $menu['parentId'] = $currNode->hasAttribute('parentId') ? strtolower($currNode->getAttribute('parentId')) : ($currNode->parentNode->hasAttribute('id') ? strtolower($currNode->parentNode->getAttribute('id')) : '');
         $menu['pageType'] = $currNode->hasAttribute('pageType') ? $currNode->getAttribute('pageType') : $currNode->getAttribute('id');
         $menu['isPublished'] = 1;
         $menu['isVisible'] = $currNode->getAttribute('visible');
         $menu['cssClass'] = $currNode->getAttribute('cssClass');
         $menu['icon'] = $currNode->getAttribute('icon');
         $menu['sortChild'] = $currNode->hasAttribute('sortChild') && $currNode->getAttribute('sortChild') == 'true';
         if (!$currNode->hasAttribute('visible')) {
             if ($currNode->hasAttribute('adm:acl') || in_array($menu['id'], $pagesAcl)) {
                 $menu['isVisible'] = '{php:$user.acl("' . $menu['id'] . '", "visible")}';
             } else {
                 if (!$currNode->hasAttribute('adm:acl') && $currNode->hasAttribute('adm:aclPageTypes')) {
                     $temp = array();
                     $aclPages = explode(',', strtolower($currNode->getAttribute('adm:aclPageTypes')));
                     foreach ($aclPages as $v) {
                         $temp[] = '$user.acl("' . $v . '", "visible")';
                     }
                     $menu['isVisible'] = '{php:(' . implode(' OR ', $temp) . ')}';
                 }
             }
         }
         $menu['title'] = $nodeTitle;
         $menu['depth'] = 1;
         $menu['childNodes'] = array();
         // solo admin
         $menu['order'] = 0;
         $menu['hasPreview'] = 0;
         $menu['type'] = 'PAGE';
         $menu['creationDate'] = 0;
         $menu['modificationDate'] = 0;
         $menu['url'] = str_replace('%', '&', $currNode->getAttribute('url'));
         if (strpos($menu['url'], '&') === 0) {
             $menu['url'] = __Link::scriptUrl(true) . $menu['url'];
         }
         $menu['select'] = strtolower($currNode->getAttribute('select'));
         $menu['nodeObj'] = NULL;
         $menu['adm:acl'] = $currNode->hasAttribute('adm:acl') ? $currNode->getAttribute('adm:acl') : null;
         $menu['adm:aclLabel'] = $currNode->hasAttribute('adm:aclLabel') ? $currNode->getAttribute('adm:aclLabel') : null;
         $menu['adm:aclPageTypes'] = $currNode->hasAttribute('adm:aclPageTypes') ? $currNode->getAttribute('adm:aclPageTypes') : null;
         if ($menu['adm:aclPageTypes']) {
             $pagesAcl = array_merge(explode(',', strtolower($menu['adm:aclPageTypes'])), $pagesAcl);
         }
         $this->_siteMapArray[$menu["id"]] = $menu;
     }
 }
Example #12
0
 /**
  * @param DOMElement $param
  * @param      $name
  * @param bool $child
  */
 private function compileNode(&$param, $name, $child, $prefix, $middleware)
 {
     $value = $param->hasAttribute('value') ? $param->getAttribute('value') : $param->firstChild->nodeValue;
     $value = !$param->hasAttribute('method') && !$param->hasAttribute('skipLanguage') ? $this->language . $prefix . $value : $prefix . $value;
     $parseUrl = $param->hasAttribute('parseUrl') ? $param->getAttribute('parseUrl') : 'true';
     $keyName = $param->hasAttribute('keyName') ? $param->getAttribute('keyName') : '';
     $keyValue = $param->hasAttribute('keyValue') ? $param->getAttribute('keyValue') : '';
     $method = $param->hasAttribute('method') ? strtolower($param->getAttribute('method')) : '';
     $child = $child ? '[]' : '';
     $urlPattern = '';
     $urlValues = array();
     $staticValues = array();
     if ($middleware) {
         $staticValues['__middleware__'] = $middleware;
     }
     if ($parseUrl == 'true') {
         $attributeToSkip = array('name', 'value', 'parseUrl', 'keyValue', 'keyValue');
         foreach ($param->attributes as $index => $attr) {
             // NOTA: su alcune versioni di PHP (es 5.1)  empty( $attr->prefix ) non viene valutato in modo corretto
             $prefix = $attr->prefix == "" || is_null($attr->prefix) ? "" : $attr->prefix . ":";
             $attrName = $prefix . $attr->name;
             if (!in_array($attrName, $attributeToSkip)) {
                 $staticValues[$attrName] = $attr->value;
             }
         }
         /** @var org_glizy_application_Application $application */
         $application =& org_glizy_ObjectValues::get('org.glizy', 'application');
         $siteMap =& $application->getSiteMap();
         $isApplicationDB = $siteMap && $siteMap->getType() == 'db';
         $urlPattern = str_replace('/', '\\/', $value);
         preg_match_all("|\\{(.*)\\}|U", $urlPattern, $match, PREG_PATTERN_ORDER);
         for ($i = 0; $i < count($match[0]); $i++) {
             $command = explode('=', $match[1][$i]);
             $urlValuesKey = $command[count($command) - 1];
             switch ($command[0]) {
                 case 'language':
                     $urlPartValue = '(.{2})';
                     break;
                 case '*':
                 case 'currentMenu':
                     $urlPartValue = '(.*)';
                     $urlValuesKey = 'pageId';
                     break;
                 case 'pageId':
                     if (count($command) > 1 && is_object($siteMap)) {
                         if (is_numeric($command[1])) {
                             $page = $siteMap->getNodeById($command[1]);
                         } else {
                             $page = $siteMap->getMenuByPageType($command[1]);
                             if (is_null($page)) {
                                 $module = org_glizy_Modules::getModule($command[1]);
                                 if (!is_null($module) && $module->pageType) {
                                     $page = $siteMap->getMenuByPageType($module->pageType);
                                 }
                             }
                         }
                         if ($isApplicationDB) {
                             $urlPartValue = strtolower('(' . $page->id . '\\/[^\\/]*?)');
                         } else {
                             $urlPartValue = strtolower('(' . str_replace('/', '\\/', $page->id) . ')');
                         }
                     } else {
                         $urlPartValue = '([^\\/]*)';
                     }
                     $urlValuesKey = $command[0];
                     break;
                 case 'pageTitle':
                     $urlPartValue = '([^\\/]*)';
                     break;
                 case 'value':
                     $urlPartValue = '([^\\/]*)';
                     break;
                 case 'integer':
                     $urlPartValue = '(\\d*)';
                     break;
                 case 'static':
                     $urlPartValue = '';
                     $urlValuesKey = $command[1];
                     break;
                 case 'state':
                     $urlPartValue = '(' . $command[1] . ')';
                     $urlValuesKey = $command[0];
                     break;
                 case 'config':
                     $urlPartValue = '';
                     $urlValuesKey = '';
                     break;
                 default:
                     $urlPartValue = '(' . (count($command) > 1 ? $command[1] : $command[0]) . ')';
                     $urlValuesKey = $command[0];
                     break;
             }
             if (empty($urlPartValue)) {
                 $urlPattern = str_replace(array($match[0][$i] . '\\/', $match[0][$i]), '()', $urlPattern);
                 $urlValues[$urlValuesKey] = $command[2];
                 continue;
             }
             $urlValues[$urlValuesKey] = '';
             $urlPattern = str_replace($match[0][$i], $urlPartValue, $urlPattern);
             if (strpos($urlPattern, '#') !== false) {
                 list($urlPattern) = explode('#', $urlPattern);
             }
         }
         $urlPattern = rtrim($urlPattern, '\\/');
         $urlPattern = '|^' . $urlPattern . '(\\/?)$|i';
     }
     $this->output .= '$configArray["' . $name . '"]' . $child . ' = array("value" => "' . addslashes($value) . '", "urlPattern" => "' . addcslashes($urlPattern, '"\\') . '", "urlValues" => "' . addcslashes(serialize($urlValues), '"\\') . '", "staticValues" => "' . addcslashes(serialize($staticValues), '"\\') . '", "parseUrl" => ' . $parseUrl . ', "keyName" => "' . $keyName . '", "keyValue" => "' . $keyValue . '", "method" => "' . $method . '" )' . GLZ_COMPILER_NEWLINE;
 }
Example #13
0
 function compileChildren(&$node, &$registredNameSpaces, &$counter, $oldcounter = 'NULL', $idPrefix = '')
 {
     foreach ($node->childNodes as $nc) {
         $counter++;
         $this->_compileXml($nc, $registredNameSpaces, $counter, '$n' . $oldcounter, $idPrefix);
     }
     if ($node->hasAttribute('allowModulesSnippets') && $node->getAttribute('allowModulesSnippets') == "true") {
         $modulesState = org_glizy_Modules::getModulesState();
         $modules = org_glizy_Modules::getModules();
         foreach ($modules as $m) {
             $isEnabled = !isset($modulesState[$m->id]) || $modulesState[$m->id];
             if ($isEnabled && $m->pluginInPageType && $m->pluginSnippet) {
                 $counter++;
                 $this->compile_glzinclude($m->pluginSnippet, $registredNameSpaces, $counter, '$n' . $oldcounter, $idPrefix);
             }
         }
     }
 }
Example #14
0
 protected function readFromModules()
 {
     if ($this->getAttribute('showAllPageTypes')) {
         $modules = org_glizy_Modules::getModules();
         foreach ($modules as $moduleVO) {
             $pageType = $moduleVO->pageType;
             if ($pageType) {
                 if (isset($this->items[$pageType])) {
                     continue;
                 }
                 if (!$moduleVO->show) {
                     continue;
                 }
                 if ($moduleVO->unique && $pageType != $this->_content) {
                     // TODO migliorare
                     $ar =& org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu');
                     $result = $ar->find(array('menu_pageType' => $pageType));
                     unset($ar);
                     if ($result) {
                         continue;
                     }
                 }
                 $this->items[$pageType] = array('label' => __T($pageType), 'type' => $pageType, 'cssClass' => 'button-generic');
             }
         }
     }
 }
Example #15
0
 /**
  * @param $options
  *
  * @return mixed
  */
 function compile($options)
 {
     $this->initOutput();
     if (isset($options['mode'])) {
         $this->mode = $options['mode'];
     }
     $pageXml = org_glizy_ObjectFactory::createObject('org.glizy.parser.XML');
     $pageXml->loadAndParseNS($this->_fileName);
     $pageRootNode = $pageXml->documentElement;
     $registredNameSpaces = $pageXml->namespaces;
     $registredNameSpaces['glz'] = 'org.glizy.components';
     // include i componenti usati
     foreach ($registredNameSpaces as $key => $value) {
         if ($key != 'glz' && substr($value, -1, 1) == '*') {
             $this->output .= 'glz_loadLocale(\'' . $value . '\')' . GLZ_COMPILER_NEWLINE;
         }
     }
     $className = glz_basename($this->_cacheObj->getFileName());
     $componentClassInfo = $this->_getComponentClassInfo($pageRootNode->nodeName, $registredNameSpaces);
     //if (!empty($componentClassInfo['classPath']))
     //{
     //	$this->_classSource .= 'glz_import(\''.$componentClassInfo['classPath'].'\')'.GLZ_COMPILER_NEWLINE;
     //}
     $this->_classSource .= 'class ' . $className . ' extends ' . $componentClassInfo['className'] . ' {' . GLZ_COMPILER_NEWLINE2;
     $this->_classSource .= 'function ' . $className . '(&$application, &$parent, $tagName=\'\', $id=\'\', $originalId=\'\', $skipImport=false) {' . GLZ_COMPILER_NEWLINE2;
     if (isset($options['originalClassName'])) {
         $this->_classSource .= '$this->_className = \'' . $options['originalClassName'] . '\'' . GLZ_COMPILER_NEWLINE;
     }
     $this->_classSource .= 'parent::__construct($application, $parent, $tagName, $id, $originalId)' . GLZ_COMPILER_NEWLINE;
     $this->_classSource .= '$mode = ""' . GLZ_COMPILER_NEWLINE;
     $this->_classSource .= '$idPrefix = ""' . GLZ_COMPILER_NEWLINE;
     $this->_classSource .= '$n0 = &$this' . GLZ_COMPILER_NEWLINE;
     $this->_classSource .= 'if (!empty($id)) $id .= \'-\'' . GLZ_COMPILER_NEWLINE;
     $this->_classSource .= 'if (!empty($originalId)) $originalId .= \'-\'' . GLZ_COMPILER_NEWLINE;
     if (count($pageRootNode->attributes)) {
         // compila  gli attributi
         $this->_classSource .= '$attributes = array(';
         foreach ($pageRootNode->attributes as $index => $attr) {
             if ($attr->name != 'id') {
                 // NOTA: su alcune versioni di PHP (es 5.1)  empty( $attr->prefix ) non viene valutato in modo corretto
                 $prefix = $attr->prefix == "" || is_null($attr->prefix) ? "" : $attr->prefix . ":";
                 $this->_classSource .= '\'' . $prefix . $attr->name . '\' => \'' . addslashes($attr->value) . '\', ';
             }
         }
         $this->_classSource .= ')' . GLZ_COMPILER_NEWLINE;
         $this->_classSource .= '$this->setAttributes( $attributes )' . GLZ_COMPILER_NEWLINE;
     }
     $counter = 0;
     $oldcounter = $counter;
     foreach ($pageRootNode->childNodes as $nc) {
         $counter++;
         $this->_compileXml($nc, $registredNameSpaces, $counter, '$n' . $oldcounter, '$id.', '$originalId.');
     }
     if (isset($options['originalClassName']) && $pageRootNode->hasAttribute('allowModulesSnippets') && $pageRootNode->getAttribute('allowModulesSnippets') == "true") {
         $modulesState = org_glizy_Modules::getModulesState();
         $modules = org_glizy_Modules::getModules();
         foreach ($modules as $m) {
             $isEnabled = !isset($modulesState[$m->id]) || $modulesState[$m->id];
             if ($isEnabled && $m->pluginInPageType && $m->pluginSnippet) {
                 $counter++;
                 $this->compile_glzinclude($m->pluginSnippet, $registredNameSpaces, $counter, '$n' . $oldcounter, '$id.');
             }
         }
     }
     $this->_classSource .= '}' . GLZ_COMPILER_NEWLINE2;
     $this->_classSource .= '}' . GLZ_COMPILER_NEWLINE2;
     $this->output .= $this->_classSource;
     $this->output .= $this->_customClassSource;
     return $this->save();
 }
Example #16
0
 function render()
 {
     // TODO: controllo acl
     $name = $this->getId();
     if (!$this->_user->acl($this->_application->getPageId(), 'new')) {
         $output = org_glizy_helpers_Html::hidden($name, $this->_content, array('class' => $this->getAttribute('cssClass')));
     } else {
         $pageTypes = array();
         if ($dh = @opendir(org_glizy_Paths::get('APPLICATION_TO_ADMIN_PAGETYPE'))) {
             // scan the pageType folder
             while ($fileName = readdir($dh)) {
                 // check if the item is a folder
                 if ($fileName != "." && $fileName != ".." && strpos($fileName, '.xml') !== false) {
                     if ($fileName == 'Common.xml') {
                         continue;
                     }
                     $pageTypes[] = preg_replace('/\\.xml/i', '', $fileName);
                 }
             }
             closedir($dh);
             glz_loadLocale(org_glizy_Paths::get('APPLICATION_TO_ADMIN_PAGETYPE'));
         } else {
             // can't open pageTypes folder
             // show the error
             new org_glizy_Exception(array('[%s] %s: %s', $this->getClassName(), GLZ_ERR_NO_PAGETYPE_FOLDER, org_glizy_Paths::get('APPLICATION_TO_ADMIN') . '/pageTypes/'));
         }
         $modules = org_glizy_Modules::getModules();
         foreach ($modules as $moduleVO) {
             if ($moduleVO->pageType) {
                 $pageTypes[] = $moduleVO->pageType;
             }
         }
         $output = '<option value=""></option>';
         $values = array(array($this->getAttribute('emptyValue'), '', 1, array(), 0));
         $modifyMode = $this->getAttribute('modify');
         foreach ($pageTypes as $item) {
             $moduleVO = null;
             foreach ($modules as $m) {
                 if ($m->pageType == $item) {
                     $moduleVO = $m;
                     break;
                 }
             }
             if ($moduleVO) {
                 if (!$moduleVO->show) {
                     continue;
                 }
                 if ($moduleVO->unique && (!$modifyMode || $modifyMode && $item != $this->_content)) {
                     $ar =& org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu');
                     $result = $ar->find(array('menu_pageType' => $item));
                     unset($ar);
                     if ($result) {
                         continue;
                     }
                 }
             }
             $pageName = __T($item);
             $output .= '<option value="' . $item . '"' . ($item == $this->_content ? ' selected' : '') . '>' . __T($item) . '</option>';
         }
         $attributes = array();
         $attributes['id'] = $this->getId();
         $attributes['name'] = $this->getOriginalId();
         $attributes['disabled'] = $this->getAttribute('disabled') ? 'disabled' : '';
         $attributes['class'] = $this->getAttribute('required') ? 'required' : '';
         $attributes['class'] .= $this->getAttribute('cssClass') != '' ? ($attributes['class'] != '' ? ' ' : '') . $this->getAttribute('cssClass') : '';
         $output = '<select ' . $this->_renderAttributes($attributes) . '>' . $output . '</select>';
         $cssClassLabel = $this->getAttribute('cssClassLabel');
         $cssClassLabel .= ($cssClassLabel ? ' ' : '') . ($this->getAttribute('required') ? 'required' : '');
         if ($this->getAttribute('wrapLabel')) {
             $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), true, $output, array('class' => $cssClassLabel), false);
             $output = '';
         } else {
             $label = org_glizy_helpers_Html::label($this->getAttributeString('label'), $this->getId(), false, '', array('class' => $cssClassLabel), false);
         }
         $this->addOutputCode($this->applyItemTemplate($label, $output));
     }
 }
Example #17
0
 /**
  * @param string $route
  * @param array  $queryVars
  * @param array  $addParam
  *
  * @return mixed|string
  */
 static function _makeURL_SEF($route = '', $queryVars = array(), $addParam = array())
 {
     if (!isset($addParam['__modal__']) && __Request::exists('__modal__')) {
         $addParam['__modal__'] = __Request::get('__modal__');
     }
     $url = '';
     if (!empty($route)) {
         $configArray =& org_glizy_Routing::_getValuesArray();
         /** @var org_glizy_application_Application $application */
         $application =& org_glizy_ObjectValues::get('org.glizy', 'application');
         /** @var org_glizy_application_SiteMap $siteMap */
         $siteMap =& $application->getSiteMap();
         $isApplicationDB = $siteMap->getType() == 'db';
         // TODO
         // controllare se il route richiesto esiste.
         //
         // TODO
         // ci sono molte classi che usano lo stesso concetto di memorizzare
         // i dati in un array statico
         // conviene fare una classe base e estendere questa
         //
         $routing = $configArray[strtolower($route)];
         if (isset($routing[0])) {
             foreach ($routing as $v) {
                 if ($queryVars[$v['keyName']] == $v['keyValue'] || empty($v['keyValue'])) {
                     $url = $v['value'];
                     break;
                 }
             }
         } else {
             $url = $routing['value'];
         }
         if (strpos($url, 'http://') !== false) {
             return $url;
         }
         $pageId = 0;
         preg_match_all("|\\{(.*)\\}|U", $url, $match, PREG_PATTERN_ORDER);
         for ($i = 0; $i < count($match[0]); $i++) {
             $sanitize = true;
             $value = '';
             $value2 = '';
             $command = explode('=', $match[1][$i]);
             switch ($command[0]) {
                 case 'language':
                     $value = isset($queryVars['language']) ? $queryVars['language'] : $application->getLanguage();
                     break;
                 case '*':
                 case 'currentMenu':
                     $page =& $application->getCurrentMenu();
                     $value = $page->id;
                     $value2 = $page->title;
                     unset($page);
                     break;
                 case 'currentMenuId':
                     $page =& $application->getCurrentMenu();
                     $value = $page->id;
                     unset($page);
                     break;
                 case 'pageId':
                     // ricerca la pagina da linkare
                     if (count($command) > 1) {
                         if (is_numeric($command[1])) {
                             $page = $siteMap->getNodeById($command[1]);
                         } else {
                             $page = $siteMap->getMenuByPageType($command[1]);
                             if (is_null($page)) {
                                 $module = org_glizy_Modules::getModule($command[1]);
                                 if (!is_null($module) && $module->pageType) {
                                     $page = $siteMap->getMenuByPageType($module->pageType);
                                 }
                             }
                         }
                         $value = $page->id;
                         $value2 = $isApplicationDB ? $page->title : '';
                     } else {
                         $pageId = @$queryVars[$command[0]];
                         if (empty($pageId)) {
                             $page =& $application->getCurrentMenu();
                             $pageId = $page->id;
                             unset($page);
                         }
                         $value = $pageId;
                         $value2 = '';
                     }
                     break;
                 case 'pageTitle':
                     // ricerca la pagina da linkare
                     if (!isset($queryVars['title'])) {
                         // TODO
                         // non deve instanziare un nuovo menĂ¹ altrimenti rilegge tutto dal db ogni volta
                         $page = $siteMap->getNodeById($pageId);
                         $value = $page->title;
                     } else {
                         $value = $queryVars['title'];
                     }
                     break;
                 case 'value':
                 case 'integer':
                     $value = isset($queryVars[$command[1]]) ? $queryVars[$command[1]] : __Request::get($command[1], '');
                     break;
                 case 'static':
                     $value = '';
                     break;
                 case 'config':
                     $sanitize = false;
                     $value = __Config::get($command[1]);
                     break;
                 default:
                     $value = $command[1];
                     break;
             }
             if (is_string($value) && empty($value)) {
                 $url = str_replace($match[0][$i] . '/', '', $url);
                 $url = str_replace($match[0][$i], '', $url);
                 continue;
             }
             if ($sanitize) {
                 $value = glz_sanitizeUrlTitle($value) . ($value2 != '' ? '/' : '');
                 $value2 = glz_sanitizeUrlTitle($value2);
             }
             $url = str_replace($match[0][$i], $value . $value2, $url);
         }
         // aggiunge in coda i valori della query string che non sono usati
         if (is_array($addParam) && count($addParam)) {
             $url .= self::$baseUrlParam;
             foreach ($addParam as $k => $v) {
                 $url .= '&' . $k . '=' . urlencode($v);
             }
         } else {
             if (is_string($addParam)) {
                 $url .= $addParam;
             }
         }
     }
     $url = !empty($url) ? $url : $route;
     return !preg_match('/^(javascript:|http:|https:)/', $url) ? self::$baseUrl . $url : $url;
 }
Example #18
0
 private function getModuleVO($id)
 {
     // TODO controllare che il modulo sia corretto
     $modules = org_glizy_Modules::getModules();
     return $modules[$id];
 }