Esempio n. 1
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;
}
$_SESSION['LAST_ROOTPATH'] = isset($_GET["rootpath"]) ? $_GET["rootpath"] : '';
$_SESSION['LAST_CURRENT_DIR'] = isset($_GET["current_dir"]) ? $_GET["current_dir"] : '';
if (!isset($_GET["rootpath"]) || $_GET["rootpath"] == '' || preg_match("/\\.\\./", urldecode($_GET["rootpath"]))) {
    if (isset($_GET["current_dir"]) && $_GET["current_dir"] != '' && !preg_match("/\\.\\./", urldecode($_GET["current_dir"]))) {
        $rootpath = SITE_PATH . urljsdecode($_GET["current_dir"]);
        $_GET["current_dir"] = '';
    } else {
        $rootpath = SITE_PATH;
    }
} else {
    $rootpath = SITE_PATH . (isset($_GET["rootpath"]) ? urldecode($_GET["rootpath"]) : '');
}
if (!isset($_GET["current_dir"]) || $_GET["current_dir"] == '' || preg_match("/\\.\\./", urldecode($_GET["current_dir"]))) {
    $current_dir = $rootpath;
} else {
    $current_dir = $rootpath . SLASH . urljsdecode($_GET["current_dir"]);
}
$pcurrent_dir =& getFileObject($current_dir);
$proot_dir = new PDir($rootpath);
if (!is_dir($rootpath)) {
    die('root path not exists.');
}
if (!$pcurrent_dir) {
    die('current directory not found');
}
$rootpathdir = $proot_dir->getRelativePath();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">