Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

dayreport.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: dayreport.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, "dayreport.php" );
43
44 $t->setAllStrings();
45
46 $t->set_file( "day_report_tpl", "dayreport.tpl" );
47
48 $t->set_block( "day_report_tpl", "result_list_tpl", "result_list" );
49 $t->set_block( "result_list_tpl", "hour_tpl", "hour" );
50
51 $t->set_block( "hour_tpl", "percent_marker_tpl", "percent_marker" );
52 $t->set_block( "hour_tpl", "no_percent_marker_tpl", "no_percent_marker" );
53
54 $t->set_block( "result_list_tpl", "day_tpl", "day" );
55 $t->set_block( "day_tpl", "day_previous_tpl", "day_previous" );
56 $t->set_block( "day_tpl", "day_previous_inactive_tpl", "day_previous_inactive" );
57 $t->set_block( "day_tpl", "day_next_tpl", "day_next" );
58 $t->set_block( "day_tpl", "day_next_inactive_tpl", "day_next_inactive" );
59
60 if ( !is_numeric( $Year ) || !is_numeric( $Month ) || !is_numeric( $Day ) )
61 {
62 $cur_date = new eZDate();
63 $Year = $cur_date->year();
64 $Month = $cur_date->month();
65 $Day = $cur_date->day();
66 }
67
68 $cur_date = new eZDate( $Year, $Month, $Day );
69 if ( !$cur_date->isValid() )
70 {
71 $cur_date = new eZDate();
72 $Year = $cur_date->year();
73 $Month = $cur_date->month();
74 $Day = $cur_date->day();
75 }
76
77 $dayReport =& eZPageViewQuery::dayStats( $Year, $Month, $Day );
78
79 if ( count( $dayReport ) > 0 )
80 {
81 $maxCount = 0;
82 // find the largest hit value
83 foreach ( $dayReport["Hours"] as $day )
84 {
85 $count = $day["Count"];
86
87 if ( $count > $maxCount )
88 $maxCount = $count;
89 }
90
91 $i=0;
92 foreach ( $dayReport["Hours"] as $day )
93 {
94 $count = $day["Count"];
95 $totalCount = $dayReport["TotalPages"];
96
97 $t->set_var( "page_view_count", $count );
98 $t->set_var( "current_hour", $i > 9 ? $i : "0" . $i );
99
100 if ( $totalCount > 0 )
101 {
102 $pageViewPercent = ( $count / $totalCount ) * 100;
103 $pageViewPercent = round($pageViewPercent);
104 }
105 else
106 {
107 $pageViewPercent = 0;
108 }
109
110 $newMax = $totalCount - $maxCount;
111
112 if ( $maxCount > 0 )
113 {
114 $normalizedPercent = ( $count / $maxCount ) * 100;
115 $normalizedPercent = round($normalizedPercent);
116 }
117 else
118 {
119 $normalizedPercent = 0;
120 }
121
122 $t->set_var( "page_view_percent", $normalizedPercent );
123 $t->set_var( "page_view_inverted_percent", 100 - $normalizedPercent );
124
125 $t->set_var( "percent_count", $pageViewPercent );
126
127 $t->set_var( "percent_marker", "" );
128 $t->set_var( "no_percent_marker", "" );
129
130 if ( $count == 0 )
131 $t->parse( "no_percent_marker", "no_percent_marker_tpl" );
132 else
133 $t->parse( "percent_marker", "percent_marker_tpl" );
134
135 $t->parse( "hour", "hour_tpl", true );
136 $i++;
137 }
138 $t->set_var( "total_page_views", $dayReport["TotalPages"] );
139 $t->set_var( "pages_pr_hour", $dayReport["PagesPrHour"] );
140
141 $t->parse( "result_list", "result_list_tpl" );
142 }
143 else
144 {
145 $t->set_var( "result_list", "" );
146 }
147
148 $months = array( 1 => "jan",
149 2 => "feb",
150 3 => "mar",
151 4 => "apr",
152 5 => "may",
153 6 => "jun",
154 7 => "jul",
155 8 => "aug",
156 9 => "sep",
157 10 => "oct",
158 11 => "nov",
159 12 => "dec" );
160
161 $t->set_var( "this_month_named", $locale->monthName( $months[$Month], false ) );
162
163 $t->set_var( "this_day", $Day );
164 $t->set_var( "this_month", $Month );
165 $t->set_var( "this_year", $Year );
166
167 $NextYear = $Year;
168 $PrevYear = $Year;
169 $NextMonth = $Month;
170 $PrevMonth = $Month;
171 $NextDay = $Day + 1;
172 $PrevDay = $Day - 1;
173 $tmp_day = new eZDate( $Year, $Month, 1 );
174 if ( $NextDay > $tmp_day->daysInMonth() )
175 {
176 $NextDay = 1;
177 $NextMonth++;
178 }
179 if ( $NextMonth > 12 )
180 {
181 $NextYear++;
182 $NextMonth = 1;
183 }
184
185 if ( $PrevDay < 1 )
186 {
187 $PrevMonth--;
188 if ( $PrevMonth < 1 )
189 {
190 $PrevYear--;
191 $PrevMonth = 12;
192 }
193 $tmp_day = new eZDate( $PrevYear, $PrevMonth, 1 );
194 $PrevDay = $tmp_day->daysInMonth();
195 }
196 $t->set_var( "next_day", $NextDay );
197 $t->set_var( "previous_day", $PrevDay );
198 $t->set_var( "next_month", $NextMonth );
199 $t->set_var( "previous_month", $PrevMonth );
200 $t->set_var( "next_year", $NextYear );
201 $t->set_var( "previous_year", $PrevYear );
202
203 $t->set_var( "day_next_inactive", "" );
204 $t->set_var( "day_next", "" );
205 $t->set_var( "day_previous", "" );
206 $t->set_var( "day_previous_inactive", "" );
207
208 $cur_date = new eZDate();
209 $next_date = new eZDate( $NextYear, $NextMonth, $NextDay );
210
211 if ( $cur_date->isGreater( $next_date ) )
212 $t->parse( "day_next_inactive", "day_next_inactive_tpl" );
213 else
214 $t->parse( "day_next", "day_next_tpl" );
215
216 $t->parse( "day_previous", "day_previous_tpl" );
217 $t->parse( "day", "day_tpl" );
218
219 $t->pparse( "output", "day_report_tpl" );
220
221 ?>
$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\dayStats
static & dayStats( $year, $month, $day)
Definition: ezpageviewquery.php:628
eZTemplate
Definition: eztemplate.php:107
$next_date
$next_date
Definition: dayreport.php:209
$NextMonth
$NextMonth
Definition: dayreport.php:169
$NextDay
$NextDay
Definition: dayreport.php:171
$locale
$locale
Definition: dayreport.php:33
$t
$t
Definition: dayreport.php:41
$cur_date
if(!is_numeric( $Year)||!is_numeric( $Month)||!is_numeric( $Day)) $cur_date
Definition: dayreport.php:68
$dayReport
if(! $cur_date->isValid()) $dayReport
Definition: dayreport.php:77
$NextYear
$NextYear
Definition: dayreport.php:167
$months
$months
Definition: dayreport.php:148
$Language
$Language
Definition: dayreport.php:30
$ini
$ini
Definition: dayreport.php:28
$tmp_day
$tmp_day
Definition: dayreport.php:173
$PrevMonth
$PrevMonth
Definition: dayreport.php:170
$PrevYear
$PrevYear
Definition: dayreport.php:168
$PrevDay
$PrevDay
Definition: dayreport.php:172
$totalCount
$totalCount
Definition: ezarticle/admin/formlist.php:73
$Month
$Month
Definition: ezcalendar/user/dayview.php:78
$Day
$Day
Definition: ezcalendar/user/dayview.php:79
$count
$count
Definition: onlinetypelist.php:108
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.