Author: chabotc
Date: Wed Nov 12 16:49:28 2008
New Revision: 713585
URL: http://svn.apache.org/viewvc?rev=713585&view=rev
Log:
SHINDIG-683 by Eiji Kitamura - Supporting Icon and required on UserPref
Added:
incubator/shindig/trunk/php/src/gadgets/Icon.php
Modified:
incubator/shindig/trunk/php/src/gadgets/Gadget.php
incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php
Modified: incubator/shindig/trunk/php/src/gadgets/Gadget.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/Gadget.php?rev=713585&r1=713584&r2=713585&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/Gadget.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/Gadget.php Wed Nov 12 16:49:28 2008
@@ -64,6 +64,7 @@
public $scrolling;
public $views = array();
public $links = array();
+ public $icons = array();
public function __construct($id = false, $context)
{
@@ -298,6 +299,11 @@
return false;
}
+ public function getIcons()
+ {
+ return $this->icons;
+ }
+
public function getViews()
{
return $this->views;
@@ -333,5 +339,3 @@
return $this->checksum;
}
}
-
-
Modified: incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php?rev=713585&r1=713584&r2=713585&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php Wed Nov 12
16:49:28 2008
@@ -69,7 +69,9 @@
foreach ($doc->ModulePrefs->Optional as $feature) {
$this->processFeature($gadget, $feature, false);
}
- //TODO Parse icons
+ foreach ($doc->ModulePrefs->Icon as $icon) {
+ $this->processIcon($gadget, $icon);
+ }
return $gadget;
}
@@ -168,6 +170,7 @@
$preference->name = trim($attributes['name']);
$preference->displayName = isset($attributes['display_name']) ?
$gadget->getSubstitutions()->substitute(trim($attributes['display_name'])) : '';
// if its set -and- in our valid 'enum' of types, use it,
otherwise assume STRING, to try and emulate java's enum behavior
+ $preference->required = isset($attributes['required']) ?
$gadget->getSubstitutions()->substitute(trim($attributes['required'])) :
'false';
$preference->dataType = isset($attributes['datatype']) &&
in_array(strtoupper($attributes['datatype']), $preference->DataTypes) ?
strtoupper($attributes['datatype']) : 'STRING';
$preference->defaultValue = isset($attributes['default_value'])
? $gadget->getSubstitutions()->substitute(trim($attributes['default_value'])) :
'';
if (isset($pref->EnumValue)) {
@@ -228,6 +231,16 @@
$gadget->requires[$featureSpec->name] = $featureSpec;
}
+ private function processIcon(Gadget &$gadget, $icon)
+ {
+ $attributes = $icon->attributes();
+ $iconSpec = new Icon();
+ $iconSpec->content = (string)(trim($icon));
+ $iconSpec->mode = isset($attributes['mode']) ?
trim($attributes['mode']) : '';
+ $iconSpec->type = isset($attributes['type']) ?
trim($attributes['type']) : '';
+ $gadget->icons[] = $iconSpec;
+ }
+
private function processOAuthSpec(Gadget &$gadget, $OAuthSpec)
{
$oauthSpec = new OAuthSpec($OAuthSpec->Service);
Added: incubator/shindig/trunk/php/src/gadgets/Icon.php
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/Icon.php?rev=713585&view=auto
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/Icon.php (added)
+++ incubator/shindig/trunk/php/src/gadgets/Icon.php Wed Nov 12 16:49:28 2008
@@ -0,0 +1,40 @@
+<?php
+/*
+ * 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 Icon {
+ public $content;
+ public $mode;
+ public $type;
+
+ public function getContent()
+ {
+ return $this->content;
+ }
+
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+}