Exemplo n.º 1
0
 function Copy($strNewName, $strParentPath = false)
 {
     $strCPageName = $strNewName;
     $strCDirName = $this->getUnixName($strNewName);
     if (strlen($strCDirName) == 0) {
         return setError(_("Can not copy page with empty name."));
     }
     if (!$this->checkname($strCPageName)) {
         return false;
     }
     if (!$strParentPath) {
         $strParentPath = $this->getParentPath();
     }
     $strCDirPath = $strParentPath . SLASH . $strCDirName;
     if (getFileObjectAndFind($strCDirPath)) {
         return setError(sprintf(_('Page %s ever exists.'), $strNewName));
     }
     //reset the menucache
     if (!deleteMenuCache()) {
         return false;
     }
     //Copy the directory
     if (!parent::Copy($strCDirName, $strParentPath)) {
         return false;
     }
     //then copy the ini file if exists
     if (!($oCDirCategory =& getFileObject($strCDirPath))) {
         return setError(_('Internal Error. In copy, page not exists'));
     }
     if (is_file($this->oPConfigFile->path)) {
         if (!$this->oPConfigFile->Copy($oCDirCategory->oPConfigFile->getName(), $strParentPath)) {
             return false;
         }
     }
     //reset the MENU NAME for the newfile, set the menu order and set the virtual name
     if (!$oCDirCategory->oPConfigFile->setParam('MENU_NAME', '')) {
         return false;
     }
     if (!$oCDirCategory->oPConfigFile->setParam('MENU_ORDER', '99')) {
         return false;
     }
     if (!$oCDirCategory->setVirtualName($strCPageName)) {
         return false;
     }
     return true;
 }