Author: chabotc Date: Sun Jun 8 04:32:33 2008 New Revision: 664484 URL: http://svn.apache.org/viewvc?rev=664484&view=rev Log: Fixes views in metadata and adds SHINDIG-354 - Links in ModulePrefs
Added: incubator/shindig/trunk/php/src/gadgets/LinkSpec.php Modified: incubator/shindig/trunk/php/src/gadgets/Gadget.php incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php incubator/shindig/trunk/php/src/gadgets/JsonRpcHandler.php incubator/shindig/trunk/php/src/gadgets/LocaleSpec.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=664484&r1=664483&r2=664484&view=diff ============================================================================== --- incubator/shindig/trunk/php/src/gadgets/Gadget.php (original) +++ incubator/shindig/trunk/php/src/gadgets/Gadget.php Sun Jun 8 04:32:33 2008 @@ -63,6 +63,7 @@ public $scaling; public $scrolling; public $views = array(); + public $links = array(); public function __construct($id = false, $context) { @@ -286,6 +287,21 @@ $this->messageBundle = $messageBundle; } + public function getLinks() + { + return $this->links; + } + + public function getLink($rel) + { + foreach ($this->links as $link) { + if ($link->getRel() == $rel) { + return $link; + } + } + return false; + } + public function getViews() { return $this->views; Modified: incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php?rev=664484&r1=664483&r2=664484&view=diff ============================================================================== --- incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php (original) +++ incubator/shindig/trunk/php/src/gadgets/GadgetSpecParser.php Sun Jun 8 04:32:33 2008 @@ -89,10 +89,22 @@ $gadget->renderInline = isset($attributes['render_inline']) ? trim($attributes['render_inline']) : ''; $gadget->scaling = isset($attributes['scaling']) ? trim($attributes['scaling']) : ''; $gadget->scrolling = isset($attributes['scrolling']) ? trim($attributes['scrolling']) : ''; + foreach ($ModulePrefs->Link as $link) { + $gadget->links[] = $this->processLink($link); + } foreach ($ModulePrefs->Locale as $locale) { $gadget->localeSpecs[] = $this->processLocale($locale, $context); } } + + private function processLink($link) + { + $attributes = $link->attributes(); + $rel = isset($attributes['rel']) ? trim($attributes['rel']) : ''; + $href = isset($attributes['href']) ? trim($attributes['href']) : ''; + $link = new LinkSpec($rel, $href); + return $link; + } private function processLocale($locale, $context) { Modified: incubator/shindig/trunk/php/src/gadgets/JsonRpcHandler.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/JsonRpcHandler.php?rev=664484&r1=664483&r2=664484&view=diff ============================================================================== --- incubator/shindig/trunk/php/src/gadgets/JsonRpcHandler.php (original) +++ incubator/shindig/trunk/php/src/gadgets/JsonRpcHandler.php Sun Jun 8 04:32:33 2008 @@ -33,23 +33,25 @@ } $views = array(); + foreach ($gadget->getViews() as $view) { + // we want to include all information, except for the content + unset($view->content); + $views[$view->getName()] = $view; + } + + $links = array(); + foreach ($gadget->links as $link) { + $links[] = $link; + } //TODO add views and actual iframe url $response['showInDirectory'] = $gadget->getShowInDirectory(); + $response['links'] = $links; $response['width'] = $gadget->getWidth(); $response['title'] = $gadget->getTitle(); $response['singleton'] = $gadget->getSingleton(); $response['categories'] = Array($gadget->getCategory(), $gadget->getCategory2()); - $response['views'] = ''; - /*stdClass Object - ( - $response['default'] = stdClass Object - ( - $response['type'] = html - $response['quirks'] = 1 - ) - - )*/ + $response['views'] = $views; $response['description'] = $gadget->getDescription(); $response['screenshot'] = $gadget->getScreenShot(); $response['thumbnail'] = $gadget->getThumbnail(); Added: incubator/shindig/trunk/php/src/gadgets/LinkSpec.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/LinkSpec.php?rev=664484&view=auto ============================================================================== --- incubator/shindig/trunk/php/src/gadgets/LinkSpec.php (added) +++ incubator/shindig/trunk/php/src/gadgets/LinkSpec.php Sun Jun 8 04:32:33 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 LinkSpec { + public $rel; + public $href; + + public function __construct($rel, $href) + { + $this->rel = $rel; + $this->href = $href; + } + + public function getRel() + { + return $this->rel; + } + + public function getHref() + { + return $this->href; + } +} \ No newline at end of file Modified: incubator/shindig/trunk/php/src/gadgets/LocaleSpec.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/LocaleSpec.php?rev=664484&r1=664483&r2=664484&view=diff ============================================================================== --- incubator/shindig/trunk/php/src/gadgets/LocaleSpec.php (original) +++ incubator/shindig/trunk/php/src/gadgets/LocaleSpec.php Sun Jun 8 04:32:33 2008 @@ -24,7 +24,8 @@ public $rightToLeft; public $localeMessageBundles = array(); - public function getLocaleMessageBundles() { + public function getLocaleMessageBundles() + { return $this->localeMessageBundles; }