Project

General

Profile

« Previous | Next » 

Revision 1846

Added by darkviper over 11 years ago

added variable root page for tree generation in class a_pages_PageTree
fixed missing css class jsadmin for drop/down activation in PageTree

View differences:

PageTree.php
17 17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 18
 */
19 19
/**
20
 * Description of PageTree
20
 * PageTree generator
21 21
 *
22 22
 * @category     WbACP
23 23
 * @package      WbACP_Pages
24
 * @author       Werner v.d. Decken <wkl@isteam.de>
25
 * @copyright    Werner v.d. Decken <wkl@isteam.de>
24
 * @author       Werner v.d.Decken <wkl@isteam.de>
25
 * @copyright    Werner v.d.Decken <wkl@isteam.de>
26 26
 * @license      http://www.gnu.org/licenses/gpl.html   GPL License
27 27
 * @version      1.0.0
28 28
 * @revision     $Revision$
......
67 67
	}
68 68
/**
69 69
 * parse the page tree and return
70
 * @param int use page-ID as root of the generated page tree. (default: 0)
70 71
 * @return type
71 72
 */	
72
	public function parseTree() {
73
		return $this->_createTree();
73
	public function parseTree($iTreeRoot = 0) {
74
		return $this->_createTree($iTreeRoot);
74 75
	}
75 76
/**
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)
77 79
 */	
78
	public function displayTree() {
79
		echo $this->parseTree();
80
	public function displayTree($iTreeRoot = 0) {
81
		echo $this->parseTree($iTreeRoot);
80 82
	}
81 83
/**
82 84
 * total number of found pages which are visible for actual user
......
123 125
	}
124 126
/**
125 127
 * create a page tree as a well formatted, unordered list
128
 * @param int use page-ID as root of the generated page tree. (default: 0)
126 129
 * @return string the whoole list
127 130
 */
128
	private function _createTree()
131
	private function _createTree($iTreeRoot = 0)
129 132
	{
130 133
		// compose the complete list
131 134
		$sOutput = ''
132 135
		// build the head
133
		      . $this->_Tabs(0 , true).'<div class="pages_list">'.PHP_EOL
136
		      . $this->_Tabs(0 , true).'<div class="jsadmin pages_list">'.PHP_EOL
134 137
		      . $this->_Tabs(1).'<table>'.PHP_EOL
135 138
		      . $this->_Tabs(1).'<tbody>'.PHP_EOL
136 139
		      . $this->_Tabs(1).'<tr class="pages_list_header">'.PHP_EOL
......
146 149
		      . $this->_Tabs(-1).'</tbody>'.PHP_EOL
147 150
		      . $this->_Tabs(-1).'</table>'.PHP_EOL
148 151
		// generate the page lines
149
		      . $this->_IterateTree()
152
		      . $this->_IterateTree($iTreeRoot)
150 153
		// build the footer
151 154
		      . $this->_Tabs(-1).'</div>'.PHP_EOL;
152 155
		;
......
201 204
	}
202 205
/**
203 206
 * iterate through all nodes which having subnodes 
204
 * @param integer $iParent
207
 * @param integer start iteration from this parent page ( 0 = root)
205 208
 * @return string all of the item lines 
206 209
 */	
207 210
	private function _IterateTree($iParent = 0)
......
225 228
			$iMinPosition = 1;
226 229
			while($aPage = $oPages->fetchRow(MYSQL_ASSOC))
227 230
			{ // iterate through the current branch
231
				if($this->_aReg['PAGE_LEVEL_LIMIT'] && ($aPage['level'] > $this->_aReg['PAGE_LEVEL_LIMIT'])) {
232
					return '';
233
				}
228 234
				$aPage['min_position'] = ($aPage['position'] < $iMinPosition ? $aPage['position'] : $iMinPosition);
229 235
				$this->_iLineColor = $this->_iPagesTotal++ % 2;
230 236
				$aPage['iswriteable'] = false;
......
278 284
		}
279 285
		$sOutput .= '</td>'.PHP_EOL;
280 286
	// --- TAB 2 --- (menu title) --------------------------------------------------------
281
		switch($aPage['visibility']):
282
			case 'private':
283
				$sIcon = 'private_16.png';
284
				$sText = $this->_TEXT['PRIVATE'];
285
				break;
286
			case 'registered':
287
				$sIcon = 'keys_16.png';
288
				$sText = $this->_TEXT['REGISTERED'];
289
				break;
290
			case 'hidden':
291
				$sIcon = 'hidden_16.png';
292
				$sText = $this->_TEXT['HIDDEN'];
293
				break;
294
			case 'none':
295
				$sIcon = 'none_16.png';
296
				$sText = $this->_TEXT['NONE'];
297
				break;
298
			case 'deleted':
299
				$sIcon = 'deleted_16.png';
300
				$sText = $this->_TEXT['DELETED'];
301
				break;
302
			default: // public
303
				$sIcon = 'visible_16.png';
304
				$sText = $this->_TEXT['PUBLIC'];
305
				break;
306
		endswitch;
307 287
		$sOutput .= $this->_Tabs(0).'<td class="list_menu_title">';
308 288
		if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
309 289
			$sOutput .= '<a href="'.$this->_aReg['ACP_REL'].'/pages/modify.php?page_id='
310 290
			          . $aPage['page_id'].'" title="'.$this->_TEXT['MODIFY'].'">';
311 291
		}
312
		$sOutput .= '<img src="'.$this->_aReg['THEME_REL'].'/images/'.$sIcon.'" '
313
		          . 'alt="'.$this->_TEXT['VISIBILITY'].': '.$sText.'" class="page_list_rights" />';
292
		$sIcon = $this->_aReg['THEME_REL'].'/images/'.$aPage['visibility'].'_16.png';
293
		if(!is_readable($sIcon)) {
294
			$sIcon = $this->_aReg['THEME_REL'].'/images/public_16.png';
295
		}
296
		$sOutput .= '<img src="'.$sIcon.'" alt="'.$this->_TEXT['VISIBILITY'].': '
297
		          . $sText.'" class="page_list_rights" />';
314 298
		if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
315 299
			$sOutput .= '<span class="modify_link">'.$aPage['menu_title'].'</span></a>';
316 300
		}else {

Also available in: Unified diff