Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

companystats.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: companystats.php 9529 2002-05-14 11:17:05Z jhe $
5 //
6 // Created on: <20-Mar-2001 18:21:41 amos>
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
29 $ini =& eZINI::instance( 'site.ini' );
30 $Language = $ini->variable( "eZContactMain", "Language" );
31
32 // include_once( "classes/ezlocale.php" );
33 $locale = new eZLocale( $Language );
34
35 // include_once( "classes/eztemplate.php" );
36 // include_once( "ezcontact/classes/ezcompany.php" );
37
38 $t = new eZTemplate( "kernel/ezcontact/admin/" . $ini->variable( "eZContactMain", "AdminTemplateDir" ),
39 "kernel/ezcontact/admin/intl/", $Language, "companystats.php" );
40 $t->setAllStrings();
41
42 $t->set_file( "company_stats_tpl", "companystats.tpl" );
43
44 $t->set_block( "company_stats_tpl", "month_tpl", "month" );
45 $t->set_block( "month_tpl", "month_link_tpl", "month_link" );
46 $t->set_block( "month_tpl", "month_link_end_tpl", "month_link_end" );
47 $t->set_block( "month_tpl", "percent_marker_tpl", "percent_marker" );
48 $t->set_block( "month_tpl", "no_percent_marker_tpl", "no_percent_marker" );
49
50 $t->set_block( "company_stats_tpl", "date_nav_tpl", "date_nav" );
51 $t->set_block( "date_nav_tpl", "year_previous_tpl", "year_previous" );
52 $t->set_block( "date_nav_tpl", "year_previous_inactive_tpl", "year_previous_inactive" );
53 $t->set_block( "date_nav_tpl", "year_next_tpl", "year_next" );
54 $t->set_block( "date_nav_tpl", "year_next_inactive_tpl", "year_next_inactive" );
55
56 if ( !is_numeric( $Year ) )
57 {
58 $cur_date = new eZDate();
59 $Year = $cur_date->year();
60 }
61 if ( !is_numeric( $Month ) )
62 {
63 $cur_date = new eZDate();
64 $Month = $cur_date->month();
65 }
66 if ( !is_numeric( $Day ) )
67 {
68 $cur_date = new eZDate();
69 $Day = $cur_date->day();
70 }
71
72 $company = new eZCompany( $CompanyID );
73 $t->set_var( "company_name", $company->name() );
74 $t->set_var( "company_id", $company->id() );
75 $categories =& $company->categories( false, false, 1 );
76 $t->set_var( "category_id", "" );
77 if ( count( $categories ) > 0 )
78 $t->set_var( "category_id", $categories[0] );
79
80 $date = new eZDate( $Year, $Month, 1 );
81
82 $t->set_var( "month", "" );
83 $counts =& $company->yearViewCounts( $Year );
84 if ( count( $counts ) > 0 )
85 {
86 $maxCount = 0;
87 $totalCount = 0;
88 // find the largest hit value
89 foreach ( $counts as $month )
90 {
91 $maxCount = max( $maxCount, $month["count"] );
92 $totalCount += $month["count"];
93 }
94
95 $cur_date = new eZDate();
96 foreach ( $counts as $month )
97 {
98 $count = $month["count"];
99 $t->set_var( "page_view_count", $count );
100 $t->set_var( "current_month", $month["month"] );
101
102 $pageViewPercent = 0;
103 if ( $totalCount > 0 )
104 $pageViewPercent = round( ( $count / $totalCount ) * 100 );
105 $newMax = $totalCount - $maxCount;
106
107 $normalizedPercent = 0;
108 if ( $maxCount > 0 )
109 $normalizedPercent = round( ( $count / $maxCount ) * 100 );
110
111 $t->set_var( "page_view_percent", $normalizedPercent );
112 $t->set_var( "page_view_inverted_percent", 100 - $normalizedPercent );
113
114 $t->set_var( "percent_count", $pageViewPercent );
115
116 $t->set_var( "percent_marker", "" );
117 $t->set_var( "no_percent_marker", "" );
118
119 if ( $count == 0 )
120 $t->parse( "no_percent_marker", "no_percent_marker_tpl" );
121 else
122 $t->parse( "percent_marker", "percent_marker_tpl" );
123
124 $t->set_var( "month_link", "" );
125 $t->set_var( "month_link_end", "" );
126
127 $t->set_var( "month_named", $locale->monthName( $month["month"], false ) );
128
129 $t->set_var( "this_month", $month["month"] );
130
131 $next_date = new eZDate( $Year, $month["month"], 1 );
132 if ( !$cur_date->isGreater( $next_date ) )
133 {
134 $t->parse( "month_link", "month_link_tpl" );
135 $t->parse( "month_link_end", "month_link_end_tpl" );
136 }
137
138 $t->parse( "month", "month_tpl", true );
139 }
140 $t->set_var( "total_page_views", $totalCount );
141 $t->set_var( "pages_pr_month", 1 );
142 }
143
144 $t->set_var( "this_year", $Year );
145
146 $NextYear = $Year + 1;
147 $PrevYear = $Year - 1;
148 $t->set_var( "next_year", $NextYear );
149 $t->set_var( "previous_year", $PrevYear );
150
151 $t->set_var( "next_year", $NextYear );
152 $t->set_var( "previous_year", $PrevYear );
153 $t->set_var( "next_year", $NextYear );
154 $t->set_var( "previous_year", $PrevYear );
155
156 $t->set_var( "year_next_inactive", "" );
157 $t->set_var( "year_next", "" );
158 $t->set_var( "year_previous", "" );
159 $t->set_var( "year_previous_inactive", "" );
160
161 $cur_date = new eZDate();
162 $next_date = new eZDate( $NextYear, 1, 1 );
163
164 if ( $cur_date->isGreater( $next_date ) )
165 $t->parse( "year_next_inactive", "year_next_inactive_tpl" );
166 else
167 $t->parse( "year_next", "year_next_tpl" );
168
169 $t->parse( "year_previous", "year_previous_tpl" );
170
171 $t->parse( "date_nav", "date_nav_tpl" );
172
173 $t->pparse( "output", "company_stats_tpl" );
174
175 ?>
$month
else $month
Definition: appointmentedit.php:660
eZCompany
Definition: ezcompany.php:54
eZDate
Definition: ezdate.php:46
eZLocale
Definition: ezlocale.php:119
eZTemplate
Definition: eztemplate.php:107
$next_date
$next_date
Definition: companystats.php:162
$locale
$locale
Definition: companystats.php:33
$t
$t
Definition: companystats.php:38
$date
$date
Definition: companystats.php:80
$cur_date
$cur_date
Definition: companystats.php:161
$NextYear
$NextYear
Definition: companystats.php:146
$counts
$counts
Definition: companystats.php:83
$Language
$Language
Definition: companystats.php:30
$ini
$ini
Definition: companystats.php:29
$PrevYear
$PrevYear
Definition: companystats.php:147
$company
if(!is_numeric( $Year)) if(!is_numeric( $Month)) if(!is_numeric( $Day)) $company
Definition: companystats.php:72
$categories
$categories
Definition: companystats.php:75
$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+.