You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by bh...@apache.org on 2011/01/14 15:41:45 UTC
svn commit: r1059023 [1/2] - in /shindig/trunk/php/src: common/
common/sample/ gadgets/ gadgets/oauth/ gadgets/render/ gadgets/rewrite/
gadgets/sample/ gadgets/templates/
Author: bhofmann
Date: Fri Jan 14 14:41:43 2011
New Revision: 1059023
URL: http://svn.apache.org/viewvc?rev=1059023&view=rev
Log:
SHINDIG-952: PHP: added and corrected a lot of PHPdocs
Modified:
shindig/trunk/php/src/common/BlobCrypter.php
shindig/trunk/php/src/common/Cache.php
shindig/trunk/php/src/common/CacheStorage.php
shindig/trunk/php/src/common/Config.php
shindig/trunk/php/src/common/File.php
shindig/trunk/php/src/common/Locale.php
shindig/trunk/php/src/common/OAuthLookupService.php
shindig/trunk/php/src/common/RemoteContent.php
shindig/trunk/php/src/common/RemoteContentFetcher.php
shindig/trunk/php/src/common/RemoteContentRequest.php
shindig/trunk/php/src/common/SecurityToken.php
shindig/trunk/php/src/common/SecurityTokenDecoder.php
shindig/trunk/php/src/common/ShindigOAuth.php
shindig/trunk/php/src/common/XmlError.php
shindig/trunk/php/src/common/sample/BasicBlobCrypter.php
shindig/trunk/php/src/common/sample/BasicOAuthLookupService.php
shindig/trunk/php/src/common/sample/BasicRemoteContent.php
shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
shindig/trunk/php/src/common/sample/BasicSecurityToken.php
shindig/trunk/php/src/common/sample/BasicSecurityTokenDecoder.php
shindig/trunk/php/src/common/sample/CacheStorageApc.php
shindig/trunk/php/src/common/sample/CacheStorageFile.php
shindig/trunk/php/src/common/sample/CacheStorageMemcache.php
shindig/trunk/php/src/gadgets/ContainerConfig.php
shindig/trunk/php/src/gadgets/Gadget.php
shindig/trunk/php/src/gadgets/GadgetBlacklist.php
shindig/trunk/php/src/gadgets/GadgetContext.php
shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php
shindig/trunk/php/src/gadgets/GadgetSpec.php
shindig/trunk/php/src/gadgets/GadgetSpecParser.php
shindig/trunk/php/src/gadgets/MakeRequest.php
shindig/trunk/php/src/gadgets/MetadataContext.php
shindig/trunk/php/src/gadgets/MetadataHandler.php
shindig/trunk/php/src/gadgets/ProxyBase.php
shindig/trunk/php/src/gadgets/ProxyHandler.php
shindig/trunk/php/src/gadgets/SigningFetcher.php
shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php
shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php
shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php
shindig/trunk/php/src/gadgets/oauth/OAuthAccessor.php
shindig/trunk/php/src/gadgets/oauth/OAuthCallbackState.php
shindig/trunk/php/src/gadgets/oauth/OAuthFetcher.php
shindig/trunk/php/src/gadgets/oauth/OAuthFetcherFactory.php
shindig/trunk/php/src/gadgets/oauth/OAuthRequestParams.php
shindig/trunk/php/src/gadgets/oauth/OAuthService.php
shindig/trunk/php/src/gadgets/oauth/OAuthServiceProvider.php
shindig/trunk/php/src/gadgets/oauth/OAuthSpec.php
shindig/trunk/php/src/gadgets/oauth/OAuthStore.php
shindig/trunk/php/src/gadgets/render/GadgetHtmlRenderer.php
shindig/trunk/php/src/gadgets/render/GadgetRenderer.php
shindig/trunk/php/src/gadgets/rewrite/ContentRewriter.php
shindig/trunk/php/src/gadgets/rewrite/DomRewriter.php
shindig/trunk/php/src/gadgets/rewrite/GadgetRewriter.php
shindig/trunk/php/src/gadgets/sample/BasicGadgetBlacklist.php
shindig/trunk/php/src/gadgets/sample/BasicGadgetSpecFactory.php
shindig/trunk/php/src/gadgets/templates/DataPipelining.php
shindig/trunk/php/src/gadgets/templates/ExpType.php
shindig/trunk/php/src/gadgets/templates/ExpressionParser.php
shindig/trunk/php/src/gadgets/templates/TemplateLibrary.php
shindig/trunk/php/src/gadgets/templates/TemplateParser.php
Modified: shindig/trunk/php/src/common/BlobCrypter.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/BlobCrypter.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/BlobCrypter.php (original)
+++ shindig/trunk/php/src/common/BlobCrypter.php Fri Jan 14 14:41:43 2011
@@ -32,8 +32,8 @@ abstract class BlobCrypter {
/**
* Time stamps, encrypts, and signs a blob.
*
- * @param in name/value pairs to encrypt
- * @return a base64 encoded blob
+ * @param array $in name/value pairs to encrypt
+ * @return string a base64 encoded blob
*
* @throws BlobCrypterException
*/
@@ -42,9 +42,9 @@ abstract class BlobCrypter {
/**
* Unwraps a blob.
*
- * @param in blob
- * @param maxAgeSec maximum age for the blob
- * @return the name/value pairs, including the origin timestamp.
+ * @param string $in blob
+ * @param int $maxAgeSec maximum age for the blob
+ * @return array the name/value pairs, including the origin timestamp.
*
* @throws BlobExpiredException if the blob is too old to be accepted.
* @throws BlobCrypterException if the blob can't be decoded.
Modified: shindig/trunk/php/src/common/Cache.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/Cache.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/Cache.php (original)
+++ shindig/trunk/php/src/common/Cache.php Fri Jan 14 14:41:43 2011
@@ -40,12 +40,21 @@ class Cache {
private $storage = null;
/**
+ * @param string $cacheClass
+ * @param string $name
+ * @param RequestTime $time
* @return Cache
*/
static public function createCache($cacheClass, $name, RequestTime $time = null) {
return new Cache($cacheClass, $name, $time);
}
+ /**
+ *
+ * @param string $cacheClass
+ * @param string $name
+ * @param RequestTime $time
+ */
private function __construct($cacheClass, $name, RequestTime $time = null) {
$this->storage = new $cacheClass($name);
if ($time == null) {
@@ -55,6 +64,11 @@ class Cache {
}
}
+ /**
+ *
+ * @param string $key
+ * @return array or false
+ */
public function get($key) {
if ($this->storage->isLocked($key)) {
$this->storage->waitForLock($key);
@@ -69,6 +83,11 @@ class Cache {
return false;
}
+ /**
+ *
+ * @param string $key
+ * @return array
+ */
public function expiredGet($key) {
if ($this->storage->isLocked($key)) {
$this->storage->waitForLock($key);
@@ -81,6 +100,12 @@ class Cache {
return array('found' => false);
}
+ /**
+ *
+ * @param string $key
+ * @param mixed $value
+ * @param int $ttl optional
+ */
public function set($key, $value, $ttl = false) {
if (! $ttl) {
$ttl = Config::Get('cache_time');
@@ -99,6 +124,10 @@ class Cache {
}
}
+ /**
+ *
+ * @param string $key
+ */
public function delete($key) {
if ($this->storage->isLocked($key)) {
$this->storage->waitForLock($key);
@@ -108,6 +137,10 @@ class Cache {
$this->storage->unlock($key);
}
+ /**
+ *
+ * @param string $key
+ */
public function invalidate($key) {
if ($this->storage->isLocked($key)) {
$this->storage->waitForLock($key);
Modified: shindig/trunk/php/src/common/CacheStorage.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/CacheStorage.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/CacheStorage.php (original)
+++ shindig/trunk/php/src/common/CacheStorage.php Fri Jan 14 14:41:43 2011
@@ -19,18 +19,48 @@
*/
abstract class CacheStorage {
+
+ /**
+ *
+ * @param string $key
+ * @param mixed $value
+ */
abstract public function store($key, $value);
+ /**
+ *
+ * @param string $key
+ */
abstract public function fetch($key);
+ /**
+ *
+ * @param string $key
+ */
abstract public function delete($key);
+ /**
+ *
+ * @param string $key
+ */
abstract public function lock($key);
+ /**
+ *
+ * @param string $key
+ */
abstract public function unlock($key);
+ /**
+ *
+ * @param string $key
+ */
abstract public function isLocked($key);
+ /**
+ *
+ * @param string $key
+ */
public function waitForLock($key) {
$tries = 10;
$cnt = 0;
Modified: shindig/trunk/php/src/common/Config.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/Config.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/Config.php (original)
+++ shindig/trunk/php/src/common/Config.php Fri Jan 14 14:41:43 2011
@@ -26,8 +26,17 @@ class ConfigException extends Exception
* and (if the file exists) config/local.php.
*/
class Config {
+ /**
+ *
+ * @var boolean
+ */
private static $config = false;
+ /**
+ *
+ * @global array $shindigConfig
+ * @param string $local
+ */
static public function loadConfig($local = 'local') {
global $shindigConfig;
if (! self::$config) {
@@ -48,6 +57,8 @@ class Config {
/**
* Merges the given array with the config array. It uses the keys/values from config/container.php.
+ *
+ * @param array $tconfig
*/
static function setConfig($tconfig) {
if (!is_array(self::$config))
@@ -56,6 +67,12 @@ class Config {
self::$config = array_merge(self::$config, $tconfig);
}
+ /**
+ *
+ * @param string $key
+ * @return array
+ * @throws ConfigException
+ */
static function get($key) {
if (! self::$config) {
self::loadConfig();
Modified: shindig/trunk/php/src/common/File.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/File.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/File.php (original)
+++ shindig/trunk/php/src/common/File.php Fri Jan 14 14:41:43 2011
@@ -21,6 +21,11 @@
class File {
+ /**
+ *
+ * @param string $file
+ * @return boolean
+ */
public static function exists($file) {
// only really check if check_file_exists == true, big performance hit on production systems, but also much safer :)
if (Config::get('check_file_exists')) {
@@ -30,6 +35,11 @@ class File {
}
}
+ /**
+ *
+ * @param string $file
+ * @return boolean
+ */
public static function readable($file) {
// only really check if check_file_exists == true, big performance hit on production systems, but also much safer :)
if (Config::get('check_file_exists')) {
Modified: shindig/trunk/php/src/common/Locale.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/Locale.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/Locale.php (original)
+++ shindig/trunk/php/src/common/Locale.php Fri Jan 14 14:41:43 2011
@@ -24,14 +24,33 @@
* interpretation one, we created our own
*/
class Locale {
+ /**
+ *
+ * @var string
+ */
public $language;
+
+ /**
+ *
+ * @var string
+ */
public $country;
+ /**
+ *
+ * @param string $language
+ * @param string $country
+ */
public function __construct($language, $country) {
$this->language = $language;
$this->country = $country;
}
+ /**
+ *
+ * @param Locale $obj
+ * @return boolean
+ */
public function equals($obj) {
if (! ($obj instanceof Locale)) {
return false;
@@ -39,10 +58,18 @@ class Locale {
return ($obj->language == $this->language && $obj->country == $this->country);
}
+ /**
+ *
+ * @return string
+ */
public function getLanguage() {
return $this->language;
}
+ /**
+ *
+ * @return string
+ */
public function getCountry() {
return $this->country;
}
Modified: shindig/trunk/php/src/common/OAuthLookupService.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/OAuthLookupService.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/OAuthLookupService.php (original)
+++ shindig/trunk/php/src/common/OAuthLookupService.php Fri Jan 14 14:41:43 2011
@@ -24,6 +24,12 @@
*/
abstract class OAuthLookupService {
+ /**
+ * @var OAuthRequest $oauthRequest
+ * @var string $appUrl
+ * @var string $userId
+ * @var string $contentType
+ */
abstract public function getSecurityToken($oauthRequest, $appUrl, $userId, $contentType);
}
Modified: shindig/trunk/php/src/common/RemoteContent.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/RemoteContent.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/RemoteContent.php (original)
+++ shindig/trunk/php/src/common/RemoteContent.php Fri Jan 14 14:41:43 2011
@@ -32,9 +32,20 @@ class RemoteContentException extends Exc
abstract class RemoteContent {
+ /**
+ * @param RemoteContentRequest $request
+ * @return RemoteContentRequest
+ */
abstract public function fetch(RemoteContentRequest $request);
+ /**
+ * @param array $requests
+ * @return array
+ */
abstract public function multiFetch(Array $requests);
-
+
+ /**
+ * @param RemoteContentRequest $request
+ */
abstract public function invalidate(RemoteContentRequest $request);
}
Modified: shindig/trunk/php/src/common/RemoteContentFetcher.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/RemoteContentFetcher.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/RemoteContentFetcher.php (original)
+++ shindig/trunk/php/src/common/RemoteContentFetcher.php Fri Jan 14 14:41:43 2011
@@ -20,7 +20,15 @@
abstract class RemoteContentFetcher {
+ /**
+ * @param RemoteContentRequest $request
+ * @return RemoteContentRequest
+ */
abstract public function fetchRequest(RemoteContentRequest $request);
+ /**
+ * @param array $requests
+ * @return array
+ */
abstract public function multiFetchRequest(Array $requests);
}
Modified: shindig/trunk/php/src/common/RemoteContentRequest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/RemoteContentRequest.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/RemoteContentRequest.php (original)
+++ shindig/trunk/php/src/common/RemoteContentRequest.php Fri Jan 14 14:41:43 2011
@@ -422,6 +422,8 @@ class Options {
/**
* Copy constructor
+ *
+ * @param Options $copyFrom
*/
public function copyOptions(Options $copyFrom) {
$this->ignoreCache = $copyFrom->ignoreCache;
Modified: shindig/trunk/php/src/common/SecurityToken.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/SecurityToken.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/SecurityToken.php (original)
+++ shindig/trunk/php/src/common/SecurityToken.php Fri Jan 14 14:41:43 2011
@@ -88,6 +88,9 @@ abstract class SecurityToken {
* @return string
*/
abstract public function getAuthenticationMode();
-
+
+ /**
+ * @param string $mode
+ */
abstract public function setAuthenticationMode($mode);
}
Modified: shindig/trunk/php/src/common/SecurityTokenDecoder.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/SecurityTokenDecoder.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/SecurityTokenDecoder.php (original)
+++ shindig/trunk/php/src/common/SecurityTokenDecoder.php Fri Jan 14 14:41:43 2011
@@ -26,7 +26,7 @@ abstract class SecurityTokenDecoder {
/**
* Decrypts and verifies a gadget security token to return a gadget token.
*
- * @param tokenString String representation of the token to be created.
+ * @param string $tokenString String representation of the token to be created.
* @return The token representation of the input data.
* @throws GadgetException If tokenString is not a valid token
*/
Modified: shindig/trunk/php/src/common/ShindigOAuth.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/ShindigOAuth.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/ShindigOAuth.php (original)
+++ shindig/trunk/php/src/common/ShindigOAuth.php Fri Jan 14 14:41:43 2011
@@ -68,6 +68,8 @@ class ShindigOAuth {
class ShindigOAuthRequest extends OAuthRequest {
/**
* Needed so that OAuthFetcher works with the correct type of requests.
+ *
+ * @param OAuthRequest $request
*/
public function __construct(OAuthRequest $request) {
$this->parameters = $request->parameters;
@@ -93,6 +95,9 @@ class ShindigOAuthRequest extends OAuthR
/**
* Needed in OAuthFetcher.php
+ *
+ * @param array $params
+ * @return array
*/
public function set_parameters($params) {
return $this->parameters = $params;
@@ -100,6 +105,8 @@ class ShindigOAuthRequest extends OAuthR
/**
* Needed in OAuthFetcher.php
+ *
+ * @param array $names
*/
public function requireParameters($names) {
$present = $this->parameters;
@@ -116,6 +123,8 @@ class ShindigOAuthRequest extends OAuthR
/**
* Needed in OAuthFetcher.php
+ *
+ * @return string
*/
public function get_url() {
return $this->http_url;
@@ -123,6 +132,8 @@ class ShindigOAuthRequest extends OAuthR
/**
* Needed in SigningFetcher.php
+ *
+ * @return string
*/
public static function generate_nonce() {
$mt = microtime();
@@ -132,6 +143,8 @@ class ShindigOAuthRequest extends OAuthR
/**
* Needed for from_consumer_and_token
+ *
+ * @return int
*/
private static function generate_timestamp() {
return time();
@@ -146,6 +159,9 @@ class ShindigOAuthUtil extends OAuthUtil
/**
* Needed in OAuthFetcher.php
+ *
+ * @param array $params
+ * @return string
*/
public static function getPostBodyString(Array $params) {
$result = '';
@@ -164,6 +180,9 @@ class ShindigOAuthUtil extends OAuthUtil
/**
* Needed in OAuthFetcher.php
* Return true if the given Content-Type header means FORM_ENCODED.
+ *
+ * @param string $contentType
+ * @return boolean
*/
public static function isFormEncoded($contentType) {
if (! isset($contentType)) {
@@ -178,6 +197,10 @@ class ShindigOAuthUtil extends OAuthUtil
/**
* Needed in OAuthFetcher.php
+ *
+ * @param string $url
+ * @param array $oauthParams
+ * @return string
*/
public static function addParameters($url, $oauthParams) {
$url .= strchr($url, '?') === false ? '?' : '&';
@@ -189,6 +212,9 @@ class ShindigOAuthUtil extends OAuthUtil
/**
* Needed in OAuthFetcher.php
+ *
+ * @param string $form
+ * @return array
*/
public static function decodeForm($form) {
$parameters = array();
@@ -208,6 +234,9 @@ class ShindigOAuthUtil extends OAuthUtil
* Parse the parameters from an OAuth Authorization or WWW-Authenticate
* header. The realm is included as a parameter. If the given header doesn't
* start with "OAuth ", return an empty list.
+ *
+ * @param string $authorization
+ * @return array
*/
public static function decodeAuthorization($authorization) {
$into = array();
Modified: shindig/trunk/php/src/common/XmlError.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/XmlError.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/XmlError.php (original)
+++ shindig/trunk/php/src/common/XmlError.php Fri Jan 14 14:41:43 2011
@@ -25,6 +25,11 @@
*/
class XmlError {
+ /**
+ *
+ * @param string $xml
+ * @return string
+ */
static public function getErrors($xml = false) {
$errors = libxml_get_errors();
$ret = '';
@@ -38,6 +43,12 @@ class XmlError {
return $ret;
}
+ /**
+ *
+ * @param object $error
+ * @param array $xml
+ * @return string
+ */
static public function parseXmlError($error, $xml) {
if ($xml) {
$ret = $xml[$error->line - 1] . "\n";
Modified: shindig/trunk/php/src/common/sample/BasicBlobCrypter.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicBlobCrypter.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicBlobCrypter.php (original)
+++ shindig/trunk/php/src/common/sample/BasicBlobCrypter.php Fri Jan 14 14:41:43 2011
@@ -69,6 +69,11 @@ class BasicBlobCrypter extends BlobCrypt
return $b64;
}
+ /**
+ *
+ * @param array $in
+ * @return string
+ */
protected function serializeAndTimestamp(Array $in) {
$encoded = "";
foreach ($in as $key => $val) {
@@ -115,9 +120,9 @@ class BasicBlobCrypter extends BlobCrypt
}
/**
- * {@inheritDoc}
- *
* Parses the security token
+ * @param string $stringToken
+ * @return array
*/
protected function parseToken($stringToken) {
$data = explode(":", $stringToken);
@@ -130,12 +135,22 @@ class BasicBlobCrypter extends BlobCrypt
return $data;
}
+ /**
+ * @param string $plain
+ * @return array
+ */
protected function deserialize($plain) {
$map = array();
parse_str($plain, $map);
return $map;
}
+ /**
+ *
+ * @param array $out
+ * @param int $maxAge
+ * @throws BlobExpiredException
+ */
protected function checkTimestamp(Array $out, $maxAge) {
$minTime = (int)$out[$this->TIMESTAMP_KEY] - $this->CLOCK_SKEW_ALLOWANCE;
$maxTime = (int)$out[$this->TIMESTAMP_KEY] + $maxAge + $this->CLOCK_SKEW_ALLOWANCE;
Modified: shindig/trunk/php/src/common/sample/BasicOAuthLookupService.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicOAuthLookupService.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicOAuthLookupService.php (original)
+++ shindig/trunk/php/src/common/sample/BasicOAuthLookupService.php Fri Jan 14 14:41:43 2011
@@ -20,14 +20,22 @@
/**
- * Basic implementation of OAuthLookupService using BasicOAuthDataStore.
+ * Basic implementation of OAuthLookupService
*/
class BasicOAuthLookupService extends OAuthLookupService {
+ /**
+ * {@inheritDoc}
+ */
public function getSecurityToken($oauthRequest, $appUrl, $userId, $contentType) {
return new OAuthSecurityToken($userId, $appUrl, $this->getAppId($appUrl), "samplecontainer");
}
+ /**
+ *
+ * @param string $appUrl
+ * @return int
+ */
private function getAppId($appUrl) {
return 0; // a real implementation would look this up
}
Modified: shindig/trunk/php/src/common/sample/BasicRemoteContent.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicRemoteContent.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicRemoteContent.php (original)
+++ shindig/trunk/php/src/common/sample/BasicRemoteContent.php Fri Jan 14 14:41:43 2011
@@ -45,7 +45,7 @@ class BasicRemoteContent extends RemoteC
private $invalidateService = null;
/**
- * @var cachePostRequest
+ * @var boolean cachePostRequest
*/
private $cachePostRequest = false;
@@ -62,10 +62,19 @@ class BasicRemoteContent extends RemoteC
$this->invalidateService = new DefaultInvalidateService($this->cache);
}
+ /**
+ *
+ * @param RemoteContentFetcher $basicFetcher
+ */
public function setBasicFetcher(RemoteContentFetcher $basicFetcher) {
$this->basicFetcher = $basicFetcher;
}
+ /**
+ *
+ * @param RemoteContentRequest $request
+ * @return RemoteContentRequest
+ */
public function fetch(RemoteContentRequest $request) {
$ignoreCache = $request->getOptions()->ignoreCache;
if (! $ignoreCache && ($this->cachePostRequest || ! $request->isPost()) && ($cachedRequest = $this->cache->get($request->toHash())) !== false && $this->invalidateService->isValid($cachedRequest)) {
@@ -84,6 +93,11 @@ class BasicRemoteContent extends RemoteC
return $response;
}
+ /**
+ *
+ * @param array $requests
+ * @return array
+ */
public function multiFetch(Array $requests) {
$rets = array();
$requestsToProc = array();
@@ -140,10 +154,20 @@ class BasicRemoteContent extends RemoteC
return $rets;
}
+ /**
+ *
+ * @param RemoteContentRequest $request
+ */
public function invalidate(RemoteContentRequest $request) {
$this->cache->invalidate($request->toHash());
}
+ /**
+ *
+ * @param RemoteContentRequest $originalRequest
+ * @param RemoteContentRequest $request
+ * @param Cache $cache
+ */
private function setRequestCache(RemoteContentRequest $originalRequest, RemoteContentRequest $request, Cache $cache) {
if ($request->isStrictNoCache()) {
return;
@@ -184,6 +208,11 @@ class BasicRemoteContent extends RemoteC
}
}
+ /**
+ *
+ * @param RemoteContentRequest $request
+ * @return RemoteContentRequest
+ */
private function divertFetch(RemoteContentRequest $request) {
switch ($request->getAuthType()) {
case RemoteContentRequest::$AUTH_SIGNED:
@@ -205,7 +234,7 @@ class BasicRemoteContent extends RemoteC
* Returns the cached request, or false if there's no cached copy of this request, ignoreCache = true or if it's invalidated
*
* @param RemoteContentRequest $request
- * @return unknown
+ * @return mixed
*/
public function getCachedRequest(RemoteContentRequest $request) {
$ignoreCache = $request->getOptions()->ignoreCache;
Modified: shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php (original)
+++ shindig/trunk/php/src/common/sample/BasicRemoteContentFetcher.php Fri Jan 14 14:41:43 2011
@@ -50,7 +50,7 @@ class BasicRemoteContentFetcher extends
* in the $request objects
*
* @param Array of RemoteContentRequest's $requests
- * @return $requests
+ * @return array $requests
*/
public function multiFetchRequest(Array $requests) {
$mh = curl_multi_init();
Modified: shindig/trunk/php/src/common/sample/BasicSecurityToken.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicSecurityToken.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicSecurityToken.php (original)
+++ shindig/trunk/php/src/common/sample/BasicSecurityToken.php Fri Jan 14 14:41:43 2011
@@ -217,6 +217,9 @@ class BasicSecurityToken extends Securit
return $this->authenticationMode;
}
+ /**
+ * {@inheritDoc}
+ */
public function setAuthenticationMode($mode) {
$this->authenticationMode = $mode;
}
Modified: shindig/trunk/php/src/common/sample/BasicSecurityTokenDecoder.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/BasicSecurityTokenDecoder.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/BasicSecurityTokenDecoder.php (original)
+++ shindig/trunk/php/src/common/sample/BasicSecurityTokenDecoder.php Fri Jan 14 14:41:43 2011
@@ -54,9 +54,10 @@ class BasicSecurityTokenDecoder extends
}
/**
- * {@inheritDoc}
- *
* Parses the security token
+ *
+ * @param string $stringToken
+ * @return array
*/
private function parseToken($stringToken) {
$data = explode(":", $stringToken);
Modified: shindig/trunk/php/src/common/sample/CacheStorageApc.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/CacheStorageApc.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/CacheStorageApc.php (original)
+++ shindig/trunk/php/src/common/sample/CacheStorageApc.php Fri Jan 14 14:41:43 2011
@@ -21,24 +21,39 @@
class CacheStorageApc extends CacheStorage {
private $prefix = null;
+ /**
+ * {@inheritDoc}
+ */
public function __construct($name) {
$this->prefix = $name;
}
+ /**
+ * {@inheritDoc}
+ */
public function store($key, $value) {
if (($ret = @apc_fetch($key)) === false) {
return @apc_store($this->storageKey($key), $value);
}
}
+ /**
+ * {@inheritDoc}
+ */
public function fetch($key) {
return @apc_fetch($this->storageKey($key));
}
+ /**
+ * {@inheritDoc}
+ */
public function delete($key) {
return @apc_delete($this->storageKey($key));
}
+ /**
+ * {@inheritDoc}
+ */
public function isLocked($key) {
if ((@apc_fetch($this->storageKey($key) . '.lock')) === false) {
return false;
@@ -46,17 +61,26 @@ class CacheStorageApc extends CacheStora
return true;
}
+ /**
+ * {@inheritDoc}
+ */
public function lock($key) {
// the interesting thing is that this could fail if the lock was created in the meantime..
// but we'll ignore that out of convenience
@apc_add($this->storageKey($key) . '.lock', '', 5);
}
+ /**
+ * {@inheritDoc}
+ */
public function unlock($key) {
// suppress all warnings, if some other process removed it that's ok too
@apc_delete($this->storageKey($key) . '.lock');
}
+ /**
+ * {@inheritDoc}
+ */
private function storageKey($key) {
return $this->prefix . '_' . $key;
}
Modified: shindig/trunk/php/src/common/sample/CacheStorageFile.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/CacheStorageFile.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/CacheStorageFile.php (original)
+++ shindig/trunk/php/src/common/sample/CacheStorageFile.php Fri Jan 14 14:41:43 2011
@@ -21,10 +21,16 @@
class CacheStorageFile extends CacheStorage {
private $prefix = null;
+ /**
+ * {@inheritDoc}
+ */
public function __construct($name) {
$this->prefix = $name;
}
+ /**
+ * {@inheritDoc}
+ */
public function store($key, $value) {
$cacheDir = CacheStorageFile::getCacheDir($key);
$cacheFile = CacheStorageFile::getCacheFile($key);
@@ -37,6 +43,9 @@ class CacheStorageFile extends CacheStor
return file_put_contents($cacheFile, $value);
}
+ /**
+ * {@inheritDoc}
+ */
public function fetch($key) {
$cacheFile = CacheStorageFile::getCacheFile($key);
if (File::exists($cacheFile) && File::readable($cacheFile)) {
@@ -45,6 +54,9 @@ class CacheStorageFile extends CacheStor
return false;
}
+ /**
+ * {@inheritDoc}
+ */
public function delete($key) {
$cacheFile = CacheStorageFile::getCacheFile($key);
if (! @unlink($cacheFile)) {
@@ -52,12 +64,18 @@ class CacheStorageFile extends CacheStor
}
}
+ /**
+ * {@inheritDoc}
+ */
public function isLocked($key) {
// our lock file convention is simple: /the/file/path.lock
clearstatcache();
return file_exists($key . '.lock');
}
+ /**
+ * {@inheritDoc}
+ */
public function lock($key) {
$cacheDir = CacheStorageFile::getCacheDir($key);
$cacheFile = CacheStorageFile::getCacheFile($key);
@@ -72,12 +90,20 @@ class CacheStorageFile extends CacheStor
@touch($cacheFile . '.lock');
}
+ /**
+ * {@inheritDoc}
+ */
public function unlock($key) {
// suppress all warnings, if some other process removed it that's ok too
$cacheFile = CacheStorageFile::getCacheFile($key);
@unlink($cacheFile . '.lock');
}
+ /**
+ *
+ * @param string $key
+ * @return string
+ */
private function getCacheDir($key) {
// use the first 2 characters of the hash as a directory prefix
// this should prevent slowdowns due to huge directory listings
@@ -86,6 +112,11 @@ class CacheStorageFile extends CacheStor
substr($key, 0, 2);
}
+ /**
+ *
+ * @param string $key
+ * @return string
+ */
private function getCacheFile($key) {
return $this->getCacheDir($key) . '/' . $key;
}
Modified: shindig/trunk/php/src/common/sample/CacheStorageMemcache.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/common/sample/CacheStorageMemcache.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/common/sample/CacheStorageMemcache.php (original)
+++ shindig/trunk/php/src/common/sample/CacheStorageMemcache.php Fri Jan 14 14:41:43 2011
@@ -26,6 +26,9 @@ class CacheStorageMemcache extends Cache
private $prefix = null;
+ /**
+ * {@inheritDoc}
+ */
public function __construct($name) {
$this->prefix = $name;
if (!self::$memcache) {
@@ -44,6 +47,9 @@ class CacheStorageMemcache extends Cache
}
}
+ /**
+ * {@inheritDoc}
+ */
public function isLocked($key) {
if ((@self::$memcache->get($this->storageKey($key) . '.lock')) === false) {
return false;
@@ -51,31 +57,51 @@ class CacheStorageMemcache extends Cache
return true;
}
+ /**
+ * {@inheritDoc}
+ */
public function lock($key) {
// the interesting thing is that this could fail if the lock was created in the meantime..
// but we'll ignore that out of convenience
@self::$memcache->add($this->storageKey($key) . '.lock', '', 0, 2);
}
+ /**
+ * {@inheritDoc}
+ */
public function unlock($key) {
// suppress all warnings, if some other process removed it that's ok too
@self::$memcache->delete($this->storageKey($key) . '.lock');
}
+ /**
+ * {@inheritDoc}
+ */
public function store($key, $value) {
return self::$memcache->set($this->storageKey($key), $value, false, 0);
}
+ /**
+ * {@inheritDoc}
+ */
public function fetch($key) {
return self::$memcache->get($this->storageKey($key));
}
+ /**
+ * {@inheritDoc}
+ */
public function delete($key) {
if (!@self::$memcache->delete($this->storageKey($key))) {
throw new CacheException("Cache memcache could not be deleted");
}
}
+ /**
+ *
+ * @param string $key
+ * @return string
+ */
private function storageKey($key) {
return $this->prefix . '_' . $key;
}
Modified: shindig/trunk/php/src/gadgets/ContainerConfig.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/ContainerConfig.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/ContainerConfig.php (original)
+++ shindig/trunk/php/src/gadgets/ContainerConfig.php Fri Jan 14 14:41:43 2011
@@ -19,16 +19,35 @@
*/
class ContainerConfig {
+ /**
+ * @var string
+ */
public $default_container = 'default';
+
+ /**
+ * @var string
+ */
public $container_key = 'gadgets.container';
+
+ /**
+ * @var array
+ */
private $config = array();
+ /**
+ *
+ * @param string $defaultContainer
+ */
public function __construct($defaultContainer) {
if (! empty($defaultContainer)) {
$this->loadContainers($defaultContainer);
}
}
+ /**
+ *
+ * @param array $containers
+ */
private function loadContainers($containers) {
if (! File::exists($containers)) {
throw new Exception("Invalid container path");
@@ -46,6 +65,10 @@ class ContainerConfig {
}
}
+ /**
+ *
+ * @param string $file
+ */
private function loadFromFile($file) {
$contents = file_get_contents($file);
$contents = $this->removeComments($contents);
@@ -63,6 +86,10 @@ class ContainerConfig {
}
}
+ /**
+ * @param string $str
+ * @return string
+ */
public function removeComments($str) {
// remove /* */ style comments
$str = preg_replace('@/\\*.*?\\*/@s', '', $str);
@@ -72,6 +99,12 @@ class ContainerConfig {
return $str;
}
+ /**
+ *
+ * @param string $container
+ * @param string $name
+ * @return array
+ */
public function getConfig($container, $name) {
$config = array();
if (isset($this->config[$container]) && isset($this->config[$container][$name])) {
@@ -83,11 +116,15 @@ class ContainerConfig {
return $config;
}
- // Code sniplet borrowed from: http://nl.php.net/manual/en/function.array-merge-recursive.php#81409
- // default array merge recursive doesn't overwrite values, but creates multiple elementents for that key,
- // which is not what we want here, we want array_merge like behavior
+ /**
+ * Code sniplet borrowed from: http://nl.php.net/manual/en/function.array-merge-recursive.php#81409
+ * default array merge recursive doesn't overwrite values, but creates multiple elementents for that key,
+ * which is not what we want here, we want array_merge like behavior
+ *
+ * @return array
+ */
private function mergeConfig() // $array1, $array2, etc
-{
+ {
$arrays = func_get_args();
$narrays = count($arrays);
for ($i = 0; $i < $narrays; $i ++) {
Modified: shindig/trunk/php/src/gadgets/Gadget.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/Gadget.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/Gadget.php (original)
+++ shindig/trunk/php/src/gadgets/Gadget.php Fri Jan 14 14:41:43 2011
@@ -27,6 +27,10 @@ class Gadget {
public $gadgetSpec;
public $features;
+
+ /*
+ * @var Substitutions
+ */
public $substitutions;
public $rightToLeft;
@@ -35,11 +39,23 @@ class Gadget {
*/
public $gadgetContext;
+ /**
+ *
+ * @param GadgetSpec $gadgetSpec
+ * @param GadgetContext $gadgetContext
+ */
public function __construct(GadgetSpec $gadgetSpec, GadgetContext $gadgetContext) {
$this->gadgetSpec = $gadgetSpec;
$this->gadgetContext = $gadgetContext;
}
+ /**
+ * returns all information about the given viewName
+ *
+ * @param string $viewName
+ * @throws GadgetException
+ * @return array
+ */
public function getView($viewName) {
if (isset($this->gadgetSpec->views[$viewName])) {
return $this->gadgetSpec->views[$viewName];
Modified: shindig/trunk/php/src/gadgets/GadgetBlacklist.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetBlacklist.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetBlacklist.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetBlacklist.php Fri Jan 14 14:41:43 2011
@@ -20,5 +20,9 @@
interface GadgetBlacklist {
+ /**
+ * @param string $url
+ * @return boolean
+ */
function isBlacklisted($url);
}
Modified: shindig/trunk/php/src/gadgets/GadgetContext.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetContext.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetContext.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetContext.php Fri Jan 14 14:41:43 2011
@@ -25,21 +25,81 @@
*/
class GadgetContext {
const DEFAULT_VIEW = 'profile';
+ /**
+ *
+ * @var RemoteContentFetcher
+ */
protected $httpFetcher = null;
+ /**
+ *
+ * @var array
+ */
protected $locale = null;
+ /**
+ *
+ * @var string
+ */
protected $renderingContext = null;
+ /**
+ *
+ * @var GadgetFeatureRegistry
+ */
protected $registry = null;
+ /**
+ *
+ * @var string
+ */
protected $view = null;
+ /**
+ *
+ * @var string
+ */
protected $moduleId = null;
+ /**
+ *
+ * @var string
+ */
protected $url = null;
+ /**
+ *
+ * @var array
+ */
protected $cache = null;
+ /**
+ *
+ * @var GadgetBlacklist
+ */
protected $blacklist = null;
+ /**
+ *
+ * @var boolean
+ */
protected $ignoreCache = null;
+ /**
+ *
+ * @var string
+ */
protected $forcedJsLibs = null;
+ /**
+ *
+ * @var array
+ */
protected $containerConfig = null;
+ /**
+ *
+ * @var string
+ */
protected $container = null;
+ /**
+ *
+ * @var int
+ */
protected $refreshInterval;
+ /**
+ *
+ * @param string $renderingContext
+ */
public function __construct($renderingContext) {
// Rendering context is set by the calling event handler (either GADGET or CONTAINER)
$this->setRenderingContext($renderingContext);
@@ -55,10 +115,18 @@ class GadgetContext {
//NOTE All classes are initialized when called (aka lazy loading) because we don't need all of them in every situation
}
+ /**
+ *
+ * @return int
+ */
protected function getRefreshIntervalParam() {
return isset($_GET['refresh']) ? $_GET['refresh'] : Config::get('default_refresh_interval');
}
+ /**
+ *
+ * @return string
+ */
protected function getContainerParam() {
$container = 'default';
if (! empty($_GET['container'])) {
@@ -74,15 +142,27 @@ class GadgetContext {
return $container;
}
+ /**
+ *
+ * @return boolean
+ */
protected function getIgnoreCacheParam() {
// Support both the old Orkut style &bpc and new standard style &nocache= params
return (isset($_GET['nocache']) && intval($_GET['nocache']) == 1) || (isset($_GET['bpc']) && intval($_GET['bpc']) == 1);
}
+ /**
+ *
+ * @return string
+ */
protected function getForcedJsLibsParam() {
return isset($_GET['libs']) ? trim($_GET['libs']) : null;
}
+ /**
+ *
+ * @return string
+ */
protected function getUrlParam() {
if (! empty($_GET['url'])) {
return $_GET['url'];
@@ -92,14 +172,26 @@ class GadgetContext {
return null;
}
+ /**
+ *
+ * @return int
+ */
protected function getModuleIdParam() {
return isset($_GET['mid']) && is_numeric($_GET['mid']) ? intval($_GET['mid']) : 0;
}
+ /**
+ *
+ * @return string
+ */
protected function getViewParam() {
return ! empty($_GET['view']) ? $_GET['view'] : self::DEFAULT_VIEW;
}
+ /**
+ *
+ * @return GadgetBlacklist
+ */
protected function instanceBlacklist() {
$blackListClass = Config::get('blacklist_class');
if (! empty($blackListClass)) {
@@ -109,11 +201,19 @@ class GadgetContext {
}
}
+ /**
+ *
+ * @return RemoteContentFetcher
+ */
protected function instanceHttpFetcher() {
$remoteContent = Config::get('remote_content');
return new $remoteContent();
}
+ /**
+ *
+ * @return GadgetFeatureRegistry
+ */
protected function instanceRegistry() {
// feature parsing is very resource intensive so by caching the result this saves upto 30% of the processing time
$featureCache = Cache::createCache(Config::get('feature_cache'), 'FeatureCache');
@@ -125,6 +225,10 @@ class GadgetContext {
return $registry;
}
+ /**
+ *
+ * @return array
+ */
protected 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');
@@ -132,15 +236,27 @@ class GadgetContext {
return array('lang' => strtolower($language), 'country' => strtoupper($country));
}
+ /**
+ *
+ * @return ContainerConfig
+ */
protected function instanceContainerConfig() {
$containerConfigClass = Config::get('container_config_class');
return new $containerConfigClass(Config::get('container_path'));
}
+ /**
+ *
+ * @return string
+ */
public function getContainer() {
return $this->container;
}
+ /**
+ *
+ * @return ContainerConfig
+ */
public function getContainerConfig() {
if ($this->containerConfig == null) {
$this->containerConfig = $this->instanceContainerConfig();
@@ -148,10 +264,18 @@ class GadgetContext {
return $this->containerConfig;
}
+ /**
+ *
+ * @return int
+ */
public function getModuleId() {
return $this->moduleId;
}
+ /**
+ *
+ * @return GadgetFeatureRegistry
+ */
public function getRegistry() {
if ($this->registry == null) {
$this->setRegistry($this->instanceRegistry());
@@ -159,82 +283,162 @@ class GadgetContext {
return $this->registry;
}
+ /**
+ *
+ * @return string
+ */
public function getUrl() {
return $this->url;
}
+ /**
+ *
+ * @return string
+ */
public function getView() {
return $this->view;
}
+ /**
+ *
+ * @param int $interval
+ */
public function setRefreshInterval($interval) {
$this->refreshInterval = $interval;
}
+ /**
+ *
+ * @param string $container
+ */
public function setContainer($container) {
$this->container = $container;
}
+ /**
+ *
+ * @param array $containerConfig
+ */
public function setContainerConfig($containerConfig) {
$this->containerConfig = $containerConfig;
}
+ /**
+ *
+ * @param GadgetBlacklist $blacklist
+ */
public function setBlacklist($blacklist) {
$this->blacklist = $blacklist;
}
+ /**
+ *
+ * @param array $cache
+ */
public function setCache($cache) {
$this->cache = $cache;
}
+ /**
+ *
+ * @param RemoteContentFetcher $httpFetcher
+ */
public function setHttpFetcher($httpFetcher) {
$this->httpFetcher = $httpFetcher;
}
+ /**
+ *
+ * @param array $locale
+ */
public function setLocale($locale) {
$this->locale = $locale;
}
+ /**
+ *
+ * @param int $moduleId
+ */
public function setModuleId($moduleId) {
$this->moduleId = $moduleId;
}
+ /**
+ *
+ * @param GadgetFeatureRegistry $registry
+ */
public function setRegistry($registry) {
$this->registry = $registry;
}
+ /**
+ *
+ * @param string $renderingContext
+ */
public function setRenderingContext($renderingContext) {
$this->renderingContext = $renderingContext;
}
+ /**
+ *
+ * @param string $url
+ */
public function setUrl($url) {
$this->url = $url;
}
+ /**
+ *
+ * @param string $view
+ */
public function setView($view) {
$this->view = $view;
}
+ /**
+ *
+ * @param boolean $ignoreCache
+ */
public function setIgnoreCache($ignoreCache) {
$this->ignoreCache = $ignoreCache;
}
+ /**
+ *
+ * @param string $forcedJsLibs
+ */
public function setForcedJsLibs($forcedJsLibs) {
$this->forcedJsLibs = $forcedJsLibs;
}
+ /**
+ *
+ * @return int
+ */
public function getRefreshInterval() {
return $this->refreshInterval;
}
+ /**
+ *
+ * @return boolean
+ */
public function getIgnoreCache() {
return $this->ignoreCache;
}
+ /**
+ *
+ * @return string
+ */
public function getForcedJsLibs() {
return $this->forcedJsLibs;
}
+ /**
+ *
+ * @return GadgetBlacklist
+ */
public function getBlacklist() {
if ($this->blacklist == null) {
$this->setBlacklist($this->instanceBlacklist());
@@ -242,10 +446,18 @@ class GadgetContext {
return $this->blacklist;
}
+ /**
+ *
+ * @return string
+ */
public function getRenderingContext() {
return $this->renderingContext;
}
+ /**
+ *
+ * @return RemoteContentFetcher
+ */
public function getHttpFetcher() {
if ($this->httpFetcher == null) {
$this->setHttpFetcher($this->instanceHttpFetcher());
@@ -253,6 +465,10 @@ class GadgetContext {
return $this->httpFetcher;
}
+ /**
+ *
+ * @return array
+ */
public function getLocale() {
if ($this->locale == null) {
$this->setLocale($this->instanceLocale());
Modified: shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php Fri Jan 14 14:41:43 2011
@@ -26,10 +26,25 @@ require_once 'external/jsmin-php/jsmin.p
*
*/
class GadgetFeatureRegistry {
+ /**
+ * @var array
+ */
public $features = array();
+
+ /**
+ * @var array
+ */
private $coreFeatures;
+
+ /**
+ * @var array
+ */
private $sortedFeatures;
-
+
+ /**
+ *
+ * @param miexed $featurePath
+ */
public function __construct($featurePath) {
if (is_array($featurePath)) {
foreach ($featurePath as $path) {
@@ -41,6 +56,13 @@ class GadgetFeatureRegistry {
$this->processFeatures();
}
+ /**
+ *
+ * @param array $features
+ * @param GadgetContext $context
+ * @param boolean $isGadgetContext
+ * @return string
+ */
public function getFeaturesContent($features, GadgetContext $context, $isGadgetContext) {
$ret = '';
foreach ($features as $feature) {
@@ -48,7 +70,14 @@ class GadgetFeatureRegistry {
}
return $ret;
}
-
+
+ /**
+ *
+ * @param string $feature
+ * @param GadgetContext $context
+ * @param boolean $isGadgetContext
+ * @return string
+ */
public function getFeatureContent($feature, GadgetContext $context, $isGadgetContext) {
if (empty($feature)) return '';
if (!isset($this->features[$feature])) {
@@ -94,6 +123,13 @@ class GadgetFeatureRegistry {
return $ret;
}
+ /**
+ *
+ * @param array $needed
+ * @param array $resultsFound
+ * @param array $resultsMissing
+ * @return boolean
+ */
public function resolveFeatures($needed, &$resultsFound, &$resultsMissing) {
$resultsFound = array();
$resultsMissing = array();
@@ -110,7 +146,12 @@ class GadgetFeatureRegistry {
}
return count($resultsMissing) == 0;
}
-
+
+ /**
+ *
+ * @param array $features
+ * @param array $sortedFeatures
+ */
public function sortFeatures($features, &$sortedFeatures) {
if (empty($features)) {
return;
@@ -122,7 +163,12 @@ class GadgetFeatureRegistry {
}
}
}
-
+
+ /**
+ *
+ * @param array $results
+ * @param array $feature
+ */
private function addFeatureToResults(&$results, $feature) {
if (in_array($feature['name'], $results)) {
return;
@@ -218,8 +264,8 @@ class GadgetFeatureRegistry {
/**
* Loads the feature's xml content
*
- * @param unknown_type $file
- * @return unknown
+ * @param string $file
+ * @return array
*/
private function processFile($file) {
$feature = null;
@@ -236,7 +282,7 @@ class GadgetFeatureRegistry {
*
* @param string $content
* @param string $path
- * @return feature array
+ * @return array
*/
private function parse($content, $path) {
$doc = simplexml_load_string($content);
@@ -314,6 +360,12 @@ class GadgetFeatureRegistry {
}
}
+ /**
+ *
+ * @param string $feature1
+ * @param string $feature2
+ * @return boolean
+ */
private function sortFeaturesFiles($feature1, $feature2) {
$feature1 = basename(str_replace('/feature.xml', '', $feature1));
$feature2 = basename(str_replace('/feature.xml', '', $feature2));
Modified: shindig/trunk/php/src/gadgets/GadgetSpec.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetSpec.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetSpec.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetSpec.php Fri Jan 14 14:41:43 2011
@@ -27,44 +27,151 @@ class GadgetSpec {
public $checksum;
// Basic and extended ModulePrefs attributes
+ /**
+ * @var string
+ */
public $title;
+ /**
+ * @var string
+ */
public $author;
+ /**
+ * @var string
+ */
public $authorEmail;
+ /**
+ * @var string
+ */
public $description;
+ /**
+ * @var string
+ */
public $directoryTitle;
+ /**
+ * @var string
+ */
public $screenshot;
+ /**
+ * @var string
+ */
public $thumbnail;
+ /**
+ * @var string
+ */
public $titleUrl;
+ /**
+ * @var string
+ */
public $authorAffiliation;
+ /**
+ * @var string
+ */
public $authorLocation;
+ /**
+ * @var string
+ */
public $authorPhoto;
+ /**
+ * @var string
+ */
public $authorAboutme;
+ /**
+ * @var string
+ */
public $authorQuote;
+ /**
+ * @var string
+ */
public $authorLink;
+ /**
+ * @var string
+ */
public $showStats;
+ /**
+ * @var string
+ */
public $showInDirectory;
+ /**
+ * @var string
+ */
public $string;
+ /**
+ * @var string
+ */
public $width;
+ /**
+ * @var string
+ */
public $height;
+ /**
+ * @var string
+ */
public $category;
+ /**
+ * @var string
+ */
public $category2;
+ /**
+ * @var string
+ */
public $singleton;
+ /**
+ * @var string
+ */
public $renderInline;
+ /**
+ * @var string
+ */
public $scaling;
+ /**
+ * @var string
+ */
public $scrolling;
-
+ /**
+ * @var string
+ */
public $preloads;
+ /**
+ * @var string
+ */
public $locales;
+ /**
+ * @var string
+ */
public $icon;
+ /**
+ * @var string
+ */
public $optionalFeatures;
+ /**
+ * @var string
+ */
public $requiredFeatures;
-
+ /**
+ * @var string
+ */
public $links;
+ /**
+ * @var string
+ */
public $userPrefs;
+ /**
+ * @var string
+ */
public $rewrite = null;
+ /**
+ * @var string
+ */
public $oauth = null;
// used to track os-templating
+
+ /**
+ * @var boolean
+ */
public $templatesRequireLibraries = false;
+ /**
+ * @var boolean
+ */
public $templatesDisableAutoProcessing = false;
}
Modified: shindig/trunk/php/src/gadgets/GadgetSpecParser.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/GadgetSpecParser.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/GadgetSpecParser.php (original)
+++ shindig/trunk/php/src/gadgets/GadgetSpecParser.php Fri Jan 14 14:41:43 2011
@@ -26,12 +26,18 @@ class GadgetSpecException extends Except
*/
class GadgetSpecParser {
+ /**
+ *
+ * @var GadgetContext
+ */
protected $context;
/**
* Parses the $xmlContent into a Gadget class
*
* @param string $xmlContent
+ * @param GadgetContext $context
+ * @return GadgetSpec
*/
public function parse($xmlContent, GadgetContext $context = null) {
$this->context = $context;
@@ -161,6 +167,7 @@ class GadgetSpecParser {
* This function also parses the ModulePref's child elements (Icon, Features, Preload and Locale)
*
* @param DOMDocument $doc
+ * @param GadgetSpec $gadget
*/
private function parseModulePrefs(DOMDocument &$doc, GadgetSpec &$gadget) {
$modulePrefs = $doc->getElementsByTagName("ModulePrefs");
@@ -200,7 +207,7 @@ class GadgetSpecParser {
* override if needed
*
* @param DOMElement $modulePrefs
- * @param Gadget $gadget
+ * @param GadgetSpec $gadget
*/
protected function parseContainerSpecific(DOMElement &$modulePrefs, GadgetSpec &$gadget) {
@@ -210,7 +217,7 @@ class GadgetSpecParser {
* Parses the (optional) Icon element, returns a Icon class or null
*
* @param DOMElement $modulePrefs
- * @param Gadget $gadget
+ * @param GadgetSpec $gadget
*/
private function parseIcon(DOMElement &$modulePrefs, GadgetSpec &$gadget) {
if (($iconNodes = $modulePrefs->getElementsByTagName('Icon')) != null) {
@@ -227,7 +234,7 @@ class GadgetSpecParser {
* Parses the Required and Optional feature entries in the ModulePrefs
*
* @param DOMElement $modulePrefs
- * @param Gadget $gadget
+ * @param GadgetSpec $gadget
*/
private function parseFeatures(DOMElement &$modulePrefs, GadgetSpec &$gadget) {
$gadget->requiredFeatures = $gadget->optionalFeatures = array();
@@ -382,7 +389,7 @@ class GadgetSpecParser {
* Parses the preload elements
*
* @param DOMElement $modulePrefs
- * @param Gadget $gadget
+ * @param GadgetSpec $gadget
*/
private function parsePreloads(DOMElement &$modulePrefs, GadgetSpec &$gadget) {
$gadget->preloads = array();
@@ -400,7 +407,7 @@ class GadgetSpecParser {
* Parses the Locale (message bundle) entries
*
* @param DOMElement $modulePrefs
- * @param Gadget $gadget
+ * @param GadgetSpec $gadget
*/
private function parseLocales(DOMElement &$modulePrefs, GadgetSpec &$gadget) {
$gadget->locales = array();
Modified: shindig/trunk/php/src/gadgets/MakeRequest.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/MakeRequest.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/MakeRequest.php (original)
+++ shindig/trunk/php/src/gadgets/MakeRequest.php Fri Jan 14 14:41:43 2011
@@ -53,7 +53,10 @@ class MakeRequest {
"SET-COOKIE", "CONTENT-LENGTH", "CONTENT-ENCODING", "ETAG", "LAST-MODIFIED",
"ACCEPT-RANGES", "VARY", "EXPIRES", "DATE", "PRAGMA", "CACHE-CONTROL",
"TRANSFER-ENCODING", "WWW-AUTHENTICATE");
-
+
+ /**
+ * @var RemoteContentFetcher
+ */
private $remoteFetcher;
/**
@@ -246,6 +249,10 @@ class MakeRequest {
/**
* Handles (RSS & Atom) Type.FEED parsing using Zend's feed parser
*
+ * @param RemoteContentRequest $result
+ * @param string $url
+ * @param int $numEntries
+ * @param boolean $getSummaries
* @return response string, either a json encoded feed structure or an error message
*/
private function parseFeed($result, $url, $numEntries = 3, $getSummaries = false) {
Modified: shindig/trunk/php/src/gadgets/MetadataContext.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/MetadataContext.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/MetadataContext.php (original)
+++ shindig/trunk/php/src/gadgets/MetadataContext.php Fri Jan 14 14:41:43 2011
@@ -20,6 +20,11 @@
class MetadataGadgetContext extends GadgetContext {
+ /**
+ *
+ * @param object $jsonContext
+ * @param string $url
+ */
public function __construct($jsonContext, $url) {
parent::__construct('GADGET');
$this->url = $url;
@@ -28,6 +33,9 @@ class MetadataGadgetContext extends Gadg
$this->container = $jsonContext->container;
}
+ /**
+ * @return array
+ */
public function getView() {
return $this->view;
}
Modified: shindig/trunk/php/src/gadgets/MetadataHandler.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/MetadataHandler.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/MetadataHandler.php (original)
+++ shindig/trunk/php/src/gadgets/MetadataHandler.php Fri Jan 14 14:41:43 2011
@@ -20,6 +20,11 @@
class MetadataHandler {
+ /**
+ *
+ * @param object $requests
+ * @return array
+ */
public function process($requests) {
$response = array();
foreach ($requests->gadgets as $gadget) {
@@ -40,6 +45,10 @@ class MetadataHandler {
return $response;
}
+ /**
+ *
+ * @return SecurityToken
+ */
private function getSecurityToken() {
$token = BasicSecurityToken::getTokenStringFromRequest();
if (empty($token)) {
@@ -59,6 +68,12 @@ class MetadataHandler {
return $gadgetSigner->createToken($token);
}
+ /**
+ *
+ * @param Gadget $gadget
+ * @param GadgetContext $context
+ * @return array
+ */
private function getIframeURL(Gadget $gadget, GadgetContext $context) {
$v = $gadget->getChecksum();
$view = $gadget->getView($context->getView());
Modified: shindig/trunk/php/src/gadgets/ProxyBase.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/ProxyBase.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/ProxyBase.php (original)
+++ shindig/trunk/php/src/gadgets/ProxyBase.php Fri Jan 14 14:41:43 2011
@@ -29,7 +29,18 @@ class ProxyBase {
*/
public $context;
- public function __construct($context, MakeRequest $makeRequest = null) {
+ /**
+ *
+ * @var MakeRequest
+ */
+ protected $makeRequest;
+
+ /**
+ *
+ * @param GadgetContext $context
+ * @param MakeRequest $makeRequest
+ */
+ public function __construct(GadgetContext $context, MakeRequest $makeRequest = null) {
$this->context = $context;
if (isset($makeRequest)) {
$this->makeRequest = $makeRequest;
@@ -42,6 +53,8 @@ class ProxyBase {
/**
* Sets the caching (Cache-Control & Expires) with a cache age of $lastModified
* or if $lastModified === false, sets Pragma: no-cache & Cache-Control: no-cache
+ *
+ * @param boolean $lastModified
*/
protected function setCachingHeaders($lastModified = false) {
$maxAge = $this->context->getIgnoreCache() ? false : $this->context->getRefreshInterval();
@@ -66,7 +79,7 @@ class ProxyBase {
* Returns the request headers, using the apache_request_headers function if it's
* available, and otherwise tries to guess them from the $_SERVER superglobal
*
- * @return unknown
+ * @return array
*/
protected function request_headers() {
// Try to use apache's request headers if available
Modified: shindig/trunk/php/src/gadgets/ProxyHandler.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/ProxyHandler.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/ProxyHandler.php (original)
+++ shindig/trunk/php/src/gadgets/ProxyHandler.php Fri Jan 14 14:41:43 2011
@@ -91,6 +91,11 @@ class ProxyHandler extends ProxyBase {
}
}
+ /**
+ *
+ * @param string $gadgetUrl
+ * @param RemoteContentRequest $result
+ */
private function rewriteContent($gadgetUrl, RemoteContentRequest &$result) {
try {
// At the moment we're only able to rewrite CSS files, so check the content type and/or the file extension before rewriting
@@ -120,6 +125,7 @@ class ProxyHandler extends ProxyBase {
* Uses the GadgetFactory to instrance the specified gadget
*
* @param string $gadgetUrl
+ * @return Gadget
*/
private function createGadget($gadgetUrl) {
// Only include these files if appropiate, else it would slow down the entire proxy way to much
Modified: shindig/trunk/php/src/gadgets/SigningFetcher.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/SigningFetcher.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/SigningFetcher.php (original)
+++ shindig/trunk/php/src/gadgets/SigningFetcher.php Fri Jan 14 14:41:43 2011
@@ -42,11 +42,15 @@ class SigningFetcher extends RemoteConte
* Private key we pass to the OAuth RSA_SHA1 algorithm.This can be a
* PrivateKey object, or a PEM formatted private key, or a DER encoded byte
* array for the private key.(No, really, they accept any of them.)
+ *
+ * @var resource
*/
protected $privateKeyObject;
/**
* The name of the key, included in the fetch to help with key rotation.
+ *
+ * @var string
*/
protected $keyName;
@@ -60,8 +64,8 @@ class SigningFetcher extends RemoteConte
* from the openssl_pkey_get_private method.
*
* @param RemoteContentFetcher $fetcher
- * @param keyName name of the key to include in the request
- * @param privateKey A key resource identifier, as returned from
+ * @param string $keyName name of the key to include in the request
+ * @param resource $privateKey A key resource identifier, as returned from
* openssl_pkey_get_private
* @return SigningFetcher
*/
@@ -69,17 +73,33 @@ class SigningFetcher extends RemoteConte
return new SigningFetcher($fetcher, $keyName, $privateKey);
}
+ /**
+ *
+ * @param RemoteContentFetcher $fetcher
+ * @param string $keyName
+ * @param resource $privateKeyObject
+ */
protected function __construct(RemoteContentFetcher $fetcher, $keyName, $privateKeyObject) {
$this->fetcher = $fetcher;
$this->keyName = $keyName;
$this->privateKeyObject = $privateKeyObject;
}
+ /**
+ *
+ * @param RemoteContentRequest $request
+ * @return RemoteContentRequest
+ */
public function fetchRequest(RemoteContentRequest $request) {
$this->signRequest($request);
return $this->fetcher->fetchRequest($request);
}
+ /**
+ *
+ * @param array $requests
+ * @return array
+ */
public function multiFetchRequest(Array $requests) {
foreach ($requests as $request) {
$this->signRequest($request);
@@ -87,6 +107,10 @@ class SigningFetcher extends RemoteConte
return $this->fetcher->multiFetchRequest($requests);
}
+ /**
+ *
+ * @param RemoteContentRequest $request
+ */
private function signRequest(RemoteContentRequest $request) {
$url = $request->getUrl();
$method = $request->getMethod();
@@ -163,6 +187,13 @@ class SigningFetcher extends RemoteConte
}
}
+ /**
+ *
+ * @param array $msgParams
+ * @param SecurityToken $token
+ * @param boolean $signOwner
+ * @param boolean $signViewer
+ */
private function addOpenSocialParams(&$msgParams, SecurityToken $token, $signOwner, $signViewer) {
if ($signOwner) {
$owner = $token->getOwnerId();
@@ -192,6 +223,11 @@ class SigningFetcher extends RemoteConte
}
}
+ /**
+ *
+ * @param array $msgParams
+ * @param SecurityToken $token
+ */
private function addOAuthParams(&$msgParams, SecurityToken $token) {
$msgParams[ShindigOAuth::$OAUTH_TOKEN] = '';
$domain = $token->getDomain();
@@ -211,6 +247,9 @@ class SigningFetcher extends RemoteConte
/**
* Strip out any owner or viewer id passed by the client.
+ *
+ * @param array $params
+ * @return array
*/
private function sanitize($params) {
$list = array();
@@ -222,6 +261,11 @@ class SigningFetcher extends RemoteConte
return $list;
}
+ /**
+ *
+ * @param string $paramName
+ * @return booelan
+ */
private function allowParam($paramName) {
$canonParamName = strtolower($paramName);
// Exclude the fields which are only used to tell the proxy what to do
Modified: shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/BasicGadgetOAuthTokenStore.php Fri Jan 14 14:41:43 2011
@@ -26,11 +26,19 @@ class BasicGadgetOAuthTokenStore extends
private $CONSUMER_KEY_KEY = "consumer_key";
private $KEY_TYPE_KEY = "key_type";
- public function __construct($store, $fetcher) {
- parent::__construct($store, $fetcher);
+ /**
+ *
+ * @param OAuthStore $store
+ * @param BasicGadgetSpecFactory $specFadtory
+ */
+ public function __construct($store, $specFadtory) {
+ parent::__construct($store, $specFadtory);
$this->OAUTH_CONFIG = Config::get('container_path') . $this->OAUTH_CONFIG;
}
+ /**
+ * @param SigningFetcher $fetcher
+ */
public function initFromConfigFile($fetcher) {
// Read our consumer keys and secrets from config/oauth.js
// This actually involves fetching gadget specs
@@ -51,6 +59,11 @@ class BasicGadgetOAuthTokenStore extends
}
}
+ /**
+ *
+ * @param string $gadgetUri
+ * @param array $oauthConfig
+ */
protected function storeConsumerInfos($gadgetUri, $oauthConfig) {
foreach ($oauthConfig as $key => $value) {
$serviceName = $key;
@@ -59,6 +72,12 @@ class BasicGadgetOAuthTokenStore extends
}
}
+ /**
+ *
+ * @param string $gadgetUri
+ * @param string $serviceName
+ * @param array $consumerInfo
+ */
protected function storeConsumerInfo($gadgetUri, $serviceName, $consumerInfo) {
if (! isset($consumerInfo[$this->CONSUMER_SECRET_KEY]) || ! isset($consumerInfo[$this->CONSUMER_KEY_KEY]) || ! isset($consumerInfo[$this->KEY_TYPE_KEY])) {
throw new Exception("Invalid configuration in oauth.json");
Modified: shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/BasicOAuthStore.php Fri Jan 14 14:41:43 2011
@@ -20,22 +20,56 @@
class BasicOAuthStore implements OAuthStore {
+ /**
+ *
+ * @var array
+ */
private $consumerInfos = array();
+
+ /**
+ *
+ * @var array
+ */
private $tokens = array();
+ /**
+ *
+ * @var string
+ */
private $defaultConsumerKey;
+
+ /**
+ *
+ * @var string
+ */
private $defaultConsumerSecret;
+ /**
+ *
+ * @param string $consumerKey
+ * @param string $privateKey
+ */
public function __construct($consumerKey = null, $privateKey = null) {
$this->defaultConsumerKey = $consumerKey;
$this->defaultConsumerSecret = $privateKey;
}
+ /**
+ *
+ * @param array $consumerInfos
+ * @param array $tokens
+ */
public function setHashMapsForTesting($consumerInfos, $tokens) {
$this->consumerInfos = $consumerInfos;
$this->tokens = $tokens;
}
+ /**
+ *
+ * @param TokenKey $tokenKey
+ * @param ProviderInfo $provInfo
+ * @return AccesorInfo
+ */
public function getOAuthAccessorTokenKey(TokenKey $tokenKey, ProviderInfo $provInfo) {
$provKey = new ProviderKey();
$provKey->setGadgetUri($tokenKey->getGadgetUri());
@@ -52,6 +86,12 @@ class BasicOAuthStore implements OAuthSt
return $result;
}
+ /**
+ *
+ * @param ProviderKey $providerKey
+ * @param ProviderInfo $provInfo
+ * @return AccesorInfo
+ */
public function getOAuthAccessorProviderKey(ProviderKey $providerKey, ProviderInfo $provInfo) {
if ($provInfo == null) {
throw new ShindigOAuthNoDataException("must pass non-null provider info to getOAuthAccessor");
@@ -95,19 +135,38 @@ class BasicOAuthStore implements OAuthSt
return $result;
}
+ /**
+ *
+ * @param ProviderKey $providerKey
+ * @param ConsumerKeyAndSecret $keyAndSecret
+ */
public function setOAuthConsumerKeyAndSecret($providerKey, $keyAndSecret) {
$key = md5(serialize($providerKey));
$this->consumerInfos[$key] = $keyAndSecret;
}
+ /**
+ *
+ * @param TokenKey $tokenKey
+ * @param TokenInfo $tokenInfo
+ */
public function setTokenAndSecret($tokenKey, $tokenInfo) {
$this->tokens[md5(serialize($tokenKey))] = $tokenInfo;
}
+ /**
+ *
+ * @param TokenKey $tokenKey
+ */
public function removeTokenAndSecret($tokenKey) {
unset($this->tokens[md5(serialize($tokenKey))]);
}
+ /**
+ *
+ * @param TokenKey $tokenKey
+ * @return TokenInfo
+ */
protected function getTokenInfo($tokenKey) {
$key = md5(serialize($tokenKey));
return isset($this->tokens[$key]) ? $this->tokens[$key] : null;
Modified: shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/GadgetOAuthTokenStore.php Fri Jan 14 14:41:43 2011
@@ -51,8 +51,9 @@ class GadgetOAuthTokenStore {
/**
* Public constructor.
*
- * @param store an {@link OAuthStore} that can store and retrieve OAuth
+ * @param OAuthStore $store an {@link OAuthStore} that can store and retrieve OAuth
* tokens, as well as information about service providers.
+ * @param BasicGadgetSpecFactory $specFactory
*/
public function __construct($store, $specFactory) {
$this->specFactory = $specFactory;
@@ -65,9 +66,10 @@ class GadgetOAuthTokenStore {
* or it can be a PKCS8-then-Base64 encoded private key that we'll be using
* with this service provider.
*
- * @param gadgetUrl the URL of the gadget
- * @param serviceName the service provider with whom we have negotiated a
+ * @param string $gadgetUrl the URL of the gadget
+ * @param string $serviceName the service provider with whom we have negotiated a
* consumer key and secret.
+ * @param ConsumerKeyAndSecret $keyAndSecret
*/
public function storeConsumerKeyAndSecret($gadgetUrl, $serviceName, $keyAndSecret) {
$providerKey = new ProviderKey();
@@ -78,8 +80,8 @@ class GadgetOAuthTokenStore {
/**
* Stores an access token in the OAuth Data Store.
- * @param tokenKey information about the Gadget storing the token.
- * @param tokenInfo the TokenInfo to be stored in the OAuth data store.
+ * @param TokenKey $tokenKey information about the Gadget storing the token.
+ * @param TokenInfo $tokenInfo the TokenInfo to be stored in the OAuth data store.
*/
public function storeTokenKeyAndSecret($tokenKey, $tokenInfo) {
$getGadgetUri = $tokenKey->getGadgetUri();
@@ -93,6 +95,10 @@ class GadgetOAuthTokenStore {
$this->store->setTokenAndSecret($tokenKey, $tokenInfo);
}
+ /**
+ *
+ * @param TokenKey $tokenKey
+ */
public function removeTokenAndSecret(TokenKey $tokenKey) {
$this->store->removeTokenAndSecret($tokenKey);
}
@@ -100,9 +106,9 @@ class GadgetOAuthTokenStore {
/**
* Retrieve an OAuthAccessor that is ready to sign OAuthMessages.
*
- * @param tokenKey information about the gadget retrieving the accessor.
+ * @param TokenKey $tokenKey information about the gadget retrieving the accessor.
*
- * @return an OAuthAccessorInfo containing an OAuthAccessor (whic can be
+ * @return OAuthAccessorInfo containing an OAuthAccessor (whic can be
* passed to an OAuthMessage.sign method), as well as httpMethod and
* signatureType fields.
*/
@@ -122,8 +128,9 @@ class GadgetOAuthTokenStore {
/**
* Reads OAuth provider information out of gadget spec.
- * @param spec
- * @return a GadgetInfo
+ * @param GadgetSpec $spec
+ * @param string $serviceName
+ * @return GadgetInfo
*/
public static function getProviderInfo(GadgetSpec $spec, $serviceName) {
$oauthSpec = $spec->oauth;
@@ -188,9 +195,9 @@ class GadgetOAuthTokenStore {
* throwing an exception if the parameter could not be found (unless the
* parameter is optional, in which case null is returned).
*
- * @param params the key-value map from which to pull the value (parameter)
- * @param paramName the name of the parameter (key).
- * @param isOptional if it's optional, don't throw an exception if it's not
+ * @param array $params the key-value map from which to pull the value (parameter)
+ * @param string $ paramName the name of the parameter (key).
+ * @param boolean $isOptional if it's optional, don't throw an exception if it's not
* found.
* @return the value corresponding to the key (paramName)
* @throws GadgetException if the parameter value couldn't be found.
@@ -206,21 +213,46 @@ class GadgetOAuthTokenStore {
}
class GadgetInfo {
+ /**
+ *
+ * @var string
+ */
private $serviceName;
+
+ /**
+ *
+ * @var ProviderInfo
+ */
private $providerInfo;
+ /**
+ *
+ * @return string
+ */
public function getServiceName() {
return $this->serviceName;
}
+ /**
+ *
+ * @param string $serviceName
+ */
public function setServiceName($serviceName) {
$this->serviceName = $serviceName;
}
+ /**
+ *
+ * @return ProviderInfo
+ */
public function getProviderInfo() {
return $this->providerInfo;
}
+ /**
+ *
+ * @param ProviderInfo $providerInfo
+ */
public function setProviderInfo(ProviderInfo $providerInfo) {
$this->providerInfo = $providerInfo;
}
Modified: shindig/trunk/php/src/gadgets/oauth/OAuthAccessor.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/OAuthAccessor.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/OAuthAccessor.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/OAuthAccessor.php Fri Jan 14 14:41:43 2011
@@ -25,6 +25,10 @@ class OAuthAccessor {
public $tokenSecret;
private $properties = array();
+ /**
+ *
+ * @param OAuthConsumer $consumer
+ */
public function __construct(OAuthConsumer $consumer) {
$this->consumer = $consumer;
$this->requestToken = null;
@@ -32,16 +36,29 @@ class OAuthAccessor {
$this->tokenSecret = null;
}
+ /**
+ *
+ * @param string $name
+ * @return string
+ */
public function getProperty($name) {
return $this->properties[$name];
}
+ /**
+ *
+ * @param stirng $name
+ * @param string $value
+ */
public function setProperty($name, $value) {
$this->properties[$name] = $value;
}
/**
- * @return OAuthRequest
+ * @param string $method
+ * @param string $url
+ * @param string $parameters
+ * @return ShindigOAuthRequest
*/
public function newRequestMessage($method, $url, $parameters) {
if (! isset($method)) {
Modified: shindig/trunk/php/src/gadgets/oauth/OAuthCallbackState.php
URL: http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/oauth/OAuthCallbackState.php?rev=1059023&r1=1059022&r2=1059023&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/oauth/OAuthCallbackState.php (original)
+++ shindig/trunk/php/src/gadgets/oauth/OAuthCallbackState.php Fri Jan 14 14:41:43 2011
@@ -24,9 +24,24 @@
class OAuthCallbackState {
public static $CALLBACK_STATE_MAX_AGE_SECS = 600;
private static $REAL_CALLBACK_URL_KEY = "u";
+
+ /**
+ *
+ * @var BlobCrypter
+ */
private $crypter;
+
+ /**
+ *
+ * @var array
+ */
private $state = array();
+ /**
+ *
+ * @param BlobCrypter $crypter
+ * @param string $stateBlob
+ */
public function __construct($crypter, $stateBlob = null) {
$this->crypter = $crypter;
if ($stateBlob != null) {
@@ -42,10 +57,18 @@ class OAuthCallbackState {
return;
}
+ /**
+ *
+ * @return string
+ */
public function getEncryptedState() {
return $this->crypter->wrap($this->state);
}
+ /**
+ *
+ * @return string
+ */
public function getRealCallbackUrl() {
if (isset($this->state[self::$REAL_CALLBACK_URL_KEY])) {
return $this->state[self::$REAL_CALLBACK_URL_KEY];
@@ -54,6 +77,10 @@ class OAuthCallbackState {
}
}
+ /**
+ *
+ * @param string $callbackUrl
+ */
public function setRealCallbackUrl($callbackUrl) {
$this->state[self::$REAL_CALLBACK_URL_KEY] = $callbackUrl;
}