/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/network-stats-mashup/includes/class.trunk.php
ViewVC logotype

Diff of /trunk/nl.nikhef.ndpf.tools/network-stats-mashup/includes/class.trunk.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1287 by aramv, Fri Dec 11 17:11:59 2009 UTC revision 1288 by aramv, Fri Dec 11 23:07:26 2009 UTC
# Line 6  class Trunk { Line 6  class Trunk {
6              $constituents = array(),  // an array of links that compose the current link              $constituents = array(),  // an array of links that compose the current link
7              $daily_image_url,         // the url to the daily graph image              $daily_image_url,         // the url to the daily graph image
8              $weekly_image_url,        // the url to the weekly graph image              $weekly_image_url,        // the url to the weekly graph image
9              $random_token;            // a random token, to ensure images are fresh              $random_token,            // a random token, to ensure images are fresh
10                $is_constituent;
11    
12    public function __construct($trunk_page_url, $metatrunk_page_url, $is_constituent = false){    public function __construct($trunk_page_url, $metatrunk_page_url, $is_constituent = false){
13      if($this->is_relative_url($trunk_page_url)){      if($this->is_relative_url($trunk_page_url)){
# Line 15  class Trunk { Line 16  class Trunk {
16        $this->trunk_page_url = $trunk_page_url;        $this->trunk_page_url = $trunk_page_url;
17        $this->get_cricket_images_from_url($trunk_page_url);        $this->get_cricket_images_from_url($trunk_page_url);
18      }      }
19    
20      $this->metatrunk_page_url = $metatrunk_page_url;      $this->metatrunk_page_url = $metatrunk_page_url;
21      $this->random_token  = rand();      $this->random_token  = rand();
22      $this->name = $this->name_from_url($trunk_page_url);      $this->is_constituent = $is_constituent;
23      if(!$is_constituent){      if(!$this->is_constituent){
24        $this->find_constituents();        $this->find_constituents();
25      }      }
26        
27        $this->name = $this->name_from_url($trunk_page_url);
28    }    }
29    
30    public function to_html(){    public function to_html(){
# Line 52  class Trunk { Line 56  class Trunk {
56    
57    /* returns the two key components from the url, separated by <-> delimiter */    /* returns the two key components from the url, separated by <-> delimiter */
58    private function name_from_url($url){    private function name_from_url($url){
59        $name = "";
60      $name_parts = split("%2F", CricketSpider::code_from_url($url));      $name_parts = split("%2F", CricketSpider::code_from_url($url));
61      if(@$name_parts[1]){      if(@$name_parts[1]){
62        return $name_parts[0] . " &harr; " . $name_parts[1];        if($this->is_constituent){
63            $name = $name_parts[1];
64          } else {
65            $name = $name_parts[0] . " &harr; " . $name_parts[1];
66          }
67      } else {      } else {
68        return $url;        $url_parts = split("/", $url);
69          $name = $url_parts[1];
70      }      }
71        return $name;
72    }    }
73    
74    private function find_constituents(){    private function find_constituents(){
75      $constituent_urls = array();      $constituent_urls = CricketSpider::get_urls_from_html_file($this->metatrunk_page_url);
76      if($this->metatrunk_page_url){      foreach($constituent_urls[3] as $index => $url){
77        $constituent_urls = CricketSpider::get_urls_from_html_file($this->metatrunk_page_url);        $this->constituents[] = new Trunk($constituent_urls[3][$index], $constituent_urls[2][$index], true);
       foreach($constituent_urls[3] as $index => $url){  
         $this->constituents[] = new Trunk($constituent_urls[3][$index], $constituent_urls[2][$index], true);  
       }  
78      }      }
79    }    }
80    

Legend:
Removed from v.1287  
changed lines
  Added in v.1288

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28