Author: chabotc
Date: Tue Jun 10 07:49:18 2008
New Revision: 666139
URL: http://svn.apache.org/viewvc?rev=666139&view=rev
Log:
SHINDIG-357 added refresh interval to the gadget context, using it in the
fetcher and removed the temporary hack
Modified:
incubator/shindig/trunk/php/src/common/samplecontainer/BasicRemoteContent.php
incubator/shindig/trunk/php/src/gadgets/GadgetContext.php
incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
Modified:
incubator/shindig/trunk/php/src/common/samplecontainer/BasicRemoteContent.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/samplecontainer/BasicRemoteContent.php?rev=666139&r1=666138&r2=666139&view=diff
==============================================================================
---
incubator/shindig/trunk/php/src/common/samplecontainer/BasicRemoteContent.php
(original)
+++
incubator/shindig/trunk/php/src/common/samplecontainer/BasicRemoteContent.php
Tue Jun 10 07:49:18 2008
@@ -29,7 +29,7 @@
throw new RemoteContentException("Invalid request type
in remoteContent");
}
// determine which requests we can load from cache, and which
we have to actually fetch
- if (! $context->getIgnoreCache() && ! $request->isPost() &&
($cachedRequest = $cache->get($request->toHash())) !== false) {
+ if (! $context->getIgnoreCache() && ! $request->isPost() &&
($cachedRequest = $cache->get($request->toHash(),
$context->getRefreshInterval())) !== false) {
$ret = $cachedRequest;
} else {
$ret = $remoteContentFetcher->fetchRequest($request);
Modified: incubator/shindig/trunk/php/src/gadgets/GadgetContext.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/GadgetContext.php?rev=666139&r1=666138&r2=666139&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/GadgetContext.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/GadgetContext.php Tue Jun 10
07:49:18 2008
@@ -41,6 +41,7 @@
protected $forcedJsLibs = null;
protected $containerConfig = null;
protected $container = null;
+ protected $refreshInterval;
public function __construct($renderingContext)
{
@@ -54,8 +55,13 @@
$this->setModuleId($this->getModuleIdParam());
$this->setView($this->getViewParam());
$this->setContainer($this->getContainerParam());
- //NOTE All classes are initialized when called (aka lazy
loading) because we don't
- //need all of them in every situation
+ $this->setRefreshInterval($this->getRefreshIntervalParam());
+ //NOTE All classes are initialized when called (aka lazy
loading) because we don't need all of them in every situation
+ }
+
+ private function getRefreshIntervalParam()
+ {
+ $this->refreshInterval = isset($_GET['refresh']) ?
$_GET['refresh'] : Config::get('cache_time');
}
private function getContainerParam()
@@ -159,8 +165,8 @@
private function instanceLocale()
{
// Get language and country params, try the GET params first,
if their not set try the POST, else use 'all' as default
- $language = !empty($_GET['lang']) ? $_GET['lang'] :
(!empty($_POST['lang']) ? $_POST['lang'] : 'all');
- $country = !empty($_GET['country']) ? $_GET['country'] :
(!empty($_POST['country']) ? $_POST['country'] : 'all');
+ $language = ! empty($_GET['lang']) ? $_GET['lang'] : (!
empty($_POST['lang']) ? $_POST['lang'] : 'all');
+ $country = ! empty($_GET['country']) ? $_GET['country'] : (!
empty($_POST['country']) ? $_POST['country'] : 'all');
return new Locale($language, $country);
}
@@ -229,6 +235,11 @@
return $this->view;
}
+ public function setRefreshInterval($interval)
+ {
+ $this->refreshInterval = $interval;
+ }
+
public function setContainer($container)
{
$this->container = $container;
@@ -304,6 +315,11 @@
$this->forcedJsLibs = $forcedJsLibs;
}
+ public function getRefreshInterval()
+ {
+ return $this->refreshInterval;
+ }
+
public function getIgnoreCache()
{
return $this->ignoreCache;
Modified: incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php?rev=666139&r1=666138&r2=666139&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php Tue Jun 10
07:49:18 2008
@@ -79,16 +79,8 @@
$numEntries = $_GET['numEntries'];
$getSummaries = $_GET['getSummaries'];
$channel = array();
- //TODO fix the hack below by updating content
fetcher..
- // we cheat a litle here, we want a different
caching time for feed's
- // but atm the content fetcher doesn't allow
this to be configured
- $originalCacheTime = Config::get('cache_time');
- $newTime = isset($_GET['refresh']) ?
$_GET['refresh'] : 5 * 60;
- Config::set('cache_time', $newTime);
$request = new RemoteContentRequest($url);
$request =
$this->context->getHttpFetcher()->fetch($request, $this->context);
- // Restore original caching time
- Config::set('cache_time', $originalCacheTime);
if ((int)$result->getHttpCode() == 200) {
$content =
$result->getResponseContent();
try {