Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 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 (almost)
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 * 120: class SC_alt_db_navframe
47 * 130: function init()
48 * 219: function main()
49 * 252: 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 src="gfx/recordlock_warning3.gif" width="17" height="12" vspace=2 border="0" align=top'.t3lib_BEfunc::titleAttrib($lockInfo["msg"]).' alt="" />'.
96 '</a>';
97 } else $lockIcon="";
98
99 // Add title attribute to input icon tag
100 $thePageIcon = substr($icon,0,-1).' '.$this->titleAttrib.'="'.$this->getTitleAttrib($row).'" border="0" />';
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 * Main script class
115 *
116 * @author Kasper Skaarhoj <kasper@typo3.com>
117 * @package TYPO3
118 * @subpackage core
119 */
120 class SC_alt_db_navframe {
121 var $content;
122 var $pagetree;
123 var $doc;
124
125 /**
126 * Initialiation
127 *
128 * @return void
129 */
130 function init() {
131 global $BE_USER,$BACK_PATH;
132
133 $this->pagetree = t3lib_div::makeInstance('localPageTree');
134 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
135 $this->pagetree->thisScript = 'alt_db_navframe.php';
136 $this->pagetree->addField('alias');
137 $this->pagetree->addField('shortcut');
138 $this->pagetree->addField('shortcut_mode');
139 $this->pagetree->addField('mount_pid');
140 $this->pagetree->addField('url');
141
142 $currentSubScript = t3lib_div::GPvar('currentSubScript');
143
144 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
145
146 // Create template object:
147 $this->doc = t3lib_div::makeInstance('template');
148
149 // Hmmm, setting "xhtml_trans" for the page will unfortunately break the Context Sensitive menu in Mozilla! But apart from that - and duplicate ID's for same page in different mounts - the document checks out well as XHTML
150 # $this->doc->docType='xhtml_trans';
151
152 // Setting backPath
153 $this->doc->backPath = $BACK_PATH;
154
155 // Setting JavaScript for menu.
156 $this->doc->JScode=$this->doc->wrapScriptTags(
157 ($currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($currentSubScript).'");':'').'
158 function jumpTo(id,linkObj) { //
159 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
160
161 if (top.condensedMode) {
162 top.content.document.location=theUrl;
163 } else {
164 parent.list_frame.document.location=theUrl;
165 }
166 '.($this->doHighlight?'hilight_row("pages"+top.fsMod.recentIds["web"],"pages"+id);':'').'
167 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
168 return false;
169 }
170 function refresh_nav() { //
171 window.setTimeout("_refresh_nav();",0);
172 }
173 function _refresh_nav() { //
174 document.location="'.$this->pagetree->thisScript.'?unique='.time().'";
175 }
176 function hilight_row(old_rowid,new_rowid) { //
177 if(document.all) {
178 if(document.all.item(old_rowid)) {
179 document.all.item(old_rowid).style.backgroundColor="";
180 }
181 if(document.all.item(new_rowid)) {
182 document.all.item(new_rowid).style.backgroundColor="'.
183 t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).
184 '";
185 }
186 } else {
187 if(document.getElementsByName) {
188 old_row_obj = document.getElementsByName(old_rowid)[0];
189 new_row_obj = document.getElementsByName(new_rowid)[0];
190 bgc = document.createAttribute("bgcolor");
191 bgc.value="'.
192 t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).
193 '";
194 if(old_row_obj) {
195 old_row_obj.removeAttribute("bgcolor");
196 }
197 if(new_row_obj) {
198 new_row_obj.setAttributeNode(bgc);
199 }
200 }
201 }
202 }
203
204 '.(t3lib_div::GPvar('cMR')?"jumpTo(top.fsMod.recentIds['web'],'');":"").';
205 ');
206
207 // Click menu code is added:
208 $CMparts=$this->doc->getContextMenuCode();
209 $this->doc->bodyTagAdditions = $CMparts[1];
210 $this->doc->JScode.=$CMparts[0];
211 $this->doc->postCode.= $CMparts[2];
212 }
213
214 /**
215 * Main function
216 *
217 * @return void
218 */
219 function main() {
220 global $LANG,$CLIENT;
221
222 // Produce browse-tree:
223 $tree = $this->pagetree->getBrowsableTree();
224 /*
225 if ($CLIENT['BROWSER']=='konqu') {
226 // Where <nobr> does not work, this will secure non-breaks in lines:
227 $tree = '<table border=0 cellspacing=0 cellpadding=0><tr><td nowrap>'.$tree.'</td></tr></table>';
228 }
229 */
230
231 $this->content='';
232 $this->content.=$this->doc->startPage('Page tree');
233 $this->content.=$tree;
234 $this->content.='<br />
235 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
236 '<img src="gfx/refresh_n.gif" width="14" hspace="2" height="14" hspace="4" border="0" align="top" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'" alt="" />'.
237 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
238 <br /><br />';
239
240 // Adding highlight - JavaScript
241 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
242 rowid="pages"+top.fsMod.recentIds["web"];
243 hilight_row("",rowid);
244 ');
245 }
246
247 /**
248 * Output tree.
249 *
250 * @return void
251 */
252 function printContent() {
253 $this->content.= $this->doc->endPage();
254 echo $this->content;
255 }
256 }
257
258 // Include extension?
259 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
260 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
261 }
262
263
264
265
266
267
268
269
270
271
272
273
274 // Make instance:
275 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
276 $SOBE->init();
277 $SOBE->main();
278 $SOBE->printContent();
279
280 ?>