コード例 #1
0
 /**
  * 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);
     }
 }
コード例 #2
0
 /**
  * Changes the current main language as normal language
  *
  * @param  object optional The current main language 
  * 
  * @return bool false - The save operation failed
  *              true  - Operation success
  */
 private function resetMain($mainLanguage = null)
 {
     $result = true;
     if ($mainLanguage == null) {
         $mainLanguage = W3sLanguagePeer::getMainLanguage();
     }
     $mainLanguage->setMainLanguage(0);
     $result = $mainLanguage->save();
     if ($mainLanguage->isModified() && $result == 0) {
         $result = false;
     }
     return $result;
 }