Advertisement
oocieni

Wordpress/Filmotech/page_stats

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