Ejemplo n.º 1
0
 function get_data($url)
 {
     if (array_key_exists($url, $this->_content)) {
         return new FetchedDataURL($this->_content[$url], array(), "");
     }
     return parent::get_data($url);
 }
Ejemplo n.º 2
0
 function get($url, &$pipeline)
 {
     global $g_config, $g_image_cache;
     if (!$g_config['renderimages']) {
         return null;
     }
     // Check if this URL have been cached
     //
     if (isset($g_image_cache[$url])) {
         //      return do_image_open($g_image_cache[$url]);
         return $g_image_cache[$url];
     }
     // Download image; we should do it before we call do_image_open,
     // as it tries to open image file twice: first to determine image type
     // and second to actually create the image - PHP url wrappers do no caching
     // at all
     //
     $filename = ImageFactory::make_cache_filename($url);
     // REQUIRES: PHP 4.3.0+
     // we suppress warning messages, as missing image files will cause 'copy' to print
     // several warnings
     //
     // @TODO: change to fetcher class call
     //
     // simplify our url by fetcher simlify functionality
     $url = FetcherUrl::_simplify_path($url);
     $data = $pipeline->fetch($url);
     if (is_null($data)) {
         trigger_error("Cannot fetch image: " . $url, E_USER_WARNING);
         return null;
     }
     $file = fopen($filename, 'wb');
     fwrite($file, $data->content);
     fclose($file);
     $pipeline->pop_base_url();
     // register it in the cached objects array
     //
     $handle = do_image_open($filename, $type);
     if ($handle) {
         $g_image_cache[$url] =& new Image($handle, $filename, $type);
     } else {
         $g_image_cache[$url] = null;
     }
     // return image
     //
     // return do_image_open($filename);
     return $g_image_cache[$url];
 }