private function render($params) { $this->log("Found {myFlickr} in content"); $this->log("User parameters: " . $params[1]); // Import external API library require_once 'includes/myFlickrApi.class.php'; // Import external Renderer library require_once 'includes/myFlickrRenderer.class.php'; // Set flag to load additional css/js libs $this->found_myflickr = true; // Setup Basic Parameters & defaults $this->init(); // Parse gallery specific paramaters $this->parseParams($params[1]); if ($this->thumbstyle == 'custom') { if ($this->custom_css) { $style = "div.myF-custom img{" . $this->custom_css . "}" . PHP_EOL; $style .= "div.myF-custom img:hover{" . $this->custom_css_hover . "}" . PHP_EOL; $this->document->addStyleDeclaration($style); } } $html_output = ""; // Set all all image sizes to enable "find size" function Flickr API if ($this->find_size) { $extras = "url_sq,url_q,url_t,url_n,url_m,url_z,url_c,url_l,url_o,owner_name"; } else { $extras = "url_" . $this->thumbsize . ",url_" . $this->imagesize . ",owner_name"; } // Get additional data if captions enabled if ($this->captions) { $extras .= ",description,date_taken,tags"; } // Set arguments passed to Flickr API $args = array('photoset_id' => $this->photoset_id, 'user_id' => $this->user_id, 'group_id' => $this->group_id, 'gallery_id' => $this->gallery_id, 'gallery_url' => $this->gallery_url, 'tags' => $this->tags, 'tag_mode' => $this->tag_mode, 'search_user_id' => $this->search_user_id, 'text' => $this->text, 'sort' => $this->sort, 'min_upload_date' => $this->min_upload_date, 'max_upload_date' => $this->max_upload_date, 'min_taken_date' => $this->min_taken_date, 'max_taken_date' => $this->max_taken_date, 'per_page' => $this->perpage, 'page' => $this->page, 'extras' => $extras); if ($this->debug_level >= 3) { $this->log("Flickr API request params: <pre>" . print_r($args, true) . "</pre>"); } // Create MyFlickr $api = new myFlickrApi($this->api_key, $this); // Get response from flickr api if ($this->cache_enabled) { // ** TODO: REWRITE THIS SECTION AND CACHE FOR BETTER PERFORMANCE ** // $this->log("Looking for cached API response"); require_once 'includes/JG_Cache.class.php'; $cache = new JG_Cache($this->get_media_web_path('cache')); $hash = sha1(serialize($args)); $key = $this->feed . '_' . $hash; if (!($this->flickrrsp = $cache->get($key, $this->cache_expired * 60))) { $this->log("No cached api response found."); switch ($this->feed) { case 'search': $this->flickrrsp = $api->photosSearch($args); break; case 'group': $this->flickrrsp = $api->groupsPoolsGetPhotos($args); break; case 'user': $this->flickrrsp = $api->peopleGetPublicPhotos($args); break; case 'photoset': $this->flickrrsp = $api->photosetsGetPhotos($args); break; case 'gallery': $this->flickrrsp = $api->galleriesGetPhotos($args); break; case 'recent': $this->flickrrsp = $api->photosGetRecent($args); break; default: $this->flickrrsp = $api->photosGetRecent($args); break; } $cache->set($key, $this->flickrrsp); } else { $this->log("Cached API response found and loaded"); } } else { $this->log("Load data from flickr API"); switch ($this->feed) { case 'search': $this->flickrrsp = $api->photosSearch($args); break; case 'group': $this->flickrrsp = $api->groupsPoolsGetPhotos($args); break; case 'user': $this->flickrrsp = $api->peopleGetPublicPhotos($args); break; case 'photoset': $this->flickrrsp = $api->photosetsGetPhotos($args); break; case 'gallery': $this->flickrrsp = $api->galleriesGetPhotos($args); break; case 'recent': $this->flickrrsp = $api->photosGetRecent($args); break; default: $this->flickrrsp = $api->photosGetRecent($args); break; } } // HTML renderer if ($this->flickrrsp) { $renderer = new myFlickrRenderer($this); $html_output = $renderer->render(); } else { $html_output = $api->getLastError(); } return $html_output; }
/** * Retrieves a local or remote RSS/Atom news feed */ public function getNewsFeed() { include_once HV_ROOT_DIR . '/../lib/JG_Cache/JG_Cache.php'; // Create cache dir if it doesn't already exist $cacheDir = HV_CACHE_DIR . '/remote'; if (!@file_exists($cacheDir)) { @mkdir($cacheDir, 0777, true); } // Check for feed in cache $cache = new JG_Cache($cacheDir); if (!($feed = $cache->get('news.xml', 1800))) { // Re-fetch if it is old than 30 mins include_once HV_ROOT_DIR . '/../src/Net/Proxy.php'; $proxy = new Net_Proxy(HV_NEWS_FEED_URL); $feed = $proxy->query(array(), true); $cache->set('news.xml', $feed); } // Print Response as XML or JSONP/XML if (isset($this->_params['callback'])) { $this->_printJSON($feed, true, true); } else { header('Content-Type: text/xml;charset=UTF-8'); echo $feed; } }