1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
5
|
*
|
6
|
* This program is free software: you can redistribute it and/or modify
|
7
|
* it under the terms of the GNU General Public License as published by
|
8
|
* the Free Software Foundation, either version 3 of the License, or
|
9
|
* (at your option) any later version.
|
10
|
*
|
11
|
* This program is distributed in the hope that it will be useful,
|
12
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
* GNU General Public License for more details.
|
15
|
*
|
16
|
* You should have received a copy of the GNU General Public License
|
17
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
*/
|
19
|
/**
|
20
|
* PageTree generator
|
21
|
*
|
22
|
* @category WbACP
|
23
|
* @package WbACP_Pages
|
24
|
* @author Werner v.d.Decken <wkl@isteam.de>
|
25
|
* @copyright Werner v.d.Decken <wkl@isteam.de>
|
26
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
27
|
* @version 1.0.0
|
28
|
* @revision $Revision: 1867 $
|
29
|
* @link $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/PageTree.php $
|
30
|
* @lastmodified $Date: 2013-02-19 21:52:42 +0100 (Tue, 19 Feb 2013) $
|
31
|
* @since file added on 2012-12-21
|
32
|
*/
|
33
|
|
34
|
class a_pages_PageTree
|
35
|
{
|
36
|
/** @var array language definitions */
|
37
|
private $_TEXT = null;
|
38
|
/** @var array language definitions */
|
39
|
private $_MESSAGE = null;
|
40
|
/** @var array language definitions */
|
41
|
private $_HEADING = null;
|
42
|
/** @var object instance of the application object */
|
43
|
private $_oApp = null;
|
44
|
/** @var object instance of the database object */
|
45
|
private $_oDb = null;
|
46
|
/** @var array holds several values from the application global scope */
|
47
|
private $_aReg = array();
|
48
|
/** @var string full HTML formattet list of pages */
|
49
|
private $_sOutput = '';
|
50
|
/** @var integer number of all reachable pages */
|
51
|
private $_iPagesTotal = 0;
|
52
|
/** @var integer number of all writeable pages */
|
53
|
private $_iPagesWriteable = 0;
|
54
|
/** @var integer index for toggle background color of the list */
|
55
|
private $_iLineColor = 0;
|
56
|
/** @var array entries to build a select list for parents */
|
57
|
private $_aParentList = array();
|
58
|
/** @var integer count all executed database requests passing all iterations. */
|
59
|
private $_queries = 0;
|
60
|
/**
|
61
|
* constructor used to import some application constants and objects
|
62
|
*/
|
63
|
public function __construct()
|
64
|
{
|
65
|
// import global vars and objects
|
66
|
$this->_wbAdaptor();
|
67
|
}
|
68
|
/**
|
69
|
* parse the page tree and return
|
70
|
* @param int use page-ID as root of the generated page tree. (default: 0)
|
71
|
* @return type
|
72
|
*/
|
73
|
public function parseTree($iTreeRoot = 0) {
|
74
|
return $this->_createTree($iTreeRoot);
|
75
|
}
|
76
|
/**
|
77
|
* parse the page tree and print it out
|
78
|
* @param int use page-ID as root of the generated page tree. (default: 0)
|
79
|
*/
|
80
|
public function displayTree($iTreeRoot = 0) {
|
81
|
echo $this->parseTree($iTreeRoot);
|
82
|
}
|
83
|
/**
|
84
|
* total number of found pages which are visible for actual user
|
85
|
* @return integer
|
86
|
*/
|
87
|
public function getTotalPages() {
|
88
|
return $this->_iPagesTotal;
|
89
|
}
|
90
|
/**
|
91
|
* number of found pages which are writable for actual user
|
92
|
* @return integer
|
93
|
*/
|
94
|
public function getWriteablePages() {
|
95
|
return $this->_iPagesWriteable;
|
96
|
}
|
97
|
/**
|
98
|
* a list with all possible parent pages
|
99
|
* @return array
|
100
|
*/
|
101
|
public function getParentList() {
|
102
|
if(!$this->_sOutput) {
|
103
|
$this->parseTree();
|
104
|
}
|
105
|
return $this->_aParentList;
|
106
|
}
|
107
|
/**
|
108
|
* used to import some WB-constants and objects
|
109
|
*/
|
110
|
private function _wbAdaptor()
|
111
|
{
|
112
|
$this->_TEXT = $GLOBALS['TEXT'];
|
113
|
$this->_MESSAGE = $GLOBALS['MESSAGE'];
|
114
|
$this->_HEADING = $GLOBALS['HEADING'];
|
115
|
$this->_oApp = $GLOBALS['admin'];
|
116
|
$this->_oDb = WbDatabase::getInstance();
|
117
|
$this->_aReg['PAGE_TRASH'] = PAGE_TRASH;
|
118
|
$this->_aReg['PAGE_LEVEL_LIMIT'] = PAGE_LEVEL_LIMIT;
|
119
|
$this->_aReg['MANAGE_SECTIONS'] = MANAGE_SECTIONS;
|
120
|
$this->_aReg['DOCUMENT_ROOT'] = $_SERVER['DOCUMENT_ROOT'];
|
121
|
$this->_aReg['WB_URL'] = WB_URL;
|
122
|
$this->_aReg['WB_REL'] = WB_REL;
|
123
|
$this->_aReg['ACP_REL'] = ADMIN_REL;
|
124
|
$this->_aReg['THEME_REL'] = THEME_REL;
|
125
|
$this->_aReg['TABLE_PREFIX'] = TABLE_PREFIX;
|
126
|
}
|
127
|
/**
|
128
|
* create a page tree as a well formatted, unordered list
|
129
|
* @param int use page-ID as root of the generated page tree. (default: 0)
|
130
|
* @return string the whoole list
|
131
|
*/
|
132
|
private function _createTree($iTreeRoot = 0)
|
133
|
{
|
134
|
// compose the complete list
|
135
|
$sOutput = ''
|
136
|
// build the head
|
137
|
. $this->_Tabs(0 , true).'<div class="jsadmin pages_list">'.PHP_EOL
|
138
|
. $this->_Tabs(1).'<table>'.PHP_EOL
|
139
|
. $this->_Tabs(1).'<tbody>'.PHP_EOL
|
140
|
. $this->_Tabs(1).'<tr class="pages_list_header">'.PHP_EOL
|
141
|
. $this->_Tabs(1).'<th style="width:20px;">'.PHP_EOL.'</th>'.PHP_EOL
|
142
|
. $this->_Tabs(1).'<th class="list_menu_title">'.$this->_TEXT['VISIBILITY'].
|
143
|
' / '.$this->_TEXT['MENU_TITLE'].':</th>'.PHP_EOL
|
144
|
. $this->_Tabs(0).'<th class="list_page_title">'.$this->_TEXT['PAGE_TITLE'].
|
145
|
'</th>'.PHP_EOL
|
146
|
. $this->_Tabs(0).'<th class="list_page_id">PID</th>'.PHP_EOL
|
147
|
. $this->_Tabs(0).'<th class="header_list_actions">'.$this->_TEXT['ACTIONS'].
|
148
|
':</th>'.PHP_EOL
|
149
|
. $this->_Tabs(0).'<th class="list_page_id"> </th>'.PHP_EOL
|
150
|
. $this->_Tabs(-1).'</tr>'.PHP_EOL
|
151
|
. $this->_Tabs(-1).'</tbody>'.PHP_EOL
|
152
|
. $this->_Tabs(-1).'</table>'.PHP_EOL
|
153
|
// generate the page lines
|
154
|
. $this->_IterateTree($iTreeRoot)
|
155
|
// build the footer
|
156
|
. $this->_Tabs(-1).'</div>'.PHP_EOL;
|
157
|
;
|
158
|
$this->_sOutput = $sOutput;
|
159
|
return $sOutput;
|
160
|
}
|
161
|
/**
|
162
|
* Create a string of multiple TABs to prettify the HTML-output
|
163
|
* ingrease the number of TABs with a positive and degrease with an negative Value.
|
164
|
* '0' means: do not change the value. Or set an absolute number using $bRelative=false
|
165
|
* @staticvar int $iTabLevel
|
166
|
* @param integer $iTabsDiv number of TABs to add/sub
|
167
|
* @param bool $bRelative false if should be set to absolute value
|
168
|
* @return string
|
169
|
*/
|
170
|
private function _Tabs($iTabsDiv = 0, $bRelative = true)
|
171
|
{
|
172
|
static $iTabLevel = 0;
|
173
|
$iTabLevel = ($bRelative ? $iTabLevel + $iTabsDiv : $iTabsDiv);
|
174
|
$iTabLevel += ($iTabLevel < 0 ? 0 - $iTabLevel : $iTabsDiv);
|
175
|
return str_repeat("\t", $iTabLevel);
|
176
|
}
|
177
|
/**
|
178
|
* compose the needed SQL statement
|
179
|
* @param integer $iParentKey
|
180
|
* @return string SQL statement
|
181
|
*/
|
182
|
private function _makeSql($iParentKey = 0)
|
183
|
{
|
184
|
if($this->_aReg['PAGE_TRASH'] != 'inline') {
|
185
|
$sUseTrash = ' AND `visibility`!=\'deleted\'';
|
186
|
}else { $sUseTrash = ''; }
|
187
|
$sql = 'SELECT ( SELECT COUNT(*) '
|
188
|
. 'FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` `x` '
|
189
|
. 'WHERE x.`parent`=p.`page_id`'
|
190
|
. ') `children`, '
|
191
|
. 's.`module`, MAX(s.`publ_start` + s.`publ_end`) published, p.`link`, '
|
192
|
. '(SELECT MAX(`position`) FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` '
|
193
|
. 'WHERE `parent`='.$iParentKey.') max_position, '
|
194
|
. '0 min_position, '
|
195
|
. 'p.`position`, '
|
196
|
. 'p.`page_id`, p.`parent`, p.`level`, p.`language`, p.`admin_groups`, '
|
197
|
. 'p.`admin_users`, p.`viewing_groups`, p.`viewing_users`, p.`visibility`, '
|
198
|
. 'p.`menu_title`, p.`page_title`, p.`page_trail` '
|
199
|
. 'FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` p '
|
200
|
. 'INNER JOIN `'.$this->_aReg['TABLE_PREFIX'].'sections` s '
|
201
|
. 'ON p.`page_id`=s.`page_id` '
|
202
|
. 'WHERE `parent`='.$iParentKey.$sUseTrash.' '
|
203
|
. 'GROUP BY p.`page_id` '
|
204
|
. 'ORDER BY p.`position` ASC';
|
205
|
return $sql;
|
206
|
}
|
207
|
/**
|
208
|
* iterate through all nodes which having subnodes
|
209
|
* @param integer start iteration from this parent page ( 0 = root)
|
210
|
* @return string all of the item lines
|
211
|
*/
|
212
|
private function _IterateTree($iParent = 0)
|
213
|
{
|
214
|
$sOutput = '';
|
215
|
// Get page list from database
|
216
|
if(($oPages = $this->_oDb->query($this->_makeSql($iParent))))
|
217
|
{
|
218
|
$this->_queries++;
|
219
|
// output block-header
|
220
|
$sOutput .= $this->_Tabs(0).'<ul id="p'.$iParent.'" class="page_list"';
|
221
|
if(!$iParent) {
|
222
|
$sOutput .= ' style="display: block;"';
|
223
|
}else {
|
224
|
// show block depending from Cookies
|
225
|
if (isset ($_COOKIE['p'.$iParent]) && $_COOKIE['p'.$iParent] == '1') {
|
226
|
$sOutput .= ' style="display: block;"';
|
227
|
}
|
228
|
}
|
229
|
$sOutput .= '>'.PHP_EOL;
|
230
|
$iMinPosition = 1;
|
231
|
while($aPage = $oPages->fetchRow(MYSQL_ASSOC))
|
232
|
{ // iterate through the current branch
|
233
|
if($this->_aReg['PAGE_LEVEL_LIMIT'] && ($aPage['level'] > $this->_aReg['PAGE_LEVEL_LIMIT'])) {
|
234
|
return '';
|
235
|
}
|
236
|
$aPage['min_position'] = ($aPage['position'] < $iMinPosition ? $aPage['position'] : $iMinPosition);
|
237
|
$this->_iLineColor = $this->_iPagesTotal++ % 2;
|
238
|
$aPage['iswriteable'] = false;
|
239
|
if( $this->_oApp->ami_group_member($aPage['admin_users']) ||
|
240
|
$this->_oApp->is_group_match($this->_oApp->get_groups_id(), $aPage['admin_groups']))
|
241
|
{
|
242
|
if(($aPage['visibility'] == 'deleted' && $this->_aReg['PAGE_TRASH'] == 'inline') ||
|
243
|
($aPage['visibility'] != 'deleted'))
|
244
|
{
|
245
|
$aPage['iswriteable'] = true;
|
246
|
$this->_iPagesWriteable++;
|
247
|
}
|
248
|
} else {
|
249
|
if($aPage['visibility'] == 'private') { continue; }
|
250
|
}
|
251
|
// add this item to the secondary list of parents
|
252
|
$this->_addToParentList($aPage);
|
253
|
$sOutput .= $this->_createListItem($aPage);
|
254
|
}
|
255
|
$sOutput .= $this->_Tabs(-1).'</ul>'.PHP_EOL;
|
256
|
}
|
257
|
return $sOutput;
|
258
|
}
|
259
|
/**
|
260
|
* formating the given page object for output
|
261
|
* @param type $aPage
|
262
|
* @return string
|
263
|
*/
|
264
|
private function _createListItem($aPage)
|
265
|
{
|
266
|
// output the current item
|
267
|
// --- HEADER ------------------------------------------------------------------------
|
268
|
$sOutput = $this->_Tabs(0).'<li class="p'.$aPage['parent'].'">'.PHP_EOL
|
269
|
. $this->_Tabs(1).'<table class="pages_view">'.PHP_EOL
|
270
|
. $this->_Tabs(1).'<tbody>'.PHP_EOL
|
271
|
. $this->_Tabs(1).'<tr class="row_'.$this->_iLineColor.'">'.PHP_EOL;
|
272
|
// --- TAB 1 --- (expand/collapse) ---------------------------------------------------
|
273
|
$sOutput .= $this->_Tabs(1).'<td valign="middle" width="20" style="padding-left: '
|
274
|
. (int)($aPage['level']*20).'px;">';
|
275
|
if((bool)$aPage['children']) {
|
276
|
$sOutput .= '<a href="javascript:toggle_visibility(\'p'.$aPage['page_id'].'\');" '
|
277
|
. 'title="'.$this->_TEXT['EXPAND'].'/'.$this->_TEXT['COLLAPSE'].'">'
|
278
|
. '<span><img src="'.$this->_aReg['THEME_REL'].'/images/'
|
279
|
. ( ((isset($_COOKIE['p'.$aPage['page_id']])
|
280
|
&& $_COOKIE['p'.$aPage['page_id']] == '1') ? 'minus' : 'plus')
|
281
|
)
|
282
|
. '_16.png" onclick="toggle_plus_minus(\''.$aPage['page_id'].'\');" '
|
283
|
. 'name="plus_minus_'.$aPage['page_id'].'" alt="+" /></span></a>';
|
284
|
}else {
|
285
|
$sOutput .= ' ';
|
286
|
}
|
287
|
$sOutput .= '</td>'.PHP_EOL;
|
288
|
// --- TAB 2 --- (menu title) --------------------------------------------------------
|
289
|
$sOutput .= $this->_Tabs(0).'<td class="list_menu_title">';
|
290
|
if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
|
291
|
$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/modify.php?page_id='
|
292
|
. $aPage['page_id'].'" title="'.$this->_TEXT['MODIFY'].'">';
|
293
|
}
|
294
|
$sIcon = $this->_aReg['THEME_REL'].'/images/'.$aPage['visibility'].'_16.png';
|
295
|
if(!is_readable($this->_aReg['DOCUMENT_ROOT'].$sIcon)) {
|
296
|
$sIcon = $this->_aReg['THEME_REL'].'/images/public_16.png';
|
297
|
}
|
298
|
$sOutput .= '<img src="'.$sIcon.'" alt="'.$this->_TEXT['VISIBILITY'].': '
|
299
|
. $this->_TEXT[strtoupper($aPage['visibility'])].'" class="page_list_rights" />';
|
300
|
if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
|
301
|
$sOutput .= '<span class="modify_link">'.$aPage['menu_title'].'</span></a>';
|
302
|
}else {
|
303
|
$sOutput .= '<span class="bold grey">'.$aPage['menu_title'].'</span>';
|
304
|
}
|
305
|
$sOutput .= '</td>'.PHP_EOL;
|
306
|
// --- TAB 3 --- (page title) --------------------------------------------------------
|
307
|
$sOutput .= $this->_Tabs(0).'<td class="list_page_title">'.$aPage['page_title'].'</td>'.PHP_EOL;
|
308
|
// --- TAB 4 --- (page ID) -----------------------------------------------------------
|
309
|
$sOutput .= $this->_Tabs(0).'<td class="list_page_id right">'.$aPage['page_id'].'</td>'.PHP_EOL;
|
310
|
// --- TAB 5 --- (show this page in new window) --------------------------------------
|
311
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
312
|
if($aPage['visibility'] != 'deleted' && $aPage['visibility'] != 'none') {
|
313
|
$sPageLink = $this->_aReg['WB_REL'].preg_replace(
|
314
|
'/^'.preg_quote($this->_aReg['WB_URL'], '/').'/siU',
|
315
|
'',
|
316
|
$this->_oApp->page_link($aPage['link'])
|
317
|
);
|
318
|
$sOutput .= '<a href="'.$sPageLink.'" target="_blank" title="'.$this->_TEXT['VIEW']
|
319
|
. '"><img src="'.$this->_aReg['THEME_REL'].'/images/view_16.png" alt="'
|
320
|
. $this->_TEXT['VIEW'].'" /></a>';
|
321
|
}else {
|
322
|
$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/blank_16.gif" alt=" " />';
|
323
|
}
|
324
|
$sOutput .= '</td>'.PHP_EOL;
|
325
|
|
326
|
// --- TAB 6 --- (edit settings) -----------------------------------------------------
|
327
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
328
|
if($aPage['visibility'] != 'deleted') {
|
329
|
if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
|
330
|
$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/settings.php?page_id='
|
331
|
. $aPage['page_id'].'" title="'.$this->_TEXT['SETTINGS'].'">'
|
332
|
. '<img src="'.$this->_aReg['THEME_REL'].'/images/modify_16.png" alt="'
|
333
|
. $this->_TEXT['SETTINGS'].'" /></a>';
|
334
|
}
|
335
|
}else {
|
336
|
$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/restore.php?page_id='.$aPage['page_id'].'" '
|
337
|
. 'title="'.$this->_TEXT['RESTORE'].'"><img src="'.$this->_aReg['THEME_REL']
|
338
|
. '/images/restore_16.png" alt="'.$this->_TEXT['RESTORE'].'" /></a>';
|
339
|
}
|
340
|
$sOutput .= '</td>'.PHP_EOL;
|
341
|
|
342
|
// --- TAB 7 --- (edit sections) -----------------------------------------------------
|
343
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
344
|
if( $this->_aReg['MANAGE_SECTIONS'] && $this->_oApp->get_permission('pages_add') && $aPage['iswriteable'] ) {
|
345
|
$file = $this->_oApp->page_is_active($aPage) ? "clock_16.png" : "clock_red_16.png";
|
346
|
$file = ($aPage['published'] && $aPage['module'] != 'menu_link') ? $file : 'noclock_16.png';
|
347
|
$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/sections.php?page_id='
|
348
|
. $aPage['page_id'].'" title="'.$this->_HEADING['MANAGE_SECTIONS'].'">'
|
349
|
. '<img src="'.$this->_aReg['THEME_REL'].'/images/'.$file.'" alt="'
|
350
|
. $this->_HEADING['MANAGE_SECTIONS'].'" /></a>';
|
351
|
}else {
|
352
|
$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/blank_16.gif" alt=" " />';
|
353
|
}
|
354
|
$sOutput .= '</td>'.PHP_EOL;
|
355
|
|
356
|
// --- TAB 8 --- (move up) -----------------------------------------------------------
|
357
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
358
|
if($aPage['position'] > $aPage['min_position']) {
|
359
|
if($aPage['visibility'] != 'deleted') {
|
360
|
if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
|
361
|
$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/move_up.php?page_id='
|
362
|
. $aPage['page_id'].'" title="'.$this->_TEXT['MOVE_UP']
|
363
|
. '"><img src="'.$this->_aReg['THEME_REL'].'/images/up_16.png" alt="'
|
364
|
. $this->_TEXT['MOVE_UP'].'" /></a>';
|
365
|
}
|
366
|
}
|
367
|
}
|
368
|
$sOutput .= '</td>'.PHP_EOL;
|
369
|
|
370
|
// --- TAB 9 --- (move down) ---------------------------------------------------------
|
371
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
372
|
if($aPage['position'] < $aPage['max_position']) {
|
373
|
if($aPage['visibility'] != 'deleted') {
|
374
|
if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
|
375
|
$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/move_down.php?page_id='
|
376
|
. $aPage['page_id'].'" title="'.$this->_TEXT['MOVE_DOWN']
|
377
|
. '"><img src="'.$this->_aReg['THEME_REL'].'/images/down_16.png" alt="'
|
378
|
. $this->_TEXT['MOVE_DOWN'].'" /></a>';
|
379
|
}
|
380
|
}
|
381
|
}
|
382
|
$sOutput .= '</td>'.PHP_EOL;
|
383
|
|
384
|
// --- TAB 10 --- (delete page) ------------------------------------------------------
|
385
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
386
|
if($this->_oApp->get_permission('pages_delete') && $aPage['iswriteable']) {
|
387
|
$sOutput .= '<a href="javascript:confirm_link(pages_delete_confirm+\'?\',\''
|
388
|
. $this->_aReg['ACP_REL'].'/pages/delete.php?page_id='
|
389
|
. $this->_oApp->getIDKEY($aPage['page_id']).'\');" title="'
|
390
|
. $this->_TEXT['DELETE'].'"><img src="'.$this->_aReg['THEME_REL']
|
391
|
. '/images/delete_16.png" alt="'.$this->_TEXT['DELETE'].'" /></a>';
|
392
|
}else {
|
393
|
$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/blank_16.gif" alt=" " />';
|
394
|
}
|
395
|
$sOutput .= '</td>'.PHP_EOL;
|
396
|
|
397
|
// --- TAB 11 --- (add child page) ---------------------------------------------------
|
398
|
$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
|
399
|
if(
|
400
|
$this->_oApp->get_permission('pages_add')
|
401
|
&& $aPage['iswriteable']
|
402
|
&& ($aPage['visibility'] != 'deleted')
|
403
|
&& $aPage['level'] < ($this->_aReg['PAGE_LEVEL_LIMIT'] - 1)
|
404
|
)
|
405
|
{
|
406
|
$sOutput .= '<a href="javascript:add_child_page(\''.$aPage['page_id'].'\');" '
|
407
|
. 'title="'.$this->_HEADING['ADD_CHILD_PAGE'].'"><img src="'
|
408
|
. $this->_aReg['THEME_REL'].'/images/siteadd.png" name="addpage_'.$aPage['page_id']
|
409
|
. '" alt="'.$this->_HEADING['ADD_CHILD_PAGE'].'" /></a>';
|
410
|
}else {
|
411
|
$sOutput .= ' ';
|
412
|
}
|
413
|
$sOutput .= '</td>'.PHP_EOL;
|
414
|
// --- TAB 12 --- (show language) ----------------------------------------------------
|
415
|
$sOutput .= $this->_Tabs(0).'<td class="list_page_id center">'.$aPage['language'].'</td>'.PHP_EOL;
|
416
|
// --- FOOTER ------------------------------------------------------------------------
|
417
|
$sOutput .= $this->_Tabs(-1).'</tr>'.PHP_EOL
|
418
|
. $this->_Tabs(-1).'</tbody>'.PHP_EOL
|
419
|
. $this->_Tabs(-1).'</table>'.PHP_EOL;
|
420
|
// if there children, iterate through this children now
|
421
|
if((bool)$aPage['children']) {
|
422
|
$sOutput .= $this->_IterateTree($aPage['page_id']);
|
423
|
}
|
424
|
$sOutput .= $this->_Tabs(-1).'</li>'.PHP_EOL;
|
425
|
return $sOutput;
|
426
|
} // end of method _createListItem
|
427
|
/**
|
428
|
* build a list of possible parent pages
|
429
|
* @param array $aPage
|
430
|
*/
|
431
|
private function _addToParentList(array $aPage)
|
432
|
{
|
433
|
if( ($aPage['level'] < ($this->_aReg['PAGE_LEVEL_LIMIT'] - 1))
|
434
|
&& $aPage['iswriteable']
|
435
|
&& ($aPage['visibility'] != 'deleted')
|
436
|
&& $this->_oApp->get_permission('pages_add') )
|
437
|
{
|
438
|
$aNewEntry = array();
|
439
|
$aNewEntry['ID'] = $aPage['page_id'];
|
440
|
$aNewEntry['TITLE'] = $aPage['menu_title'];
|
441
|
$aNewEntry['DISABLED'] = ($aPage['iswriteable'] ? 0 : 1);
|
442
|
$aNewEntry['PARENT'] = $aPage['parent'];
|
443
|
$aNewEntry['FLAG_ROOT_ICON'] = '';
|
444
|
$aNewEntry['LEVEL'] = $aPage['level'];
|
445
|
$aNewEntry['LANGUAGE'] = $aPage['language'];
|
446
|
$this->_aParentList[] = $aNewEntry;
|
447
|
}
|
448
|
}
|
449
|
|
450
|
} // end of class PageTree
|