Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

monthreport.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: monthreport.php 6230 2001-07-20 11:28:54Z jakobn $
5 //
6 // Created on: <07-Jan-2001 14:47:04 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 $ini =& eZINI::instance( 'site.ini' );
29
30 $Language = $ini->variable( "eZStatsMain", "Language" );
31
32 // include_once( "classes/ezlocale.php" );
33 $locale = new eZLocale( $Language );
34
35 // include_once( "classes/eztemplate.php" );
36 // include_once( "classes/ezdate.php" );
37
38 // include_once( "ezstats/classes/ezpageview.php" );
39 // include_once( "ezstats/classes/ezpageviewquery.php" );
40
41 $t = new eZTemplate( "kernel/ezstats/admin/" . $ini->variable( "eZStatsMain", "AdminTemplateDir" ),
42 "kernel/ezstats/admin/intl", $Language, "monthreport.php" );
43
44 $t->setAllStrings();
45
46 $t->set_file( "month_report_tpl", "monthreport.tpl" );
47
48 $t->set_block( "month_report_tpl", "result_list_tpl", "result_list" );
49 $t->set_block( "result_list_tpl", "day_tpl", "day" );
50
51 $t->set_block( "day_tpl", "day_link_tpl", "day_link" );
52 $t->set_block( "day_tpl", "no_day_link_tpl", "no_day_link" );
53
54 $t->set_block( "day_tpl", "percent_marker_tpl", "percent_marker" );
55 $t->set_block( "day_tpl", "no_percent_marker_tpl", "no_percent_marker" );
56
57 $t->set_block( "result_list_tpl", "month_tpl", "month" );
58 $t->set_block( "month_tpl", "month_previous_tpl", "month_previous" );
59 $t->set_block( "month_tpl", "month_previous_inactive_tpl", "month_previous_inactive" );
60 $t->set_block( "month_tpl", "month_next_tpl", "month_next" );
61 $t->set_block( "month_tpl", "month_next_inactive_tpl", "month_next_inactive" );
62
63 $t->set_var( "day", "" );
64
65 if ( isset( $Year ) && !is_numeric( $Year ) || isset( $Month ) && !is_numeric( $Month ) )
66 {
67 $cur_date = new eZDate();
68 $Year = $cur_date->year();
69 $Month = $cur_date->month();
70 }
71
72 $query = new eZPageViewQuery();
73 $monthReport =& $query->monthStats( $Year, $Month );
74
75 if ( count( $monthReport ) > 0 )
76 {
77 $maxCount = 0;
78 // find the largest hit value
79 foreach ( $monthReport["Days"] as $day )
80 {
81 $count = $day["Count"];
82
83 if ( $count > $maxCount )
84 $maxCount = $count;
85 }
86
87 $cur_date = new eZDate();
88 $i=1;
89 foreach ( $monthReport["Days"] as $day )
90 {
91 $count = $day["Count"];
92 $totalCount = $monthReport["TotalPages"];
93
94 $t->set_var( "page_view_count", $count );
95 $t->set_var( "current_day", $i );
96
97 if ( $totalCount > 0 )
98 {
99 $pageViewPercent = ( $count / $totalCount ) * 100;
100 $pageViewPercent = round($pageViewPercent);
101 }
102 else
103 {
104 $pageViewPercent = 0;
105 }
106
107 $newMax = $totalCount - $maxCount;
108
109 if ( $maxCount > 0 )
110 {
111 $normalizedPercent = ( $count / $maxCount ) * 100;
112 $normalizedPercent = round($normalizedPercent);
113 }
114 else
115 {
116 $normalizedPercent = 0;
117 }
118
119 $t->set_var( "page_view_percent", $normalizedPercent );
120 $t->set_var( "page_view_inverted_percent", 100 - $normalizedPercent );
121
122 $t->set_var( "percent_count", $pageViewPercent );
123
124 $t->set_var( "percent_marker", "" );
125 $t->set_var( "no_percent_marker", "" );
126
127 if ( $count == 0 )
128 $t->parse( "no_percent_marker", "no_percent_marker_tpl" );
129 else
130 $t->parse( "percent_marker", "percent_marker_tpl" );
131
132 $t->set_var( "day_link", "" );
133 $t->set_var( "no_day_link", "" );
134
135 $next_date = new eZDate( $Year, $Month, $i );
136 if ( $cur_date->isGreater( $next_date ) )
137 $t->parse( "no_day_link", "no_day_link_tpl" );
138 else
139 $t->parse( "day_link", "day_link_tpl" );
140
141 $t->parse( "day", "day_tpl", true );
142 $i++;
143 }
144 $t->set_var( "total_page_views", $monthReport["TotalPages"] );
145 $t->set_var( "pages_pr_day", $monthReport["PagesPrDay"] );
146
147 $t->parse( "result_list", "result_list_tpl" );
148 }
149 else
150 {
151 $t->set_var( "result_list", "" );
152 }
153
154 $months = array( 1 => "jan",
155 2 => "feb",
156 3 => "mar",
157 4 => "apr",
158 5 => "may",
159 6 => "jun",
160 7 => "jul",
161 8 => "aug",
162 9 => "sep",
163 10 => "oct",
164 11 => "nov",
165 12 => "dec" );
166
167 $t->set_var( "this_month_named", $locale->monthName( $months[$Month], false ) );
168
169 $t->set_var( "this_month", $Month );
170 $t->set_var( "this_year", $Year );
171
172 $NextYear = $Year;
173 $PrevYear = $Year;
174 $NextMonth = $Month + 1;
175 if ( $NextMonth > 12 )
176 {
177 $NextYear++;
178 $NextMonth = 1;
179 }
180 $PrevMonth = $Month - 1;
181 if ( $PrevMonth < 1 )
182 {
183 $PrevYear--;
184 $PrevMonth = 12;
185 }
186 $t->set_var( "next_month", $NextMonth );
187 $t->set_var( "previous_month", $PrevMonth );
188 $t->set_var( "next_year", $NextYear );
189 $t->set_var( "previous_year", $PrevYear );
190
191 $t->set_var( "month_next_inactive", "" );
192 $t->set_var( "month_next", "" );
193 $t->set_var( "month_previous", "" );
194 $t->set_var( "month_previous_inactive", "" );
195
196 $cur_date = new eZDate();
197 $next_date = new eZDate( $NextYear, $NextMonth, 1 );
198
199 if ( $cur_date->isGreater( $next_date ) )
200 $t->parse( "month_next_inactive", "month_next_inactive_tpl" );
201 else
202 $t->parse( "month_next", "month_next_tpl" );
203
204 $t->parse( "month_previous", "month_previous_tpl" );
205 $t->parse( "month", "month_tpl" );
206
207 $t->pparse( "output", "month_report_tpl" );
208
209 ?>
$i
$i
Definition: admin/adlist.php:91
$day
else $day
Definition: appointmentedit.php:665
eZDate
Definition: ezdate.php:46
eZLocale
Definition: ezlocale.php:119
eZPageViewQuery
Definition: ezpageviewquery.php:45
eZTemplate
Definition: eztemplate.php:107
$totalCount
$totalCount
Definition: ezarticle/admin/formlist.php:73
$Month
$Month
Definition: ezcalendar/user/dayview.php:78
$next_date
$next_date
Definition: monthreport.php:197
$NextMonth
$NextMonth
Definition: monthreport.php:174
$locale
$locale
Definition: monthreport.php:33
$t
$t
Definition: monthreport.php:41
$cur_date
$cur_date
Definition: monthreport.php:196
$monthReport
$monthReport
Definition: monthreport.php:73
$NextYear
$NextYear
Definition: monthreport.php:172
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: monthreport.php:72
$months
$months
Definition: monthreport.php:154
$Language
$Language
Definition: monthreport.php:30
$ini
$ini
Definition: monthreport.php:28
$PrevYear
$PrevYear
Definition: monthreport.php:173
$PrevMonth
if( $NextMonth > 12) $PrevMonth
Definition: monthreport.php:180
$count
$count
Definition: onlinetypelist.php:108
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.