Hooks in tslib_fe, Frontend login mode feature for pages; various other things. see...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / web_info / class.tx_cms_webinfo.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@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 * Contains a class with functions for page related statistics added to the backend Info module
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 5/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 66: class tx_cms_webinfo_page extends t3lib_extobjbase
41 * 73: function modMenu()
42 * 100: function main()
43 *
44 *
45 * 199: class tx_cms_webinfo_hits extends tx_cms_webinfo_page
46 *
47 * TOTAL FUNCTIONS: 2
48 * (This index is automatically created/updated by the extension "extdeveval")
49 *
50 */
51
52 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
53 require_once(PATH_t3lib.'class.t3lib_recordlist.php');
54 require_once(PATH_typo3.'class.db_list.inc');
55 require_once(t3lib_extMgm::extPath('cms').'layout/class.tx_cms_layout.php');
56 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
57
58
59 /**
60 * Class for displaying page information (records, page record properties)
61 *
62 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
63 * @package TYPO3
64 * @subpackage tx_cms
65 */
66 class tx_cms_webinfo_page extends t3lib_extobjbase {
67
68 /**
69 * Returns the menu array
70 *
71 * @return array
72 */
73 function modMenu() {
74 global $LANG;
75 return array (
76 'pages' => array (
77 0 => $LANG->getLL('pages_0'),
78 2 => $LANG->getLL('pages_2'),
79 1 => $LANG->getLL('pages_1')
80 ),
81 'stat_type' => array(
82 0 => $LANG->getLL('stat_type_0'),
83 1 => $LANG->getLL('stat_type_1'),
84 2 => $LANG->getLL('stat_type_2'),
85 ),
86 'depth' => array(
87 0 => $LANG->getLL('depth_0'),
88 1 => $LANG->getLL('depth_1'),
89 2 => $LANG->getLL('depth_2'),
90 3 => $LANG->getLL('depth_3')
91 )
92 );
93 }
94
95 /**
96 * MAIN function for page information display (including hit statistics)
97 *
98 * @return string Output HTML for the module.
99 */
100 function main() {
101 global $BACK_PATH,$LANG,$SOBE;
102
103 $dblist = t3lib_div::makeInstance('tx_cms_layout');
104 $dblist->descrTable = '_MOD_'.$GLOBALS['MCONF']['name'];
105 $dblist->backPath = $BACK_PATH;
106 $dblist->thumbs = 0;
107 $dblist->script = 'index.php';
108 $dblist->showIcon = 0;
109 $dblist->setLMargin=0;
110 $dblist->agePrefixes=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
111
112 $dblist->pI_showUser=1;
113 $dblist->pI_showStat=0;
114
115
116 // PAGES:
117 $this->pObj->MOD_SETTINGS['pages_levels']=$this->pObj->MOD_SETTINGS['depth']; // ONLY for the sake of dblist module which uses this value.
118
119 $h_func = t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[depth]',$this->pObj->MOD_SETTINGS['depth'],$this->pObj->MOD_MENU['depth'],'index.php');
120 if ($this->pObj->MOD_SETTINGS['function']=='tx_cms_webinfo_hits') {
121 $h_func.= t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[stat_type]',$this->pObj->MOD_SETTINGS['stat_type'],$this->pObj->MOD_MENU['stat_type'],'index.php');
122
123 if ($this->pObj->MOD_SETTINGS['stat_type']==1) $dblist->stat_select_field='rl0';
124 if ($this->pObj->MOD_SETTINGS['stat_type']==2) $dblist->stat_select_field='rl1';
125
126 // Timespan
127 for ($a=0;$a<30;$a++) {
128 $dblist->stat_codes[]='HITS_days:'.(-$a);
129 }
130 $timespan_b = mktime (0,0,0);
131 $timespan_e = mktime (0,0,0)-(30-1)*3600*24+1;
132 $header='<br />'.sprintf($LANG->getLL('stat_period'),t3lib_BEfunc::date($timespan_b),t3lib_BEfunc::date($timespan_e)).'<br />';
133
134 //
135 $dblist->start($this->pObj->id,'pages',0);
136 $dblist->pages_noEditColumns=1;
137 $dblist->generateList();
138
139
140 $theOutput.= $this->pObj->doc->section($LANG->getLL('hits_title'),
141 t3lib_BEfunc::cshItem($dblist->descrTable,'stat',$GLOBALS['BACK_PATH'],'|<br/>'). // CSH
142 $h_func.
143 $header.
144 $dblist->HTMLcode,
145 0,
146 1
147 );
148 } else {
149 $h_func.= t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[pages]',$this->pObj->MOD_SETTINGS['pages'],$this->pObj->MOD_MENU['pages'],'index.php');
150 $dblist->start($this->pObj->id,'pages',0);
151 $dblist->generateList();
152
153 // CSH
154 $theOutput.=$this->pObj->doc->section($LANG->getLL('page_title'),
155 t3lib_BEfunc::cshItem($dblist->descrTable,'pagetree_overview',$GLOBALS['BACK_PATH'],'|<br/>'). // CSH
156 $h_func.
157 $dblist->HTMLcode,
158 0,
159 1
160 );
161
162 // SYS_NOTES:
163 if (t3lib_extMgm::isLoaded('sys_note')) {
164 $dblist->start($this->pObj->id,'sys_note',0);
165 $dblist->generateList();
166 if ($dblist->HTMLcode) {
167 $theOutput.=$this->pObj->doc->spacer(10);
168 $theOutput.=$this->pObj->doc->section($LANG->getLL('page_sysnote'),
169 $dblist->HTMLcode,
170 0,
171 1
172 );
173 }
174 }
175
176 // PAGE INFORMATION
177 if ($this->pObj->pageinfo['uid']) {
178 $theOutput.=$this->pObj->doc->spacer(10);
179 $theOutput.=$this->pObj->doc->section($LANG->getLL('pageInformation'),$dblist->getPageInfoBox($this->pObj->pageinfo,$this->pObj->CALC_PERMS&2),0,1);
180 }
181 }
182
183 return $theOutput;
184 }
185 }
186
187 /**
188 * Extension class for hits display, basically using tx_cms_webinfo_page (internally this is detected).
189 * This construction is due to the old "pre-extensions" structure
190 *
191 * IMPORTANT: This class is used by the extension "sys_stat" and will be added to the Info module only when "sys_stat" is installed.
192 * The display of statistics goes on in "tx_cms_webinfo_page" though
193 *
194 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
195 * @package TYPO3
196 * @subpackage tx_cms
197 */
198 class tx_cms_webinfo_hits extends tx_cms_webinfo_page {
199 }
200
201
202 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo.php']) {
203 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/web_info/class.tx_cms_webinfo.php']);
204 }
205 ?>