Advertisement
oocieni

page_stats_genre_3.2.9.2

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