コード例 #1
0
ファイル: variables.all.php プロジェクト: MenZil/pluck
    define('THEME_DIR', 'data/themes/' . $themepref);
}
if (isset($direction) && ($direction = 'rtl')) {
    define('DIRECTION_RTL', true);
} else {
    define('DIRECTION_RTL', false);
}
if (isset($_GET['module'])) {
    define('MODULE_DIR', 'data/modules/' . $_GET['module']);
    define('MODULE_SETTINGS_DIR', 'data/settings/modules/' . $_GET['module']);
}
if (file_exists(PAGE_DIR)) {
    $homepage = read_dir_contents(PAGE_DIR, 'files');
    if ($homepage != false) {
        sort($homepage, SORT_NUMERIC);
        $homepage = get_page_seoname($homepage[0]);
    } else {
        $homepage = '404';
    }
    $page_url_prefix = '?file=';
    run_hook('page_url_prefix', array(&$page_url_prefix));
    define('PAGE_URL_PREFIX', $page_url_prefix);
    unset($page_url_prefix);
    $homepage = SITE_URI . '/' . PAGE_URL_PREFIX . $homepage;
    run_hook('const_home_page', array(&$homepage));
    define('HOME_PAGE', $homepage);
    unset($homepage);
}
//Some GET-variables for general use.
if (isset($_GET['var1'])) {
    $var1 = $_GET['var1'];
コード例 #2
0
ファイル: deletepage.php プロジェクト: MenZil/pluck
                     show_error($lang['trashcan']['same_name'], 1);
                     redirect('?action=page', 2);
                     include_once 'data/inc/footer.php';
                     exit;
                 }
             }
             unset($page);
         }
     }
 }
 //Move the file.
 rename(PAGE_DIR . '/' . get_page_filename($var1), 'data/trash/pages/' . $newfile . '.php');
 //Then move the sub-pages, if any.
 if (isset($sub_pages)) {
     foreach ($sub_pages as $sub_page) {
         rename(PAGE_DIR . '/' . $sub_page, 'data/trash/pages/' . str_replace(get_sub_page_dir(get_page_seoname($sub_page)) . '/', '', get_page_seoname($sub_page)) . '.php');
     }
     //Delete the dir where the sub-pages were in.
     rmdir(PAGE_DIR . '/' . $var1);
 }
 //If it's a sub-page, we have to do a few things.
 if (strpos($var1, '/') !== false) {
     //Delete the dir, if there are no other pages.
     if (read_dir_contents(PAGE_DIR . '/' . get_sub_page_dir($var1), 'files') == false) {
         rmdir(PAGE_DIR . '/' . get_sub_page_dir($var1));
     } else {
         reorder_pages(PAGE_DIR . '/' . get_sub_page_dir($var1));
     }
 } else {
     reorder_pages(PAGE_DIR);
 }
コード例 #3
0
/**
 * Generates page menu. Only for internal use. For themes, use theme_menu().
 *
 * @since 4.7
 * @package site
 */
function theme_menu_data($block, $inline, $active_id, $level, $dir)
{
    //If specified directory does not exist, just return.
    if (!is_dir($dir)) {
        return;
    }
    $files = read_dir_contents($dir, 'files');
    if ($files) {
        //Sort the array.
        natcasesort($files);
        echo '<' . $block . '>';
        foreach ($files as $file) {
            include $dir . '/' . $file;
            $file = get_page_seoname($dir . '/' . $file);
            //Only display in menu if page isn't hidden by user.
            if (isset($hidden) && $hidden == 'no') {
                //Get parents of the currently displayed page
                $parents = get_page_parents(CURRENT_PAGE_SEONAME);
                //Strip parents from $file, but only if it's a sub page
                if (strpos($file, '/') !== false && file_exists(PAGE_DIR . '/' . get_page_filename($file))) {
                    $file_levels = preg_split('|\\/|', $file);
                    $file_stripped = $file_levels[count($file_levels) - 1];
                } else {
                    $file_stripped = $file;
                }
                //Show an active inline for current page...
                if ($active_id && CURRENT_PAGE_SEONAME == $file) {
                    echo '<' . $inline . ' class="' . $active_id . '" id="' . $active_id . '">';
                } elseif ($active_id && $parents && array_search($file_stripped, $parents) !== false) {
                    echo '<' . $inline . ' class="' . $active_id . '">';
                } else {
                    echo '<' . $inline . '>';
                }
                //Unset parents array
                unset($parents);
                //Display link
                echo '<a href="' . SITE_URL . '/' . PAGE_URL_PREFIX . $file . '" >' . $title . '</a>';
                preg_match_all('|\\/|', $file, $page_level);
                $page_level = count($page_level[0]);
                if ($level > $page_level && is_dir(PAGE_DIR . '/' . $file)) {
                    theme_menu_data($block, $inline, $active_id, $level, PAGE_DIR . '/' . $file);
                }
                echo '</' . $inline . '>';
            }
        }
        unset($file);
        echo '</' . $block . '>';
    }
}
コード例 #4
0
ファイル: functions.admin.php プロジェクト: MenZil/pluck
/**
 * Save a page with a lot of options.
 *
 * @since 4.7
 * @package admin
 * @param mixed $title if string - The title, if array title => The title, seo_name => The seo_name.
 * @param string $content The content.
 * @param string $hidden Should it be hidden ('yes' or 'no')?
 * @param string $subpage Specifies the parent page, if the saved page should be a sub page. Default to null.
 * @param string $description Description of the page. Defaults to null.
 * @param string $keywords Keywords of the page. Defaults to null.
 * @param array $module_additional_data Additional data variable, can be edited by modules through hooks (admin_save_page_module_additional_data). Defaults to null.
 * @param string $current_seoname Current seoname of the page, if we are editing a page. Defaults to null.
 * @return string Seoname of the saved page.
 */
