Project

General

Profile

« Previous | Next » 

Revision 1973

Added by darkviper about 11 years ago

/update-script.php last correction for loading PasswordHash packet and Typo fix line 87
/admin/pages/PageTree // SmallRawPageTree : adaption of Translate and WbAdapter

View differences:

PageTree.php
33 33
	
34 34
class a_pages_PageTree
35 35
{
36
/** @var array language definitions */
37
	protected $_TEXT     = null;
38
/** @var array language definitions */
39
	protected $_MESSAGE  = null;
40
/** @var array language definitions */
41
	protected $_HEADING  = null;
42 36
/** @var object instance of the application object */
43 37
	protected $_oApp     = null;
44 38
/** @var object instance of the database object */
45 39
	protected $_oDb      = null;
46
/** @var array holds several values from the application global scope */	
47
	protected $_aReg     = array();
40
/** @var object instance holds several values from the application global scope */
41
	protected $_oReg     = null;
42
/** @var object instance holds all of the translations */
43
	protected $_oTrans   = null;
48 44
/** @var string full HTML formattet list of pages */
49 45
	protected $_sOutput         = '';
50 46
/** @var integer number of all reachable pages */	
......
63 59
	public function __construct() 
64 60
	{
65 61
		// import global vars and objects
66
		$this->_wbAdaptor();
62
		$this->_oApp   = $GLOBALS['admin'];
63
		$this->_oDb    = WbDatabase::getInstance();
64
		$this->_oReg   = WbAdaptor::getInstance();
65
		$this->_oTrans = Translate::getInstance();
67 66
	}
68 67
/**
69 68
 * parse the page tree and return
......
105 104
		return $this->_aParentList;
106 105
	}
107 106
/**
108
 * used to import some WB-constants and objects
109
 */	
110
	protected 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 107
 * create a page tree as a well formatted, unordered list
129 108
 * @param int use page-ID as root of the generated page tree. (default: 0)
130 109
 * @return string the whoole list
......
139 118
		      . $this->_Tabs(1).'<tbody>'.PHP_EOL
140 119
		      . $this->_Tabs(1).'<tr class="pages_list_header">'.PHP_EOL
141 120
		      . $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'].
121
		      . $this->_Tabs(1).'<th class="list_menu_title">'.$this->_oTrans->TEXT_VISIBILITY.
122
		                        ' / '.$this->_oTrans->TEXT_MENU_TITLE.':</th>'.PHP_EOL
123
		      . $this->_Tabs(0).'<th class="list_page_title">'.$this->_oTrans->TEXT_PAGE_TITLE.
145 124
		                        '</th>'.PHP_EOL
146 125
		      . $this->_Tabs(0).'<th class="list_page_id">PID</th>'.PHP_EOL
147
		      . $this->_Tabs(0).'<th class="header_list_actions">'.$this->_TEXT['ACTIONS'].
126
		      . $this->_Tabs(0).'<th class="header_list_actions">'.$this->_oTrans->TEXT_ACTIONS.
148 127
		                        ':</th>'.PHP_EOL
149 128
		      . $this->_Tabs(0).'<th class="list_page_id">&nbsp;</th>'.PHP_EOL
150 129
		      . $this->_Tabs(-1).'</tr>'.PHP_EOL
......
176 155
	}
177 156
/**
178 157
 * compose the needed SQL statement
179
 * @param integer $iParentKey
158
 * @param  integer $iParentKey
180 159
 * @return string SQL statement
181 160
 */			
182 161
	protected function _makeSql($iParentKey = 0)
