/** * Executes add action * */ public function executeAdd($request) { if ($request->hasParameter('languageName')) { $language = W3sLanguagePeer::getFromLanguageName($this->getRequestParameter('languageName')); if ($language == null) { $isMain = $request->hasParameter('isMain') ? $this->getRequestParameter('isMain') : 0; $params = array("isMain" => $isMain, "languageName" => $this->getRequestParameter('languageName')); $language = new w3sLanguageManager(); $result = $language->add($params); } else { $result = 2; } } else { $result = 4; } if ($result != 1) { $this->getResponse()->setStatusCode(404); } return $this->renderPartial('add', array('result' => $result)); }
/** * Constructor. * * @param int The current language id * @param int The current page id * */ public function __construct($language, $page) { // When language is null, main language is retrieved if ($language == null) { $language = 'none'; } // When page is null, home page is retrieved if ($page == null) { $page = 'none'; } // Checks that the two parameters are integers values if ((int) $language == 0) { $oLanguage = $language != 'none' ? W3sLanguagePeer::getFromLanguageName($language) : W3sLanguagePeer::getMainLanguage(); } else { $oLanguage = DbFinder::from('W3sLanguage')->findPk($language); //W3sLanguagePeer::getMainLanguage(); } if ($oLanguage != null) { $this->idLanguage = $oLanguage->getId(); $this->languageName = $oLanguage->getLanguage(); } else { $this->idLanguage = -1; $this->languageName = 'none'; } if ((int) $page == 0) { $oPage = $page != 'none' ? W3sPagePeer::getFromPageName($page) : W3sPagePeer::getHomePage(); } else { $oPage = DbFinder::from('W3sPage')->findPk($page); } if ($oPage != null) { $this->idPage = $oPage->getId(); $this->pageName = $oPage->getPageName(); } else { $this->idPage = -1; $this->pageName = 'none'; } if ($this->idPage != -1) { $this->setTemplateInfo($this->idPage); } }