/** * Draws the web page * */ public function executeIndex() { $this->template = new w3sTemplateEngineFrontend($this->getRequestParameter('lang'), $this->getRequestParameter('page')); $styles = $this->template->retrieveTemplateStylesheets($this->template->getPageContents()); foreach ($styles as $style) { $this->response->addStyleSheet($style["href"], 'last', array('media' => $style["media"])); } if ($this->template->getIdLanguage() == -1) { $message = sprintf($this->getContext()->getI18N()->__('The language %s does not exist'), $this->getRequestParameter('lang')); } else { if ($this->template->getIdPage() == -1) { $message = sprintf($this->getContext()->getI18N()->__('The page %s does not exist for the language %s'), $this->getRequestParameter('page'), $this->template->getLanguageName()); } else { $message = null; } } //$this->forward404If($this->template->getIdLanguage() == -1 || $this->template->getIdPage() == -1, $message); $this->includeFiles($this->template->getJavascripts()); $this->includeFiles($this->template->getStylesheets()); // Retrieves the page's metatags $oMetatag = W3sSearchEnginePeer::getFromPageAndLanguage($this->template->getIdLanguage(), $this->template->getIdPage()); // Sets metatags $this->getResponse()->addMeta('title', $oMetatag != null ? $oMetatag->getMetaTitle() : sfConfig::get('app_w3s_meta_title', 'A website powered by W3StudioCMS')); $this->getResponse()->addMeta('keywords', $oMetatag != null ? $oMetatag->getMetaKeywords() : sfConfig::get('app_w3s_meta_keywords', '')); $this->getResponse()->addMeta('description', $oMetatag != null ? $oMetatag->getMetaDescription() : sfConfig::get('app_w3s_meta_description', '')); }
/** * Saves the metatags for the current page * */ public function executeSaveMetas($request) { if ($request->hasParameter('lang') && $request->hasParameter('page')) { if ($this->getRequestParameter('lang') != 0 && $this->getRequestParameter('page') != 0) { $oMetas = W3sSearchEnginePeer::getFromPageAndLanguage($this->getRequestParameter('lang'), $this->getRequestParameter('page')); // W3StudioCMS adds a new meta, if metatags for corrent page haven't already been setted if ($oMetas == null) { $oMetas = new W3sSearchEngine(); } $metaValues = array("PageId" => $this->getRequestParameter('page'), "LanguageId" => $this->getRequestParameter('lang'), "MetaTitle" => $this->getRequestParameter('title'), "MetaDescription" => $this->getRequestParameter('description'), "MetaKeywords" => $this->getRequestParameter('keywords')); $oMetas->fromArray($metaValues); $result = $oMetas->save(); } else { $result = 4; $this->getResponse()->setStatusCode(404); } } else { $result = 2; $this->getResponse()->setStatusCode(404); } return $this->renderPartial('saveMetatags', array('result' => $result)); }