183 162
	{
163
		$iParentKey = intval($iParentKey);
184 164
		$sql  = 'SELECT ( SELECT COUNT(*) '
185
		      .          'FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` `x` '
165
		      .          'FROM `'.$this->_oDb->TablePrefix.'pages` `x` '
186 166
		      .          'WHERE x.`parent`=p.`page_id`'
187 167
		      .        ') `children`, '
188 168
		      .        's.`module`, MAX(s.`publ_start` + s.`publ_end`) published, p.`link`, '
189
		      .        '(SELECT MAX(`position`) FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` '
169
		      .        '(SELECT MAX(`position`) FROM `'.$this->_oDb->TablePrefix.'pages` '
190 170
		      .        'WHERE `parent`='.$iParentKey.') max_position, '
191 171
		      .        '0 min_position, '
192 172
		      .        'p.`position`, '
193 173
		      .        'p.`page_id`, p.`parent`, p.`level`, p.`language`, p.`admin_groups`, '
194 174
		      .        'p.`admin_users`, p.`viewing_groups`, p.`viewing_users`, p.`visibility`, '
195 175
		      .        'p.`menu_title`, p.`page_title`, p.`page_trail` '
196
		      . 'FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` p '
197
		      .    'INNER JOIN `'.$this->_aReg['TABLE_PREFIX'].'sections` s '
176
		      . 'FROM `'.$this->_oDb->TablePrefix.'pages` p '
177
		      .    'INNER JOIN `'.$this->_oDb->TablePrefix.'sections` s '
198 178
		      .    'ON p.`page_id`=s.`page_id` ';
199 179
//		if($iParentKey) {
200 180
//
......
204 184
			$sql .= 'WHERE `parent`='.$iParentKey.' ';
205 185
//		}
206 186
	// do not get pages with 'deleted' flag set on activated trashcan
207
		if($this->_aReg['PAGE_TRASH'] != 'inline') {
187
		if($this->_oReg->PageTrash != 'inline') {
208 188
			$sql .= 'AND `visibility`!=\'deleted\' ';
209 189
		}
210 190
		$sql .= 'GROUP BY p.`page_id` '
......
237 217
			$iMinPosition = 1;
238 218
			while($aPage = $oPages->fetchRow(MYSQL_ASSOC))
239 219
			{ // iterate through the current branch
240
				if($this->_aReg['PAGE_LEVEL_LIMIT'] && ($aPage['level'] > $this->_aReg['PAGE_LEVEL_LIMIT'])) {
220
				if($this->_oReg->PageLevelLimit && ($aPage['level'] > $this->_oReg->PageLevelLimit)) {
241 221
					return '';
242 222
				}
243 223
				$aPage['min_position'] = ($aPage['position'] < $iMinPosition ? $aPage['position'] : $iMinPosition);
......
246 226
				if( $this->_oApp->ami_group_member($aPage['admin_users']) ||
247 227
					$this->_oApp->is_group_match($this->_oApp->get_groups_id(), $aPage['admin_groups']))
248 228
				{
249
					if(($aPage['visibility'] == 'deleted' && $this->_aReg['PAGE_TRASH'] == 'inline') ||
229
					if(($aPage['visibility'] == 'deleted' && $this->_oReg->PageTrash == 'inline') ||
250 230
					   ($aPage['visibility'] != 'deleted'))
251 231
					{
252 232
						$aPage['iswriteable'] = true;
......
281 261
		          . (int)($aPage['level']*20).'px;">';
282 262
		if((bool)$aPage['children']) {
283 263
			$sOutput .= '<a href="javascript:toggle_visibility(\'p'.$aPage['page_id'].'\');" '
284
			          . 'title="'.$this->_TEXT['EXPAND'].'/'.$this->_TEXT['COLLAPSE'].'">'
285
			          . '<span><img src="'.$this->_aReg['THEME_REL'].'/images/'
264
			          . 'title="'.$this->_oTrans->TEXT_EXPAND.'/'.$this->_oTrans->TEXT_COLLAPSE.'">'
265
			          . '<span><img src="'.$this->_oReg->ThemeRel.'/images/'
286 266
			          . ( ((isset($_COOKIE['p'.$aPage['page_id']]) 
287 267
						  && $_COOKIE['p'.$aPage['page_id']] == '1') ? 'minus' : 'plus')
288 268
						)
......
295 275
	// --- TAB 2 --- (menu title) --------------------------------------------------------
296 276
		$sOutput .= $this->_Tabs(0).'<td class="list_menu_title">';
297 277
		if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
298
			$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/modify.php?page_id='
299
			          . $aPage['page_id'].'" title="'.$this->_TEXT['MODIFY'].'">';
278
			$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/modify.php?page_id='
279
			          . $aPage['page_id'].'" title="'.$this->_oTrans->TEXT_MODIFY.'">';
300 280
		}
301
		$sIcon = $this->_aReg['THEME_REL'].'/images/'.$aPage['visibility'].'_16.png';
302
		if(!is_readable($this->_aReg['DOCUMENT_ROOT'].$sIcon)) {
303
			$sIcon = $this->_aReg['THEME_REL'].'/images/public_16.png';
281
		$sIcon = $this->_oReg->ThemeRel.'/images/'.$aPage['visibility'].'_16.png';
282
		if(!is_readable($this->_oReg->DocumentRoot.$sIcon)) {
283
			$sIcon = $this->_oReg->ThemeRel.'/images/public_16.png';
304 284
		}
305
		$sOutput .= '<img src="'.$sIcon.'" alt="'.$this->_TEXT['VISIBILITY'].': '
306
		          . $this->_TEXT[strtoupper($aPage['visibility'])].'" class="page_list_rights" />';
285
		$sOutput .= '<img src="'.$sIcon.'" alt="'.$this->_oTrans->TEXT_VISIBILITY.': '
286
				  . $this->_oTrans->{'TEXT_'.strtoupper($aPage['visibility'])}  .'" class="page_list_rights" />';
307 287
		if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
308 288
			$sOutput .= '<span class="modify_link">'.$aPage['menu_title'].'</span></a>';
309 289
		}else {
......
317 297
	// --- TAB 5 --- (show this page in new window) --------------------------------------
318 298
		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
319 299
		if($aPage['visibility'] != 'deleted' && $aPage['visibility'] != 'none') {
320
			$sPageLink = $this->_aReg['WB_REL'].preg_replace(
321
			                                 '/^'.preg_quote($this->_aReg['WB_URL'], '/').'/siU', 
300
			$sPageLink = $this->_oReg->AppRel.preg_replace(
301
			                                 '/^'.preg_quote($this->_oReg->AppUrl, '/').'/siU',
322 302
			                                 '', 
323 303
			                                 $this->_oApp->page_link($aPage['link'])
324 304
			                                );
325
			$sOutput .= '<a href="'.$sPageLink.'" target="_blank" title="'.$this->_TEXT['VIEW']
326
			          . '"><img src="'.$this->_aReg['THEME_REL'].'/images/view_16.png" alt="'
327
			          . $this->_TEXT['VIEW'].'" /></a>';
305
			$sOutput .= '<a href="'.$sPageLink.'" target="_blank" title="'.$this->_oTrans->TEXT_VIEW
306
			          . '"><img src="'.$this->_oReg->ThemeRel.'/images/view_16.png" alt="'
307
			          . $this->_oTrans->TEXT_VIEW.'" /></a>';
328 308
		}else { 
329
			$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/blank_16.gif" alt=" " />'; 
309
			$sOutput .= '<img src="'.$this->_oReg->ThemeRel.'/images/blank_16.gif" alt=" " />';
330 310
		}
331 311
		$sOutput .= '</td>'.PHP_EOL;
332 312

  
......
334 314
		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
335 315
		if($aPage['visibility'] != 'deleted') { 
336 316
			if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
337
				$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/settings.php?page_id='
338
				          . $aPage['page_id'].'" title="'.$this->_TEXT['SETTINGS'].'">'
339
				          . '<img src="'.$this->_aReg['THEME_REL'].'/images/modify_16.png" alt="'
340
				          . $this->_TEXT['SETTINGS'].'" /></a>';
317
				$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/settings.php?page_id='
318
				          . $aPage['page_id'].'" title="'.$this->_oTrans->TEXT_SETTINGS.'">'
319
				          . '<img src="'.$this->_oReg->ThemeRel.'/images/modify_16.png" alt="'
320
				          . $this->_oTrans->TEXT_SETTINGS.'" /></a>';
341 321
			}
342 322
		}else {
343
			$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/restore.php?page_id='.$aPage['page_id'].'" '
344
			          . 'title="'.$this->_TEXT['RESTORE'].'"><img src="'.$this->_aReg['THEME_REL']
345
			          . '/images/restore_16.png" alt="'.$this->_TEXT['RESTORE'].'" /></a>';
323
			$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/restore.php?page_id='.$aPage['page_id'].'" '
324
			          . 'title="'.$this->_oTrans->TEXT_RESTORE.'"><img src="'.$this->_oReg->ThemeRel
325
			          . '/images/restore_16.png" alt="'.$this->_oTrans->TEXT_RESTORE.'" /></a>';
346 326
		}
347 327
		$sOutput .= '</td>'.PHP_EOL;
348 328

  
349 329
	// --- TAB 7 --- (edit sections) -----------------------------------------------------
350 330
		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
351
		if( $this->_aReg['MANAGE_SECTIONS'] && $this->_oApp->get_permission('pages_add') && $aPage['iswriteable'] ) {
331
		if( $this->_oReg->ManageSections && $this->_oApp->get_permission('pages_add') && $aPage['iswriteable'] ) {
352 332
			$file = $this->_oApp->page_is_active($aPage) ? "clock_16.png" : "clock_red_16.png";
353 333
			$file = ($aPage['published'] && $aPage['module'] != 'menu_link') ? $file : 'noclock_16.png';
354
			$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/sections.php?page_id='
355
			          . $aPage['page_id'].'" title="'.$this->_HEADING['MANAGE_SECTIONS'].'">'
356
			          . '<img src="'.$this->_aReg['THEME_REL'].'/images/'.$file.'" alt="'
357
			          . $this->_HEADING['MANAGE_SECTIONS'].'" /></a>';
334
			$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/sections.php?page_id='
335
			          . $aPage['page_id'].'" title="'.$this->_oTrans->HEADING_MANAGE_SECTIONS.'">'
336
			          . '<img src="'.$this->_oReg->ThemeRel.'/images/'.$file.'" alt="'
337
			          . $this->_oTrans->HEADING_MANAGE_SECTIONS.'" /></a>';
358 338
		}else { 
359
			$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/blank_16.gif" alt=" " />'; 
339
			$sOutput .= '<img src="'.$this->_oReg->ThemeRel.'/images/blank_16.gif" alt=" " />';
360 340
		}
361 341
		$sOutput .= '</td>'.PHP_EOL;
362 342

  
......
365 345
		if($aPage['position'] > $aPage['min_position']) {
366 346
			if($aPage['visibility'] != 'deleted') {
367 347
				if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
368
					$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/move_up.php?page_id='
369
					          . $aPage['page_id'].'" title="'.$this->_TEXT['MOVE_UP']
370
					          . '"><img src="'.$this->_aReg['THEME_REL'].'/images/up_16.png" alt="'
371
					          . $this->_TEXT['MOVE_UP'].'" /></a>';
348
					$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/move_up.php?page_id='
349
					          . $aPage['page_id'].'" title="'.$this->_oTrans->TEXT_MOVE_UP
350
					          . '"><img src="'.$this->_oReg->ThemeRel.'/images/up_16.png" alt="'
351
					          . $this->_oTrans->TEXT_MOVE_UP.'" /></a>';
372 352
				}
373 353
			}
374 354
		}
......
379 359
		if($aPage['position'] < $aPage['max_position']) {
380 360
			if($aPage['visibility'] != 'deleted') {
381 361
				if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
382
					$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/move_down.php?page_id='
383
					          . $aPage['page_id'].'" title="'.$this->_TEXT['MOVE_DOWN']
384
					          . '"><img src="'.$this->_aReg['THEME_REL'].'/images/down_16.png" alt="'
385
					          . $this->_TEXT['MOVE_DOWN'].'" /></a>';
362
					$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/move_down.php?page_id='
363
					          . $aPage['page_id'].'" title="'.$this->_oTrans->TEXT_MOVE_DOWN
364
					          . '"><img src="'.$this->_oReg->ThemeRel.'/images/down_16.png" alt="'
365
					          . $this->_oTrans->TEXT_MOVE_DOWN.'" /></a>';
386 366
				}
387 367
			}
388 368
		}
......
392 372
		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
393 373
		if($this->_oApp->get_permission('pages_delete') && $aPage['iswriteable']) {
394 374
			$sOutput .= '<a href="javascript:confirm_link(pages_delete_confirm+\'?\',\''
395
			          . $this->_aReg['ACP_REL'].'/pages/delete.php?page_id='
375
			          . $this->_oReg->AcpRel.'/pages/delete.php?page_id='
396 376
			          . $this->_oApp->getIDKEY($aPage['page_id']).'\');" title="'
397
			          . $this->_TEXT['DELETE'].'"><img src="'.$this->_aReg['THEME_REL']
398
			          . '/images/delete_16.png" alt="'.$this->_TEXT['DELETE'].'" /></a>';
377
			          . $this->_oTrans->TEXT_DELETE.'"><img src="'.$this->_oReg->ThemeRel
378
			          . '/images/delete_16.png" alt="'.$this->_oTrans->TEXT_DELETE.'" /></a>';
399 379
		}else { 
400
			$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/blank_16.gif" alt=" " />'; 
380
			$sOutput .= '<img src="'.$this->_oReg->ThemeRel.'/images/blank_16.gif" alt=" " />';
401 381
		}
402 382
		$sOutput .= '</td>'.PHP_EOL;
403 383

  
......
407 387
			$this->_oApp->get_permission('pages_add')
408 388
			&& $aPage['iswriteable'] 
409 389
			&& ($aPage['visibility'] != 'deleted') 
410
			&& $aPage['level'] < ($this->_aReg['PAGE_LEVEL_LIMIT'] - 1)
390
			&& $aPage['level'] < ($this->_oReg->PageLevelLimit - 1)
411 391
		  )
412 392
		{
413 393
			$sOutput .= '<a href="javascript:add_child_page(\''.$aPage['page_id'].'\');" '
414
			          . 'title="'.$this->_HEADING['ADD_CHILD_PAGE'].'"><img src="'
415
			          . $this->_aReg['THEME_REL'].'/images/siteadd.png" name="addpage_'.$aPage['page_id']
416
			          . '" alt="'.$this->_HEADING['ADD_CHILD_PAGE'].'" /></a>';
394
			          . 'title="'.$this->_oTrans->HEADING_ADD_CHILD_PAGE.'"><img src="'
395
			          . $this->_oReg->ThemeRel.'/images/siteadd.png" name="addpage_'.$aPage['page_id']
396
			          . '" alt="'.$this->_oTrans->HEADING_ADD_CHILD_PAGE.'" /></a>';
417 397
		}else { 
418 398
			$sOutput .= '&nbsp;'; 
419 399
		}
......
437 417
 */	
438 418
	protected function _addToParentList(array $aPage)
439 419
	{
440
		if( ($aPage['level'] < ($this->_aReg['PAGE_LEVEL_LIMIT'] - 1))
420
		if( ($aPage['level'] < ($this->_oReg->PageLevelLimit - 1))
441 421
			&& $aPage['iswriteable'] 
442 422
			&& ($aPage['visibility'] != 'deleted')
443 423
			&& $this->_oApp->get_permission('pages_add') ) 

Also available in: Unified diff