This adds initial support for the new invalidation service, and contains the
[shindig.git] / php / src / gadgets / Gadget.php
blob2ba4c38d05d8b0a9169ccc6bbd9cecd36c8cd81b
1 <?php
2 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
21 class Gadget {
22 const DEFAULT_VIEW = 'profile';
24 /**
25 * @var GadgetSpec
27 public $gadgetSpec;
29 public $features;
30 public $substitutions;
31 public $rightToLeft;
33 /**
34 * @var GadgetContext
36 public $gadgetContext;
38 public function __construct(GadgetSpec $gadgetSpec, GadgetContext $gadgetContext) {
39 $this->gadgetSpec = $gadgetSpec;
40 $this->gadgetContext = $gadgetContext;
43 public function getView($viewName) {
44 if (isset($this->gadgetSpec->views[$viewName])) {
45 return $this->gadgetSpec->views[$viewName];
46 } elseif (isset($this->gadgetSpec->views[self::DEFAULT_VIEW])) {
47 return $this->gadgetSpec->views[self::DEFAULT_VIEW];
48 } else {
49 // see if there's any empty entries, we'll use that as default then (old iGoogle style)
50 foreach ($this->gadgetSpec->views as $view) {
51 if (empty($view['view'])) {
52 return $view;
56 throw new GadgetException("Invalid view specified for this gadget");
59 /**
60 * @return unknown
62 public function getAuthor() {
63 return $this->substitutions->substitute($this->gadgetSpec->author);
66 /**
67 * @return unknown
69 public function getAuthorAboutme() {
70 return $this->substitutions->substitute($this->gadgetSpec->authorAboutme);
73 /**
74 * @return unknown
76 public function getAuthorAffiliation() {
77 return $this->substitutions->substitute($this->gadgetSpec->authorAffiliation);
80 /**
81 * @return unknown
83 public function getAuthorEmail() {
84 return $this->substitutions->substitute($this->gadgetSpec->authorEmail);
87 /**
88 * @return unknown
90 public function getAuthorLink() {
91 return $this->substitutions->substitute($this->gadgetSpec->authorLink);
94 /**
95 * @return unknown
97 public function getAuthorLocation() {
98 return $this->substitutions->substitute($this->gadgetSpec->authorLocation);
102 * @return unknown
104 public function getAuthorPhoto() {
105 return $this->substitutions->substitute($this->gadgetSpec->authorPhoto);
109 * @return unknown
111 public function getAuthorQuote() {
112 return $this->substitutions->substitute($this->gadgetSpec->authorQuote);
116 * @return unknown
118 public function getCategory() {
119 return $this->substitutions->substitute($this->gadgetSpec->category);
123 * @return unknown
125 public function getCategory2() {
126 return $this->substitutions->substitute($this->gadgetSpec->category2);
130 * @return unknown
132 public function getChecksum() {
133 return $this->gadgetSpec->checksum;
137 * @return unknown
139 public function getDescription() {
140 return $this->substitutions->substitute($this->gadgetSpec->description);
144 * @return unknown
146 public function getDirectoryTitle() {
147 return $this->substitutions->substitute($this->gadgetSpec->directoryTitle);
151 * @return unknown
153 public function getHeight() {
154 return $this->substitutions->substitute($this->gadgetSpec->height);
158 * @return unknown
160 public function getIcon() {
161 return $this->substitutions->substitute($this->gadgetSpec->icon);
165 * @return unknown
167 public function getLinks() {
168 return $this->gadgetSpec->links;
172 * @return unknown
174 public function getLocales() {
175 return $this->gadgetSpec->locales;
179 * @return unknown
181 public function getOptionalFeatures() {
182 return $this->gadgetSpec->optionalFeatures;
186 * @return unknown
188 public function getPreloads() {
189 return $this->gadgetSpec->preloads;
193 * @return unknown
195 public function getRenderInline() {
196 return $this->substitutions->substitute($this->gadgetSpec->renderInline);
200 * @return unknown
202 public function getRequiredFeatures() {
203 return $this->substitutions->substitute($this->gadgetSpec->requiredFeatures);
207 * @return unknown
209 public function getScaling() {
210 return $this->substitutions->substitute($this->gadgetSpec->scaling);
214 * @return unknown
216 public function getScreenshot() {
217 return $this->substitutions->substitute($this->gadgetSpec->screenshot);
221 * @return unknown
223 public function getScrolling() {
224 return $this->substitutions->substitute($this->gadgetSpec->scrolling);
228 * @return unknown
230 public function getShowInDirectory() {
231 return $this->substitutions->substitute($this->gadgetSpec->showInDirectory);
235 * @return unknown
237 public function getShowStats() {
238 return $this->substitutions->substitute($this->gadgetSpec->showStats);
242 * @return unknown
244 public function getSingleton() {
245 return $this->substitutions->substitute($this->gadgetSpec->singleton);
249 * @return unknown
251 public function getString() {
252 return $this->substitutions->substitute($this->gadgetSpec->string);
256 * @return unknown
258 public function getThumbnail() {
259 return $this->substitutions->substitute($this->gadgetSpec->thumbnail);
263 * @return unknown
265 public function getTitle() {
266 return $this->substitutions->substitute($this->gadgetSpec->title);
270 * @return unknown
272 public function getTitleUrl() {
273 return $this->substitutions->substitute($this->gadgetSpec->titleUrl);
277 * @return unknown
279 public function getUserPrefs() {
280 return $this->gadgetSpec->userPrefs;
284 * @return unknown
286 public function getWidth() {
287 return $this->substitutions->substitute($this->gadgetSpec->width);
291 * @param unknown_type $author
293 public function setAuthor($author) {
294 $this->gadgetSpec->author = $author;
298 * @param unknown_type $authorAboutme
300 public function setAuthorAboutme($authorAboutme) {
301 $this->gadgetSpec->authorAboutme = $authorAboutme;
305 * @param unknown_type $authorAffiliation
307 public function setAuthorAffiliation($authorAffiliation) {
308 $this->gadgetSpec->authorAffiliation = $authorAffiliation;
312 * @param unknown_type $authorEmail
314 public function setAuthorEmail($authorEmail) {
315 $this->gadgetSpec->authorEmail = $authorEmail;
319 * @param unknown_type $authorLink
321 public function setAuthorLink($authorLink) {
322 $this->gadgetSpec->authorLink = $authorLink;
326 * @param unknown_type $authorLocation
328 public function setAuthorLocation($authorLocation) {
329 $this->gadgetSpec->authorLocation = $authorLocation;
333 * @param unknown_type $authorPhoto
335 public function setAuthorPhoto($authorPhoto) {
336 $this->gadgetSpec->authorPhoto = $authorPhoto;
340 * @param unknown_type $authorQuote
342 public function setAuthorQuote($authorQuote) {
343 $this->gadgetSpec->authorQuote = $authorQuote;
347 * @param unknown_type $category
349 public function setCategory($category) {
350 $this->gadgetSpec->category = $category;
354 * @param unknown_type $category2
356 public function setCategory2($category2) {
357 $this->gadgetSpec->category2 = $category2;
361 * @param unknown_type $checksum
363 public function setChecksum($checksum) {
364 $this->gadgetSpec->checksum = $checksum;
368 * @param unknown_type $description
370 public function setDescription($description) {
371 $this->gadgetSpec->description = $description;
375 * @param unknown_type $directoryTitle
377 public function setDirectoryTitle($directoryTitle) {
378 $this->gadgetSpec->directoryTitle = $directoryTitle;
382 * @param unknown_type $height
384 public function setHeight($height) {
385 $this->gadgetSpec->height = $height;
389 * @param unknown_type $icon
391 public function setIcon($icon) {
392 $this->gadgetSpec->icon = $icon;
396 * @param unknown_type $links
398 public function setLinks($links) {
399 $this->gadgetSpec->links = $links;
403 * @param unknown_type $locales
405 public function setLocales($locales) {
406 $this->gadgetSpec->locales = $locales;
410 * @param unknown_type $optionalFeatures
412 public function setOptionalFeatures($optionalFeatures) {
413 $this->gadgetSpec->optionalFeatures = $optionalFeatures;
417 * @param unknown_type $preloads
419 public function setPreloads($preloads) {
420 $this->gadgetSpec->preloads = $preloads;
424 * @param unknown_type $renderInline
426 public function setRenderInline($renderInline) {
427 $this->gadgetSpec->renderInline = $renderInline;
431 * @param unknown_type $requiredFeatures
433 public function setRequiredFeatures($requiredFeatures) {
434 $this->gadgetSpec->requiredFeatures = $requiredFeatures;
438 * @param unknown_type $scaling
440 public function setScaling($scaling) {
441 $this->gadgetSpec->scaling = $scaling;
445 * @param unknown_type $screenshot
447 public function setScreenshot($screenshot) {
448 $this->gadgetSpec->screenshot = $screenshot;
452 * @param unknown_type $scrolling
454 public function setScrolling($scrolling) {
455 $this->gadgetSpec->scrolling = $scrolling;
459 * @param unknown_type $showInDirectory
461 public function setShowInDirectory($showInDirectory) {
462 $this->gadgetSpec->showInDirectory = $showInDirectory;
466 * @param unknown_type $showStats
468 public function setShowStats($showStats) {
469 $this->gadgetSpec->showStats = $showStats;
473 * @param unknown_type $singleton
475 public function setSingleton($singleton) {
476 $this->gadgetSpec->singleton = $singleton;
480 * @param unknown_type $string
482 public function setString($string) {
483 $this->gadgetSpec->string = $string;
487 * @param unknown_type $thumbnail
489 public function setThumbnail($thumbnail) {
490 $this->gadgetSpec->thumbnail = $thumbnail;
494 * @param unknown_type $title
496 public function setTitle($title) {
497 $this->gadgetSpec->title = $title;
501 * @param unknown_type $titleUrl
503 public function setTitleUrl($titleUrl) {
504 $this->gadgetSpec->titleUrl = $titleUrl;
508 * @param unknown_type $userPrefs
510 public function setUserPrefs($userPrefs) {
511 $this->gadgetSpec->userPrefs = $userPrefs;
515 * @param unknown_type $width
517 public function setWidth($width) {
518 $this->gadgetSpec->width = $width;