function save_page($title, $content, $hidden, $subpage = null, $description = null, $keywords = null, $module_additional_data = null, $current_seoname = null)
{
    //Run a few hooks.
    run_hook('admin_save_page', array(&$title, &$content));
    run_hook('admin_save_page_meta', array(&$description, &$keywords));
    run_hook('admin_save_page_module_additional_data', array(&$module_additional_data));
    //Configure title and seo_name
    if (is_array($title)) {
        if (!empty($title['seo_name'])) {
            $seo_title = $title['seo_name'];
            $title = $title['title'];
        } else {
            $seo_title = seo_url($title['title']);
            $title = $title['title'];
        }
    } else {
        $seo_title = seo_url($title);
    }
    //Check if the seo url  is empty.
    if (empty($seo_title)) {
        return false;
    }
    //Check if a page already exists with the name.
    if ((!isset($current_seoname) || $current_seoname != $subpage . $seo_title) && get_page_filename($subpage . $seo_title) != false) {
        return false;
    }
    //Do we want to create a new page?
    if (!isset($current_seoname)) {
        //Check if we want a sub-page.
        if (!empty($subpage)) {
            //We need to make sure that the dir exists, and if not, create it.
            if (!file_exists(PAGE_DIR . '/' . rtrim($subpage, '/'))) {
                mkdir(PAGE_DIR . '/' . rtrim($subpage, '/'));
                chmod(PAGE_DIR . '/' . rtrim($subpage, '/'), 0777);
            }
            $pages = read_dir_contents(PAGE_DIR . '/' . rtrim($subpage, '/'), 'files');
        } else {
            $pages = read_dir_contents(PAGE_DIR, 'files');
        }
        //Are there any pages?
        if ($pages == false) {
            $number = 1;
        } else {
            $number = count($pages) + 1;
        }
        $newfile = $subpage . $number . '.' . $seo_title;
    } else {
        $filename = get_page_filename($current_seoname);
        //the old file name
        //Is it a sub-page, or do we want to make it one?
        if (strpos($current_seoname, '/') !== false || !empty($subpage)) {
            $page_name = explode('/', $subpage);
            $count = count($page_name);
            unset($page_name[$count]);
            $dir = get_sub_page_dir($current_seoname);
            $filename_array = str_replace($dir . '/', '', $filename);
            $filename_array = explode('.', $filename_array);
            $newfilename = implode('/', $page_name) . '/' . $filename_array[0] . '.' . $seo_title;
            $newdir = get_sub_page_dir($newfilename);
            //We need to make sure that the dir exists, and if not, create it.
            if (!file_exists(PAGE_DIR . '/' . $newdir)) {
                mkdir(PAGE_DIR . '/' . $newdir);
                chmod(PAGE_DIR . '/' . $newdir, 0777);
            }
            //If the name isn't the same as before, we have to find the correct number.
            if ($newfilename . '.php' != $filename) {
                //If the sub-folder is the same, use the same number as before.
                if ($dir . '/' == $newdir) {
                    $number = $filename_array[0];
                } else {
                    $pages = read_dir_contents(PAGE_DIR . '/' . $newdir, 'files');
                    if ($pages) {
                        $count = count($pages);
                        $number = $count + 1;
                    } else {
                        $number = 1;
                    }
                }
                $newfile = implode('/', $page_name) . $number . '.' . $seo_title;
            }
        } else {
            $filename_array = explode('.', $filename);
            $newfile = $filename_array[0] . '.' . $seo_title;
        }
    }
    //Save the title, content and hidden status.
    $data = '<?php' . "\n" . '$title = \'' . sanitize($title) . '\';' . "\n" . '$seoname = \'' . sanitize($seo_title) . '\';' . "\n" . '$content = \'' . sanitize($content, false) . '\';' . "\n" . '$hidden = \'' . $hidden . '\';';
    //Save the description and keywords, if any.
    if ($description != null) {
        $data .= "\n" . '$description = \'' . sanitize($description) . '\';';
    }
    if ($keywords != null) {
        $data .= "\n" . '$keywords = \'' . sanitize($keywords) . '\';';
    }
    //If modules have supplied additional data, save it.
    if ($module_additional_data != null && is_array($module_additional_data)) {
        foreach ($module_additional_data as $var => $value) {
            $data .= "\n" . '$' . $var . ' = \'' . $value . '\';';
        }
    }
    $data .= "\n" . '?>';
    //Save the file.
    save_file(PAGE_DIR . '/' . $newfile . '.php', $data);
    //Do a little cleanup if we are editing a page.
    if (isset($current_seoname)) {
        //Check if the title is different from what we started with.
        if ($newfile . '.php' != $filename) {
            //If there are sub-pages, rename the folder.
            if (file_exists(PAGE_DIR . '/' . get_page_seoname($filename))) {
                rename(PAGE_DIR . '/' . get_page_seoname($filename), PAGE_DIR . '/' . get_page_seoname($newfile . '.php'));
            }
            //Remove the old file.
            unlink(PAGE_DIR . '/' . $filename);
            //If there are no files in the old dir, delete it.
            if (isset($dir) && read_dir_contents(PAGE_DIR . '/' . $dir, 'files') == false) {
                rmdir(PAGE_DIR . '/' . $dir);
            } elseif (isset($dir)) {
                reorder_pages(PAGE_DIR . '/' . $dir);
            } else {
                reorder_pages(PAGE_DIR);
            }
        }
    }
    //Return the seoname.
    return get_page_seoname($newfile . '.php');
}