if (!$linker->admin->isAdmin()) { /*if(!($linker->rights->getUserRights() & sh_rights::RIGHT_READ)){ $linker->path->error(403); exit; }*/ $cache = sh_cache::getCachedFile(); if ($cache) { echo $cache; exit(1); } } // Gets some variables $element = $linker->path->page['element']; $action = $linker->path->page['action']; if (!$linker->{$element}->isMinimal($action)) { sh_html::$willRender = true; } // Redirect to the 404 error page if the required method doesn't exist. if (!method_exists($linker->{$element}, $action)) { $linker->path->error('404'); } $linker->events->onAfterBaseConstruction(); // Calls the method $linker->{$element}->{$action}(); $linker->events->onBeforeOutput(); // If the action is not minimal, we render the html if (!$linker->{$element}->isMinimal($action)) { // Renders the document $linker->html->render(); } $linker->events->onAfterOutput();
public function render() { $this->debug('function : ' . __FUNCTION__, 2, __LINE__); self::$willRender = false; // We check if there are classes to construct before managing the contents (as they may add some) $classes = $this->helper->getClassesSharedMethods(__CLASS__, 'construct'); foreach ($classes as $class) { $tempClass = $this->linker->{$class}; } $tempClass = null; // We first prepare the common contents for mobile and complete versions $specialContentsClasses = $this->get_shared_methods('add_special_content'); foreach ($specialContentsClasses as $class) { $this->linker->{$class}->add_special_content(); } $data = $this->specialContents; $data['html']['isAdminPage'] = $this->helper->isAdminPage(); if ($data['html']['isAdminPage']) { $data['html']['isAdminPage_class'] = 'this_is_an_admin_page'; } else { $data['html']['isAdminPage_class'] = 'this_is_not_an_admin_page'; } $data['body']['headline'] = $this->getHeadLine(); $data['body']['title'] = $this->getTitle(true); $data['body']['content'] = ''; $data['body']['beforeContent'] = ''; if (!empty($_SESSION[__CLASS__]['messages_alert'])) { $values['messages'] = $_SESSION[__CLASS__]['messages_alert']; $data['body']['content'] .= parent::render('message_alert', $values, false, false); $data['body']['beforeContent'] .= parent::render('message_alert', $values, false, false); unset($_SESSION[__CLASS__]['messages_alert']); } if (!empty($_SESSION[__CLASS__]['messages_normal'])) { $values['messages'] = $_SESSION[__CLASS__]['messages_normal']; $data['body']['content'] .= parent::render('message_normal', $values, false, false); $data['body']['beforeContent'] .= parent::render('message_normal', $values, false, false); unset($_SESSION[__CLASS__]['messages_normal']); } $data['body']['onlyContent'] = $this->getBodyContent(); $data['body']['content'] .= $data['body']['onlyContent']; $data['body']['logo'] = $this->linker->site->logo; $data['body']['copyrights'] = $this->linker->legacy->getLegacyLine(); $data['body']['analytics'] = $this->linker->googleServices->getAnalytics(true); /*if($this->linker->session->checkIfIsMobileDevice()) { // We render using a special template // We only get the first menu for the mobile template $menuNumber = 1; $data['menu'] = $this->linker->menu->getForMobile($menuNumber); $data['language']['selector'] = $this->linker->i18n->getLanguageSelector(true); $data['head']['content'] = $this->getHead(true); // Sending to classic mode $uri = $this->linker->path->url; if(strpos($uri,'?') === false) { $linkerChar = '?'; }else { $linkerChar = '&'; } $data['mode']['classicLink'] = $uri.$linkerChar.'mode=classic'; $variation = $this->linker->site->variation; $data['variation']['background'] = $this->getParam('variation_'.$variation); // Rendering $pageContent = parent::render('mobile_template',$data,false,false); $pageContent = str_replace('</body>',$data['body']['adminpanel'].$data['body']['analytics'].'</body>',$pageContent); $pageContent = $this->linker->renderer->toHtml($pageContent); $docType = '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">'."\n"; }else {/**/ // We render the complete version $this->linker->javascript->get(sh_javascript::SCRIPTACULOUS); $this->linker->javascript->get(sh_javascript::POPUPS); $this->linker->javascript->get(sh_javascript::WINDOW); $this->addCSS('main.css', 'MAIN', '/templates/global/global.css', 'GLOBAL'); $data['language']['selector'] = $this->linker->i18n->getLanguageSelector(); $loadClasses = $this->linker->template->get('loadClasses', array()); if (is_array($loadClasses)) { foreach ($loadClasses as $loadClass) { $this->linker->{$loadClass}; } } // Prepares the data for the output $this->bodyContent = $this->fromRoot(str_replace('#TEMPLATE_DIR#', $this->template, $this->bodyContent)); // Sets the variables to fill the output $data['body']['adminpanel'] = $this->linker->admin->get(); $data['body']['searchEngine'] = $this->linker->searcher->get(); for ($menuNumber = 1; $menuNumber <= $this->menusNumber; $menuNumber++) { $data['body']['menu_' . $menuNumber] = $this->linker->menu->get($menuNumber); } $data['body']['global_image'] = str_replace(SH_ROOT_FOLDER, SH_ROOT_PATH, $this->global_image); $data['body']['global_image_text'] = $this->global_image_text; $data['diaporamas']['display'] = $this->linker->site->diaporamaDisplay; $data['body']['otherContents'] = $this->getOtherContent(); $data['body']['otherContents'] .= '<script>$$(".toggle_next_element").each(function(el){el.next().addClassName("toggle_keep_hidden")});</script>'; $data['body']['otherContents'] .= '<style>.toggle_keep_hidden{display:none;}</style>'; //$data['body']['analytics'] = $this->linker->googleServices->getAnalytics(true); $ending = ''; $data['body']['analytics'] .= '<script type="text/javascript">' . $this->endingScripts . '</script>'; list($action, $link) = $this->linker->user->getConnectionLink(); $data[$action]['link'] = $link; $data['profile']['link'] = $this->linker->user->getProfileLink(); // These vars should be built just before rendering, // to be sure that they contain everything that is built $this->addToBody('class', 'shopsailors_navigator'); $data['body']['data'] = $this->getBodyData(); $data['body']['beginning'] = $this->getAfterBody(); $data['head']['content'] = $this->getHead(); // Renders the html document $template = $this->template . '/template.rf.xml'; if (!empty($this->specialTemplate)) { $template = $this->specialTemplate; } $pageContent = parent::render($template, $data, false, false); $pageContent = str_replace('</body>', $data['body']['adminpanel'] . $data['body']['analytics'] . '</body>', $pageContent); $pageContent = $this->linker->renderer->toHtml($pageContent); $docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n"; /*}/**/ $cpt = 1; $pageContent = str_replace('<html ', '<html xmlns="http://www.w3.org/1999/xhtml" ', $pageContent, $cpt); // xmlDeclaration $xmlTag = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n"; // DocType $pageContent = $xmlTag . $docType . $pageContent; if ($_SESSION['this_is_a_temp_session']) { // We don't cache temp sessions pages $pageContent = preg_replace(array('`(src|href)="([^\\?"]*)"`', '`(src|href)="([^"]*)\\?([^"]*)"`'), array('$1="$2?nothing_special=true"', '$1="$2?$3&temp_session=' . $_SESSION['temp_session'] . '"'), $pageContent); echo $pageContent; } else { echo sh_cache::saveCache($pageContent); } }