View difference between Paste ID: kYiZZq6E and fB8sxPsC
SHOW: | | - or go back to the newest paste.
1
<?php /* ATOM/digitalnature */
2
3
   // The template for the "page" post type. It acts for pages just like single.php does for posts
4
   // pagename.php, page-slug.php or page-id.php can override it.
5
6
   /* Template Name: Page Stats */
7
8
  //get_header();
9
?>
10
11
<?php atom()->template('header'); ?>
12
13
  <!-- main content: primary + sidebar(s) -->
14
  <div id="mask-3" class="clear-block">
15
   <div id="mask-2">
16
    <div id="mask-1">
17
             
18
      <!-- primary content -->
19
      <div id="primary-content">
20
       <div class="blocks clear-block">
21
           
22
        <?php //$app->action('before_primary'); ?>
23
		<?php atom()->action('before_primary'); ?>
24
25
		 <?php
26
			/*$args=array(
27
			  'orderby' => 'name',
28
			  'order' => 'ASC'
29
			  );*/
30
			$args=array(
31
			  'orderby' => 'ID',
32
			  'order' => 'ASC'
33
			  );
34
  
35
			$categories=get_categories($args);
36
			//echo count($categories);
37
			foreach($categories as $category) { 
38
				//echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
39
				//echo '<p> Description:'. $category->description . '</p>';
40
				//echo '<p> Post Count: '. $category->count . '</p>';
41
42
				$data_genre.="['".$category->name."',".$category->count."],";
43
				//echo $category->term_id.$category->name;
44
				$data_ref_id.='"'.$category->term_id.'",';
45
			}
46
			$data_genre=substr($data_genre, 0, -1);	//suppression de la derniere virgule !
47
			$data_ref_id=substr($data_ref_id, 0, -1);	//suppression de la derniere virgule !
48
			//echo $data_genre;
49
			?>
50
<!--Load the AJAX API-->
51
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
52
    <script type="text/javascript">
53
    
54
      // Load the Visualization API and the piechart package.
55
      google.load('visualization', '1.0', {'packages':['corechart']});
56
      
57
      // Set a callback to run when the Google Visualization API is loaded.
58
      google.setOnLoadCallback(drawChart);
59
      
60
      // Callback that creates and populates a data table, 
61
      // instantiates the pie chart, passes in the data and
62
      // draws it.
63
      function drawChart() {
64
65
      // Create the data table.
66
      var data = new google.visualization.DataTable();
67
      data.addColumn('string', 'Categorie');
68
      data.addColumn('number', 'Nombre');
69
      data.addRows([
70
        <?php echo $data_genre; ?>
71
      ]);
72
73
      // Set chart options
74
      var options = {'title':'Statistiques par Genre',
75
                     'width':600,
76
                     'height':500};
77
78
      // Instantiate and draw our chart, passing in some options.
79
      var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
80
      chart.draw(data, options);
81
82
	var IdCat=[<?php echo $data_ref_id; ?>];
83
84
	google.visualization.events.addListener(chart,'select', 
85
                                         function() {
86
                                           var selection = chart.getSelection();
87
                                           var item = selection[0];
88
                                           //alert(data.getValue(item.row,0));
89
					   document.location.href = "?cat="+IdCat[item.row];
90
                                         });
91
92
    }
93
94
    </script>
95
96
	<!--Div that will hold the pie chart-->
97
    <div id="chart_div"></div>
98
99
	<?php
100
	//query_posts('showposts=60','&orderby=title&order=asc');
101
	query_posts( 'posts_per_page=-1'.'&orderby=title&order=asc');
102
103
	$tableau_pays=array();
104
	$tableau_pays_cpt=array();
105
	$tableau_pays_wordpress=array();
106
107
108
	while ( have_posts() ) : the_post(); ?>
109
110
<?php
111
	$values = get_post_custom_values("dvd_pays");
112
	//if (isset($values[0])) {}
113
	$pays="";
