Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

yearreport.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: yearreport.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, "yearreport.php" );
43
44 $t->setAllStrings();
45
46 $t->set_file( "year_report_tpl", "yearreport.tpl" );
47
48 $t->set_block( "year_report_tpl", "result_list_tpl", "result_list" );
49 $t->set_block( "result_list_tpl", "month_tpl", "month" );
50
51 $t->set_block( "month_tpl", "month_link_tpl", "month_link" );
52 $t->set_block( "month_tpl", "month_link_end_tpl", "month_link_end" );
53
54 $t->set_block( "month_tpl", "percent_marker_tpl", "percent_marker" );
55 $t->set_block( "month_tpl", "no_percent_marker_tpl", "no_percent_marker" );
56
57 $t->set_block( "result_list_tpl", "year_tpl", "year" );
58 $t->set_block( "year_tpl", "year_previous_tpl", "year_previous" );
59 $t->set_block( "year_tpl", "year_previous_inactive_tpl", "year_previous_inactive" );
60 $t->set_block( "year_tpl", "year_next_tpl", "year_next" );
61 $t->set_block( "year_tpl", "year_next_inactive_tpl", "year_next_inactive" );
62
63 if ( !is_numeric( $Year ) )
64 {
65 $cur_date = new eZDate();
66 $Year = $cur_date->year();
67 $Month = $cur_date->month();
68 }
69
70 $yearReport =& eZPageViewQuery::yearStats( $Year );
71
72 $months = array( 1 => "jan",
73 2 => "feb",
74 3 => "mar",
75 4 => "apr",
76 5 => "may",
77 6 => "jun",
78 7 => "jul",
79 8 => "aug",
80 9 => "sep",
81 10 => "oct",
82 11 => "nov",
83 12 => "dec" );
84
85 if ( count( $yearReport ) > 0 )
86 {
87 $maxCount = 0;
88 // find the largest hit value
89 foreach ( $yearReport["Months"] as $month )
90 {
91 $count = $month["Count"];
92
93 if ( $count > $maxCount )
94 $maxCount = $count;
95 }
96
97 $cur_date = new eZDate();
98 $i=1;
99 foreach ( $yearReport["Months"] as $month )
100 {
101 $count = $month["Count"];
102 $totalCount = $yearReport["TotalPages"];
103
104 $t->set_var( "page_view_count", $count );
105 $t->set_var( "current_month", $i );
106
107 if ( $totalCount > 0 )
108 {
109 $pageViewPercent = ( $count / $totalCount ) * 100;
110 $pageViewPercent = round($pageViewPercent);
111 }
112 else
113 {
114 $pageViewPercent = 0;
115 }
116
117 $newMax = $totalCount - $maxCount;
118
119 if ( $maxCount > 0 )
120 {
121 $normalizedPercent = ( $count / $maxCount ) * 100;
122 $normalizedPercent = round($normalizedPercent);
123 }
124 else
125 {
126 $normalizedPercent = 0;
127 }
128
129 $t->set_var( "page_view_percent", $normalizedPercent );
130 $t->set_var( "page_view_inverted_percent", 100 - $normalizedPercent );
131
132 $t->set_var( "percent_count", $pageViewPercent );
133
134 $t->set_var( "percent_marker", "" );
135 $t->set_var( "no_percent_marker", "" );
136
137 if ( $count == 0 )
138 $t->parse( "no_percent_marker", "no_percent_marker_tpl" );
139 else
140 $t->parse( "percent_marker", "percent_marker_tpl" );
141
142 $t->set_var( "month_link", "" );
143 $t->set_var( "month_link_end", "" );
144
145 $t->set_var( "month_named", $locale->monthName( $months[$i], false ) );
146
147 $t->set_var( "this_month", $i );
148
149 $next_date = new eZDate( $Year, $i, 1 );
150 if ( !$cur_date->isGreater( $next_date ) )
151 {
152 $t->parse( "month_link", "month_link_tpl" );
153 $t->parse( "month_link_end", "month_link_end_tpl" );
154 }
155
156 $t->parse( "month", "month_tpl", true );
157 $i++;
158 }
159 $t->set_var( "total_page_views", $yearReport["TotalPages"] );
160 $t->set_var( "pages_pr_month", $yearReport["PagesPrMonth"] );
161
162 $t->parse( "result_list", "result_list_tpl" );
163 }
164 else
165 {
166 $t->set_var( "result_list", "" );
167 }
168
169 $t->set_var( "this_month", $Month );
170 $t->set_var( "this_year", $Year );
171
172 $NextYear = $Year + 1;
173 $PrevYear = $Year - 1;
174 $t->set_var( "next_year", $NextYear );
175 $t->set_var( "previous_year", $PrevYear );
176
177 $t->set_var( "next_year", $NextYear );
178 $t->set_var( "previous_year", $PrevYear );
179 $t->set_var( "next_year", $NextYear );
180 $t->set_var( "previous_year", $PrevYear );
181
182 $t->set_var( "year_next_inactive", "" );
183 $t->set_var( "year_next", "" );
184 $t->set_var( "year_previous", "" );
185 $t->set_var( "year_previous_inactive", "" );
186
187 $cur_date = new eZDate();
188 $next_date = new eZDate( $NextYear, 1, 1 );
189
190 if ( $cur_date->isGreater( $next_date ) )
191 $t->parse( "year_next_inactive", "year_next_inactive_tpl" );
192 else
193 $t->parse( "year_next", "year_next_tpl" );
194
195 $t->parse( "year_previous", "year_previous_tpl" );
196 $t->parse( "year", "year_tpl" );
197
198 $t->pparse( "output", "year_report_tpl" );
199
200 ?>
$i
$i
Definition: admin/adlist.php:91
$month
else $month
Definition: appointmentedit.php:660
eZDate
Definition: ezdate.php:46
eZLocale
Definition: ezlocale.php:119
eZPageViewQuery\yearStats
static & yearStats( $year)
Definition: ezpageviewquery.php:532
eZTemplate
Definition: eztemplate.php:107
$totalCount
$totalCount
Definition: ezarticle/admin/formlist.php:73
$Month
$Month
Definition: ezcalendar/user/dayview.php:78
$count
$count
Definition: onlinetypelist.php:108
$next_date
$next_date
Definition: yearreport.php:188
$locale
$locale
Definition: yearreport.php:33
$t
$t
Definition: yearreport.php:41
$cur_date
$cur_date
Definition: yearreport.php:187
$NextYear
$NextYear
Definition: yearreport.php:172
$months
$months
Definition: yearreport.php:72
$Language
$Language
Definition: yearreport.php:30
$yearReport
if(!is_numeric( $Year)) $yearReport
Definition: yearreport.php:70
$ini
$ini
Definition: yearreport.php:28
$PrevYear
$PrevYear
Definition: yearreport.php:173
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.