/** * @param string $query * @param null $params * * @return $this */ public function load($query, $params = null) { if (method_exists($this, $query)) { $this->querySqlToExec = org_glizy_helpers_PhpScript::callMethodWithParams($this, $query, $params); } else { // TODO errore } $this->lastQuery = $query; $this->lastParams = null; return $this; }
public function load($query, $params = null) { $driverName = $this->ar->getDriverName(); if (method_exists($this->ar, 'query_' . $query)) { // NOTE: verificare se i parametri nel caso di query di tipo function // vengono passati nell'array params o come array diretto // così da pulire questa parte di codice $params = is_array($params) ? isset($params['params']) ? $params['params'] : $params : array($params); $params['iterator'] = $this; org_glizy_helpers_PhpScript::callMethodWithParams($this->ar, 'query_' . $query, $params); unset($params['iterator']); } else { if (method_exists($this->ar, 'querysql_' . $driverName . '_' . $query)) { $this->querySqlToExec = org_glizy_helpers_PhpScript::callMethodWithParams($this->ar, 'querysql_' . $driverName . '_' . $query); } else { if (method_exists($this->ar, 'querysql_' . $query)) { $this->querySqlToExec = org_glizy_helpers_PhpScript::callMethodWithParams($this->ar, 'querysql_' . $query); } } } $this->lastQuery = $query; $this->lastParams = $params; return $this; }
function _makeNavigationMenu(&$node, $endDepth, &$menu, $skip = false) { $skip = !$skip ? $node->depth < $this->_startDepth : $skip; if ($node->type == 'BLOCK') { return true; } if ($node->depth > $endDepth) { return true; } if ($node->isVisible == 0) { return true; } if (is_string($node->isVisible) && preg_match("/\\{php\\:.*\\}/i", $node->isVisible)) { $phpcode = org_glizy_helpers_PhpScript::parse($node->isVisible); if (!eval($phpcode)) { return true; } } if ($node->type == 'SYSTEM' && !$skip) { return true; } if (!$this->_application->canViewPage($node->id)) { return true; } $nodeTitle = empty($node->titleLink) ? $node->title : $node->titleLink; $nodeDescription = empty($node->linkDescription) ? $nodeTitle : $node->linkDescription; $menuNode = array(); if (!$skip) { $menuNode['id'] = $node->id; $menuNode['title'] = $nodeTitle; $menuNode['label'] = $nodeDescription; $menuNode['depth'] = $node->depth; $menuNode['type'] = $node->pageType; $menuNode['cssClass'] = $node->cssClass; $menuNode['haveChild'] = $node->hasChildNodes(); if ($this->_currentMenuId == $node->id && !$this->getAttribute('forceLink')) { $menuNode['node'] = $nodeTitle; } else { $cssClass = $this->getAttribute('selectLink') && $this->_currentMenuId == $node->id ? $this->getAttribute('cssCurrent') : ''; if (empty($node->url)) { $linkParams = array('pageId' => $node->id, 'title' => $nodeDescription, 'label' => $nodeTitle, 'cssClass' => $cssClass, 'icon' => $node->icon); $menuNode['node'] = org_glizy_helpers_Link::makeLink('link', $linkParams); } else { $url = $node->url; if (strpos($url, 'route:') !== false) { $url = substr($url, 6); $url = __Routing::makeUrl($url, __Request::getAllAsArray()); } $menuNode['node'] = org_glizy_helpers_Link::makeSimpleLink($nodeTitle, $url, $nodeDescription, $cssClass); } } if (!$this->getAttribute('selectLink')) { if (!$this->getAttribute('selectParent')) { $menuNode['selected'] = $this->_currentMenuId == $node->id ? ' ' . $this->getAttribute('attributeToSelect') . '="' . $this->getAttribute('cssCurrent') . '"' : ''; } else { $parentNode =& $this->_currentMenu->parentNodeByDepth($node->depth); if (is_object($parentNode) && $node->depth > 1) { $menuNode['selected'] = $parentNode->id == $node->id || $this->_currentMenuId == $node->id ? ' ' . $this->getAttribute('attributeToSelect') . '="' . $this->getAttribute('cssCurrent') . '"' : ''; } } } } if (count($menuNode)) { $menu[] = $menuNode; } if ($node->hasChildNodes()) { $childNodes =& $node->childNodes(); $tempMenu = array(); for ($i = 0; $i < count($childNodes); $i++) { $newEndDepth = max($this->_endDepth + (in_array($node->id, $this->_menuToOpen) ? 1 : 0), $node->depth + (in_array($node->id, $this->_menuToOpen) ? 1 : 0)); if ($this->getAttribute('showOnlyChilds')) { if (in_array($node->id, $this->_menuToOpen) || $this->_startMenu->depth == $node->depth || $this->_currentMenuId == $node->id || $this->getAttribute('drawAllChilds')) { $this->_makeNavigationMenu($childNodes[$i], $newEndDepth, $tempMenu); } } else { $this->_makeNavigationMenu($childNodes[$i], $newEndDepth, $tempMenu); } } if (count($tempMenu)) { $menuNode['node'] = $tempMenu; $menuNode['selected'] = ''; if ($this->getAttribute('flat') && count($menu)) { $menu = array_merge($menu, $menuNode['node']); } else { $menu[] = $menuNode; } } } if ($skip && count($menu)) { $menu = $menu[0]['node']; } }
function _makeChilds() { // ripassa l'array creando i link parente creando l'aray per mappare pageId con ID $menuIdToSort = array(); $IDs = array_keys($this->_siteMapArray); foreach ($IDs as $key) { $menuNode =& $this->_siteMapArray[$key]; $parentId = $menuNode['parentId']; if (!is_bool($menuNode['isVisible'])) { if (preg_match("/\\{php\\:.*\\}/i", $menuNode['isVisible'])) { $phpcode = org_glizy_helpers_PhpScript::parse($menuNode['isVisible']); $menuNode['isVisible'] = eval($phpcode) == 1 ? true : false; } else { $menuNode['isVisible'] = $menuNode['isVisible'] === 'false' ? false : true; } } if (!$this->isAdmin && $menuNode['isLocked'] && !$this->_user->isLogged() && $this->hidePrivatePage) { $menuNode['isVisible'] = false; } $this->_pageTypeMap[strtolower($menuNode['pageType'])] =& $menuNode; if ($this->_type == 'db' && $parentId == 0 || $this->_type == 'xml' && $parentId == '' || $this->_type == '' && $parentId === 0) { continue; } if (isset($this->_siteMapArray[$parentId])) { $menuNodeParent =& $this->_siteMapArray[$parentId]; // aggiunge il riferimento come childNode $menuNodeParent['childNodes'][] = $menuNode['id']; $menuNode['depth'] = $menuNodeParent['depth'] + 1; } else { // cancella il menu // perché è orfano unset($this->_siteMapArray[$key]); // TODO cancellare anche i figli in modo ricorsivo } if ($menuNode['sortChild']) { $menuIdToSort[] = $key; } } // order the menus foreach ($menuIdToSort as $key) { $menuNode =& $this->_siteMapArray[$key]; $tempNode = array(); foreach ($menuNode['childNodes'] as $childId) { $tempNode[$childId] =& $this->_siteMapArray[$childId]; } usort($tempNode, function ($a, $b) { if (!$a['title'] && !$b['title']) { return 0; } else { if (!$a['title']) { return 1; } else { if (!$b['title']) { return -1; } else { return strnatcasecmp($a['title'], $b['title']); } } } }); $menuNode['childNodes'] = array(); foreach ($tempNode as $node) { $menuNode['childNodes'][] = $node['id']; } } $this->_makeDepth($IDs[0], 0); }
/** * @return string */ function getOriginalId() { $originalId = $this->_originalId; if (preg_match("/\\{php\\:.*\\}/i", $originalId)) { $phpcode = org_glizy_helpers_PhpScript::parse($originalId); $originalId = eval($phpcode); } return $originalId; }
function _startProcess($readPageId = true) { $this->log("startProcess", GLZ_LOG_SYSTEM); $this->checkSwitchLanguage(); $controller = __Request::get('controller', '', GLZ_REQUEST_ROUTING); if ($controller) { $controllerClass = org_glizy_ObjectFactory::createObject($controller, null, $this); org_glizy_helpers_PhpScript::callMethodWithParams($controllerClass, 'execute'); } $this->readSiteProperties(); $this->setTemplateFolder(); if ($readPageId) { $evt = array('type' => GLZ_EVT_BEFORE_CREATE_PAGE); $this->dispatchEvent($evt); $this->_readPageId(); } if ($this->siteMapMenu->isVisible === false) { while (true) { $parentMenu =& $this->siteMapMenu->parentNode(); if (is_null($parentMenu)) { // ERROR $e = new org_glizy_Exception(array('[%s] %s', $this->getClassName(), __T(GLZ_ERR_EMPTY_APP_PATH))); } $this->siteMapMenu =& $parentMenu; if ($parentMenu->isVisible === true) { $this->_pageId = $this->siteMapMenu->id; break; } } } // TODO da risolvare in modo migliore // creando un nuovo menu_type if ($this->siteMapMenu->pageType == 'Empty') { $currentPage =& $this->siteMapMenu; while (true) { $childNodes = $currentPage->childNodes(); if (!count($childNodes)) { org_glizy_helpers_Navigation::gotoUrl(GLZ_HOST); break; } $tempPage =& $childNodes[0]; $currentPage =& $tempPage; if ($currentPage->pageType != 'Empty') { $this->siteMapMenu =& $currentPage; $this->_pageId = $currentPage->id; break; } } } parent::_startProcess(false); }