1 |
1358
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package pages
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
1373
|
Luisehahne
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9 |
1358
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
1373
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
13 |
1358
|
Luisehahne
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
1402
|
Luisehahne
|
// Create new admin object
|
19 |
|
|
require('../../config.php');
|
20 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
21 |
|
|
$admin = new admin('Pages', 'pages_settings');
|
22 |
|
|
|
23 |
1664
|
darkviper
|
/*-- Parent page list ------------------------------------------------------------------*/
|
24 |
|
|
function parent_list($parent)
|
25 |
|
|
{
|
26 |
|
|
global $admin, $database, $oTpl, $aCurrentPage, $field_set;
|
27 |
|
|
$sDisabled = ' disabled="disabled"';
|
28 |
|
|
$sSelected = ' selected="selected"';
|
29 |
|
|
|
30 |
|
|
$sql = 'SELECT `page_id`, `level`, `parent`, `menu_title`, `page_title`, '
|
31 |
|
|
. '`language`, `admin_groups`, `admin_users`, `visibility`, '
|
32 |
|
|
. '`viewing_groups`, `viewing_users` '
|
33 |
|
|
. 'FROM `'.TABLE_PREFIX.'pages` '
|
34 |
|
|
. 'WHERE `parent`='.$parent.' '
|
35 |
|
|
. 'ORDER BY `position` ASC';
|
36 |
|
|
$get_pages = $database->query($sql);
|
37 |
|
|
|
38 |
|
|
while($page = $get_pages->fetchRow(MYSQL_ASSOC))
|
39 |
|
|
{
|
40 |
|
|
if(!$admin->page_is_visible($page)) { continue; }
|
41 |
|
|
// if parent = 0 set flag_icon
|
42 |
|
|
$oTpl->set_var('FLAG_ROOT_ICON',' none ');
|
43 |
|
|
if( $page['parent'] == 0 && $field_set) {
|
44 |
|
|
$oTpl->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
|
45 |
|
|
}
|
46 |
|
|
// If the current page cannot be parent, then its children neither
|
47 |
|
|
$list_next_level = true;
|
48 |
|
|
// Stop users from adding pages with a level of more than the set page level limit
|
49 |
|
|
if($page['level']+1 < PAGE_LEVEL_LIMIT)
|
50 |
|
|
{
|
51 |
|
|
// Get user permisions
|
52 |
|
|
$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
|
53 |
|
|
$admin->is_group_match($admin->get_user_id(), $page['admin_users']));
|
54 |
|
|
// Title -'s prefix
|
55 |
|
|
$title_prefix = '';
|
56 |
|
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; }
|
57 |
|
|
$oTpl->set_var(array(
|
58 |
|
|
'ID' => $page['page_id'],
|
59 |
|
|
'TITLE' => ($title_prefix.$page['menu_title']),
|
60 |
|
|
'MENU-TITLE' => ($title_prefix.$page['menu_title']),
|
61 |
|
|
'PAGE-TITLE' => ($title_prefix.$page['page_title']),
|
62 |
|
|
'FLAG_ICON' => ' none ',
|
63 |
|
|
));
|
64 |
|
|
if($aCurrentPage['parent'] == $page['page_id']) {
|
65 |
|
|
$oTpl->set_var('SELECTED', $sSelected);
|
66 |
|
|
} elseif($aCurrentPage['page_id'] == $page['page_id']) {
|
67 |
|
|
$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
|
68 |
|
|
$list_next_level=false;
|
69 |
|
|
} elseif($can_modify != true) {
|
70 |
|
|
$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
|
71 |
|
|
} else {
|
72 |
|
|
$oTpl->set_var('SELECTED', '');
|
73 |
|
|
}
|
74 |
|
|
$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
|
75 |
|
|
}
|
76 |
|
|
if ($list_next_level) {
|
77 |
|
|
parent_list($page['page_id']);
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
} // end of function parent_list
|
81 |
|
|
/* -------------------------------------------------------------------------------------*/
|
82 |
1681
|
darkviper
|
$mLang = ModLanguage::getInstance();
|
83 |
|
|
$mLang->setLanguage(dirname(__FILE__).'/languages/', LANGUAGE, DEFAULT_LANGUAGE);
|
84 |
1664
|
darkviper
|
$sDisabled = ' disabled="disabled"';
|
85 |
|
|
$sSelected = ' selected="selected"';
|
86 |
|
|
$sChecked = ' checked="checked"';
|
87 |
|
|
|
88 |
1358
|
Luisehahne
|
// Get page id
|
89 |
1664
|
darkviper
|
$page_id = $_GET['page_id'] ? intval($_GET['page_id']) : 0;
|
90 |
|
|
if(!$page_id) {
|
91 |
|
|
header("Location: index.php");
|
92 |
|
|
exit(0);
|
93 |
|
|
}
|
94 |
|
|
/*-- get all details of current page ---------------------------------------------------*/
|
95 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
|
96 |
|
|
if( ($oPages = $database->query($sql)) ) {
|
97 |
|
|
$aCurrentPage = $oPages->fetchRow(MYSQL_ASSOC);
|
98 |
|
|
// Work-out if we should check for existing page_code
|
99 |
|
|
$field_set = isset($aCurrentPage['page_code']);
|
100 |
|
|
if( !$admin->ami_group_member($aCurrentPage['admin_groups']) &&
|
101 |
|
|
!$admin->is_group_match($admin->get_user_id(), $aCurrentPage['admin_users']) )
|
102 |
|
|
{
|
103 |
|
|
$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
|
104 |
|
|
}
|
105 |
|
|
}else {
|
106 |
|
|
$admin->print_header();
|
107 |
|
|
$admin->print_error($database->get_error());
|
108 |
1358
|
Luisehahne
|
}
|
109 |
1664
|
darkviper
|
if(!isset($aCurrentPage['page_code'])) {
|
110 |
|
|
$database->field_add(TABLE_PREFIX.'pages', 'page_code', 'INT NOT NULL DEFAULT \'0\'');
|
111 |
|
|
}
|
112 |
|
|
if($oPages->numRows() == 0) {
|
113 |
|
|
$admin->print_header();
|
114 |
|
|
$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
|
115 |
|
|
}
|
116 |
1358
|
Luisehahne
|
// Get display name of person who last modified the page
|
117 |
1664
|
darkviper
|
$user=$admin->get_user_details($aCurrentPage['modified_by']);
|
118 |
1358
|
Luisehahne
|
// Convert the unix ts for modified_when to human a readable form
|
119 |
1664
|
darkviper
|
if($aCurrentPage['modified_when'] != 0) {
|
120 |
|
|
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $aCurrentPage['modified_when']+TIMEZONE);
|
121 |
|
|
}else {
|
122 |
|
|
$modified_ts = 'Unknown';
|
123 |
|
|
}
|
124 |
1358
|
Luisehahne
|
// Setup template object, parse vars to it, then parse it
|
125 |
1529
|
Luisehahne
|
// Create new template object
|
126 |
1664
|
darkviper
|
$oTpl = new Template(dirname($admin->correct_theme_source('pages_settings.htt')), 'keep');
|
127 |
|
|
$oTpl->set_file('page', 'pages_settings.htt');
|
128 |
|
|
$oTpl->set_block('page', 'main_block', 'main');
|
129 |
|
|
$oTpl->set_var('FTAN', $admin->getFTAN());
|
130 |
|
|
$oTpl->set_var(array(
|
131 |
|
|
'PAGE_ID' => $aCurrentPage['page_id'],
|
132 |
|
|
'PAGE_IDKEY' => $admin->getIDKEY($aCurrentPage['page_id']),
|
133 |
|
|
'PAGE_TITLE' => ($aCurrentPage['page_title']),
|
134 |
|
|
'MENU_TITLE' => ($aCurrentPage['menu_title']),
|
135 |
|
|
'DESCRIPTION' => ($aCurrentPage['description']),
|
136 |
|
|
'KEYWORDS' => ($aCurrentPage['keywords']),
|
137 |
|
|
'MODIFIED_BY' => $user['display_name'],
|
138 |
|
|
'MODIFIED_BY_USERNAME' => $user['username'],
|
139 |
|
|
'MODIFIED_WHEN' => $modified_ts,
|
140 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
141 |
|
|
'WB_URL' => WB_URL,
|
142 |
|
|
'THEME_URL' => THEME_URL
|
143 |
|
|
));
|
144 |
|
|
/*-- workout if we should show the "manage sections" link ------------------------------*/
|
145 |
|
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
|
146 |
|
|
. 'WHERE `page_id`='.$page_id.' AND `module`=\'menu_link\'';
|
147 |
1681
|
darkviper
|
$bIsMenuLink = (intval($database->get_one($sql)) != 0);
|
148 |
|
|
$oTpl->set_block('main_block', 'show_manage_sections_block', 'show_manage_sections');
|
149 |
|
|
if(!$bIsMenuLink && (MANAGE_SECTIONS == true)) {
|
150 |
|
|
$oTpl->parse('show_manage_sections', 'show_manage_sections_block', true);
|
151 |
|
|
}else {
|
152 |
|
|
$oTpl->set_block('show_manage_sections', '');
|
153 |
1664
|
darkviper
|
}
|
154 |
1358
|
Luisehahne
|
|
155 |
1681
|
darkviper
|
/*-- collect page-icons for select boxes -----------------------------------------------*/
|
156 |
|
|
$sAllowedImageTypes = '\.jpg|\.jpeg|\.png|\.gif';
|
157 |
|
|
$aPageIcons = array();
|
158 |
|
|
$aIcon = array();
|
159 |
|
|
$sTemplate = ($aCurrentPage['template'] == '' ? DEFAULT_TEMPLATE : $aCurrentPage['template']);
|
160 |
|
|
$sIconDir = str_replace('\\', '/', ((defined('PAGE_ICON_DIR') && PAGE_ICON_DIR != '') ? PAGE_ICON_DIR : MEDIA_DIRECTORY));
|
161 |
|
|
$sIconDir = str_replace('/*', '/'.$sTemplate, $sIconDir);
|
162 |
|
|
$oTpl->set_var('ICON_DIR', WB_REL.$sIconDir);
|
163 |
|
|
if(is_readable(WB_PATH.$sIconDir)) {
|
164 |
|
|
$oIterator = new DirectoryIterator(WB_PATH.$sIconDir);
|
165 |
|
|
foreach ($oIterator as $fileinfo) {
|
166 |
|
|
if(preg_match('/'.$sAllowedImageTypes.'$/i', $fileinfo->getFilename())) {
|
167 |
|
|
$sItem = str_replace(WB_PATH, '', str_replace('\\', '/', $fileinfo->getPathname()));
|
168 |
|
|
// $sItem = WB_REL.$sItem;
|
169 |
|
|
$aPageIcons[] = array('VALUE'=>$sItem, 'NAME'=>$fileinfo->getFilename());
|
170 |
|
|
}
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
|
|
/*-- show page-icon select box ---------------------------------------------------------*/
|
174 |
|
|
$oTpl->set_block('main_block', 'page_icon_list_block', 'page_icon_list');
|
175 |
|
|
foreach($aPageIcons as $value) {
|
176 |
|
|
$aIcon = $value;
|
177 |
|
|
$aIcon['SELECTED'] = ($aCurrentPage['page_icon'] == $aIcon['VALUE'] ? $sSelected : '');
|
178 |
|
|
$oTpl->set_var($aIcon);
|
179 |
|
|
$oTpl->parse('page_icon_list', 'page_icon_list_block', true);
|
180 |
|
|
}
|
181 |
|
|
/*-- show menu-icon-0 select box -------------------------------------------------------*/
|
182 |
|
|
$oTpl->set_block('main_block', 'menu_icon0_list_block', 'menu_icon0_list');
|
183 |
|
|
foreach($aPageIcons as $value) {
|
184 |
|
|
$aIcon = $value;
|
185 |
|
|
$aIcon['SELECTED'] = ($aCurrentPage['menu_icon_0'] == $aIcon['VALUE'] ? $sSelected : '');
|
186 |
|
|
$oTpl->set_var($aIcon);
|
187 |
|
|
$oTpl->parse('menu_icon0_list', 'menu_icon0_list_block', true);
|
188 |
|
|
}
|
189 |
|
|
/*-- show menu-icon-1 select box -------------------------------------------------------*/
|
190 |
|
|
$oTpl->set_block('main_block', 'menu_icon1_list_block', 'menu_icon1_list');
|
191 |
|
|
foreach($aPageIcons as $value) {
|
192 |
|
|
$aIcon = $value;
|
193 |
|
|
$aIcon['SELECTED'] = ($aCurrentPage['menu_icon_1'] == $aIcon['VALUE'] ? $sSelected : '');
|
194 |
|
|
$oTpl->set_var($aIcon);
|
195 |
|
|
$oTpl->parse('menu_icon1_list', 'menu_icon1_list_block', true);
|
196 |
|
|
}
|
197 |
|
|
|
198 |
1664
|
darkviper
|
/*-- show visibility select box --------------------------------------------------------*/
|
199 |
|
|
$aVisibility = array();
|
200 |
|
|
$aVisibility['PUBLIC_SELECTED'] = ($aCurrentPage['visibility'] == 'public' ? $sSelected : '');
|
201 |
|
|
$aVisibility['PRIVATE_SELECTED'] = ($aCurrentPage['visibility'] == 'private' ? $sSelected : '');
|
202 |
|
|
$aVisibility['REGISTERED_SELECTED'] = ($aCurrentPage['visibility'] == 'registered' ? $sSelected : '');
|
203 |
|
|
$aVisibility['HIDDEN_SELECTED'] = ($aCurrentPage['visibility'] == 'hidden' ? $sSelected : '');
|
204 |
|
|
$aVisibility['NO_VIS_SELECTED'] = ($aCurrentPage['visibility'] == 'none' ? $sSelected : '');
|
205 |
|
|
$oTpl->set_var($aVisibility);
|
206 |
1358
|
Luisehahne
|
|
207 |
1664
|
darkviper
|
/*-- admin group list block ------------------------------------------------------------*/
|
208 |
|
|
$aAdminGroups = explode(',', '1,'.$aCurrentPage['admin_groups']);
|
209 |
|
|
$sAdminGroups = implode(',', array_unique($aAdminGroups));
|
210 |
|
|
$sql = 'SELECT `group_id` `ID`, `name` `NAME`, `system_permissions` `permissions` '
|
211 |
|
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
212 |
|
|
. 'ORDER BY (`ID` NOT IN('.$sAdminGroups.')), `NAME`';
|
213 |
|
|
if( ($oGroups = $database->query($sql)))
|
214 |
|
|
{
|
215 |
|
|
$oTpl->set_block('main_block', 'admin_group_list_block', 'admin_group_list');
|
216 |
|
|
while( $aGroup = $oGroups->fetchRow(MYSQL_ASSOC))
|
217 |
|
|
{
|
218 |
|
|
if($aGroup['ID'] == 1) {
|
219 |
|
|
// never uncheck admin group
|
220 |
|
|
$aGroup['CHECKED'] = $sChecked;
|
221 |
|
|
$aGroup['DISABLED'] = $sDisabled;
|
222 |
|
|
}else {
|
223 |
|
|
// skip groups without system_permissions
|
224 |
|
|
if(!$admin->is_group_match('pages_modify', $aGroup['permissions'])) { continue; }
|
225 |
|
|
// check already selected groups
|
226 |
|
|
$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['admin_groups']);
|
227 |
|
|
// disable selected groups where current user is not member of
|
228 |
|
|
$bDisabled = !$admin->ami_group_member($aGroup['ID']);
|
229 |
|
|
$aGroup['CHECKED'] = $bChecked ? $sChecked : '';
|
230 |
|
|
$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
|
231 |
|
|
}
|
232 |
|
|
unset($aGroup['permissions']);
|
233 |
|
|
$oTpl->set_var($aGroup);
|
234 |
|
|
$oTpl->parse('admin_group_list', 'admin_group_list_block', true);
|
235 |
1358
|
Luisehahne
|
}
|
236 |
1664
|
darkviper
|
}
|
237 |
1358
|
Luisehahne
|
|
238 |
1664
|
darkviper
|
/*-- viewer group list block -----------------------------------------------------------*/
|
239 |
|
|
$aViewingGroups = explode(',', '1,'.$aCurrentPage['viewing_groups']);
|
240 |
|
|
$sViewingGroups = implode(',', array_unique($aViewingGroups));
|
241 |
|
|
$oTpl->set_block('main_block', 'viewer_group_list_block', 'viewer_group_list');
|
242 |
|
|
$sql = 'SELECT `group_id` `ID`, `name` `NAME` '
|
243 |
|
|
. 'FROM `'.TABLE_PREFIX.'groups` '
|
244 |
|
|
. 'ORDER BY (`ID` NOT IN('.$sViewingGroups.')), `NAME`';
|
245 |
|
|
if(($oGroups = $database->query($sql))) {
|
246 |
|
|
while($aGroup = $oGroups->fetchRow(MYSQL_ASSOC)) {
|
247 |
|
|
if($aGroup['ID'] == 1) {
|
248 |
|
|
// never uncheck admin group
|
249 |
|
|
$aGroup['CHECKED'] = $sChecked;
|
250 |
|
|
$aGroup['DISABLED'] = $sDisabled;
|
251 |
|
|
}else {
|
252 |
|
|
// check already selected groups
|
253 |
|
|
$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['viewing_groups']);
|
254 |
|
|
// disable selected groups where current user is not member of
|
255 |
|
|
$bDisabled = !$admin->ami_group_member($aGroup['ID']);
|
256 |
|
|
$aGroup['CHECKED'] = $bChecked ? $sChecked : '';
|
257 |
|
|
$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
|
258 |
1358
|
Luisehahne
|
}
|
259 |
1664
|
darkviper
|
$oTpl->set_var($aGroup);
|
260 |
|
|
$oTpl->parse('viewer_group_list', 'viewer_group_list_block', true);
|
261 |
1358
|
Luisehahne
|
}
|
262 |
|
|
}
|
263 |
1415
|
DarkViper
|
|
264 |
1664
|
darkviper
|
/*-- admin user list block -------------------------------------------------------------*/
|
265 |
|
|
$aAdminUsers = ($aCurrentPage['admin_users'] == ''
|
266 |
|
|
? array()
|
267 |
|
|
: explode(',', $aCurrentPage['admin_users']));
|
268 |
|
|
$aAdminUsers = explode(',', $aCurrentPage['admin_users']);
|
269 |
|
|
$oTpl->set_block('main_block', 'admin_user_list_block', 'admin_user_list');
|
270 |
|
|
$sAllowedAdminUsers = trim(implode(',',$aAdminUsers));
|
271 |
|
|
$sAllowedAdminUsers = $sAllowedAdminUsers ? $sAllowedAdminUsers : '-1';
|
272 |
|
|
$sql = 'SELECT `user_id`, `display_name` '
|
273 |
|
|
. 'FROM `'.TABLE_PREFIX.'users` '
|
274 |
|
|
. 'WHERE `active`=1 '
|
275 |
|
|
. 'ORDER BY (`user_id` NOT IN('.$sAllowedAdminUsers.')), `display_name`';
|
276 |
|
|
if( ($oUsers = $database->query($sql)) ) {
|
277 |
|
|
while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
|
278 |
|
|
if($aUser['user_id'] == 1) { continue; }
|
279 |
|
|
$oTpl->set_var(array(
|
280 |
|
|
'ID' => $aUser['user_id'],
|
281 |
|
|
'NAME' => $aUser['display_name'],
|
282 |
|
|
'SELECTED' => (in_array($aUser['user_id'], $aAdminUsers) ? $sSelected : ''),
|
283 |
|
|
));
|
284 |
|
|
$oTpl->parse('admin_user_list', 'admin_user_list_block', true);
|
285 |
|
|
}
|
286 |
|
|
}
|
287 |
1358
|
Luisehahne
|
|
288 |
1664
|
darkviper
|
/*-- viewer users list block -----------------------------------------------------------*/
|
289 |
|
|
$aViewingUsers = ($aCurrentPage['viewing_users'] == ''
|
290 |
|
|
? array()
|
291 |
|
|
: explode(',', $aCurrentPage['viewing_users']));
|
292 |
|
|
$aViewingUsers = explode(',', $aCurrentPage['viewing_users']);
|
293 |
|
|
$oTpl->set_block('main_block', 'viewer_user_list_block', 'viewer_user_list');
|
294 |
|
|
$sAllowedViewingUsers = trim(implode(',',$aViewingUsers));
|
295 |
|
|
$sAllowedViewingUsers = $sAllowedViewingUsers ? $sAllowedViewingUsers : '-1';
|
296 |
|
|
$sql = 'SELECT `user_id`, `display_name` '
|
297 |
|
|
. 'FROM `'.TABLE_PREFIX.'users` '
|
298 |
|
|
. 'WHERE `active`=1 '
|
299 |
|
|
. 'ORDER BY (`user_id` NOT IN('.$sAllowedViewingUsers.')), `display_name`';
|
300 |
|
|
if( ($oUsers = $database->query($sql)) ) {
|
301 |
|
|
while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
|
302 |
|
|
if($aUser['user_id'] == 1) { continue; }
|
303 |
|
|
$oTpl->set_var(array(
|
304 |
|
|
'ID' => $aUser['user_id'],
|
305 |
|
|
'NAME' => $aUser['display_name'],
|
306 |
|
|
'SELECTED' => (in_array($aUser['user_id'], $aViewingUsers) ? $sSelected : ''),
|
307 |
|
|
));
|
308 |
|
|
$oTpl->parse('viewer_user_list', 'viewer_user_list_block', true);
|
309 |
1358
|
Luisehahne
|
}
|
310 |
1664
|
darkviper
|
}
|
311 |
1358
|
Luisehahne
|
|
312 |
1664
|
darkviper
|
/*-- size user lists -------------------------------------------------------------------*/
|
313 |
|
|
$aSkaleSizeOfList = array(0 => 5, 12 => 10, 25 => 20, 50 => 30, 75 => 40, 100 => 50);
|
314 |
|
|
$iListSize = 6;
|
315 |
|
|
if($oUsers) {
|
316 |
|
|
$iNumberOfUsers = $oUsers->numRows();
|
317 |
|
|
foreach($aSkaleSizeOfList as $key => $val){
|
318 |
|
|
if($iNumberOfUsers > $key) {
|
319 |
|
|
$iListSize = $val;
|
320 |
|
|
}else { break; }
|
321 |
1358
|
Luisehahne
|
}
|
322 |
1664
|
darkviper
|
}
|
323 |
|
|
$oTpl->set_var('USER_LIST_SIZE', $iListSize);
|
324 |
1358
|
Luisehahne
|
|
325 |
1664
|
darkviper
|
/*-- show private viewers block --------------------------------------------------------*/
|
326 |
|
|
if($aCurrentPage['visibility'] == 'private' OR $aCurrentPage['visibility'] == 'registered')
|
327 |
|
|
{
|
328 |
|
|
$oTpl->set_var('DISPLAY_VIEWERS', '');
|
329 |
|
|
} else {
|
330 |
|
|
$oTpl->set_var('DISPLAY_VIEWERS', 'display:none;');
|
331 |
1358
|
Luisehahne
|
}
|
332 |
1664
|
darkviper
|
/*-- start multilanguage page_code 20090904 --------------------------------------------*/
|
333 |
1358
|
Luisehahne
|
// Work-out if page languages feature is enabled
|
334 |
1664
|
darkviper
|
$oTpl->set_block('main_block', 'show_page_code_block', 'show_page_code');
|
335 |
|
|
if( (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) &&
|
336 |
|
|
isset($aCurrentPage['page_code']) &&
|
337 |
|
|
file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') )
|
338 |
|
|
{
|
339 |
|
|
// workout field is set but module missing
|
340 |
|
|
$oTpl->set_var('TEXT_PAGE_CODE',
|
341 |
|
|
'<a href="'.WB_URL.'/modules/mod_multilingual/update_keys.php?page_id='.
|
342 |
1681
|
darkviper
|
$page_id.'">'.$mLang->TEXT_PAGE_CODE.'</a>'
|
343 |
1664
|
darkviper
|
);
|
344 |
|
|
/*-- begin recursive function page_code list ---------------------------------------*/
|
345 |
|
|
function page_code_list($parent)
|
346 |
|
|
{
|
347 |
|
|
global $admin, $database, $oTpl, $aCurrentPage, $pageCode;
|
348 |
|
|
$default_language = DEFAULT_LANGUAGE;
|
349 |
1358
|
Luisehahne
|
|
350 |
1664
|
darkviper
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` '
|
351 |
|
|
. 'WHERE `parent`='.$parent.' AND `language`=\''.$default_language.'\' '
|
352 |
|
|
. 'ORDER BY `position` ASC';
|
353 |
|
|
$get_pages = $database->query($sql);
|
354 |
1358
|
Luisehahne
|
|
355 |
1664
|
darkviper
|
while($page = $get_pages->fetchRow(MYSQL_ASSOC))
|
356 |
|
|
{
|
357 |
|
|
if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; }
|
358 |
1358
|
Luisehahne
|
|
359 |
1664
|
darkviper
|
$oTpl->set_var('FLAG_CODE_ICON',' none ');
|
360 |
|
|
if( $page['parent'] == 0 )
|
361 |
|
|
{
|
362 |
|
|
$oTpl->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
|
363 |
|
|
}
|
364 |
1358
|
Luisehahne
|
|
365 |
1664
|
darkviper
|
// If the current page cannot be parent, then its children neither
|
366 |
|
|
$list_next_level = true;
|
367 |
|
|
// Stop users from adding pages with a level of more than the set page level limit
|
368 |
|
|
if($page['level']+1 < PAGE_LEVEL_LIMIT)
|
369 |
|
|
{
|
370 |
|
|
$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
|
371 |
|
|
$admin->is_group_match($admin->get_user_id(), $page['admin_users']));
|
372 |
|
|
$title_prefix = '';
|
373 |
|
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; }
|
374 |
|
|
// $space = str_repeat(' ', 3); $space.'<'..'>'
|
375 |
|
|
$oTpl->set_var(array(
|
376 |
|
|
'VALUE' => intval($page['page_code']),
|
377 |
|
|
'PAGE_VALUE' => $title_prefix.$page['menu_title'],
|
378 |
|
|
'PAGE_CODE' => $title_prefix.$page['page_id']
|
379 |
|
|
)
|
380 |
|
|
);
|
381 |
|
|
if($aCurrentPage['page_code'] == $page['page_code'])
|
382 |
1358
|
Luisehahne
|
{
|
383 |
1664
|
darkviper
|
$oTpl->set_var('SELECTED', ' selected="selected"');
|
384 |
|
|
} elseif($aCurrentPage['page_code'] == $page['page_code'])
|
385 |
|
|
{
|
386 |
|
|
$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
|
387 |
|
|
$list_next_level=false;
|
388 |
|
|
} elseif($can_modify != true)
|
389 |
|
|
{
|
390 |
|
|
$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
|
391 |
|
|
} else {
|
392 |
|
|
$oTpl->set_var('SELECTED', '');
|
393 |
1358
|
Luisehahne
|
}
|
394 |
1664
|
darkviper
|
$oTpl->parse('page_code_list', 'page_code_list_block', true);
|
395 |
1358
|
Luisehahne
|
}
|
396 |
1664
|
darkviper
|
if ($list_next_level)
|
397 |
|
|
page_code_list($page['page_id']);
|
398 |
1358
|
Luisehahne
|
}
|
399 |
|
|
}
|
400 |
1664
|
darkviper
|
/*-- end recursive function page_code list -----------------------------------------*/
|
401 |
|
|
// Insert code_page values from page to modify
|
402 |
|
|
$oTpl->set_block('show_page_code_block', 'page_code_list_block', 'page_code_list');
|
403 |
|
|
if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
|
404 |
|
|
$selected = ($aCurrentPage['parent'] == 0 ? $sSelected : '');
|
405 |
|
|
$oTpl->set_var(array(
|
406 |
|
|
'VALUE' => 0,
|
407 |
1681
|
darkviper
|
'PAGE_CODE' => $mLang->TEXT_NONE,
|
408 |
1664
|
darkviper
|
'PAGE_VALUE' => '',
|
409 |
|
|
'SELECTED' => $selected
|
410 |
|
|
)
|
411 |
|
|
);
|
412 |
|
|
$oTpl->parse('page_code_list', 'page_code_list_block', true);
|
413 |
|
|
}
|
414 |
|
|
// get pagecode form this page_id
|
415 |
|
|
page_code_list(0);
|
416 |
|
|
$oTpl->parse('show_page_code', 'show_page_code_block', true);
|
417 |
|
|
}else {
|
418 |
|
|
$oTpl->set_block('show_page_code', '');
|
419 |
1358
|
Luisehahne
|
}
|
420 |
1664
|
darkviper
|
/*-- end multilanguage page_code 20090904 ----------------------------------------------*/
|
421 |
1358
|
Luisehahne
|
|
422 |
1664
|
darkviper
|
/*-- show list of parent pages ---------------------------------------------------------*/
|
423 |
|
|
$oTpl->set_block('main_block', 'parent_page_list_block', 'parent_page_list');
|
424 |
|
|
if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
|
425 |
|
|
$oTpl->set_var(array(
|
426 |
|
|
'ID' => '0',
|
427 |
1681
|
darkviper
|
'TITLE' => $mLang->TEXT_NONE,
|
428 |
1664
|
darkviper
|
'SELECTED' => ($aCurrentPage['parent'] == 0 ? $sSelected : ''),
|
429 |
|
|
) );
|
430 |
|
|
$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
|
431 |
1358
|
Luisehahne
|
}
|
432 |
1664
|
darkviper
|
parent_list(0);
|
433 |
|
|
$oTpl->set_var('DISPLAY_MODIFIED', ($modified_ts == 'Unknown' ? 'hide' : ''));
|
434 |
1358
|
Luisehahne
|
|
435 |
1664
|
darkviper
|
/*-- show list of templates ------------------------------------------------------------*/
|
436 |
|
|
$oTpl->set_block('main_block', 'template_list_block', 'template_list');
|
437 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
438 |
|
|
. 'WHERE `type`=\'template\' AND `function`=\'template\' '
|
439 |
|
|
. 'ORDER BY `name`';
|
440 |
|
|
if(($res_templates = $database->query($sql))) {
|
441 |
|
|
while($rec_template = $res_templates->fetchRow(MYSQL_ASSOC)) {
|
442 |
|
|
// Check if the user has perms to use this template
|
443 |
|
|
if($rec_template['directory'] == $aCurrentPage['template'] OR
|
444 |
|
|
$admin->get_permission($rec_template['directory'], 'template'))
|
445 |
|
|
{
|
446 |
|
|
$oTpl->set_var('VALUE', $rec_template['directory']);
|
447 |
|
|
$oTpl->set_var('NAME', $rec_template['name']);
|
448 |
|
|
if($rec_template['directory'] == $aCurrentPage['template']) {
|
449 |
|
|
$oTpl->set_var('SELECTED', $sSelected);
|
450 |
|
|
} else {
|
451 |
|
|
$oTpl->set_var('SELECTED', '');
|
452 |
1358
|
Luisehahne
|
}
|
453 |
1664
|
darkviper
|
$oTpl->parse('template_list', 'template_list_block', true);
|
454 |
1358
|
Luisehahne
|
}
|
455 |
|
|
}
|
456 |
|
|
}
|
457 |
|
|
|
458 |
1664
|
darkviper
|
/*-- show menu select box --------------------------------------------------------------*/
|
459 |
|
|
$oTpl->set_block('main_block', 'show_menu_list_block', 'show_menu_list');
|
460 |
|
|
if(MULTIPLE_MENUS)
|
461 |
|
|
{
|
462 |
|
|
/*-- get menusettings from template info file --------------------------------------*/
|
463 |
|
|
function getTemplateInfo($sTpl = '') {
|
464 |
|
|
if(!$sTpl) { $sTpl = DEFAULT_TEMPLATE; }
|
465 |
|
|
$sTplFile = WB_PATH.'/templates/'.$sTpl.'/info.php';
|
466 |
|
|
if(is_readable($sTplFile)) { require_once($sTplFile); }
|
467 |
|
|
$menu = isset($menu) ? $menu : array();
|
468 |
|
|
return $menu;
|
469 |
|
|
}
|
470 |
|
|
$aMenu = getTemplateInfo($aCurrentPage['template']);
|
471 |
|
|
// set menu[1] as default if there's no entry in info.php
|
472 |
|
|
$aMenu[1] = (!isset($aMenu[1]) OR ($aMenu[1] == '')) ? $TEXT['MAIN'] : $aMenu[1];
|
473 |
|
|
$oTpl->set_block('show_menu_list_block', 'menu_list_block', 'menu_list');
|
474 |
|
|
foreach($aMenu as $iIndex => $sMenuName) {
|
475 |
|
|
$aVars = array();
|
476 |
|
|
$aVars['NAME'] = $sMenuName;
|
477 |
|
|
$aVars['VALUE'] = $iIndex;
|
478 |
|
|
$aVars['SELECTED'] = ($aCurrentPage['menu'] == $iIndex) ? $sSelected : '';
|
479 |
|
|
$oTpl->set_var($aVars);
|
480 |
|
|
$oTpl->parse('menu_list', 'menu_list_block', true);
|
481 |
|
|
}
|
482 |
|
|
$oTpl->parse('show_menu_list', 'show_menu_list_block', true);
|
483 |
|
|
}else {
|
484 |
|
|
$oTpl->set_block('show_menu_list', '');
|
485 |
1358
|
Luisehahne
|
}
|
486 |
|
|
|
487 |
1664
|
darkviper
|
/*-- show language select box ----------------------------------------------------------*/
|
488 |
|
|
$sql = 'SELECT `directory`, `name` FROM `'.TABLE_PREFIX.'addons` '
|
489 |
|
|
. 'WHERE `type`=\'language\' ';
|
490 |
|
|
if( !defined('PAGE_LANGUAGES') || !PAGE_LANGUAGES) {
|
491 |
|
|
// display only default and current language if site is single language only
|
492 |
|
|
$sql .= 'AND `directory`=\''.DEFAULT_LANGUAGE.'\' ';
|
493 |
|
|
if($aCurrentPage['language'] != DEFAULT_LANGUAGE) {
|
494 |
|
|
$sql .= 'AND `directory`=\''.$aCurrentPage['language'].'\' ';
|
495 |
1358
|
Luisehahne
|
}
|
496 |
|
|
}
|
497 |
1664
|
darkviper
|
$sql .= 'ORDER BY `name`';
|
498 |
|
|
if( ($oLanguages = $database->query($sql)) )
|
499 |
|
|
{
|
500 |
|
|
$aAvailLanguages = array();
|
501 |
|
|
while($aLanguage = $oLanguages->fetchRow(MYSQL_ASSOC)) {
|
502 |
|
|
$aAvailLanguages[$aLanguage['directory']] = $aLanguage['name'];
|
503 |
|
|
}
|
504 |
|
|
natsort($aAvailLanguages);
|
505 |
|
|
$oTpl->set_block('main_block', 'language_list_block', 'language_list');
|
506 |
|
|
foreach($aAvailLanguages as $key => $val) {
|
507 |
|
|
$oTpl->set_var(array(
|
508 |
|
|
'VALUE' => $key,
|
509 |
|
|
'NAME' => $val,
|
510 |
|
|
'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($key).'.png)',
|
511 |
|
|
'SELECTED' => ($aCurrentPage['language'] == $key ? $sSelected : ''),
|
512 |
|
|
));
|
513 |
|
|
$oTpl->parse('language_list', 'language_list_block', true);
|
514 |
|
|
}
|
515 |
1358
|
Luisehahne
|
}
|
516 |
|
|
|
517 |
1664
|
darkviper
|
/*-- show search activated box ---------------------------------------------------------*/
|
518 |
|
|
$oTpl->set_var('SEARCHING_SELECTED_ON', ($aCurrentPage['searching'] == 0) ? '' : $sSelected);
|
519 |
|
|
$oTpl->set_var('SEARCHING_SELECTED_OFF', ($aCurrentPage['searching'] == 0) ? $sSelected : '');
|
520 |
1358
|
Luisehahne
|
|
521 |
1664
|
darkviper
|
/*-- show target select box ------------------------------------------------------------*/
|
522 |
|
|
$oTpl->set_var('TOP_SELECTED', ($aCurrentPage['target'] == '_top' ? $sSelected : ''));
|
523 |
|
|
$oTpl->set_var('SELF_SELECTED', ($aCurrentPage['target'] == '_self' ? $sSelected : ''));
|
524 |
|
|
$oTpl->set_var('BLANK_SELECTED', ($aCurrentPage['target'] == '_blank' ? $sSelected : ''));
|
525 |
1457
|
Luisehahne
|
|
526 |
1664
|
darkviper
|
/*-- insert all needed vars from language files ----------------------------------------*/
|
527 |
1681
|
darkviper
|
$oTpl->set_var($mLang->getLangArray());
|
528 |
|
|
/*-- finalize the page -----------------------------------------------------------------*/
|
529 |
1664
|
darkviper
|
$oTpl->parse('main', 'main_block', false);
|
530 |
|
|
$oTpl->pparse('output', 'page');
|
531 |
1358
|
Luisehahne
|
// Print admin footer
|
532 |
1664
|
darkviper
|
$admin->print_footer();
|