Advertisement
oocieni

wordpress/page_stats

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