Changed lots of stuff...
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Page navigation tree for the Web module
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * @author Kasper Skaarhoj <kasper@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 72: class localPageTree extends t3lib_browseTree
42 * 79: function localPageTree()
43 * 90: function wrapIcon($icon,&$row)
44 *
45 *
46 * 131: class SC_alt_db_navframe
47 * 147: function init()
48 * 237: function main()
49 * 265: function printContent()
50 *
51 * TOTAL FUNCTIONS: 5
52 * (This index is automatically created/updated by the extension "extdeveval")
53 *
54 */
55
56
57 $BACK_PATH='';
58 require ('init.php');
59 require ('template.php');
60 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
61
62
63
64 /**
65 * Extension class for the t3lib_browsetree class, specially made for browsing pages in the Web module
66 *
67 * @author Kasper Skaarhoj <kasper@typo3.com>
68 * @package TYPO3
69 * @subpackage core
70 * @see class t3lib_browseTree
71 */
72 class localPageTree extends t3lib_browseTree {
73
74 /**
75 * Calls init functions
76 *
77 * @return void
78 */
79 function localPageTree() {
80 $this->init();
81 }
82
83 /**
84 * Wrapping icon in browse tree
85 *
86 * @param string Icon IMG code
87 * @param array Data row for element.
88 * @return string Page icon
89 */
90 function wrapIcon($icon,&$row) {
91 // If the record is locked, present a warning sign.
92 if ($lockInfo=t3lib_BEfunc::isRecordLocked('pages',$row['uid'])) {
93 $aOnClick = 'alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;';
94 $lockIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
95 '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
96 '</a>';
97 } else $lockIcon="";
98
99 // Add title attribute to input icon tag
100 $thePageIcon = $this->addTagAttributes($icon, $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"');
101
102 // Wrap icon in click-menu link.
103 if (!$this->ext_IconMode) {
104 $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0);
105 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
106 $aOnClick = 'return jumpTo('.$this->getJumpToParm($row).',this,\''.$this->treeName.'\');';
107 $thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';
108 }
109 return $thePageIcon.$lockIcon;
110 }
111 }
112
113
114
115
116
117
118
119
120
121
122
123
124 /**
125 * Main script class for the page tree navigation frame
126 *
127 * @author Kasper Skaarhoj <kasper@typo3.com>
128 * @package TYPO3
129 * @subpackage core
130 */
131 class SC_alt_db_navframe {
132
133 // Internal:
134 var $content;
135 var $pagetree;
136 var $doc;
137
138 // Internal, static: GPvar:
139 var $currentSubScript;
140 var $cMR;
141
142 /**
143 * Initialiation of the class
144 *
145 * @return void
146 */
147 function init() {
148 global $BE_USER,$BACK_PATH;
149
150 // Setting GPvars:
151 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
152 $this->cMR = t3lib_div::_GP('cMR');
153
154 // Create page tree object:
155 $this->pagetree = t3lib_div::makeInstance('localPageTree');
156 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
157 $this->pagetree->thisScript = 'alt_db_navframe.php';
158 $this->pagetree->addField('alias');
159 $this->pagetree->addField('shortcut');
160 $this->pagetree->addField('shortcut_mode');
161 $this->pagetree->addField('mount_pid');
162 $this->pagetree->addField('url');
163
164 // Setting highlight mode:
165 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
166
167 // Create template object:
168 $this->doc = t3lib_div::makeInstance('template');
169 $this->doc->docType='xhtml_trans';
170
171 // Setting backPath
172 $this->doc->backPath = $BACK_PATH;
173
174 // Setting JavaScript for menu.
175 $this->doc->JScode=$this->doc->wrapScriptTags(
176 ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
177
178 // Function, loading the list frame from navigation tree:
179 function jumpTo(id,linkObj,highLightID) { //
180 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
181
182 if (top.condensedMode) {
183 top.content.document.location=theUrl;
184 } else {
185 parent.list_frame.document.location=theUrl;
186 }
187
188 '.($this->doHighlight?'hilight_row("web",highLightID);':'').'
189
190 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
191 return false;
192 }
193
194 // Call this function, refresh_nav(), from another script in the backend if you want to refresh the navigation frame (eg. after having changed a page title or moved pages etc.)
195 // See t3lib_BEfunc::getSetUpdateSignal()
196 function refresh_nav() { //
197 window.setTimeout("_refresh_nav();",0);
198 }
199 function _refresh_nav() { //
200 document.location="'.$this->pagetree->thisScript.'?unique='.time().'";
201 }
202
203 // Highlighting rows in the page tree:
204 function hilight_row(frameSetModule,highLightID) { //
205
206 // Remove old:
207 theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
208 if (theObj) {
209 theObj.style.backgroundColor="";
210 }
211
212 // Set new:
213 top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
214 theObj = document.getElementById(highLightID);
215 if (theObj) {
216 theObj.style.backgroundColor="'.t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).'";
217 }
218 }
219
220 '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').';
221 ');
222
223 // Click menu code is added:
224 $CMparts=$this->doc->getContextMenuCode();
225 $this->doc->bodyTagAdditions = $CMparts[1];
226 $this->doc->JScode.=$CMparts[0];
227 $this->doc->postCode.= $CMparts[2];
228 }
229
230 /**
231 * Main function, rendering the browsable page tree
232 *
233 * @return void
234 */
235 function main() {
236 global $LANG,$CLIENT;
237
238 // Produce browse-tree:
239 $tree = $this->pagetree->getBrowsableTree();
240
241 $this->content='';
242 $this->content.=$this->doc->startPage('Page tree');
243 $this->content.=$tree;
244 $this->content.='
245 <p class="c-refresh">
246 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
247 '<img'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'" alt="" />'.
248 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
249 </p>
250 <br />';
251
252 // Adding highlight - JavaScript
253 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
254 hilight_row("",top.fsMod.navFrameHighlightedID["web"]);
255 ');
256 }
257
258 /**
259 * Outputting the accumulated content to screen
260 *
261 * @return void
262 */
263 function printContent() {
264 $this->content.= $this->doc->endPage();
265 echo $this->content;
266 }
267 }
268
269 // Include extension?
270 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
271 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
272 }
273
274
275
276
277
278
279
280
281
282
283
284
285 // Make instance:
286 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
287 $SOBE->init();
288 $SOBE->main();
289 $SOBE->printContent();
290
291 ?>