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/10/28 01:20:49 UTC
svn commit: r1190083 [4/5] - in
/shindig/branches/php_namespace_refactoring/php/src/apache: ./ shindig/
shindig/common/ shindig/common/sample/ shindig/gadgets/
shindig/gadgets/oauth/ shindig/gadgets/render/ shindig/gadgets/rewrite/
shindig/gadgets/samp...
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MakeRequestServlet.php (from r1186446, shindig/trunk/php/src/gadgets/servlet/MakeRequestServlet.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MakeRequestServlet.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MakeRequestServlet.php&p1=shindig/trunk/php/src/gadgets/servlet/MakeRequestServlet.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/servlet/MakeRequestServlet.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MakeRequestServlet.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,10 @@
<?php
+namespace apache\shindig\gadgets\servlet;
+use apache\shindig\common\HttpServlet;
+use apache\shindig\common\Config;
+use apache\shindig\gadgets\MakeRequestOptions;
+use apache\shindig\gadgets\MakeRequestParameterException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,17 +24,6 @@
* under the License.
*/
-require 'src/common/HttpServlet.php';
-require 'src/gadgets/GadgetContext.php';
-require 'src/gadgets/ProxyBase.php';
-require 'src/gadgets/MakeRequestHandler.php';
-require 'src/common/RemoteContentRequest.php';
-require 'src/common/RemoteContent.php';
-require 'src/common/Cache.php';
-require 'src/common/RemoteContentFetcher.php';
-require 'src/common/ShindigOAuth.php';
-require 'src/gadgets/oauth/OAuthStore.php';
-
class MakeRequestServlet extends HttpServlet {
public function doGet() {
@@ -44,7 +39,7 @@ class MakeRequestServlet extends HttpSer
// Something was misconfigured in the request
header("HTTP/1.0 400 Bad Request", true);
echo "<html><body><h1>400 - Bad request</h1><p>" . $e->getMessage() . "</body></html>";
- } catch (Exception $e) {
+ } catch (\Exception $e) {
// catch all exceptions and give a 500 server error
header("HTTP/1.0 500 Internal Server Error");
echo "<html><body><h1>Internal server error</h1><p>" . $e->getMessage() . "</p></body></html>";
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MetadataServlet.php (from r1186446, shindig/trunk/php/src/gadgets/servlet/MetadataServlet.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MetadataServlet.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MetadataServlet.php&p1=shindig/trunk/php/src/gadgets/servlet/MetadataServlet.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/servlet/MetadataServlet.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/MetadataServlet.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,9 @@
<?php
+namespace apache\shindig\gadgets\servlet;
+use apache\shindig\gadgets\MetadataHandler;
+use apache\shindig\common\HttpServlet;
+use apache\shindig\common\Config;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,24 +23,6 @@
* under the License.
*/
-require_once 'src/common/HttpServlet.php';
-require_once 'src/common/SecurityTokenDecoder.php';
-require_once 'src/common/SecurityToken.php';
-require_once 'src/common/BlobCrypter.php';
-require_once 'src/common/RemoteContentRequest.php';
-require_once 'src/common/RemoteContent.php';
-require_once 'src/common/Cache.php';
-require_once 'src/common/RemoteContentFetcher.php';
-require_once 'src/gadgets/GadgetSpecParser.php';
-require_once 'src/gadgets/GadgetBlacklist.php';
-require_once 'src/gadgets/sample/BasicGadgetBlacklist.php';
-require_once 'src/gadgets/GadgetContext.php';
-require_once 'src/gadgets/GadgetSpec.php';
-require_once 'src/gadgets/Gadget.php';
-require_once 'src/gadgets/GadgetFactory.php';
-require_once 'src/gadgets/MetadataContext.php';
-require_once 'src/gadgets/MetadataHandler.php';
-
class MetadataServlet extends HttpServlet {
public function doPost() {
@@ -49,15 +36,15 @@ class MetadataServlet extends HttpServle
}
$request = json_decode($requestParam);
if ($request == $requestParam) {
- throw new Exception("Malformed json string");
+ throw new \Exception("Malformed json string");
}
$handler = new MetadataHandler();
$response = $handler->process($request);
echo json_encode(array('gadgets' => $response));
} else {
- throw new Exception("No post data set");
+ throw new \Exception("No post data set");
}
- } catch (Exception $e) {
+ } catch (\Exception $e) {
header("HTTP/1.0 500 Internal Server Error", true, 500);
echo "<html><body><h1>Internal Server Error</h1><br />";
if (Config::get('debug')) {
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/OAuthCallbackServlet.php (from r1186470, shindig/trunk/php/src/gadgets/servlet/OAuthCallbackServlet.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/OAuthCallbackServlet.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/OAuthCallbackServlet.php&p1=shindig/trunk/php/src/gadgets/servlet/OAuthCallbackServlet.php&r1=1186470&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/servlet/OAuthCallbackServlet.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/OAuthCallbackServlet.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,9 @@
<?php
+namespace apache\shindig\gadgets\servlet;
+use apache\shindig\common\sample\BasicBlobCrypter;
+use apache\shindig\gadgets\oauth\OAuthCallbackState;
+use apache\shindig\common\HttpServlet;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +23,6 @@
* under the License.
*/
-require_once 'src/gadgets/oauth/OAuthCallbackState.php';
-
class OAuthCallbackServlet extends HttpServlet {
public function doGet() {
$state = isset($_GET["state"]) ? $_GET["state"] : "";
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ProxyServlet.php (from r1186446, shindig/trunk/php/src/gadgets/servlet/ProxyServlet.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ProxyServlet.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ProxyServlet.php&p1=shindig/trunk/php/src/gadgets/servlet/ProxyServlet.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/servlet/ProxyServlet.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ProxyServlet.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,8 @@
<?php
+namespace apache\shindig\gadgets\servlet;
+use apache\shindig\common\HttpServlet;
+use apache\shindig\common\Config;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,15 +22,6 @@
* under the License.
*/
-require 'src/common/HttpServlet.php';
-require 'src/gadgets/GadgetContext.php';
-require 'src/gadgets/ProxyBase.php';
-require 'src/gadgets/ProxyHandler.php';
-require 'src/common/RemoteContentRequest.php';
-require 'src/common/RemoteContent.php';
-require 'src/common/Cache.php';
-require 'src/common/RemoteContentFetcher.php';
-
class ProxyServlet extends HttpServlet {
public function doGet() {
@@ -44,7 +39,7 @@ class ProxyServlet extends HttpServlet {
$proxyHandlerClass = Config::get('proxy_handler');
$proxyHandler = new $proxyHandlerClass($context);
$proxyHandler->fetch($url);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
// catch all exceptions and give a 500 server error
header("HTTP/1.0 500 Internal Server Error");
echo "<h1>Internal server error</h1><p>" . $e->getMessage() . "</p>";
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ResourcesFilesServlet.php (from r1186446, shindig/trunk/php/src/gadgets/servlet/ResourcesFilesServlet.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ResourcesFilesServlet.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ResourcesFilesServlet.php&p1=shindig/trunk/php/src/gadgets/servlet/ResourcesFilesServlet.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/servlet/ResourcesFilesServlet.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/servlet/ResourcesFilesServlet.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,7 @@
<?php
+namespace apache\shindig\gadgets\servlet;
+use apache\shindig\common\Config;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/DataPipelining.php (from r1186446, shindig/trunk/php/src/gadgets/templates/DataPipelining.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/DataPipelining.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/DataPipelining.php&p1=shindig/trunk/php/src/gadgets/templates/DataPipelining.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/DataPipelining.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/DataPipelining.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,11 @@
<?php
+namespace apache\shindig\gadgets\templates;
+use apache\shindig\common\RemoteContentRequest;
+use apache\shindig\common\sample\BasicRemoteContent;
+use apache\shindig\common\sample\BasicSecurityToken;
+use apache\shindig\common\Config;
+use apache\shindig\gadgets\GadgetContext;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,8 +25,6 @@
* under the License.
*/
-require_once 'ExpressionParser.php';
-
//TODO verify os:HttpRequest
class DataPipelining {
@@ -31,7 +36,7 @@ class DataPipelining {
* @param DOMElement $viewNode
* @return array
*/
- static public function parse(DOMElement &$viewNode) {
+ static public function parse(\DOMElement &$viewNode) {
$dataTags = $viewNode->getElementsByTagName('*');
if ($dataTags->length > 0) {
$dataPipeliningTags = array();
@@ -100,7 +105,7 @@ class DataPipelining {
if (($resolved = self::resolveRequest($request, $result)) !== false) {
$requestQueue[] = $resolved;
unset($dataPipeliningRequests[$key]);
- }
+ }
}
if (count($requestQueue)) {
$returnedResults = self::performRequests($requestQueue, $context);
@@ -208,7 +213,7 @@ class DataPipelining {
foreach ($resps as $response) {
//FIXME: this isn't completely correct yet since this picks up the status code and headers
// as they are returned by the makeRequest handler and not the ones from the original request
-
+
$url = $response->getNotSignedUrl();
$id = $httpRequests[$url]['id'];
// strip out the UNPARSEABLE_CRUFT (see makeRequestHandler.php) on assigning the body
@@ -269,7 +274,7 @@ class DataPipelining {
try {
$expressionResult = ExpressionParser::evaluate($expression, $dataContext);
$request[$key] = str_replace($toReplace, $expressionResult, $request[$key]);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
// ignore, maybe on the next pass we can resolve this
return false;
}
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexer.php (from r1186446, shindig/trunk/php/src/gadgets/templates/ExpLexer.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexer.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexer.php&p1=shindig/trunk/php/src/gadgets/templates/ExpLexer.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/ExpLexer.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexer.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\gadgets\templates;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,11 +30,6 @@
* This lexer could handle special formats like floating 12.3e-10 and string 'tell "me" \'yes\\\'' correctly.
*/
-require_once 'ExpType.php';
-
-class ExpLexerException extends Exception {
-}
-
class ExpLexer {
private static $BLANK = "/[\s]+/";
@@ -319,7 +316,7 @@ class ExpLexer {
}
}
}
-
+
private static function hasUnaryLeft($tokenStream, $i) {
$OPERATOR_LEFT_TYPE = array(ExpType::$BINARY_OP, ExpType::$UNARY_OP, ExpType::$TERNARY,
ExpType::$COMMA);
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexerException.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexerException.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexerException.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexerException.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,24 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class ExpLexerException extends \Exception {
+}
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpLexerException.php
------------------------------------------------------------------------------
svn:keywords = Id
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParser.php (from r1186446, shindig/trunk/php/src/gadgets/templates/ExpParser.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParser.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParser.php&p1=shindig/trunk/php/src/gadgets/templates/ExpParser.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/ExpParser.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParser.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\gadgets\templates;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,160 +30,6 @@
* This parser accepts the output token stream produced by ExpLexer.
*/
-require_once 'ExpType.php';
-
-class ExpParserException extends Exception {
-}
-
-class PrimitiveExp {
-
- public $reason;
- private $exp;
- private $dataContext;
-
- function __construct($reason) {
- $this->reason = $reason;
- $this->exp = array();
- }
-
- public function append($token) {
- array_push($this->exp, $token);
- }
-
- public function evaluate($dataContext) {
- $this->dataContext = $dataContext;
- if ($this->reason->type == ExpType::$FUNCTION) {
- $result = $this->evaluateFunction();
- } else {
- $result = $this->evaluateExpression();
- }
- return $result;
- }
-
- private function evaluateExpression() {
- $OPERATOR_TYPES = array(ExpType::$UNARY_OP, ExpType::$BINARY_OP, ExpType::$DOT);
- $PRIMITIVE_TYPES = array(ExpType::$INT, ExpType::$FLOAT, ExpType::$STRING, ExpType::$BOOL,
- ExpType::$NULL);
- $COMPOSITE_TYPES = array(ExpType::$ARRAY, ExpType::$OBJECT);
- $OPERAND_TYPES = array_merge($PRIMITIVE_TYPES, $COMPOSITE_TYPES, array(ExpType::$IDENTITY));
-
- $OPERATOR_PRECEDENCE = array('||' => 0, '&&' => 1, '==' => 2, '!=' => 2, '>' => 3,
- '<' => 3, '>=' => 3, '<=' => 3, '+' => 4, ' - ' => 4, '*' => 5, '/' => 5, '%' => 5,
- ' -' => 6, '!' => 6, 'empty' => 6, '.' => 7);
-
- $operatorStack = array();
- $operandStack = array();
- foreach ($this->exp as $token) {
- if (in_array($token->type, $OPERAND_TYPES)) {
- array_push($operandStack, $token);
- } elseif (in_array($token->type, $OPERATOR_TYPES)) {
- $precedence = $OPERATOR_PRECEDENCE[$token->value];
- while (! empty($operatorStack)) {
- $previousPrecedence = $OPERATOR_PRECEDENCE[end($operatorStack)->value];
- if ($precedence > $previousPrecedence || $precedence == $previousPrecedence && $token->type == ExpType::$UNARY_OP) {
- break;
- } else {
- $operator = array_pop($operatorStack);
- $operandStack = $this->compute($operandStack, $operator);
- }
- }
- array_push($operatorStack, $token);
- } else {
- throw new ExpParserException("The expected primitive expression contains complex token: ", print_r($this->exp, true));
- }
- }
- while ($operator = array_pop($operatorStack)) {
- $operandStack = $this->compute($operandStack, $operator);
- }
- if (count($operandStack) != 1) {
- throw new ExpParserException("Gramma error on the primitive expression: " . print_r($this->exp, true));
- }
- return $this->evaluateIdentity(array_pop($operandStack));
- }
-
- private function compute($operandStack, $operator) {
- $ARITHMETIC_OPS = array('+', ' - ', '*', '/', '%'); // without unary operator ' -'
- $RELATIONAL_OPS = array('==', '!=', '<', '>', '<=', '>=');
- $LOGICAL_OPS = array('&&', '||'); // without '!'
-
- $sym = $operator->value;
- if ($operator->type == ExpType::$UNARY_OP) {
- $operand = $this->evaluateIdentity(array_pop($operandStack));
- } else {
- $rhs = array_pop($operandStack);
- $rhs = ($sym != '.') ? $this->evaluateIdentity($rhs) : $rhs;
- $lhs = $this->evaluateIdentity(array_pop($operandStack));
- }
- if ($sym == '.') {
- if ($lhs->type == ExpType::$NULL || $rhs->type == ExpType::$NULL) { // Dealing with null type
- $result = new Token(ExpType::$NULL, null);
- } else {
- if ($lhs->type == ExpType::$ARRAY) {
- if ($rhs->type == ExpType::$INT || $rhs->type == ExpType::$STRING || $rhs->type == ExpType::$IDENTITY) $resval = isset($lhs->value[$rhs->value]) ? $lhs->value[$rhs->value] : null;
- else throw new ExpParserException("Can't reference key typ " . print_r($rhs, true) . " on array");
- } elseif ($lhs->type == ExpType::$OBJECT) {
- if ($rhs->type == ExpType::$IDENTITY) eval('$resval = isset($lhs->value->' . $rhs->value . ')? $lhs->value->' . $rhs->value . ': null;');
- else throw new ExpParserException("Can't reference key typ " . print_r($rhs, true) . " on object");
- } else {
- throw new ExpParserException("Can't perform ./[] operation on primitive type " . print_r($lhs, true));
- }
- $result = new Token(ExpType::detectType($resval), $resval);
- }
- } elseif ($sym == 'empty') {
- $result = new Token(ExpType::$BOOL, empty($operand->value));
- } elseif (in_array($sym, $ARITHMETIC_OPS)) {
- $lhs = ExpType::coerceToNumber($lhs);
- $rhs = ExpType::coerceToNumber($rhs);
- eval('$resval = $lhs->value ' . $sym . '$rhs->value;');
- $result = new Token(ExpType::detectType($resval), $resval);
- } elseif ($sym == ' -') { // Unary operator '-'
- $result = ExpType::coerceToNumber($operand);
- $result = new Token($result->type, -($result->value));
- } elseif (in_array($sym, $RELATIONAL_OPS)) {
- $result = new Token(ExpType::$BOOL);
- // special case: one of the operator is null
- if ($lhs->type == ExpType::$NULL && $rhs->type != ExpType::$NULL || $lhs->type != ExpType::$NULL && $rhs->type == ExpType::$NULL) $result->value = in_array($sym, array('<', '>', '<=', '>=', '==')) ? false : true;
- eval('$result->value = $lhs->value ' . $sym . ' $rhs->value;');
- } elseif (in_array($sym, $LOGICAL_OPS)) {
- $result = new Token(ExpType::$BOOL);
- $lhs = ExpType::coerceToBool($lhs);
- $rhs = ExpType::coerceToBool($rhs);
- eval('$result->value = $lhs->value ' . $sym . ' $rhs->value;');
- } elseif ($sym == '!') {
- $result = ExpType::coerceToBool($operand);
- $result = new Token(ExpType::$BOOL, ! ($result->value));
- } else {
- throw new ExpParserException("Uncovered operator: " . $sym);
- }
- array_push($operandStack, $result);
- return $operandStack;
- }
-
- private function evaluateIdentity($token) {
- if ($token->type != ExpType::$IDENTITY) return $token;
- foreach (array(false, 'Cur', 'My', 'Top') as $scope) {
- $context = $scope ? $this->dataContext[$scope] : $this->dataContext;
- if (isset($context[$token->value])) {
- $val = $context[$token->value];
- $newToken = new Token(ExpType::detectType($val), $val);
- return $newToken;
- }
- }
- throw new ExpParserException("Un-recogonized identity name in the data context: " . $token->value);
- }
-
- private function evaluateFunction() {
- $FUNCTION_TRANS = array('osx:parseJson' => 'json_decode', 'osx:decodeBase64' => 'base64_decode',
- 'osx:urlEncode' => 'rawurlencode', 'osx:urlDecode' => 'rawurldecode');
- $params = array();
- foreach ($this->exp as $param)
- array_push($params, $param->value);
- $val = call_user_func_array($FUNCTION_TRANS[$this->reason->value], $params);
- return new Token(ExpType::detectType($val), $val);
- }
-
-}
-
class ExpParser {
private static function scopePop(&$expression, &$scopes, $dataContext) {
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParserException.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParserException.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParserException.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParserException.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,24 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class ExpParserException extends \Exception {
+}
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpParserException.php
------------------------------------------------------------------------------
svn:keywords = Id
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpType.php (from r1186446, shindig/trunk/php/src/gadgets/templates/ExpType.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpType.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpType.php&p1=shindig/trunk/php/src/gadgets/templates/ExpType.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/ExpType.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpType.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\gadgets\templates;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,31 +30,6 @@
* This ExpType handles all type identifications and conversions in ExpLexer and ExpParser.
*/
-class Token {
- /**
- * @var string
- */
- public $type;
-
- /**
- * @var mixed
- */
- public $value;
-
- /**
- *
- * @param string $type
- * @param mixed $value
- */
- function __construct($type, $value = null) {
- $this->type = $type;
- $this->value = $value;
- }
-}
-
-class ExpTypeException extends Exception {
-}
-
class ExpType {
// operators
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpTypeException.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpTypeException.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpTypeException.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpTypeException.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,24 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class ExpTypeException extends \Exception {
+}
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpTypeException.php
------------------------------------------------------------------------------
svn:keywords = Id
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionException.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionException.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionException.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionException.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,24 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class ExpressionException extends \Exception {
+}
\ No newline at end of file
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionException.php
------------------------------------------------------------------------------
svn:keywords = Id
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionParser.php (from r1186446, shindig/trunk/php/src/gadgets/templates/ExpressionParser.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionParser.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionParser.php&p1=shindig/trunk/php/src/gadgets/templates/ExpressionParser.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/ExpressionParser.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/ExpressionParser.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\gadgets\templates;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -26,13 +28,6 @@
* OS Data pipelining: http://opensocial-resources.googlecode.com/svn/spec/0.9/OpenSocial-Data-Pipelining.xml
*
*/
-
-require_once 'ExpLexer.php';
-require_once 'ExpParser.php';
-
-class ExpressionException extends Exception {
-}
-
class ExpressionParser {
/**
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/PrimitiveExp.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/PrimitiveExp.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/PrimitiveExp.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/PrimitiveExp.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,170 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class PrimitiveExp {
+
+ public $reason;
+ private $exp;
+ private $dataContext;
+
+ function __construct($reason) {
+ $this->reason = $reason;
+ $this->exp = array();
+ }
+
+ public function append($token) {
+ array_push($this->exp, $token);
+ }
+
+ public function evaluate($dataContext) {
+ $this->dataContext = $dataContext;
+ if ($this->reason->type == ExpType::$FUNCTION) {
+ $result = $this->evaluateFunction();
+ } else {
+ $result = $this->evaluateExpression();
+ }
+ return $result;
+ }
+
+ private function evaluateExpression() {
+ $OPERATOR_TYPES = array(ExpType::$UNARY_OP, ExpType::$BINARY_OP, ExpType::$DOT);
+ $PRIMITIVE_TYPES = array(ExpType::$INT, ExpType::$FLOAT, ExpType::$STRING, ExpType::$BOOL,
+ ExpType::$NULL);
+ $COMPOSITE_TYPES = array(ExpType::$ARRAY, ExpType::$OBJECT);
+ $OPERAND_TYPES = array_merge($PRIMITIVE_TYPES, $COMPOSITE_TYPES, array(ExpType::$IDENTITY));
+
+ $OPERATOR_PRECEDENCE = array('||' => 0, '&&' => 1, '==' => 2, '!=' => 2, '>' => 3,
+ '<' => 3, '>=' => 3, '<=' => 3, '+' => 4, ' - ' => 4, '*' => 5, '/' => 5, '%' => 5,
+ ' -' => 6, '!' => 6, 'empty' => 6, '.' => 7);
+
+ $operatorStack = array();
+ $operandStack = array();
+ foreach ($this->exp as $token) {
+ if (in_array($token->type, $OPERAND_TYPES)) {
+ array_push($operandStack, $token);
+ } elseif (in_array($token->type, $OPERATOR_TYPES)) {
+ $precedence = $OPERATOR_PRECEDENCE[$token->value];
+ while (! empty($operatorStack)) {
+ $previousPrecedence = $OPERATOR_PRECEDENCE[end($operatorStack)->value];
+ if ($precedence > $previousPrecedence || $precedence == $previousPrecedence && $token->type == ExpType::$UNARY_OP) {
+ break;
+ } else {
+ $operator = array_pop($operatorStack);
+ $operandStack = $this->compute($operandStack, $operator);
+ }
+ }
+ array_push($operatorStack, $token);
+ } else {
+ throw new ExpParserException("The expected primitive expression contains complex token: ", print_r($this->exp, true));
+ }
+ }
+ while ($operator = array_pop($operatorStack)) {
+ $operandStack = $this->compute($operandStack, $operator);
+ }
+ if (count($operandStack) != 1) {
+ throw new ExpParserException("Gramma error on the primitive expression: " . print_r($this->exp, true));
+ }
+ return $this->evaluateIdentity(array_pop($operandStack));
+ }
+
+ private function compute($operandStack, $operator) {
+ $ARITHMETIC_OPS = array('+', ' - ', '*', '/', '%'); // without unary operator ' -'
+ $RELATIONAL_OPS = array('==', '!=', '<', '>', '<=', '>=');
+ $LOGICAL_OPS = array('&&', '||'); // without '!'
+
+ $sym = $operator->value;
+ if ($operator->type == ExpType::$UNARY_OP) {
+ $operand = $this->evaluateIdentity(array_pop($operandStack));
+ } else {
+ $rhs = array_pop($operandStack);
+ $rhs = ($sym != '.') ? $this->evaluateIdentity($rhs) : $rhs;
+ $lhs = $this->evaluateIdentity(array_pop($operandStack));
+ }
+ if ($sym == '.') {
+ if ($lhs->type == ExpType::$NULL || $rhs->type == ExpType::$NULL) { // Dealing with null type
+ $result = new Token(ExpType::$NULL, null);
+ } else {
+ if ($lhs->type == ExpType::$ARRAY) {
+ if ($rhs->type == ExpType::$INT || $rhs->type == ExpType::$STRING || $rhs->type == ExpType::$IDENTITY) $resval = isset($lhs->value[$rhs->value]) ? $lhs->value[$rhs->value] : null;
+ else throw new ExpParserException("Can't reference key typ " . print_r($rhs, true) . " on array");
+ } elseif ($lhs->type == ExpType::$OBJECT) {
+ if ($rhs->type == ExpType::$IDENTITY) eval('$resval = isset($lhs->value->' . $rhs->value . ')? $lhs->value->' . $rhs->value . ': null;');
+ else throw new ExpParserException("Can't reference key typ " . print_r($rhs, true) . " on object");
+ } else {
+ throw new ExpParserException("Can't perform ./[] operation on primitive type " . print_r($lhs, true));
+ }
+ $result = new Token(ExpType::detectType($resval), $resval);
+ }
+ } elseif ($sym == 'empty') {
+ $result = new Token(ExpType::$BOOL, empty($operand->value));
+ } elseif (in_array($sym, $ARITHMETIC_OPS)) {
+ $lhs = ExpType::coerceToNumber($lhs);
+ $rhs = ExpType::coerceToNumber($rhs);
+ eval('$resval = $lhs->value ' . $sym . '$rhs->value;');
+ $result = new Token(ExpType::detectType($resval), $resval);
+ } elseif ($sym == ' -') { // Unary operator '-'
+ $result = ExpType::coerceToNumber($operand);
+ $result = new Token($result->type, -($result->value));
+ } elseif (in_array($sym, $RELATIONAL_OPS)) {
+ $result = new Token(ExpType::$BOOL);
+ // special case: one of the operator is null
+ if ($lhs->type == ExpType::$NULL && $rhs->type != ExpType::$NULL || $lhs->type != ExpType::$NULL && $rhs->type == ExpType::$NULL) $result->value = in_array($sym, array('<', '>', '<=', '>=', '==')) ? false : true;
+ eval('$result->value = $lhs->value ' . $sym . ' $rhs->value;');
+ } elseif (in_array($sym, $LOGICAL_OPS)) {
+ $result = new Token(ExpType::$BOOL);
+ $lhs = ExpType::coerceToBool($lhs);
+ $rhs = ExpType::coerceToBool($rhs);
+ eval('$result->value = $lhs->value ' . $sym . ' $rhs->value;');
+ } elseif ($sym == '!') {
+ $result = ExpType::coerceToBool($operand);
+ $result = new Token(ExpType::$BOOL, ! ($result->value));
+ } else {
+ throw new ExpParserException("Uncovered operator: " . $sym);
+ }
+ array_push($operandStack, $result);
+ return $operandStack;
+ }
+
+ private function evaluateIdentity($token) {
+ if ($token->type != ExpType::$IDENTITY) return $token;
+ foreach (array(false, 'Cur', 'My', 'Top') as $scope) {
+ $context = $scope ? $this->dataContext[$scope] : $this->dataContext;
+ if (isset($context[$token->value])) {
+ $val = $context[$token->value];
+ $newToken = new Token(ExpType::detectType($val), $val);
+ return $newToken;
+ }
+ }
+ throw new ExpParserException("Un-recogonized identity name in the data context: " . $token->value);
+ }
+
+ private function evaluateFunction() {
+ $FUNCTION_TRANS = array('osx:parseJson' => 'json_decode', 'osx:decodeBase64' => 'base64_decode',
+ 'osx:urlEncode' => 'rawurlencode', 'osx:urlDecode' => 'rawurldecode');
+ $params = array();
+ foreach ($this->exp as $param)
+ array_push($params, $param->value);
+ $val = call_user_func_array($FUNCTION_TRANS[$this->reason->value], $params);
+ return new Token(ExpType::detectType($val), $val);
+ }
+
+}
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/PrimitiveExp.php
------------------------------------------------------------------------------
svn:keywords = Id
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/SwfConfig.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/SwfConfig.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/SwfConfig.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/SwfConfig.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,56 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class SwfConfig {
+ public static $FLASH_VER = '9.0.115';
+ public static $PARAMS = array('loop', 'menu', 'quality', 'scale', 'salign', 'wmode', 'bgcolor',
+ 'swliveconnect', 'flashvars', 'devicefont', 'allowscriptaccess', 'seamlesstabbing',
+ 'allowfullscreen', 'allownetworking');
+ public static $ATTRS = array('id', 'name', 'styleclass', 'align');
+
+ /**
+ *
+ * @param array $swfConfig
+ * @param string $altContentId
+ * @param string $flashVars
+ * @return string
+ */
+ public static function buildSwfObjectCall($swfConfig, $altContentId, $flashVars = 'null') {
+ $params = SwfConfig::buildJsObj($swfConfig, SwfConfig::$PARAMS);
+ $attrs = SwfConfig::buildJsObj($swfConfig, SwfConfig::$ATTRS);
+ $flashVersion = SwfConfig::$FLASH_VER;
+ $swfObject = "swfobject.embedSWF(\"{$swfConfig['swf']}\", \"{$altContentId}\", \"{$swfConfig['width']}\", \"{$swfConfig['height']}\", \"{$flashVersion}\", null, {$flashVars}, {$params}, {$attrs});";
+ return $swfObject;
+ }
+
+ private static function buildJsObj($swfConfig, $keymap) {
+ $arr = array();
+ foreach ($swfConfig as $key => $value) {
+ if (in_array($key, $keymap)) {
+ $arr[] = "{$key}:\"{$value}\"";
+ }
+ }
+ $output = implode(",", $arr);
+ $output = '{' . $output . '}';
+ return $output;
+ }
+}
\ No newline at end of file
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/SwfConfig.php
------------------------------------------------------------------------------
svn:keywords = Id
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibrary.php (from r1186446, shindig/trunk/php/src/gadgets/templates/TemplateLibrary.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibrary.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibrary.php&p1=shindig/trunk/php/src/gadgets/templates/TemplateLibrary.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/TemplateLibrary.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibrary.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,10 @@
<?php
+namespace apache\shindig\gadgets\templates;
+use apache\shindig\common\XmlError;
+use apache\shindig\common\Config;
+use apache\shindig\common\File;
+use apache\shindig\gadgets\GadgetContext;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -59,7 +65,7 @@ class TemplateLibrary {
public function parseTemplate($tag, $caller) {
$template = $this->getTemplate($tag);
if ($template->dom) {
- $templateDomCopy = new DOMDocument(null, 'utf-8');
+ $templateDomCopy = new \DOMDocument(null, 'utf-8');
$templateDomCopy->preserveWhiteSpace = true;
$templateDomCopy->formatOutput = false;
$templateDomCopy->strictErrorChecking = false;
@@ -102,7 +108,7 @@ class TemplateLibrary {
*
* @param DOMElement $node
*/
- public function addTemplateByNode(DOMElement &$node, $scripts = false, $styles = false) {
+ public function addTemplateByNode(\DOMElement &$node, $scripts = false, $styles = false) {
$tag = $node->getAttribute('tag');
$template = new TemplateLibraryEntry($node);
if ($scripts) {
@@ -124,7 +130,7 @@ class TemplateLibrary {
* @param TemplateLibraryContent $globalScript
* @param TemplateLibraryContent $globalStyle
*/
- private function addTemplateDef(DOMElement &$node, $globalScript, $globalStyle) {
+ private function addTemplateDef(\DOMElement &$node, $globalScript, $globalStyle) {
$tag = $node->getAttribute('tag');
if (empty($tag)) {
throw new ExpressionException("Missing tag attribute on TemplateDef element");
@@ -160,7 +166,7 @@ class TemplateLibrary {
*/
public function addTemplateLibrary($library) {
libxml_use_internal_errors(true);
- $doc = new DOMDocument(null, 'utf-8');
+ $doc = new \DOMDocument(null, 'utf-8');
$doc->preserveWhiteSpace = true;
$doc->formatOutput = false;
$doc->strictErrorChecking = false;
@@ -225,7 +231,7 @@ class TemplateLibrary {
}
/*
- *
+ *
*/
private function loadOsmlLibrary() {
$container = $this->gadgetContext->getContainer();
@@ -244,84 +250,3 @@ class TemplateLibrary {
$this->osmlLoaded = true;
}
}
-
-/**
- * Misc class that holds the template information, an inline template
- * will only contain a text blob (stored as parsed $dom node), however
- * external and OSML library templates can also container script and
- * style blocks
- *
- */
-class TemplateLibraryEntry {
- public $dom;
- public $style = array();
- public $script = array();
-
- public function __construct($dom = false) {
- $this->dom = $dom;
- }
-
- /**
- * Adds a javascript blob to this template
- *
- * @param unknown_type $script
- */
- public function addScript(TemplateLibraryContent $script) {
- $this->script[] = $script;
- }
-
- /**
- * Adds a style blob to this template
- *
- * @param unknown_type $style
- */
- public function addStyle(TemplateLibraryContent $style) {
- $this->style[] = $style;
- }
-
- /**
- * Returns the (combined, in inclusion order) script text blob, or
- * false if there's no javascript for this template
- *
- * @return javascript string or false
- */
- public function getScript() {
- $ret = '';
- foreach ($this->script as $script) {
- if (! $script->included) {
- $ret .= $script->content . "\n";
- }
- }
- return ! empty($ret) ? $ret : false;
- }
-
- /**
- * Returns the (combined, in inclusion order) stylesheet text blob, or
- * false if there's no style sheet associated with this template
- *
- * @return javascript string or false
- */
- public function getStyle() {
- $ret = '';
- foreach ($this->style as $style) {
- if (! $style->included) {
- $ret .= $style->content . "\n";
- }
- }
- return ! empty($ret) ? $ret : false;
- }
-}
-
-/**
- * Scripts can be global per library set, so we assign the global script to each actual template
- * and on calling it, the TemplateLibraryEntry will check to see if the content was already output
- */
-class TemplateLibraryContent {
- public $content;
- public $included;
-
- public function __construct($content) {
- $this->content = $content;
- $this->included = false;
- }
-}
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryContent.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryContent.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryContent.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryContent.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,35 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Scripts can be global per library set, so we assign the global script to each actual template
+ * and on calling it, the TemplateLibraryEntry will check to see if the content was already output
+ */
+class TemplateLibraryContent {
+ public $content;
+ public $included;
+
+ public function __construct($content) {
+ $this->content = $content;
+ $this->included = false;
+ }
+}
\ No newline at end of file
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryContent.php
------------------------------------------------------------------------------
svn:keywords = Id
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryEntry.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryEntry.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryEntry.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryEntry.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,88 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Misc class that holds the template information, an inline template
+ * will only contain a text blob (stored as parsed $dom node), however
+ * external and OSML library templates can also container script and
+ * style blocks
+ *
+ */
+class TemplateLibraryEntry {
+ public $dom;
+ public $style = array();
+ public $script = array();
+
+ public function __construct($dom = false) {
+ $this->dom = $dom;
+ }
+
+ /**
+ * Adds a javascript blob to this template
+ *
+ * @param unknown_type $script
+ */
+ public function addScript(TemplateLibraryContent $script) {
+ $this->script[] = $script;
+ }
+
+ /**
+ * Adds a style blob to this template
+ *
+ * @param unknown_type $style
+ */
+ public function addStyle(TemplateLibraryContent $style) {
+ $this->style[] = $style;
+ }
+
+ /**
+ * Returns the (combined, in inclusion order) script text blob, or
+ * false if there's no javascript for this template
+ *
+ * @return javascript string or false
+ */
+ public function getScript() {
+ $ret = '';
+ foreach ($this->script as $script) {
+ if (! $script->included) {
+ $ret .= $script->content . "\n";
+ }
+ }
+ return ! empty($ret) ? $ret : false;
+ }
+
+ /**
+ * Returns the (combined, in inclusion order) stylesheet text blob, or
+ * false if there's no style sheet associated with this template
+ *
+ * @return javascript string or false
+ */
+ public function getStyle() {
+ $ret = '';
+ foreach ($this->style as $style) {
+ if (! $style->included) {
+ $ret .= $style->content . "\n";
+ }
+ }
+ return ! empty($ret) ? $ret : false;
+ }
+}
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateLibraryEntry.php
------------------------------------------------------------------------------
svn:keywords = Id
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateParser.php (from r1186446, shindig/trunk/php/src/gadgets/templates/TemplateParser.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateParser.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateParser.php&p1=shindig/trunk/php/src/gadgets/templates/TemplateParser.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/templates/TemplateParser.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/TemplateParser.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,8 @@
<?php
+namespace apache\shindig\gadgets\templates;
+use apache\shindig\common\sample\BasicSecurityToken;
+use apache\shindig\common\Config;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -22,8 +26,6 @@
//TODO remove the os-templates javascript if all the templates are rendered on the server (saves many Kb's in gadget size)
-require_once 'ExpressionParser.php';
-
class TemplateParser {
/**
* @var array
@@ -36,12 +38,12 @@ class TemplateParser {
/**
* dumps a node to stdout
- *
+ *
* @param DOMnode $node
* @param string $function
*/
public function dumpNode($node, $function) {
- $doc = new DOMDocument(null, 'utf-8');
+ $doc = new \DOMDocument(null, 'utf-8');
$doc->preserveWhiteSpace = true;
$doc->formatOutput = false;
$doc->strictErrorChecking = false;
@@ -62,10 +64,10 @@ class TemplateParser {
* @param array $dataContext
* @param TemplateLibrary $templateLibrary
*/
- public function process(DOMnode &$osTemplate, $dataContext, TemplateLibrary $templateLibrary) {
+ public function process(\DOMnode &$osTemplate, $dataContext, TemplateLibrary $templateLibrary) {
$this->setDataContext($dataContext);
$this->templateLibrary = $templateLibrary;
- if ($osTemplate instanceof DOMElement) {
+ if ($osTemplate instanceof \DOMElement) {
if (($removeNode = $this->parseNode($osTemplate)) !== false) {
$removeNode->parentNode->removeChild($removeNode);
}
@@ -87,7 +89,7 @@ class TemplateParser {
/**
* returns the current datacontext, used mainly for testing purposes
- *
+ *
* @return array
*/
public function getDataContext() {
@@ -98,9 +100,9 @@ class TemplateParser {
* @param DOMNode $node
* @return boolean
*/
- public function parseNode(DOMNode &$node) {
+ public function parseNode(\DOMNode &$node) {
$removeNode = false;
- if ($node instanceof DOMText) {
+ if ($node instanceof \DOMText) {
if (! $node->isWhitespaceInElementContent() && ! empty($node->nodeValue)) {
$this->parseNodeText($node);
}
@@ -126,7 +128,7 @@ class TemplateParser {
* @param DOMElement $node
* @return array
*/
- private function nodeAttributesToScope(DOMElement &$node) {
+ private function nodeAttributesToScope(\DOMElement &$node) {
$myContext = array();
if ($node->hasAttributes()) {
foreach ($node->attributes as $attr) {
@@ -153,7 +155,7 @@ class TemplateParser {
* @param string $tagName
* @param DOMNode $node
*/
- private function parseLibrary($tagName, DOMNode &$node) {
+ private function parseLibrary($tagName, \DOMNode &$node) {
// Set the My context based on the node's attributes
$myContext = $this->nodeAttributesToScope($node);
@@ -189,7 +191,7 @@ class TemplateParser {
*
* @param DOMText $node
*/
- private function parseNodeText(DOMText &$node) {
+ private function parseNodeText(\DOMText &$node) {
if (strpos($node->nodeValue, '${') !== false) {
$expressions = array();
preg_match_all('/(\$\{)(.*)(\})/imsxU', $node->wholeText, $expressions);
@@ -208,7 +210,7 @@ class TemplateParser {
* @param DOMNode $node
* @return DOMNode or false
*/
- private function parseNodeAttributes(DOMNode &$node) {
+ private function parseNodeAttributes(\DOMNode &$node) {
if ($node->hasAttributes()) {
foreach ($node->attributes as $attr) {
if (strpos($attr->value, '${') !== false) {
@@ -347,7 +349,7 @@ class TemplateParser {
* @param DOMNode $node
* @return DOMNode or false
*/
- private function parseOsmlNode(DOMNode &$node) {
+ private function parseOsmlNode(\DOMNode &$node) {
$tagName = strtolower($node->tagName);
if (! $this->checkIf($node)) {
// If the OSML tag contains an if attribute and the expression evaluates to false
@@ -578,7 +580,7 @@ class TemplateParser {
* @param DOMElement $node
* @return boolean
*/
- private function checkIf(DOMElement &$node) {
+ private function checkIf(\DOMElement &$node) {
if (($if = $node->getAttribute('if'))) {
$expressions = array();
preg_match_all('/(\$\{)(.*)(\})/imsxU', $if, $expressions);
@@ -593,37 +595,4 @@ class TemplateParser {
}
}
-class SwfConfig {
- public static $FLASH_VER = '9.0.115';
- public static $PARAMS = array('loop', 'menu', 'quality', 'scale', 'salign', 'wmode', 'bgcolor',
- 'swliveconnect', 'flashvars', 'devicefont', 'allowscriptaccess', 'seamlesstabbing',
- 'allowfullscreen', 'allownetworking');
- public static $ATTRS = array('id', 'name', 'styleclass', 'align');
- /**
- *
- * @param array $swfConfig
- * @param string $altContentId
- * @param string $flashVars
- * @return string
- */
- public static function buildSwfObjectCall($swfConfig, $altContentId, $flashVars = 'null') {
- $params = SwfConfig::buildJsObj($swfConfig, SwfConfig::$PARAMS);
- $attrs = SwfConfig::buildJsObj($swfConfig, SwfConfig::$ATTRS);
- $flashVersion = SwfConfig::$FLASH_VER;
- $swfObject = "swfobject.embedSWF(\"{$swfConfig['swf']}\", \"{$altContentId}\", \"{$swfConfig['width']}\", \"{$swfConfig['height']}\", \"{$flashVersion}\", null, {$flashVars}, {$params}, {$attrs});";
- return $swfObject;
- }
-
- private static function buildJsObj($swfConfig, $keymap) {
- $arr = array();
- foreach ($swfConfig as $key => $value) {
- if (in_array($key, $keymap)) {
- $arr[] = "{$key}:\"{$value}\"";
- }
- }
- $output = implode(",", $arr);
- $output = '{' . $output . '}';
- return $output;
- }
-}
Added: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/Token.php
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/Token.php?rev=1190083&view=auto
==============================================================================
--- shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/Token.php (added)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/Token.php Thu Oct 27 23:20:41 2011
@@ -0,0 +1,43 @@
+<?php
+namespace apache\shindig\gadgets\templates;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+class Token {
+ /**
+ * @var string
+ */
+ public $type;
+
+ /**
+ * @var mixed
+ */
+ public $value;
+
+ /**
+ *
+ * @param string $type
+ * @param mixed $value
+ */
+ function __construct($type, $value = null) {
+ $this->type = $type;
+ $this->value = $value;
+ }
+}
\ No newline at end of file
Propchange: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/gadgets/templates/Token.php
------------------------------------------------------------------------------
svn:keywords = Id
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputActivitiesConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputActivitiesConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputActivitiesConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputActivitiesConverter.php&p1=shindig/trunk/php/src/social/converters/InputActivitiesConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputActivitiesConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputActivitiesConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,7 +30,7 @@ class InputActivitiesConverter extends I
public function convertJson($requestParam) {
$ret = json_decode($requestParam, true);
if ($ret == $requestParam) {
- throw new Exception("Mallformed activity json string");
+ throw new \Exception("Mallformed activity json string");
}
return $ret;
}
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAlbumsConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputAlbumsConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAlbumsConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAlbumsConverter.php&p1=shindig/trunk/php/src/social/converters/InputAlbumsConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputAlbumsConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAlbumsConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,7 +30,7 @@ class InputAlbumsConverter extends Input
public function convertJson($requestParam) {
$ret = json_decode($requestParam, true);
if ($ret == $requestParam) {
- throw new Exception("Mallformed album json string. " . $requestParam);
+ throw new \Exception("Mallformed album json string. " . $requestParam);
}
return $ret;
}
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAppDataConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputAppDataConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAppDataConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAppDataConverter.php&p1=shindig/trunk/php/src/social/converters/InputAppDataConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputAppDataConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputAppDataConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -23,7 +25,7 @@ class InputAppDataConverter extends Inpu
public function convertAtom($requestParam) {
$xml = InputBasicXmlConverter::loadString($requestParam);
if (! isset($xml->content) || ! isset($xml->content->appdata)) {
- throw new Exception("Mallformed AppData xml");
+ throw new \Exception("Mallformed AppData xml");
}
$data = array();
foreach (get_object_vars($xml->content->appdata) as $key => $val) {
@@ -35,7 +37,7 @@ class InputAppDataConverter extends Inpu
public function convertJson($requestParam) {
$ret = json_decode($requestParam, true);
if ($ret == $requestParam) {
- throw new Exception("Mallformed app data json string");
+ throw new \Exception("Mallformed app data json string");
}
return $ret;
}
@@ -43,7 +45,7 @@ class InputAppDataConverter extends Inpu
public function convertXml($requestParam) {
$xml = InputBasicXmlConverter::loadString($requestParam);
if (! isset($xml->entry)) {
- throw new Exception("Mallformed AppData xml");
+ throw new \Exception("Mallformed AppData xml");
}
$data = array();
foreach ($xml->entry as $entry) {
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputBasicXmlConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputBasicXmlConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputBasicXmlConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputBasicXmlConverter.php&p1=shindig/trunk/php/src/social/converters/InputBasicXmlConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputBasicXmlConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputBasicXmlConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,7 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\social\model\MediaItem;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -30,7 +33,7 @@ class InputBasicXmlConverter {
public static function convertActivities($xml, $activityXml) {
$activity = array();
if (! isset($xml->title)) {
- throw new Exception("Mallformed activity xml");
+ throw new \Exception("Mallformed activity xml");
}
// remember to either type cast to (string) or trim() the string so we don't get
// SimpleXMLString types in the internal data representation. I often prefer
@@ -46,7 +49,7 @@ class InputBasicXmlConverter {
foreach ($activityXml->mediaItems->MediaItem as $mediaItem) {
$item = array();
if (! isset($mediaItem->type) || ! isset($mediaItem->mimeType) || ! isset($mediaItem->url)) {
- throw new Exception("Invalid media item in activity xml");
+ throw new \Exception("Invalid media item in activity xml");
}
$item['type'] = trim($mediaItem->type);
$item['mimeType'] = trim($mediaItem->mimeType);
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputConverter.php&p1=shindig/trunk/php/src/social/converters/InputConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputInvalidateConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputInvalidateConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputInvalidateConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputInvalidateConverter.php&p1=shindig/trunk/php/src/social/converters/InputInvalidateConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputInvalidateConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputInvalidateConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMediaItemsConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputMediaItemsConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMediaItemsConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMediaItemsConverter.php&p1=shindig/trunk/php/src/social/converters/InputMediaItemsConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputMediaItemsConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMediaItemsConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMessagesConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputMessagesConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMessagesConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMessagesConverter.php&p1=shindig/trunk/php/src/social/converters/InputMessagesConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputMessagesConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputMessagesConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\converters;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,7 +30,7 @@ class InputMessagesConverter extends Inp
public function convertJson($requestParam) {
$ret = json_decode($requestParam, true);
if ($ret == $requestParam) {
- throw new Exception("Mallformed message string");
+ throw new \Exception("Mallformed message string");
}
return $ret;
}
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputPeopleConverter.php (from r1186446, shindig/trunk/php/src/social/converters/InputPeopleConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputPeopleConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputPeopleConverter.php&p1=shindig/trunk/php/src/social/converters/InputPeopleConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/InputPeopleConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/InputPeopleConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,8 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\social\service\SocialSpiException;
+use apache\shindig\social\service\ResponseError;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputAtomConverter.php (from r1186446, shindig/trunk/php/src/social/converters/OutputAtomConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputAtomConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputAtomConverter.php&p1=shindig/trunk/php/src/social/converters/OutputAtomConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputAtomConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputAtomConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,11 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\social\service\RestRequestItem;
+use apache\shindig\social\service\ResponseItem;
+use apache\shindig\common\SecurityToken;
+use apache\shindig\social\spi\RestfulCollection;
+use apache\shindig\social\model\Activity;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -135,7 +142,7 @@ class OutputAtomConverter extends Output
* @throws Exception
*/
function outputBatch(Array $responses, SecurityToken $token) {
- throw new Exception("Atom batch not supported");
+ throw new \Exception("Atom batch not supported");
}
/**
@@ -168,7 +175,7 @@ class OutputAtomConverter extends Output
if (($startIndex + $itemsPerPage) < $totalResults) {
$nextStartIndex = ($startIndex + $itemsPerPage) - 1;
if (($uri = $_SERVER['REQUEST_URI']) === false) {
- throw new Exception("Could not parse URI : {$_SERVER['REQUEST_URI']}");
+ throw new \Exception("Could not parse URI : {$_SERVER['REQUEST_URI']}");
}
$uri = parse_url($uri);
$params = array();
@@ -192,7 +199,7 @@ class OutputAtomConverter extends Output
* @return DOMDocument
*/
private function createAtomDoc() {
- $this->doc = new DOMDocument(self::$xmlVersion, self::$charSet);
+ $this->doc = new \DOMDocument(self::$xmlVersion, self::$charSet);
$this->doc->formatOutput = self::$formatOutput;
return $this->doc;
}
@@ -210,13 +217,13 @@ class OutputAtomConverter extends Output
/**
* Recursive function that maps an data array or object to it's xml represantation
*
- * @param DOMElement $element the element to append the new node(s) to
+ * @param DOMElement $element the element to append the new \node(s) to
* @param string $name the name of the to be created node
* @param array or object $data the data to map to xml
* @param string $nameSpace if specified, the node is created using this namespace
* @return DOMElement returns newly created element
*/
- private function addData(DOMElement $element, $name, $data, $nameSpace = false) {
+ private function addData(\DOMElement $element, $name, $data, $nameSpace = false) {
return OutputBasicXmlConverter::addData($this->doc, $element, $name, $data, $nameSpace);
}
}
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputBasicXmlConverter.php (from r1186446, shindig/trunk/php/src/social/converters/OutputBasicXmlConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputBasicXmlConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputBasicXmlConverter.php&p1=shindig/trunk/php/src/social/converters/OutputBasicXmlConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputBasicXmlConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputBasicXmlConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,7 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\social\model\Enum;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -34,7 +37,7 @@ class OutputBasicXmlConverter {
// map the Request URL to the content type to use
$params = $requestItem->getParameters();
if (! is_array($params)) {
- throw new Exception("Unsupported request type");
+ throw new \Exception("Unsupported request type");
}
$type = false;
foreach ($params as $key => $val) {
@@ -44,7 +47,7 @@ class OutputBasicXmlConverter {
}
}
if (! $type) {
- throw new Exception("Unsupported request type");
+ throw new \Exception("Unsupported request type");
}
return $type;
}
@@ -60,7 +63,7 @@ class OutputBasicXmlConverter {
* @param string $nameSpace optional namespace to use when creating node
* @return DOMElement node
*/
- public static function addNode(DOMDocument $doc, $node, $name, $value = '', $attributes = false, $nameSpace = false) {
+ public static function addNode(\DOMDocument $doc, $node, $name, $value = '', $attributes = false, $nameSpace = false) {
if ($nameSpace) {
$childNode = $node->appendChild($doc->createElementNS($nameSpace, $name));
} else {
@@ -84,13 +87,13 @@ class OutputBasicXmlConverter {
* Recursive function that maps an data array or object to it's xml represantation
*
* @param DOMDocument $doc the root document
- * @param DOMElement $element the element to append the new node(s) to
+ * @param DOMElement $element the element to append the new \node(s) to
* @param string $name the name of the to be created node
* @param array or object $data the data to map to xml
* @param string $nameSpace if specified, the node is created using this namespace
* @return DOMElement returns newly created element
*/
- public static function addData(DOMDocument $doc, DOMElement $element, $name, $data, $nameSpace = false) {
+ public static function addData(\DOMDocument $doc, \DOMElement $element, $name, $data, $nameSpace = false) {
if ($nameSpace) {
$newElement = $element->appendChild($doc->createElementNS($nameSpace, $name));
} else {
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputConverter.php (from r1186446, shindig/trunk/php/src/social/converters/OutputConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputConverter.php&p1=shindig/trunk/php/src/social/converters/OutputConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,9 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\social\service\ResponseItem;
+use apache\shindig\social\service\RestRequestItem;
+use apache\shindig\common\SecurityToken;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputJsonConverter.php (from r1186446, shindig/trunk/php/src/social/converters/OutputJsonConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputJsonConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputJsonConverter.php&p1=shindig/trunk/php/src/social/converters/OutputJsonConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputJsonConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputJsonConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,11 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\common\Config;
+use apache\shindig\social\service\ResponseItem;
+use apache\shindig\social\service\RestRequestItem;
+use apache\shindig\common\SecurityToken;
+use apache\shindig\social\spi\RestfulCollection;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputXmlConverter.php (from r1186446, shindig/trunk/php/src/social/converters/OutputXmlConverter.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputXmlConverter.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputXmlConverter.php&p1=shindig/trunk/php/src/social/converters/OutputXmlConverter.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/converters/OutputXmlConverter.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/converters/OutputXmlConverter.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,10 @@
<?php
+namespace apache\shindig\social\converters;
+use apache\shindig\social\service\ResponseItem;
+use apache\shindig\social\service\RestRequestItem;
+use apache\shindig\common\SecurityToken;
+use apache\shindig\social\spi\RestfulCollection;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -77,7 +83,7 @@ class OutputXmlConverter extends OutputC
* @param SecurityToken $token
*/
function outputBatch(Array $responses, SecurityToken $token) {
- throw new Exception("XML batch not supported");
+ throw new \Exception("XML batch not supported");
}
/**
@@ -99,7 +105,7 @@ class OutputXmlConverter extends OutputC
* @return DOMDocument
*/
private function createXmlDoc() {
- $this->doc = new DOMDocument(self::$xmlVersion, self::$charSet);
+ $this->doc = new \DOMDocument(self::$xmlVersion, self::$charSet);
$this->doc->formatOutput = self::$formatOutput;
return $this->doc;
}
@@ -117,12 +123,12 @@ class OutputXmlConverter extends OutputC
/**
* Recursive function that maps an data array or object to it's xml represantation
*
- * @param DOMElement $element the element to append the new node(s) to
+ * @param DOMElement $element the element to append the new \node(s) to
* @param string $name the name of the to be created node
* @param array or object $data the data to map to xml
* @return DOMElement returns newly created element
*/
- private function addData(DOMElement $element, $name, $data) {
+ private function addData(\DOMElement $element, $name, $data) {
return OutputBasicXmlConverter::addData($this->doc, $element, $name, $data);
}
}
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Account.php (from r1186446, shindig/trunk/php/src/social/model/Account.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Account.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Account.php&p1=shindig/trunk/php/src/social/model/Account.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/model/Account.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Account.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\model;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Copied: shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Activity.php (from r1186446, shindig/trunk/php/src/social/model/Activity.php)
URL: http://svn.apache.org/viewvc/shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Activity.php?p2=shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Activity.php&p1=shindig/trunk/php/src/social/model/Activity.php&r1=1186446&r2=1190083&rev=1190083&view=diff
==============================================================================
--- shindig/trunk/php/src/social/model/Activity.php (original)
+++ shindig/branches/php_namespace_refactoring/php/src/apache/shindig/social/model/Activity.php Thu Oct 27 23:20:41 2011
@@ -1,4 +1,6 @@
<?php
+namespace apache\shindig\social\model;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file