Example #1
0
 function Save($strText = false)
 {
     if ($strText === false) {
         $strText = $this->toString();
         if ($strText === false) {
             return false;
         }
     } else {
         //replace break lines by \\n for textarea var
         $tabResult = $this->parseIniFromString(stripslashes($strText));
         $strText = $this->toString($tabResult);
     }
     if (!$this->_Modified($strText)) {
         return true;
     }
     if (!deleteMenuCache()) {
         return false;
     }
     //save without stripslashes
     return parent::Save($strText, false);
 }
Example #2
0
 function createDir($strDirName)
 {
     $strDirName = trim($strDirName);
     if (!$this->checkName($strDirName)) {
         return false;
     }
     $strPageName = $strDirName;
     $strDirName = $this->getUnixName($strPageName);
     if (getFileObjectAndFind($this->path . SLASH . $strDirName, 'dir') !== false) {
         return setError(sprintf(_('The directory %s exists.'), $strDirName));
     }
     //on supprime le cache du menu
     if (!deleteMenuCache()) {
         return false;
     }
     if (!parent::createDir($strDirName)) {
         return false;
     }
     //set the virtual name
     if (!($oDir = getFileObject($this->path . SLASH . basename($strDirName)))) {
         return setError('internal error, pdircategory, createDir');
     }
     if (!$oDir->setVirtualName($strPageName)) {
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * Rename the page.
  * This function is called to rename the page.
  * If the new name of the page contains specific caracters as éà, it is replace by ea,
  * but the menu name is set with special caracters
  * An event is attached to this fonction: renamepage
  * This event is used for example by the search engine plugin to index the file content.
  * 
  * The difference between move and rename, is that in move do not set the menu title !!
  * @param string $newname, the new name (basename)
  * @param string $destDir, if == false the parent dir
  * @return true if suceed
  */
 function Rename($newname, $destDir = false)
 {
     $fileNewName = $this->getUnixName($newname);
     $pageNewName = $newname;
     $pageCurrName = $this->getVirtualName();
     $fileCurrName = $this->getName();
     if (strlen($fileNewName) == 0) {
         return setError(_('Can not rename with empty name'));
     }
     //manage extensions
     $oFile = new PFile($fileNewName);
     if ($oFile->getExtension() == '') {
         $fileNewName .= '.' . $this->getExtension();
     } else {
         $oFile = new PFile($pageNewName);
         $pageNewName = $oFile->getNameWithoutExt();
     }
     if ($fileNewName == $fileCurrName && $pageCurrName == $pageNewName && $destDir === false) {
         return true;
     }
     //check the name is valid, not a php file or a cgi one for example
     if (!$this->checkname($pageNewName)) {
         return false;
     }
     //set the menu name in the ini file if has been renamed !! not moved
     if (!$destDir && !$this->setVirtualName($pageNewName)) {
         return false;
     }
     if ($fileCurrName != $fileNewName || $destDir !== false) {
         //if history dir exists, rename it
         $oDirHistoryCache = new PDir(CACHE_HIST_DIR . SLASH . $this->getId());
         if (is_dir($oDirHistoryCache->path)) {
             $destDirModify = !$destDir ? $this->getParentPath() : $destDir;
             if (substr($destDirModify, -1) == SLASH) {
                 $destDirModify = substr($destDirModify, 0, strlen($destDirModify) - 1);
             }
             $oPageNewHistory = new PPage($destDirModify . SLASH . $fileNewName);
             $strNewHistoryName = $oPageNewHistory->getId();
             if ($this->getId() != $strNewHistoryName) {
                 if (!$oDirHistoryCache->Rename($strNewHistoryName)) {
                     return false;
                 }
             }
         }
         if (!doEventAction('renamepage', array(&$this, ($destDir ? $destDir : $this->getParentPath()) . SLASH . $fileNewName))) {
             return false;
         }
         //on supprime le cache du menu
         if (!deleteMenuCache()) {
             return false;
         }
         //rename the config file if exists
         if (is_file($this->oPConfigFile->path)) {
             $oFileTmp = new PFile($fileNewName);
             if (!$this->oPConfigFile->Rename($oFileTmp->getNameWithoutExt() . ".ini", $destDir)) {
                 return false;
             }
         }
         if (!parent::Rename($fileNewName, $destDir)) {
             return false;
         }
     }
     return true;
 }
Example #4
0
 /**
  * Function: display
  * If page has not been cached, calculate it.
  * Then call the smarty display fonction
  *
  *
  * param: &$oPage, a reference to the object page to display
  */
 function displayPage(&$oPage)
 {
     $strTemplateName = $oPage->getTemplateName();
     $strCompiledId = $this->getCompiledId();
     $this->oPageCurrent =& $oPage;
     $this->register_object('oPageCurrent', $oPage);
     //if page must not be cached, set the site cache to 0
     $this->caching = $this->caching && $oPage->isCached() ? 1 : 0;
     //on regénére le menu si le menu n'existe pas en cache ou si la page courante a été modifiée après le menu
     $bGenerateMenu = !is_file(SMARTY_CACHE_DIR . 'menu.cache');
     //|| (is_file(SMARTY_CACHE_DIR.'menu.cache') && $oPage->getModifiedTime()>filemtime(SMARTY_CACHE_DIR.'menu.cache'));
     //rebuild menu not exist (a page has been updated) or the page if cache not exists or page not use cache
     if ($bGenerateMenu || $this->caching == 0 || $this->force_compile || !$this->is_cached($strTemplateName, $strCompiledId)) {
         //check that the template file exists
         if (!is_file($this->template_dir . SLASH . $strTemplateName)) {
             setError(sprintf(_("The template file %s doesn't exist."), $strTemplateName));
             printFatalHtmlError();
         }
         //si on doit regénérer le menu, on le supprime avant
         if ($bGenerateMenu) {
             if (!deleteMenuCache()) {
                 printFatalError();
             }
         }
         //assign the menu
         $this->assign_by_ref("menu", $this->getMenu(isConnected()));
         $this->assign("PAGE_PATH", $oPage->path);
         $this->assign("PAGE_CONTENU", $oPage->path);
         $this->assign("PAGE_PATH_TITLE", $oPage->getPagePathForTitle());
         $this->assign('MEDIAS_URL', POFile::getPathUrl(MEDIAS_PATH));
         $oPageConfigFile = $oPage->getConfigFileObject();
         if (is_file($oPageConfigFile->path)) {
             $this->assign("CONFIG_FILE_PAGE", $oPageConfigFile->path);
         }
         $oCatConfigFile = $oPage->getConfigFileObjectCategory();
         if (is_file($oCatConfigFile->path)) {
             $this->assign("CONFIG_FILE_CATAGORY", $oCatConfigFile->path);
         }
         //we load filter only in case of cache
         $this->loadAdminFilters();
     }
     //end calcul
     if (true || checkKey()) {
         //display the page !!
         $strContent = parent::fetch($strTemplateName, $strCompiledId);
         doEventAction('beforedisplay', array(&$strContent, &$this));
         echo $strContent;
     } else {
         printError();
     }
 }