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