| 1 | 1839 | darkviper | <?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 | 1846 | darkviper |  * PageTree generator
 | 
      
        | 21 | 1839 | darkviper |  *
 | 
      
        | 22 |  |  |  * @category     WbACP
 | 
      
        | 23 |  |  |  * @package      WbACP_Pages
 | 
      
        | 24 | 1846 | darkviper |  * @author       Werner v.d.Decken <wkl@isteam.de>
 | 
      
        | 25 |  |  |  * @copyright    Werner v.d.Decken <wkl@isteam.de>
 | 
      
        | 26 | 1839 | darkviper |  * @license      http://www.gnu.org/licenses/gpl.html   GPL License
 | 
      
        | 27 |  |  |  * @version      1.0.0
 | 
      
        | 28 |  |  |  * @revision     $Revision$
 | 
      
        | 29 |  |  |  * @link         $HeadURL$
 | 
      
        | 30 |  |  |  * @lastmodified $Date$
 | 
      
        | 31 |  |  |  * @since        file added on 2012-12-21
 | 
      
        | 32 |  |  |  */
 | 
      
        | 33 |  |  | 
 | 
      
        | 34 |  |  | class a_pages_PageTree
 | 
      
        | 35 |  |  | {
 | 
      
        | 36 |  |  | /** @var object instance of the application object */
 | 
      
        | 37 | 1953 | darkviper | 	protected $_oApp     = null;
 | 
      
        | 38 | 1839 | darkviper | /** @var object instance of the database object */
 | 
      
        | 39 | 1953 | darkviper | 	protected $_oDb      = null;
 | 
      
        | 40 | 1973 | darkviper | /** @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;
 | 
      
        | 44 | 1839 | darkviper | /** @var string full HTML formattet list of pages */
 | 
      
        | 45 | 1953 | darkviper | 	protected $_sOutput         = '';
 | 
      
        | 46 | 1839 | darkviper | /** @var integer number of all reachable pages */
 | 
      
        | 47 | 1953 | darkviper | 	protected $_iPagesTotal     = 0;
 | 
      
        | 48 | 1839 | darkviper | /** @var integer number of all writeable pages */
 | 
      
        | 49 | 1953 | darkviper | 	protected $_iPagesWriteable = 0;
 | 
      
        | 50 | 1839 | darkviper | /** @var integer index for toggle background color of the list */
 | 
      
        | 51 | 1953 | darkviper | 	protected $_iLineColor      = 0;
 | 
      
        | 52 | 1839 | darkviper | /** @var array entries to build a select list for parents */
 | 
      
        | 53 | 1953 | darkviper | 	protected $_aParentList     = array();
 | 
      
        | 54 | 1839 | darkviper | /** @var integer count all executed database requests passing all iterations. */
 | 
      
        | 55 | 1953 | darkviper | 	protected $_queries = 0;
 | 
      
        | 56 | 1839 | darkviper | /**
 | 
      
        | 57 |  |  |  * constructor used to import some application constants and objects
 | 
      
        | 58 |  |  |  */
 | 
      
        | 59 |  |  | 	public function __construct()
 | 
      
        | 60 |  |  | 	{
 | 
      
        | 61 |  |  | 		// import global vars and objects
 | 
      
        | 62 | 1973 | darkviper | 		$this->_oApp   = $GLOBALS['admin'];
 | 
      
        | 63 |  |  | 		$this->_oDb    = WbDatabase::getInstance();
 | 
      
        | 64 |  |  | 		$this->_oReg   = WbAdaptor::getInstance();
 | 
      
        | 65 |  |  | 		$this->_oTrans = Translate::getInstance();
 | 
      
        | 66 | 1839 | darkviper | 	}
 | 
      
        | 67 |  |  | /**
 | 
      
        | 68 |  |  |  * parse the page tree and return
 | 
      
        | 69 | 1846 | darkviper |  * @param int use page-ID as root of the generated page tree. (default: 0)
 | 
      
        | 70 | 1839 | darkviper |  * @return type
 | 
      
        | 71 |  |  |  */
 | 
      
        | 72 | 1846 | darkviper | 	public function parseTree($iTreeRoot = 0) {
 | 
      
        | 73 |  |  | 		return $this->_createTree($iTreeRoot);
 | 
      
        | 74 | 1839 | darkviper | 	}
 | 
      
        | 75 |  |  | /**
 | 
      
        | 76 |  |  |  *  parse the page tree and print it out
 | 
      
        | 77 | 1846 | darkviper |  * @param int use page-ID as root of the generated page tree. (default: 0)
 | 
      
        | 78 | 1839 | darkviper |  */
 | 
      
        | 79 | 1846 | darkviper | 	public function displayTree($iTreeRoot = 0) {
 | 
      
        | 80 |  |  | 		echo $this->parseTree($iTreeRoot);
 | 
      
        | 81 | 1839 | darkviper | 	}
 | 
      
        | 82 |  |  | /**
 | 
      
        | 83 |  |  |  * total number of found pages which are visible for actual user
 | 
      
        | 84 |  |  |  * @return integer
 | 
      
        | 85 |  |  |  */
 | 
      
        | 86 |  |  | 	public function getTotalPages() {
 | 
      
        | 87 |  |  | 		return $this->_iPagesTotal;
 | 
      
        | 88 |  |  | 	}
 | 
      
        | 89 |  |  | /**
 | 
      
        | 90 |  |  |  * number of found pages which are writable for actual user
 | 
      
        | 91 |  |  |  * @return integer
 | 
      
        | 92 |  |  |  */
 | 
      
        | 93 |  |  | 	public function getWriteablePages() {
 | 
      
        | 94 |  |  | 		return $this->_iPagesWriteable;
 | 
      
        | 95 |  |  | 	}
 | 
      
        | 96 |  |  | /**
 | 
      
        | 97 |  |  |  * a list with all possible parent pages
 | 
      
        | 98 |  |  |  * @return array
 | 
      
        | 99 |  |  |  */
 | 
      
        | 100 | 1953 | darkviper | 	public function getParentList($iTreeRoot = 0) {
 | 
      
        | 101 | 1839 | darkviper | 		if(!$this->_sOutput) {
 | 
      
        | 102 | 1953 | darkviper | 			$this->parseTree($iTreeRoot);
 | 
      
        | 103 | 1839 | darkviper | 		}
 | 
      
        | 104 |  |  | 		return $this->_aParentList;
 | 
      
        | 105 |  |  | 	}
 | 
      
        | 106 |  |  | /**
 | 
      
        | 107 |  |  |  * create a page tree as a well formatted, unordered list
 | 
      
        | 108 | 1846 | darkviper |  * @param int use page-ID as root of the generated page tree. (default: 0)
 | 
      
        | 109 | 1839 | darkviper |  * @return string the whoole list
 | 
      
        | 110 |  |  |  */
 | 
      
        | 111 | 1953 | darkviper | 	protected function _createTree($iTreeRoot = 0)
 | 
      
        | 112 | 1839 | darkviper | 	{
 | 
      
        | 113 |  |  | 		// compose the complete list
 | 
      
        | 114 |  |  | 		$sOutput = ''
 | 
      
        | 115 |  |  | 		// build the head
 | 
      
        | 116 | 1846 | darkviper | 		      . $this->_Tabs(0 , true).'<div class="jsadmin pages_list">'.PHP_EOL
 | 
      
        | 117 | 1839 | darkviper | 		      . $this->_Tabs(1).'<table>'.PHP_EOL
 | 
      
        | 118 |  |  | 		      . $this->_Tabs(1).'<tbody>'.PHP_EOL
 | 
      
        | 119 |  |  | 		      . $this->_Tabs(1).'<tr class="pages_list_header">'.PHP_EOL
 | 
      
        | 120 | 1867 | Luisehahne | 		      . $this->_Tabs(1).'<th style="width:20px;">'.PHP_EOL.'</th>'.PHP_EOL
 | 
      
        | 121 | 1973 | darkviper | 		      . $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.
 | 
      
        | 124 | 1839 | darkviper | 		                        '</th>'.PHP_EOL
 | 
      
        | 125 | 1867 | Luisehahne | 		      . $this->_Tabs(0).'<th class="list_page_id">PID</th>'.PHP_EOL
 | 
      
        | 126 | 1973 | darkviper | 		      . $this->_Tabs(0).'<th class="header_list_actions">'.$this->_oTrans->TEXT_ACTIONS.
 | 
      
        | 127 | 1839 | darkviper | 		                        ':</th>'.PHP_EOL
 | 
      
        | 128 |  |  | 		      . $this->_Tabs(0).'<th class="list_page_id"> </th>'.PHP_EOL
 | 
      
        | 129 |  |  | 		      . $this->_Tabs(-1).'</tr>'.PHP_EOL
 | 
      
        | 130 |  |  | 		      . $this->_Tabs(-1).'</tbody>'.PHP_EOL
 | 
      
        | 131 |  |  | 		      . $this->_Tabs(-1).'</table>'.PHP_EOL
 | 
      
        | 132 |  |  | 		// generate the page lines
 | 
      
        | 133 | 1846 | darkviper | 		      . $this->_IterateTree($iTreeRoot)
 | 
      
        | 134 | 1839 | darkviper | 		// build the footer
 | 
      
        | 135 |  |  | 		      . $this->_Tabs(-1).'</div>'.PHP_EOL;
 | 
      
        | 136 |  |  | 		;
 | 
      
        | 137 |  |  | 		$this->_sOutput = $sOutput;
 | 
      
        | 138 |  |  | 		return $sOutput;
 | 
      
        | 139 |  |  | 	}
 | 
      
        | 140 |  |  | /**
 | 
      
        | 141 |  |  |  * Create a string of multiple TABs to prettify the HTML-output
 | 
      
        | 142 |  |  |  * ingrease the number of TABs with a positive and degrease with an negative Value.
 | 
      
        | 143 |  |  |  * '0' means: do not change the value. Or set an absolute number using $bRelative=false
 | 
      
        | 144 |  |  |  * @staticvar int $iTabLevel
 | 
      
        | 145 |  |  |  * @param integer $iTabsDiv number of TABs to add/sub
 | 
      
        | 146 |  |  |  * @param bool $bRelative false if should be set to absolute value
 | 
      
        | 147 |  |  |  * @return string
 | 
      
        | 148 |  |  |  */
 | 
      
        | 149 | 1953 | darkviper | 	protected function _Tabs($iTabsDiv = 0, $bRelative = true)
 | 
      
        | 150 | 1839 | darkviper | 	{
 | 
      
        | 151 |  |  | 		static $iTabLevel = 0;
 | 
      
        | 152 |  |  | 		$iTabLevel = ($bRelative ? $iTabLevel + $iTabsDiv : $iTabsDiv);
 | 
      
        | 153 |  |  | 		$iTabLevel += ($iTabLevel < 0 ? 0 - $iTabLevel : $iTabsDiv);
 | 
      
        | 154 |  |  | 		return str_repeat("\t", $iTabLevel);
 | 
      
        | 155 |  |  | 	}
 | 
      
        | 156 |  |  | /**
 | 
      
        | 157 |  |  |  * compose the needed SQL statement
 | 
      
        | 158 | 1973 | darkviper |  * @param  integer $iParentKey
 | 
      
        | 159 | 1839 | darkviper |  * @return string SQL statement
 | 
      
        | 160 |  |  |  */
 | 
      
        | 161 | 1953 | darkviper | 	protected function _makeSql($iParentKey = 0)
 | 
      
        | 162 | 1839 | darkviper | 	{
 | 
      
        | 163 | 1973 | darkviper | 		$iParentKey = intval($iParentKey);
 | 
      
        | 164 | 1953 | darkviper | 		$sql  = 'SELECT ( SELECT COUNT(*) '
 | 
      
        | 165 | 1973 | darkviper | 		      .          'FROM `'.$this->_oDb->TablePrefix.'pages` `x` '
 | 
      
        | 166 | 1953 | darkviper | 		      .          'WHERE x.`parent`=p.`page_id`'
 | 
      
        | 167 |  |  | 		      .        ') `children`, '
 | 
      
        | 168 |  |  | 		      .        's.`module`, MAX(s.`publ_start` + s.`publ_end`) published, p.`link`, '
 | 
      
        | 169 | 1973 | darkviper | 		      .        '(SELECT MAX(`position`) FROM `'.$this->_oDb->TablePrefix.'pages` '
 | 
      
        | 170 | 1953 | darkviper | 		      .        'WHERE `parent`='.$iParentKey.') max_position, '
 | 
      
        | 171 |  |  | 		      .        '0 min_position, '
 | 
      
        | 172 |  |  | 		      .        'p.`position`, '
 | 
      
        | 173 |  |  | 		      .        'p.`page_id`, p.`parent`, p.`level`, p.`language`, p.`admin_groups`, '
 | 
      
        | 174 |  |  | 		      .        'p.`admin_users`, p.`viewing_groups`, p.`viewing_users`, p.`visibility`, '
 | 
      
        | 175 |  |  | 		      .        'p.`menu_title`, p.`page_title`, p.`page_trail` '
 | 
      
        | 176 | 1973 | darkviper | 		      . 'FROM `'.$this->_oDb->TablePrefix.'pages` p '
 | 
      
        | 177 |  |  | 		      .    'INNER JOIN `'.$this->_oDb->TablePrefix.'sections` s '
 | 
      
        | 178 | 1953 | darkviper | 		      .    'ON p.`page_id`=s.`page_id` ';
 | 
      
        | 179 |  |  | //		if($iParentKey) {
 | 
      
        | 180 |  |  | //
 | 
      
        | 181 |  |  | //			$sql .= 'WHERE `root_parent`='.$iParentKey.' ';
 | 
      
        | 182 |  |  | //		} else {
 | 
      
        | 183 |  |  | //	// if tree based on root is requested (parent=0)
 | 
      
        | 184 |  |  | 			$sql .= 'WHERE `parent`='.$iParentKey.' ';
 | 
      
        | 185 |  |  | //		}
 | 
      
        | 186 |  |  | 	// do not get pages with 'deleted' flag set on activated trashcan
 | 
      
        | 187 | 1973 | darkviper | 		if($this->_oReg->PageTrash != 'inline') {
 | 
      
        | 188 | 1953 | darkviper | 			$sql .= 'AND `visibility`!=\'deleted\' ';
 | 
      
        | 189 |  |  | 		}
 | 
      
        | 190 |  |  | 		$sql .= 'GROUP BY p.`page_id` '
 | 
      
        | 191 |  |  | 		      . 'ORDER BY p.`position` ASC';
 | 
      
        | 192 | 1839 | darkviper | 		return $sql;
 | 
      
        | 193 |  |  | 	}
 | 
      
        | 194 |  |  | /**
 | 
      
        | 195 |  |  |  * iterate through all nodes which having subnodes
 | 
      
        | 196 | 1846 | darkviper |  * @param integer start iteration from this parent page ( 0 = root)
 | 
      
        | 197 | 1839 | darkviper |  * @return string all of the item lines
 | 
      
        | 198 |  |  |  */
 | 
      
        | 199 | 1953 | darkviper | 	protected function _IterateTree($iParent = 0)
 | 
      
        | 200 | 1839 | darkviper | 	{
 | 
      
        | 201 |  |  | 		$sOutput = '';
 | 
      
        | 202 |  |  | 		// Get page list from database
 | 
      
        | 203 |  |  | 		if(($oPages = $this->_oDb->query($this->_makeSql($iParent))))
 | 
      
        | 204 |  |  | 		{
 | 
      
        | 205 |  |  | 			$this->_queries++;
 | 
      
        | 206 |  |  | 			// output block-header
 | 
      
        | 207 |  |  | 			$sOutput .= $this->_Tabs(0).'<ul id="p'.$iParent.'" class="page_list"';
 | 
      
        | 208 |  |  | 			if(!$iParent) {
 | 
      
        | 209 |  |  | 				$sOutput .= ' style="display: block;"';
 | 
      
        | 210 |  |  | 			}else {
 | 
      
        | 211 |  |  | 			// show block depending from Cookies
 | 
      
        | 212 |  |  | 				if (isset ($_COOKIE['p'.$iParent]) && $_COOKIE['p'.$iParent] == '1') {
 | 
      
        | 213 |  |  | 					$sOutput .= ' style="display: block;"';
 | 
      
        | 214 |  |  | 				}
 | 
      
        | 215 |  |  | 			}
 | 
      
        | 216 |  |  | 			$sOutput .= '>'.PHP_EOL;
 | 
      
        | 217 |  |  | 			$iMinPosition = 1;
 | 
      
        | 218 |  |  | 			while($aPage = $oPages->fetchRow(MYSQL_ASSOC))
 | 
      
        | 219 |  |  | 			{ // iterate through the current branch
 | 
      
        | 220 | 1973 | darkviper | 				if($this->_oReg->PageLevelLimit && ($aPage['level'] > $this->_oReg->PageLevelLimit)) {
 | 
      
        | 221 | 1846 | darkviper | 					return '';
 | 
      
        | 222 |  |  | 				}
 | 
      
        | 223 | 1839 | darkviper | 				$aPage['min_position'] = ($aPage['position'] < $iMinPosition ? $aPage['position'] : $iMinPosition);
 | 
      
        | 224 |  |  | 				$this->_iLineColor = $this->_iPagesTotal++ % 2;
 | 
      
        | 225 |  |  | 				$aPage['iswriteable'] = false;
 | 
      
        | 226 |  |  | 				if( $this->_oApp->ami_group_member($aPage['admin_users']) ||
 | 
      
        | 227 |  |  | 					$this->_oApp->is_group_match($this->_oApp->get_groups_id(), $aPage['admin_groups']))
 | 
      
        | 228 |  |  | 				{
 | 
      
        | 229 | 1973 | darkviper | 					if(($aPage['visibility'] == 'deleted' && $this->_oReg->PageTrash == 'inline') ||
 | 
      
        | 230 | 1839 | darkviper | 					   ($aPage['visibility'] != 'deleted'))
 | 
      
        | 231 |  |  | 					{
 | 
      
        | 232 |  |  | 						$aPage['iswriteable'] = true;
 | 
      
        | 233 |  |  | 						$this->_iPagesWriteable++;
 | 
      
        | 234 |  |  | 					}
 | 
      
        | 235 |  |  | 				} else {
 | 
      
        | 236 |  |  | 					if($aPage['visibility'] == 'private') { continue; }
 | 
      
        | 237 |  |  | 				}
 | 
      
        | 238 |  |  | 				// add this item to the secondary list of parents
 | 
      
        | 239 |  |  | 				$this->_addToParentList($aPage);
 | 
      
        | 240 |  |  | 				$sOutput .= $this->_createListItem($aPage);
 | 
      
        | 241 |  |  | 			}
 | 
      
        | 242 |  |  | 			$sOutput .= $this->_Tabs(-1).'</ul>'.PHP_EOL;
 | 
      
        | 243 |  |  | 		}
 | 
      
        | 244 |  |  | 		return $sOutput;
 | 
      
        | 245 |  |  | 	}
 | 
      
        | 246 |  |  | /**
 | 
      
        | 247 |  |  |  * formating the given page object for output
 | 
      
        | 248 |  |  |  * @param type $aPage
 | 
      
        | 249 |  |  |  * @return string
 | 
      
        | 250 |  |  |  */
 | 
      
        | 251 | 1953 | darkviper | 	protected function _createListItem($aPage)
 | 
      
        | 252 | 1839 | darkviper | 	{
 | 
      
        | 253 |  |  | 	// output the current item
 | 
      
        | 254 |  |  | 	// --- HEADER ------------------------------------------------------------------------
 | 
      
        | 255 |  |  | 		$sOutput  = $this->_Tabs(0).'<li class="p'.$aPage['parent'].'">'.PHP_EOL
 | 
      
        | 256 |  |  | 		          . $this->_Tabs(1).'<table class="pages_view">'.PHP_EOL
 | 
      
        | 257 |  |  | 		          . $this->_Tabs(1).'<tbody>'.PHP_EOL
 | 
      
        | 258 |  |  | 		          . $this->_Tabs(1).'<tr class="row_'.$this->_iLineColor.'">'.PHP_EOL;
 | 
      
        | 259 |  |  | 	// --- TAB 1 --- (expand/collapse) ---------------------------------------------------
 | 
      
        | 260 |  |  | 		$sOutput .= $this->_Tabs(1).'<td valign="middle" width="20" style="padding-left: '
 | 
      
        | 261 |  |  | 		          . (int)($aPage['level']*20).'px;">';
 | 
      
        | 262 |  |  | 		if((bool)$aPage['children']) {
 | 
      
        | 263 |  |  | 			$sOutput .= '<a href="javascript:toggle_visibility(\'p'.$aPage['page_id'].'\');" '
 | 
      
        | 264 | 1973 | darkviper | 			          . 'title="'.$this->_oTrans->TEXT_EXPAND.'/'.$this->_oTrans->TEXT_COLLAPSE.'">'
 | 
      
        | 265 |  |  | 			          . '<span><img src="'.$this->_oReg->ThemeRel.'/images/'
 | 
      
        | 266 | 1839 | darkviper | 			          . ( ((isset($_COOKIE['p'.$aPage['page_id']])
 | 
      
        | 267 |  |  | 						  && $_COOKIE['p'.$aPage['page_id']] == '1') ? 'minus' : 'plus')
 | 
      
        | 268 |  |  | 						)
 | 
      
        | 269 |  |  | 			          . '_16.png" onclick="toggle_plus_minus(\''.$aPage['page_id'].'\');" '
 | 
      
        | 270 |  |  | 			          . 'name="plus_minus_'.$aPage['page_id'].'" alt="+" /></span></a>';
 | 
      
        | 271 |  |  | 		}else {
 | 
      
        | 272 |  |  | 			$sOutput .= ' ';
 | 
      
        | 273 |  |  | 		}
 | 
      
        | 274 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 275 |  |  | 	// --- TAB 2 --- (menu title) --------------------------------------------------------
 | 
      
        | 276 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_menu_title">';
 | 
      
        | 277 |  |  | 		if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
 | 
      
        | 278 | 1973 | darkviper | 			$sOutput .= '<a href="'.$this->_oReg->AcpRel.'/pages/modify.php?page_id='
 | 
      
        | 279 |  |  | 			          . $aPage['page_id'].'" title="'.$this->_oTrans->TEXT_MODIFY.'">';
 | 
      
        | 280 | 1839 | darkviper | 		}
 | 
      
        | 281 | 1973 | darkviper | 		$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';
 | 
      
        | 284 | 1846 | darkviper | 		}
 | 
      
        | 285 | 1973 | darkviper | 		$sOutput .= '<img src="'.$sIcon.'" alt="'.$this->_oTrans->TEXT_VISIBILITY.': '
 | 
      
        | 286 |  |  | 				  . $this->_oTrans->{'TEXT_'.strtoupper($aPage['visibility'])}  .'" class="page_list_rights" />';
 | 
      
        | 287 | 1839 | darkviper | 		if($this->_oApp->get_permission('pages_modify') && $aPage['iswriteable']) {
 | 
      
        | 288 |  |  | 			$sOutput .= '<span class="modify_link">'.$aPage['menu_title'].'</span></a>';
 | 
      
        | 289 |  |  | 		}else {
 | 
      
        | 290 |  |  | 			$sOutput .=  '<span class="bold grey">'.$aPage['menu_title'].'</span>';
 | 
      
        | 291 |  |  | 		}
 | 
      
        | 292 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 293 |  |  | 	// --- TAB 3 --- (page title) --------------------------------------------------------
 | 
      
        | 294 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_page_title">'.$aPage['page_title'].'</td>'.PHP_EOL;
 | 
      
        | 295 |  |  | 	// --- TAB 4 --- (page ID) -----------------------------------------------------------
 | 
      
        | 296 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_page_id right">'.$aPage['page_id'].'</td>'.PHP_EOL;
 | 
      
        | 297 |  |  | 	// --- TAB 5 --- (show this page in new window) --------------------------------------
 | 
      
        | 298 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 299 |  |  | 		if($aPage['visibility'] != 'deleted' && $aPage['visibility'] != 'none') {
 | 
      
        | 300 | 1973 | darkviper | 			$sPageLink = $this->_oReg->AppRel.preg_replace(
 | 
      
        | 301 |  |  | 			                                 '/^'.preg_quote($this->_oReg->AppUrl, '/').'/siU',
 | 
      
        | 302 | 1839 | darkviper | 			                                 '',
 | 
      
        | 303 |  |  | 			                                 $this->_oApp->page_link($aPage['link'])
 | 
      
        | 304 |  |  | 			                                );
 | 
      
        | 305 | 1973 | darkviper | 			$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>';
 | 
      
        | 308 | 1839 | darkviper | 		}else {
 | 
      
        | 309 | 1973 | darkviper | 			$sOutput .= '<img src="'.$this->_oReg->ThemeRel.'/images/blank_16.gif" alt=" " />';
 | 
      
        | 310 | 1839 | darkviper | 		}
 | 
      
        | 311 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 312 |  |  | 
 | 
      
        | 313 |  |  | 	// --- TAB 6 --- (edit settings) -----------------------------------------------------
 | 
      
        | 314 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 315 |  |  | 		if($aPage['visibility'] != 'deleted') {
 | 
      
        | 316 |  |  | 			if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
 | 
      
        | 317 | 1973 | darkviper | 				$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>';
 | 
      
        | 321 | 1839 | darkviper | 			}
 | 
      
        | 322 |  |  | 		}else {
 | 
      
        | 323 | 1973 | darkviper | 			$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>';
 | 
      
        | 326 | 1839 | darkviper | 		}
 | 
      
        | 327 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 328 |  |  | 
 | 
      
        | 329 |  |  | 	// --- TAB 7 --- (edit sections) -----------------------------------------------------
 | 
      
        | 330 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 331 | 1973 | darkviper | 		if( $this->_oReg->ManageSections && $this->_oApp->get_permission('pages_add') && $aPage['iswriteable'] ) {
 | 
      
        | 332 | 1839 | darkviper | 			$file = $this->_oApp->page_is_active($aPage) ? "clock_16.png" : "clock_red_16.png";
 | 
      
        | 333 |  |  | 			$file = ($aPage['published'] && $aPage['module'] != 'menu_link') ? $file : 'noclock_16.png';
 | 
      
        | 334 | 1973 | darkviper | 			$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>';
 | 
      
        | 338 | 1839 | darkviper | 		}else {
 | 
      
        | 339 | 1973 | darkviper | 			$sOutput .= '<img src="'.$this->_oReg->ThemeRel.'/images/blank_16.gif" alt=" " />';
 | 
      
        | 340 | 1839 | darkviper | 		}
 | 
      
        | 341 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 342 |  |  | 
 | 
      
        | 343 |  |  | 	// --- TAB 8 --- (move up) -----------------------------------------------------------
 | 
      
        | 344 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 345 |  |  | 		if($aPage['position'] > $aPage['min_position']) {
 | 
      
        | 346 |  |  | 			if($aPage['visibility'] != 'deleted') {
 | 
      
        | 347 |  |  | 				if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
 | 
      
        | 348 | 1973 | darkviper | 					$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>';
 | 
      
        | 352 | 1839 | darkviper | 				}
 | 
      
        | 353 |  |  | 			}
 | 
      
        | 354 |  |  | 		}
 | 
      
        | 355 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 356 |  |  | 
 | 
      
        | 357 |  |  | 	// --- TAB 9 --- (move down) ---------------------------------------------------------
 | 
      
        | 358 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 359 |  |  | 		if($aPage['position'] < $aPage['max_position']) {
 | 
      
        | 360 |  |  | 			if($aPage['visibility'] != 'deleted') {
 | 
      
        | 361 |  |  | 				if($this->_oApp->get_permission('pages_settings') && $aPage['iswriteable']) {
 | 
      
        | 362 | 1973 | darkviper | 					$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>';
 | 
      
        | 366 | 1839 | darkviper | 				}
 | 
      
        | 367 |  |  | 			}
 | 
      
        | 368 |  |  | 		}
 | 
      
        | 369 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 370 |  |  | 
 | 
      
        | 371 |  |  | 	// --- TAB 10 --- (delete page) ------------------------------------------------------
 | 
      
        | 372 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 373 |  |  | 		if($this->_oApp->get_permission('pages_delete') && $aPage['iswriteable']) {
 | 
      
        | 374 |  |  | 			$sOutput .= '<a href="javascript:confirm_link(pages_delete_confirm+\'?\',\''
 | 
      
        | 375 | 1973 | darkviper | 			          . $this->_oReg->AcpRel.'/pages/delete.php?page_id='
 | 
      
        | 376 | 1839 | darkviper | 			          . $this->_oApp->getIDKEY($aPage['page_id']).'\');" title="'
 | 
      
        | 377 | 1973 | darkviper | 			          . $this->_oTrans->TEXT_DELETE.'"><img src="'.$this->_oReg->ThemeRel
 | 
      
        | 378 |  |  | 			          . '/images/delete_16.png" alt="'.$this->_oTrans->TEXT_DELETE.'" /></a>';
 | 
      
        | 379 | 1839 | darkviper | 		}else {
 | 
      
        | 380 | 1973 | darkviper | 			$sOutput .= '<img src="'.$this->_oReg->ThemeRel.'/images/blank_16.gif" alt=" " />';
 | 
      
        | 381 | 1839 | darkviper | 		}
 | 
      
        | 382 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 383 |  |  | 
 | 
      
        | 384 |  |  | 	// --- TAB 11 --- (add child page) ---------------------------------------------------
 | 
      
        | 385 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_actions">';
 | 
      
        | 386 |  |  | 		if(
 | 
      
        | 387 |  |  | 			$this->_oApp->get_permission('pages_add')
 | 
      
        | 388 |  |  | 			&& $aPage['iswriteable']
 | 
      
        | 389 |  |  | 			&& ($aPage['visibility'] != 'deleted')
 | 
      
        | 390 | 1973 | darkviper | 			&& $aPage['level'] < ($this->_oReg->PageLevelLimit - 1)
 | 
      
        | 391 | 1839 | darkviper | 		  )
 | 
      
        | 392 |  |  | 		{
 | 
      
        | 393 |  |  | 			$sOutput .= '<a href="javascript:add_child_page(\''.$aPage['page_id'].'\');" '
 | 
      
        | 394 | 1973 | darkviper | 			          . '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>';
 | 
      
        | 397 | 1839 | darkviper | 		}else {
 | 
      
        | 398 |  |  | 			$sOutput .= ' ';
 | 
      
        | 399 |  |  | 		}
 | 
      
        | 400 |  |  | 		$sOutput .= '</td>'.PHP_EOL;
 | 
      
        | 401 |  |  | 	// --- TAB 12 --- (show language) ----------------------------------------------------
 | 
      
        | 402 |  |  | 		$sOutput .= $this->_Tabs(0).'<td class="list_page_id center">'.$aPage['language'].'</td>'.PHP_EOL;
 | 
      
        | 403 |  |  | 	// --- FOOTER ------------------------------------------------------------------------
 | 
      
        | 404 |  |  | 		$sOutput .= $this->_Tabs(-1).'</tr>'.PHP_EOL
 | 
      
        | 405 |  |  | 		          . $this->_Tabs(-1).'</tbody>'.PHP_EOL
 | 
      
        | 406 |  |  | 		          . $this->_Tabs(-1).'</table>'.PHP_EOL;
 | 
      
        | 407 |  |  | 	// if there children, iterate through this children now
 | 
      
        | 408 |  |  | 		if((bool)$aPage['children']) {
 | 
      
        | 409 |  |  | 			$sOutput .= $this->_IterateTree($aPage['page_id']);
 | 
      
        | 410 |  |  | 		}
 | 
      
        | 411 |  |  | 		$sOutput .= $this->_Tabs(-1).'</li>'.PHP_EOL;
 | 
      
        | 412 |  |  | 		return $sOutput;
 | 
      
        | 413 |  |  | 	} // end of method _createListItem
 | 
      
        | 414 |  |  | /**
 | 
      
        | 415 |  |  |  * build a list of possible parent pages
 | 
      
        | 416 |  |  |  * @param array $aPage
 | 
      
        | 417 |  |  |  */
 | 
      
        | 418 | 1953 | darkviper | 	protected function _addToParentList(array $aPage)
 | 
      
        | 419 | 1839 | darkviper | 	{
 | 
      
        | 420 | 1973 | darkviper | 		if( ($aPage['level'] < ($this->_oReg->PageLevelLimit - 1))
 | 
      
        | 421 | 1839 | darkviper | 			&& $aPage['iswriteable']
 | 
      
        | 422 |  |  | 			&& ($aPage['visibility'] != 'deleted')
 | 
      
        | 423 |  |  | 			&& $this->_oApp->get_permission('pages_add') )
 | 
      
        | 424 |  |  | 		{
 | 
      
        | 425 | 1953 | darkviper | 			$aPage['disabled'] = ($aPage['iswriteable'] ? 0 : 1);
 | 
      
        | 426 |  |  | 			$this->_aParentList[] = $aPage;
 | 
      
        | 427 | 1839 | darkviper | 		}
 | 
      
        | 428 |  |  | 	}
 | 
      
        | 429 |  |  | 
 | 
      
        | 430 |  |  | } // end of class PageTree
 |