Ejemplo n.º 1
0
 function pbase()
 {
     // Initialize the parent
     $this->YDRequest();
     // Initialize the template
     $this->template = new YDTemplate();
     // Set the home url
     $this->homeUrl = 'http://www.pbase.com/beachshop/';
     $this->template->assign('homeUrl', $this->homeUrl);
     // Title for the image gallery
     $this->template->assign('galTitle', 'Beachshop Pictures');
     // Start with no galleries and no selected gallery
     $this->galleries = array();
     $this->gallery = null;
     // Download the gallery index
     $pIndex = '/HREF="http:\\/\\/www.pbase.com\\/beachshop\\/(.*?)" class="thumbnail".*? src="http:\\/\\/.*?.image.pbase.com\\/.*?\\/.*?\\/small\\/([0-9]+).*?alt="(.*?)">/ism';
     $objUrl = new YDUrl($this->homeUrl . 'root&page=all');
     $contents = $objUrl->getContentsWithRegex($pIndex);
     // Loop over the matching patterns to construct the galleries list
     for ($i = 0; $i < sizeof($contents[1]); $i++) {
         // Initialize the array if needed
         if (!isset($this->galleries[$i])) {
             $this->galleries[$i] = array();
         }
         // Fill in the details
         $this->galleries[$i]['title'] = $contents[3][$i];
         $this->galleries[$i]['url'] = $this->homeUrl . $contents[1][$i] . '&page=all';
         $this->galleries[$i]['thumbnail'] = $this->homeUrl . 'image/' . $contents[2][$i] . '/small.jpg';
         $this->galleries[$i]['id'] = md5($this->galleries[$i]['url']);
         // Get the contents of the URL
         $pGallery = '/www\\.pbase\\.com\\/beachshop\\/image\\/([0-9]+)/ism';
         $objUrl = new YDUrl($this->galleries[$i]['url']);
         $pcontents = $objUrl->getContentsWithRegex($pGallery);
         // Add the list of images
         $this->galleries[$i]['images'] = $pcontents[1];
     }
     // If a gallery is selected, assign it to the gallery variable
     if (isset($_GET['gal'])) {
         foreach ($this->galleries as $gallery) {
             if ($gallery['id'] == $_GET['gal']) {
                 $this->gallery = $gallery;
                 $this->template->assign('gallery', $gallery);
             }
         }
     }
 }