Revision 1953
Added by darkviper about 11 years ago
PageTree.php | ||
---|---|---|
34 | 34 |
class a_pages_PageTree |
35 | 35 |
{ |
36 | 36 |
/** @var array language definitions */ |
37 |
private $_TEXT = null;
|
|
37 |
protected $_TEXT = null;
|
|
38 | 38 |
/** @var array language definitions */ |
39 |
private $_MESSAGE = null;
|
|
39 |
protected $_MESSAGE = null;
|
|
40 | 40 |
/** @var array language definitions */ |
41 |
private $_HEADING = null;
|
|
41 |
protected $_HEADING = null;
|
|
42 | 42 |
/** @var object instance of the application object */ |
43 |
private $_oApp = null;
|
|
43 |
protected $_oApp = null;
|
|
44 | 44 |
/** @var object instance of the database object */ |
45 |
private $_oDb = null;
|
|
45 |
protected $_oDb = null;
|
|
46 | 46 |
/** @var array holds several values from the application global scope */ |
47 |
private $_aReg = array();
|
|
47 |
protected $_aReg = array();
|
|
48 | 48 |
/** @var string full HTML formattet list of pages */ |
49 |
private $_sOutput = '';
|
|
49 |
protected $_sOutput = '';
|
|
50 | 50 |
/** @var integer number of all reachable pages */ |
51 |
private $_iPagesTotal = 0;
|
|
51 |
protected $_iPagesTotal = 0;
|
|
52 | 52 |
/** @var integer number of all writeable pages */ |
53 |
private $_iPagesWriteable = 0;
|
|
53 |
protected $_iPagesWriteable = 0;
|
|
54 | 54 |
/** @var integer index for toggle background color of the list */ |
55 |
private $_iLineColor = 0;
|
|
55 |
protected $_iLineColor = 0;
|
|
56 | 56 |
/** @var array entries to build a select list for parents */ |
57 |
private $_aParentList = array();
|
|
57 |
protected $_aParentList = array();
|
|
58 | 58 |
/** @var integer count all executed database requests passing all iterations. */ |
59 |
private $_queries = 0;
|
|
59 |
protected $_queries = 0;
|
|
60 | 60 |
/** |
61 | 61 |
* constructor used to import some application constants and objects |
62 | 62 |
*/ |
... | ... | |
98 | 98 |
* a list with all possible parent pages |
99 | 99 |
* @return array |
100 | 100 |
*/ |
101 |
public function getParentList() { |
|
101 |
public function getParentList($iTreeRoot = 0) {
|
|
102 | 102 |
if(!$this->_sOutput) { |
103 |
$this->parseTree(); |
|
103 |
$this->parseTree($iTreeRoot);
|
|
104 | 104 |
} |
105 | 105 |
return $this->_aParentList; |
106 | 106 |
} |
107 | 107 |
/** |
108 | 108 |
* used to import some WB-constants and objects |
109 | 109 |
*/ |
110 |
private function _wbAdaptor()
|
|
110 |
protected function _wbAdaptor()
|
|
111 | 111 |
{ |
112 | 112 |
$this->_TEXT = $GLOBALS['TEXT']; |
113 | 113 |
$this->_MESSAGE = $GLOBALS['MESSAGE']; |
... | ... | |
129 | 129 |
* @param int use page-ID as root of the generated page tree. (default: 0) |
130 | 130 |
* @return string the whoole list |
131 | 131 |
*/ |
132 |
private function _createTree($iTreeRoot = 0)
|
|
132 |
protected function _createTree($iTreeRoot = 0)
|
|
133 | 133 |
{ |
134 | 134 |
// compose the complete list |
135 | 135 |
$sOutput = '' |
... | ... | |
167 | 167 |
* @param bool $bRelative false if should be set to absolute value |
168 | 168 |
* @return string |
169 | 169 |
*/ |
170 |
private function _Tabs($iTabsDiv = 0, $bRelative = true)
|
|
170 |
protected function _Tabs($iTabsDiv = 0, $bRelative = true)
|
|
171 | 171 |
{ |
172 | 172 |
static $iTabLevel = 0; |
173 | 173 |
$iTabLevel = ($bRelative ? $iTabLevel + $iTabsDiv : $iTabsDiv); |
... | ... | |
179 | 179 |
* @param integer $iParentKey |
180 | 180 |
* @return string SQL statement |
181 | 181 |
*/ |
182 |
private function _makeSql($iParentKey = 0)
|
|
182 |
protected function _makeSql($iParentKey = 0)
|
|
183 | 183 |
{ |
184 |
$sql = 'SELECT ( SELECT COUNT(*) ' |
|
185 |
. 'FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` `x` ' |
|
186 |
. 'WHERE x.`parent`=p.`page_id`' |
|
187 |
. ') `children`, ' |
|
188 |
. 's.`module`, MAX(s.`publ_start` + s.`publ_end`) published, p.`link`, ' |
|
189 |
. '(SELECT MAX(`position`) FROM `'.$this->_aReg['TABLE_PREFIX'].'pages` ' |
|
190 |
. 'WHERE `parent`='.$iParentKey.') max_position, ' |
|
191 |
. '0 min_position, ' |
|
192 |
. 'p.`position`, ' |
|
193 |
. 'p.`page_id`, p.`parent`, p.`level`, p.`language`, p.`admin_groups`, ' |
|
194 |
. 'p.`admin_users`, p.`viewing_groups`, p.`viewing_users`, p.`visibility`, ' |
|
195 |
. '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 ' |
|
198 |
. 'ON p.`page_id`=s.`page_id` '; |
|
199 |
// if($iParentKey) { |
|
200 |
// |
|
201 |
// $sql .= 'WHERE `root_parent`='.$iParentKey.' '; |
|
202 |
// } else { |
|
203 |
// // if tree based on root is requested (parent=0) |
|
204 |
$sql .= 'WHERE `parent`='.$iParentKey.' '; |
|
205 |
// } |
|
206 |
// do not get pages with 'deleted' flag set on activated trashcan |
|
184 | 207 |
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'; |
|
208 |
$sql .= 'AND `visibility`!=\'deleted\' '; |
|
209 |
} |
|
210 |
$sql .= 'GROUP BY p.`page_id` ' |
|
211 |
. 'ORDER BY p.`position` ASC'; |
|
205 | 212 |
return $sql; |
206 | 213 |
} |
207 | 214 |
/** |
... | ... | |
209 | 216 |
* @param integer start iteration from this parent page ( 0 = root) |
210 | 217 |
* @return string all of the item lines |
211 | 218 |
*/ |
212 |
private function _IterateTree($iParent = 0)
|
|
219 |
protected function _IterateTree($iParent = 0)
|
|
213 | 220 |
{ |
214 | 221 |
$sOutput = ''; |
215 | 222 |
// Get page list from database |
... | ... | |
261 | 268 |
* @param type $aPage |
262 | 269 |
* @return string |
263 | 270 |
*/ |
264 |
private function _createListItem($aPage)
|
|
271 |
protected function _createListItem($aPage)
|
|
265 | 272 |
{ |
266 | 273 |
// output the current item |
267 | 274 |
// --- HEADER ------------------------------------------------------------------------ |
... | ... | |
428 | 435 |
* build a list of possible parent pages |
429 | 436 |
* @param array $aPage |
430 | 437 |
*/ |
431 |
private function _addToParentList(array $aPage)
|
|
438 |
protected function _addToParentList(array $aPage)
|
|
432 | 439 |
{ |
433 | 440 |
if( ($aPage['level'] < ($this->_aReg['PAGE_LEVEL_LIMIT'] - 1)) |
434 | 441 |
&& $aPage['iswriteable'] |
435 | 442 |
&& ($aPage['visibility'] != 'deleted') |
436 | 443 |
&& $this->_oApp->get_permission('pages_add') ) |
437 | 444 |
{ |
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; |
|
445 |
$aPage['disabled'] = ($aPage['iswriteable'] ? 0 : 1); |
|
446 |
$this->_aParentList[] = $aPage; |
|
447 | 447 |
} |
448 | 448 |
} |
449 | 449 |
|
Also available in: Unified diff
solved some problems with MultiLingual module