| 1 |
4
|
ryan
|
<?php
|
| 2 |
|
|
|
| 3 |
26
|
stefan
|
// $Id$
|
| 4 |
4
|
ryan
|
|
| 5 |
|
|
/*
|
| 6 |
|
|
|
| 7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
| 8 |
|
|
Copyright (C) 2004-2005, Ryan Djurovich
|
| 9 |
|
|
|
| 10 |
|
|
Website Baker is free software; you can redistribute it and/or modify
|
| 11 |
|
|
it under the terms of the GNU General Public License as published by
|
| 12 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
| 13 |
|
|
(at your option) any later version.
|
| 14 |
|
|
|
| 15 |
|
|
Website Baker is distributed in the hope that it will be useful,
|
| 16 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
|
|
GNU General Public License for more details.
|
| 19 |
|
|
|
| 20 |
|
|
You should have received a copy of the GNU General Public License
|
| 21 |
|
|
along with Website Baker; if not, write to the Free Software
|
| 22 |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
| 23 |
|
|
|
| 24 |
|
|
*/
|
| 25 |
|
|
|
| 26 |
|
|
// Include the config file
|
| 27 |
|
|
require('../../../config.php');
|
| 28 |
|
|
|
| 29 |
|
|
// Create new admin object
|
| 30 |
|
|
require(WB_PATH.'/framework/class.admin.php');
|
| 31 |
|
|
$admin = new admin('Pages', 'pages_modify', false);
|
| 32 |
|
|
|
| 33 |
|
|
// Setup the template
|
| 34 |
|
|
$template = new Template(WB_PATH.'/include/htmlarea/popups');
|
| 35 |
|
|
$template->set_file('page', 'link.html');
|
| 36 |
|
|
$template->set_block('page', 'main_block', 'main');
|
| 37 |
|
|
|
| 38 |
|
|
// Get the directory to browse
|
| 39 |
|
|
$directory = $admin->get_post('folder');
|
| 40 |
|
|
if($directory == '') {
|
| 41 |
|
|
$directory = '/media';
|
| 42 |
|
|
}
|
| 43 |
|
|
// If the directory contains ../ then set it to /media
|
| 44 |
|
|
if(strstr($directory, '../')) {
|
| 45 |
|
|
$directory = '/media';
|
| 46 |
|
|
}
|
| 47 |
|
|
|
| 48 |
|
|
// Include the WB functions file
|
| 49 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
| 50 |
|
|
|
| 51 |
|
|
// Insert values into template
|
| 52 |
|
|
$template->set_var('WB_URL', WB_URL);
|
| 53 |
|
|
$template->set_var('POPUP', 'link');
|
| 54 |
|
|
$template->set_var('DIRECTORY', $directory);
|
| 55 |
|
|
|
| 56 |
|
|
// Get home folder not to show
|
| 57 |
|
|
$home_folders = get_home_folders();
|
| 58 |
|
|
|
| 59 |
|
|
// Insert dirs into the dir list
|
| 60 |
|
|
$template->set_block('main_block', 'dir_list_block', 'dir_list');
|
| 61 |
|
|
foreach(directory_list(WB_PATH.MEDIA_DIRECTORY) AS $name) {
|
| 62 |
|
|
$template->set_var('NAME', str_replace(WB_PATH, '', $name));
|
| 63 |
|
|
if(!isset($home_folders[str_replace(WB_PATH.MEDIA_DIRECTORY, '', $name)])) {
|
| 64 |
|
|
if($directory == str_replace(WB_PATH, '', $name)) {
|
| 65 |
|
|
$template->set_var('SELECTED', ' selected');
|
| 66 |
|
|
} else {
|
| 67 |
|
|
$template->set_var('SELECTED', '');
|
| 68 |
|
|
}
|
| 69 |
|
|
$template->parse('dir_list', 'dir_list_block', true);
|
| 70 |
|
|
}
|
| 71 |
|
|
}
|
| 72 |
|
|
|
| 73 |
|
|
// Function to generate page list
|
| 74 |
|
|
function gen_page_list($parent) {
|
| 75 |
|
|
global $template, $database;
|
| 76 |
26
|
stefan
|
$get_pages = $database->query("SELECT page_id,menu_title,link,level FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC");
|
| 77 |
4
|
ryan
|
while($page = $get_pages->fetchRow()) {
|
| 78 |
42
|
stefan
|
$title = $admin->strip_slashes_dummy($page['menu_title']);
|
| 79 |
4
|
ryan
|
// Add leading -'s so we can tell what level a page is at
|
| 80 |
|
|
$leading_dashes = '';
|
| 81 |
|
|
for($i = 0; $i < $page['level']; $i++) {
|
| 82 |
|
|
$leading_dashes .= '- ';
|
| 83 |
|
|
}
|
| 84 |
|
|
$template->set_var('TITLE', $leading_dashes.' '.$title);
|
| 85 |
|
|
$template->set_var('LINK', '[wblink'.$page['page_id'].']');
|
| 86 |
|
|
$template->parse('page_list', 'page_list_block', true);
|
| 87 |
|
|
gen_page_list($page['page_id']);
|
| 88 |
|
|
}
|
| 89 |
|
|
}
|
| 90 |
|
|
|
| 91 |
|
|
// Get pages and put them into the pages list
|
| 92 |
|
|
$template->set_block('main_block', 'page_list_block', 'page_list');
|
| 93 |
|
|
$database = new database();
|
| 94 |
26
|
stefan
|
$get_pages = $database->query("SELECT page_id,menu_title,link FROM ".TABLE_PREFIX."pages WHERE parent = '0' AND visibility!='deleted' ORDER BY position ASC");
|
| 95 |
4
|
ryan
|
if($get_pages > 0) {
|
| 96 |
|
|
// Add 'Please select...'
|
| 97 |
|
|
$template->set_var('TITLE', 'Please select...');
|
| 98 |
|
|
$template->set_var('LINK', '');
|
| 99 |
|
|
$template->parse('page_list', 'page_list_block', true);
|
| 100 |
|
|
// Loop through pages
|
| 101 |
|
|
while($page = $get_pages->fetchRow()) {
|
| 102 |
42
|
stefan
|
$title = $admin->strip_slashes_dummy($page['menu_title']);
|
| 103 |
4
|
ryan
|
$template->set_var('TITLE', $title);
|
| 104 |
|
|
$template->set_var('LINK', '[wblink'.$page['page_id'].']');
|
| 105 |
|
|
$template->parse('page_list', 'page_list_block', true);
|
| 106 |
|
|
gen_page_list($page['page_id']);
|
| 107 |
|
|
}
|
| 108 |
|
|
} else {
|
| 109 |
|
|
$template->set_var('TITLE', 'None found');
|
| 110 |
|
|
$template->set_var('LINK', 'None found');
|
| 111 |
|
|
$template->parse('page_list', 'page_list_block', false);
|
| 112 |
|
|
}
|
| 113 |
|
|
|
| 114 |
|
|
// Parse the template object
|
| 115 |
|
|
$template->parse('main', 'main_block', false);
|
| 116 |
|
|
$template->pparse('output', 'page');
|
| 117 |
|
|
|
| 118 |
5
|
stefan
|
?>
|