function execute() { $id = __Request::get('id'); $modulesState = org_glizy_Modules::getModulesState(); $modulesState[$id] = __Request::get('action') == 'enable'; org_glizy_Modules::setModulesState($modulesState); return true; }
/** * @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(); }
/** * 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); }
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); } } } }
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; } }