/** * {@inheritdoc} */ public function collect() { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $result = array(); $result['pageId'] = $application->getPageId(); $result['routing'] = __Request::get('__routingName__') . ' > ' . __Request::get('__routingPattern__'); $result['controllers'] = implode(', ', $this->calledControllers); $user = $application->getCurrentUser(); $userData = array('id' => $user->id, 'firstName' => $user->firstName, 'lastName' => $user->lastName, 'email' => $user->email, 'groupId' => $user->groupId, 'backEndAccess' => $user->backEndAccess); $result['user'] = $this->getDataFormatter()->formatVar($userData); $menu = $application->getCurrentMenu(); $menuData = array('id' => $menu->id, 'title' => $menu->title, 'parentId' => $menu->parentId, 'pageType' => $menu->pageType, 'type' => $menu->type, 'depth' => $menu->depth); $result['menu'] = $this->getDataFormatter()->formatVar($menuData); // request $data = __Request::getAllAsArray(); $tempData = array(); foreach ($data as $k => $v) { if (strpos($k, '__') !== 0) { $tempData[$k] = $v; } } $result['__Request'] = $this->getDataFormatter()->formatVar($tempData); $result['__Config'] = $this->getDataFormatter()->formatVar(__Config::getAllAsArray()); $result['__Routing'] = $this->getDataFormatter()->formatVar(__Routing::getAllAsArray()); $result['__Session'] = $this->getDataFormatter()->formatVar(__Session::getAllAsArray()); return $result; }
function executeLater() { if ($this->submit) { if ($this->controller->validate()) { $isNewRecord = $this->id == 0; $ar = org_glizy_ObjectFactory::createModel($this->modelName); $ar->loadFromArray(__Request::getAllAsArray()); $this->id = $ar->save(); $this->redirect($isNewRecord); } } }
/** * Render * * @return void * @access public */ function render_html() { $folder = $this->getAttribute('folder'); $src = $this->getAttribute('src'); $type = $this->getAttribute('type'); $language = $this->_application->getLanguage(); $language2 = $language . '-' . strtoupper($language); $src = str_replace(array('##LANG##', '##LANG2##'), array($language, $language2), $src); if ($folder) { if (!org_glizy_ObjectValues::get('org.glizy.JS', 'run', false)) { org_glizy_ObjectValues::set('org.glizy.JS', 'run', true); $pageType = $this->_application->getPageType(); $state = __Request::get('action', ''); $params = __Request::getAllAsArray(); unset($params['__params__']); unset($params['__routingName__']); unset($params['__routingPattern__']); unset($params['__url__']); unset($params['__back__url__']); $params = json_encode($params); $jsCode = <<<EOD var GlizyApp = {}; GlizyApp.pages = {}; jQuery( function(){ \tif ( typeof( GlizyApp.pages[ '{$pageType}' ] ) != 'undefined' ) \t{ \t\tGlizyApp.pages[ '{$pageType}' ]( '{$state}', {$params} ); \t} }) EOD; $this->addOutputCode(org_glizy_helpers_JS::JScode($jsCode), 'head'); } // include tutta una cartella $jsFileName = $this->includeFolder($folder); if ($this->getAttribute('inline')) { $js = file_get_contents($jsFileName); if (strpos($js, '<script') !== false) { $this->addOutputCode($js); } else { $this->addOutputCode(org_glizy_helpers_JS::JScode($js, $type)); } } else { $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($jsFileName . (__Config::get('DEBUG') ? '?' . microtime(true) : ''), null, $type)); } } else { if ($src) { $this->addOutputCode(org_glizy_helpers_JS::linkJSfile($src, null, $type)); } else { $this->addOutputCode(org_glizy_helpers_JS::JScode($this->replaceLocale($this->getText()), $type)); } } }
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']; } }
public function afterRender($content) { $this->etag = md5($content . var_export(__Request::getAllAsArray(), true)); $this->checkIfIsChanged(); }
function _startProcess() { foreach ($this->proxyMap as $k => $v) { $v->onRegister(); } $method = __Request::$method ? __Request::$method : 'get'; $controller = __Request::get('controller', ''); $status = 200; $directOutput = false; $result = array(); if ($method != 'options' && $controller) { $actionClass = org_glizy_ObjectFactory::createObject($controller, $this); if (is_object($actionClass)) { $reflectionClass = new ReflectionClass($actionClass); $callMethod = ''; if ($reflectionClass->hasMethod("execute_" . $method)) { $callMethod = "execute_" . $method; } else { if ($reflectionClass->hasMethod("execute")) { $callMethod = "execute"; } } if ($callMethod) { $reflectionMethod = $reflectionClass->getMethod($callMethod); $methodParams = $reflectionMethod->getParameters(); $params = array(); foreach ($methodParams as $v) { $params[] = __Request::get($v->name); } $result = call_user_func_array(array($actionClass, "execute"), $params); $directOutput = $actionClass->directOutput; if (is_array($result)) { if (isset($result['http-status'])) { $status = $result['http-status']; unset($result['http-status']); } else { if (isset($result['httpStatus'])) { $status = $result['httpStatus']; unset($result['httpStatus']); } } $keys = array_keys($result); if (count($result) == 1 && $keys[0] === 0) { $result = $result[0]; } } else { if (is_object($result)) { if (property_exists($result, 'httpStatus')) { $status = $result->httpStatus; unset($result->httpStatus); } } } } else { $status = 501; } } else { $status = 404; } } else { if ($method == 'options') { $status = 200; } else { $status = 404; } } if ($result === false) { $status = 500; } if ($status === 404) { $report = array(); $report['Request'] = __Request::getAllAsArray(); $report['_SERVER'] = $_SERVER; $this->log($report, GLZ_LOG_SYSTEM, 'glizy.404'); } $httpAccept = strpos(@$_SERVER['HTTP_ACCEPT'], 'xml') !== false ? 'xml' : 'json'; // sent response header('Cache-Control: no-cache'); header('Pragma: no-cache'); header('Expires: -1'); header($_SERVER['SERVER_PROTOCOL'] . ' ' . $status . ' ' . $this->getStatusCodeMessage($status)); if ($result) { if ($httpAccept == 'json') { header("Content-Type: application/json; charset=utf-8"); if (!$directOutput) { // @ serve per evitare waring di conversione nel caso ci siano caratteri non utf8 echo @json_encode($result); } else { echo $result; } } else { header("Content-Type: text/xml; charset=" . GLZ_CHARSET); if (!is_array($result) || !isset($result['result'])) { $result = array('result' => $result); } echo $this->createXml($result); } } }
/** * @param bool $readPageId */ function _startProcess($readPageId = true) { $this->log("startProcess", GLZ_LOG_SYSTEM); if ($this->_logObj) { $this->log(array('Request' => __Request::getAllAsArray()), GLZ_LOG_SYSTEM); } if ($readPageId) { $evt = array('type' => GLZ_EVT_BEFORE_CREATE_PAGE); $this->dispatchEvent($evt); $this->_readPageId(); } org_glizy_ObjectValues::set('org.glizy.application', 'pageId', $this->_pageId); $this->_pageType = $this->siteMapMenu->pageType; if (__Request::exists('__middleware__')) { $middlewareObj = org_glizy_ObjectFactory::createObject(__Request::get('__middleware__')); // verify the cache before page rendering // this type of cache is available only for Static Page if ($middlewareObj) { $middlewareObj->beforeProcess($this->_pageId, $this->_pageType); } } org_glizy_ObjectFactory::createPage($this, $this->_pageType, null, array('pathTemplate' => org_glizy_Paths::get('APPLICATION_TEMPLATE'))); if (!is_null($this->_rootComponent)) { if (!$this->_ajaxMode) { // serve per resettare lo stato del sessionEx ad ogni caricamento delle pagine // altrimenti gli stati vecchi non vengono cancellati // quando c'è un cambio di pagina e SessionEx non è usato org_glizy_ObjectFactory::createObject('org.glizy.SessionEx', ''); $this->_rootComponent->resetDoLater(); $this->_rootComponent->init(); $this->_rootComponent->execDoLater(); $this->log("Process components", GLZ_LOG_SYSTEM); $this->_rootComponent->resetDoLater(); $evt = array('type' => GLZ_EVT_START_PROCESS); $this->dispatchEvent($evt); if (method_exists($this, 'process_onStart')) { $this->process_onStart(); } $this->_rootComponent->process(); if (method_exists($this, 'process_onEnd')) { $this->process_onEnd(); } $this->_rootComponent->execDoLater(); $evt = array('type' => GLZ_EVT_END_PROCESS); $this->dispatchEvent($evt); // check if enable the PDF output if ($this->getCurrentMenu()->printPdf) { $pdfPage = org_glizy_Paths::getRealPath('APPLICATION_TEMPLATE', 'pdf.php'); if ($pdfPage !== false) { if (__Request::get('printPdf', '0')) { org_glizy_ObjectValues::set('org.glizy.application', 'pdfMode', __Request::get('printPdf', '0') == '1'); } } else { $this->getCurrentMenu()->printPdf = false; } } $evt = array('type' => GLZ_EVT_START_RENDER); $this->dispatchEvent($evt); $this->_rootComponent->resetDoLater(); if (method_exists($this, 'render_onStart')) { $this->render_onStart(); } $this->addJScoreLibraries(); $output = $this->_rootComponent->render(); if (method_exists($this, 'render_onEnd')) { $this->render_onEnd(); } $this->_rootComponent->execDoLater(); $evt = array('type' => GLZ_EVT_END_RENDER); $this->dispatchEvent($evt); $headerErrorCode = __Request::get('glizyHeaderCode', ''); if ($headerErrorCode == '404') { header("HTTP/1.1 404 Not Found"); header("Status: 404 Not Found"); } header("Content-Type: " . $this->contentType . "; charset=" . __Config::get('CHARSET')); if ($middlewareObj) { // verify the cache after content rendering $middlewareObj->afterRender($output); } echo $output; } else { $this->startProcessAjax(); } } else { // TODO // visualizzare errore } }
} } } echo '</div></li>'; ob_start(); debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $string .= ob_get_clean(); $errors = explode("\n", $string); for ($i = 3; $i < count($errors); $i++) { if (!empty($errors[$i])) { $err = str_replace($realPathCore, '', $errors[$i]); $err = str_replace('#' . $i, '#' . ($i - 1), $err); echo '<li>' . $err . '</li>'; } } ?> </ul> <h3>Request variables</h3> <ul> <?php $params = __Request::getAllAsArray(); foreach ($params as $k => $v) { if (!empty($v)) { echo '<li><strong>' . $k . '</strong> ' . $v . '</li>'; } } ?> </ul> </div> </body> </html>