Initial revision
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (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 tree for the Web module
29 *
30 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
35 * XHTML compliant (almost)
36 */
37
38
39 $BACK_PATH='';
40 require ('init.php');
41 require ('template.php');
42 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
43
44
45
46 // ***************************
47 // Script Classes
48 // ***************************
49 /**
50 * Extension class for the t3lib_browsetree class, specially made for browsing pages in the Web module
51 * @see class t3lib_browseTree
52 */
53 class localPageTree extends t3lib_browseTree {
54
55 function localPageTree() {
56 $this->init();
57 }
58
59 function wrapIcon($icon,&$row) {
60 // If the record is locked, present a warning sign.
61 if ($lockInfo=t3lib_BEfunc::isRecordLocked("pages",$row["uid"])) {
62 $aOnClick = 'alert('.$GLOBALS['LANG']->JScharCode($lockInfo["msg"]).');return false;';
63 $lockIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
64 '<img src="gfx/recordlock_warning3.gif" width="17" height="12" vspace=2 border="0" align=top'.t3lib_BEfunc::titleAttrib($lockInfo["msg"]).' alt="" />'.
65 '</a>';
66 } else $lockIcon="";
67
68 // Add title attribute to input icon tag
69 $thePageIcon = substr($icon,0,-1).' '.$this->titleAttrib.'="'.$this->getTitleAttrib($row).'" border="0" />';
70
71 // Wrap icon in click-menu link.
72 if (!$this->ext_IconMode) {
73 $thePageIcon = $GLOBALS["TBE_TEMPLATE"]->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0);
74 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
75 $aOnClick = 'return jumpTo('.$this->getJumpToParm($row).',this,\''.$this->treeName.'\');';
76 $thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';
77 }
78 return $thePageIcon.$lockIcon;
79 }
80 }
81
82 /**
83 * Main script class
84 */
85 class SC_alt_db_navframe {
86 var $content;
87 var $pagetree;
88 var $doc;
89
90 /**
91 * Initialiation
92 */
93 function init() {
94 global $BE_USER,$BACK_PATH;
95
96 $this->pagetree = t3lib_div::makeInstance('localPageTree');
97 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
98 $this->pagetree->thisScript = 'alt_db_navframe.php';
99 $this->pagetree->addField('alias');
100 $this->pagetree->addField('shortcut');
101 $this->pagetree->addField('shortcut_mode');
102 $this->pagetree->addField('mount_pid');
103 $this->pagetree->addField('url');
104
105 $currentSubScript = t3lib_div::GPvar('currentSubScript');
106
107 $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
108
109 // Create template object:
110 $this->doc = t3lib_div::makeInstance('template');
111
112 // 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
113 # $this->doc->docType='xhtml_trans';
114
115 // Setting backPath
116 $this->doc->backPath = $BACK_PATH;
117
118 // Setting JavaScript for menu.
119 $this->doc->JScode=$this->doc->wrapScriptTags(
120 ($currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($currentSubScript).'");':'').'
121
122 function jumpTo(id,linkObj) {
123 var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
124
125 if (top.condensedMode) {
126 top.content.document.location=theUrl;
127 } else {
128 parent.list_frame.document.location=theUrl;
129 }
130 '.($this->doHighlight?'hilight_row("pages"+top.fsMod.recentIds["web"],"pages"+id);':'').'
131 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
132 return false;
133 }
134 function refresh_nav() {
135 window.setTimeout("_refresh_nav();",0);
136 }
137 function _refresh_nav() {
138 document.location="'.$this->pagetree->thisScript.'?unique='.time().'";
139 }
140
141 function hilight_row(old_rowid,new_rowid) {
142 if(document.all) {
143 if(document.all.item(old_rowid)) {
144 document.all.item(old_rowid).style.backgroundColor="";
145 }
146 if(document.all.item(new_rowid)) {
147 document.all.item(new_rowid).style.backgroundColor="'.
148 t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).
149 '";
150 }
151 } else {
152 if(document.getElementsByName) {
153 old_row_obj = document.getElementsByName(old_rowid)[0];
154 new_row_obj = document.getElementsByName(new_rowid)[0];
155 bgc = document.createAttribute("bgcolor");
156 bgc.value="'.
157 t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).
158 '";
159 if(old_row_obj) {
160 old_row_obj.removeAttribute("bgcolor");
161 }
162 if(new_row_obj) {
163 new_row_obj.setAttributeNode(bgc);
164 }
165 }
166 }
167 }
168
169 '.(t3lib_div::GPvar('cMR')?"jumpTo(top.fsMod.recentIds['web'],'');":"").';
170 ');
171
172 // Click menu code is added:
173 $CMparts=$this->doc->getContextMenuCode();
174 $this->doc->bodyTagAdditions = $CMparts[1];
175 $this->doc->JScode.=$CMparts[0];
176 $this->doc->postCode.= $CMparts[2];
177 }
178
179 /**
180 * Main function
181 */
182 function main() {
183 global $LANG,$CLIENT;
184
185 // Produce browse-tree:
186 $tree = $this->pagetree->getBrowsableTree();
187 /*
188 if ($CLIENT['BROWSER']=='konqu') {
189 // Where <nobr> does not work, this will secure non-breaks in lines:
190 $tree = '<table border=0 cellspacing=0 cellpadding=0><tr><td nowrap>'.$tree.'</td></tr></table>';
191 }
192 */
193
194 $this->content='';
195 $this->content.=$this->doc->startPage('Page tree');
196 $this->content.=$tree;
197 $this->content.='<br />
198 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
199 '<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="" />'.
200 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
201 <br /><br />';
202
203 // Adding highlight - JavaScript
204 if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
205 rowid="pages"+top.fsMod.recentIds["web"];
206 hilight_row("",rowid);
207 ');
208 }
209
210 /**
211 * Output tree.
212 */
213 function printContent() {
214 $this->content.= $this->doc->endPage();
215 echo $this->content;
216 }
217 }
218
219 // Include extension?
220 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']) {
221 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
222 }
223
224
225
226
227
228
229
230
231
232
233
234
235 // Make instance:
236 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
237 $SOBE->init();
238 $SOBE->main();
239 $SOBE->printContent();
240
241 ?>