예제 #1
0
 function listDir($options = 0, $fullpath = true, $filter = ".*", $filterFalse = false, $nofilter = false)
 {
     $tabList = parent::listDir($options, $fullpath, $filter, $filterFalse, $nofilter);
     //order by menu order
     $tabOrdered = array();
     foreach ($tabList as $aFile) {
         $oFileFilter = new PFile($this->path . SLASH . basename($aFile));
         $iOrder = 100;
         if ($oFileFilter->is_page() || $oFileFilter->is_dircategory() || $oFileFilter->is_link()) {
             $oPage =& getFileObject($oFileFilter->path);
             $iOrder = $oPage->getMenuOrder();
         }
         $strOrder = strlen('' + $iOrder) < 2 ? '0' . $iOrder : '' . $iOrder;
         $tabOrdered[$strOrder . '_' . basename($aFile)] = $aFile;
     }
     ksort($tabOrdered);
     $tabReturn = array();
     foreach ($tabOrdered as $k => $aFile) {
         $tabReturn[] = $aFile;
     }
     return $tabReturn;
 }
예제 #2
0
/**
 * Function sortpages
 * This fonction is call by the sortfile javascript plugins.
 * It renames the files. The file begin with a number are ordered.
 * 
 * If an object file not begin with a number, it is not ordered. 
 * 
 * @return: true if suceed, else return false.
 */
function sortpages()
{
    if (!isset($_REQUEST['filename'])) {
        return setError('Internal error in sortfiles, filename not defined');
    }
    $tabFilesNew = $_REQUEST['filename'];
    //if less than two files no need to sort
    if (sizeof($tabFilesNew) < 2) {
        return true;
    }
    //get the dir to order, take the second element because in some cas the first element is ../
    $pTemp = new PFile(SITE_PATH . urljsdecode($tabFilesNew[1]));
    $oDirToOrder = new PDir($pTemp->getParentPath());
    $i = 0;
    foreach ($tabFilesNew as $strFile) {
        $strFile = urljsdecode($strFile);
        //if not parent file
        if (SITE_PATH . $strFile != $oDirToOrder->getParentPath()) {
            //get the file number, if number exist reorder it
            //this is the original file number, if modified twice it change in php but not in html
            $oFileTest = new PFile($oDirToOrder->path . SLASH . basename($strFile));
            if ($oFileTest->is_page() || $oFileTest->is_dircategory() || $oFileTest->is_link()) {
                $oFile = getFileObject($oFileTest->path);
                $iCurrOrder = $oFile->getMenuOrder();
                $i++;
                if ($iCurrOrder != $i) {
                    //print('reorder '.$oFile->getName().' from '.$iCurrOrder.' to '.$i);
                    if (!$oFile->setMenuOrder($i)) {
                        return false;
                    }
                }
                //if file order has changed
            }
            //end if filenumber is set
        }
        //end if ofile not parent dir
    }
    //end foreach
    return true;
}
예제 #3
0
 /**
  * getFileObject
  * Return the file object depending of its type.
  * For example is the path is a directory, return a PDir object.
  *
  * @param string $strFilePath, the full path to the file
  * @return the file object PPage, PDir ....
  */
 function getFileObject($strFilePath)
 {
     $objFile = new PFile($strFilePath);
     if (is_dir($objFile->path)) {
         return $objFile->is_dircategory() ? new PDirCategory($strFilePath) : new PDir($strFilePath);
     }
     if (is_dir($newpath = utf8_decode($objFile->path))) {
         return $objFile->is_dircategory() ? new PDirCategory($newpath) : new PDir($newpath);
     }
     if ($objFile->is_link()) {
         return new PLink($strFilePath);
     }
     if ($objFile->is_configfile()) {
         return new PConfigFile($strFilePath, basename($strFilePath) != basename(CONFIG_FILE) ? CONFIG_FILE : false);
     }
     if ($objFile->is_image()) {
         return new PImage($strFilePath);
     }
     //if($objFile->is_video()) $objFile = new PVideo($file);
     if ($objFile->is_page_model()) {
         require SITE_PATH . 'core/lib/ppagemodel.php';
         return new PPageModel($strFilePath);
     }
     if ($objFile->is_page()) {
         return new PPage($strFilePath);
     }
     if ($objFile->is_texteditable()) {
         return new PTextFile($strFilePath);
     }
     return $objFile;
 }