114
	if(strpos($values[0],"/") || strpos($values[0],",")) {
115
		if(strpos($values[0],"/")) $pays_tab=explode("/",$values[0]);
116
		if(strpos($values[0],",")) $pays_tab=explode(",",$values[0]);
117
			
118
		for($j=0;$j<count($pays_tab);$j++) {
119
			//$key=array_search(trim($pays[$j]),$tableau_pays);
120
			$pays="";
121
			if(strtolower(trim($pays_tab[$j]))=="france") $pays="FR";
122
			if(strtolower(trim($pays_tab[$j]))=="usa" || strtolower(trim($pays_tab[$j]))=="us" || strtolower(trim($pays_tab[$j]))=="etats-unis") $pays="US";
123
			if(strtolower(trim($pays_tab[$j]))=="allemagne") $pays="DE";
124
			if(strtolower(trim($pays_tab[$j]))=="australie") $pays="AU";
125
			if(strtolower(trim($pays_tab[$j]))=="irlande") $pays="IE";
126
			if(strtolower(trim($pays_tab[$j]))=="royaume-uni") $pays="GB";
127
			if(strtolower(trim($pays_tab[$j]))=="hong-kong") $pays="HK";
128
			if(strtolower(trim($pays_tab[$j]))=="japon") $pays="JP";
129
			if(strtolower(trim($pays_tab[$j]))=="italie") $pays="IT";
130
			if(strtolower(trim($pays_tab[$j]))=="espagne") $pays="ES";
131
			if(strtolower(trim($pays_tab[$j]))=="canada") $pays="CA";
132
			if(strtolower(trim($pays_tab[$j]))=="belgique") $pays="BE";
133
			if(strtolower(trim($pays_tab[$j]))=="nouvelle-zélande") $pays="NZ";
134
			//if(strlen($pays)<1) echo $pays_tab[$j]."<br>";
135
			$key=array_search($pays,$tableau_pays);
136
			if($key==false) {
137
				$i++;
138
				$tableau_pays[$i]=trim($pays);
139
				$tableau_pays_cpt[$i]=1;
140
				$tableau_pays_wordpress[$i]=$pays_tab[$j];
141
				//echo "i : ".$i;
142
			} else {
143
				//ce genre est deja enregistré dans le tableau a l'index key
144
				$tableau_pays_cpt[$key]++;
145
			}
146
		}
147
	}else {
148
		//$key=array_search(trim($values[0]),$tableau_pays);
149
		if(strtolower(trim($values[0]))=="france") $pays="FR";
150
		if(strtolower(trim($values[0]))=="usa" || strtolower(trim($values[0]))=="us" || strtolower(trim($values[0]))=="etats-unis") $pays="US";
151
		if(strtolower(trim($values[0]))=="allemagne") $pays="DE";
152
		if(strtolower(trim($values[0]))=="australie") $pays="AU";
153
		if(strtolower(trim($values[0]))=="irlande") $pays="IE";
154
		if(strtolower(trim($values[0]))=="royaume-uni") $pays="GB";
155
		if(strtolower(trim($values[0]))=="hong-kong") $pays="HK";
156
		if(strtolower(trim($values[0]))=="japon") $pays="JP";
157
		if(strtolower(trim($values[0]))=="italie") $pays="IT";
158
		if(strtolower(trim($values[0]))=="espagne") $pays="ES";
159
		if(strtolower(trim($values[0]))=="canada") $pays="CA";
160
		if(strtolower(trim($values[0]))=="belgique") $pays="BE";
161
		if(strtolower(trim($values[0]))=="nouvelle-zélande") $pays="NZ";
162
		//if(strlen($pays)<1) echo $values[0]."<br>";
163
		$key=array_search(trim($pays),$tableau_pays);
164
		//echo $key;
165
		if($key==false) {
166
			$i++;
167
			$tableau_pays[$i]=$pays;
168
			$tableau_pays_cpt[$i]=1;
169
			$tableau_pays_wordpress[$i]=$values[0];
170
			//echo "i : ".$i;
171
		} else {
172
			//ce genre est deja enregistré dans le tableau a l'index key
173
			$tableau_pays_cpt[$key]++;
174
		}
175
//echo $values[0].'<br>';
176
	}
177
178
	endwhile;
179
	//echo count($tableau_pays);
180
	for($j=1;$j<=count($tableau_pays);$j++) {
181
182
		/*
183
		$a = DecHex(mt_rand(0,15)); $b = DecHex(mt_rand(0,15)); $c = DecHex(mt_rand(0,15)); $d = DecHex(mt_rand(0,15)); $e = DecHex(mt_rand(0,15)); $f = DecHex(mt_rand(0,15)); $hexac = $a . $b . $c . $d . $e . $f;
184
		$couleur_chart.=$hexac.'|';
185
		*/
186
		//data.setValue(0, 0, 'Germany');
187
		$index=$j-1;
188
		$data_pays.="data.setValue(".$index.", 0, '".$tableau_pays[$j]."');";
189
		$data_pays.="data.setValue(".$index.", 1, ".$tableau_pays_cpt[$j].");";
190
		$data_pays_ref_id.='"'.trim($tableau_pays_wordpress[$j]).'",';
191
	}
192
	$nbr_rows=count($tableau_pays);
193
	$data_pays_ref_id=substr($data_pays_ref_id, 0, -1);	//suppression de la derniere virgule !
194
	//echo $data_pays;
195
?>
196
197
<script type='text/javascript'>
198
   google.load('visualization', '1', {'packages': ['geochart']});
199
   google.setOnLoadCallback(drawRegionsMap);
200
201
    function drawRegionsMap() {
202
      var data = new google.visualization.DataTable();
203
      data.addRows(6);
204
	  <?php echo "data.addRows(".$nbr_rows.");"; ?>
205
      data.addColumn('string', 'Pays');
206
      data.addColumn('number', 'Films');
207
      <?php echo $data_pays; ?>
208
209
	// Set chart options
210
      var options = {'title':'Statistiques par Pays'};
211
212
      var container = document.getElementById('map_canvas');
213
      var geochart = new google.visualization.GeoChart(container);
214
      geochart.draw(data, options);
215
216
	var NomPays=[<?php echo $data_pays_ref_id; ?>];
217
218
	google.visualization.events.addListener(geochart,'select', 
219
                                         function() {
220
                                           var selection = geochart.getSelection();
221
                                           var item = selection[0];
222
                                           //alert(data.getValue(item.row,0));
223
					//alert(NomPays[item.row]);
224
					//?meta_key=dvd_pays&meta_value=USA
225
					   document.location.href = "?meta_key=dvd_pays&meta_value="+NomPays[item.row];
226
                                         });
227
228
  };
229
  </script>
230
231
	<!--Div that will hold the Map-->
232
	<div id='map_canvas'></div>
233
234
        <?php //$app->action('after_primary'); ?>
235
		<?php atom()->action('after_primary'); ?>
236
237
       </div>
238
      </div>
239
      <!-- /primary content -->
240
241
      <?php //get_sidebar(); ?>
242
	  <?php atom()->template('sidebar'); ?>
243
    </div>
244
   </div>
245
  </div>
246
  <!-- /main content -->
247
248
<?php //get_footer(); ?>
249
<?php atom()->template('footer'); ?>