示例#1
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;
 }
示例#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
 /**
  * @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();
 }
示例#4
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);
    }
示例#5
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));
     }
 }
示例#6
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);
             }
         }
     }
 }
示例#7
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');
             }
         }
     }
 }
示例#8
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;
     }
 }
示例#9
0
 private function getModuleVO($id)
 {
     // TODO controllare che il modulo sia corretto
     $modules = org_glizy_Modules::getModules();
     return $modules[$id];
 }