CMS  Version 3.9
slideshow.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::using("image");
40 
50 class Slideshow
51 {
52  var $items;
53  var $width;
54  var $height;
55  var $showInfo;
58  var $autoPlay;
59  var $preload;
60 
61  function Slideshow($items, $width=500, $height=400)
62  {
63  // If we were passed a single item, wrap it in an array
64  if (!is_array($items))
65  {
66  $items = array($items);
67  }
68 
69  $this->items = $items;
70 
71  $this->width = $width;
72  $this->height = $height;
73 
74  $this->showControls = true;
75  $this->showInfo = true;
76  $this->showThumbnails = true;
77  $this->autoPlay = false;
78  $this->preload = true;
79  }
80 
81  function add($items)
82  {
83  if (is_array($items))
84  {
85  $this->items[] = array_filter($items, validURL);
86  }
87  else
88  {
89  if (validURL($items)) $this->items[] = $items;
90  }
91  }
92 
93  function writeScript()
94  {
95  $mgr = new ImageManager();
96  global $config;
97 
98  ob_start();
99 ?>
100 <!--[if IE]>
101 <link rel="stylesheet" type="text/css" href="/fakoli/slideshow/ie.css"/>
102 <![endif]-->
103 
104 <script type="text/javascript"><!--
105 /* <![CDATA[ */
106 
107 window.addEvent('domready', function() {
108 
109  var slideshow = new Slideshow({preload: <?echo $this->preload ? "true" : "false"?>, showThumbnails: <?echo $this->showThumbnails ? "true" : "false"?>, showInfo: <?echo $this->showInfo ? "true" : "false" ?>, autoPlay: <?echo $this->autoPlay ? "true" : "false"?>});
110 
111  slideshow.thumbnails = [
112 <?
113  $thumbs = array();
114  foreach($this->items as $item)
115  {
116  $thumbs[] = "'http://".$config['http_host'].$mgr->thumbnailLink($item->image_id, 100)."'";
117  }
118 
119  echo implode(", ", $thumbs);
120 ?>
121  ];
122 
123  slideshow.images = [
124 <?
125  $images = array();
126  foreach($this->items as $item)
127  {
128  $images[] = "'http://".$config['http_host'].$mgr->imageLink($item->image_id)."'";
129  }
130 
131  echo implode(", ", $images);
132 ?>
133  ];
134 
135  slideshow.captions = [
136 <?
137 $first = true;
138 foreach($this->items as $item)
139 {
140  if (!$first) echo ", ";
141 ?>
142  "<?echo jsSafe(trim($item->getCaption())) ?>"
143 <?
144  $first = false;
145 }
146 ?>
147  ];
148 
149  slideshow.credits = [
150 <?
151 $first = true;
152 foreach($this->items as $item)
153 {
154  if (!$first) echo ", ";
155 ?>
156  "<i><? echo jsSafe(trim($item->getShortCredit())) ?></i>"
157 <?
158  $first = false;
159 }
160 ?>
161  ];
162 
163  slideshow.load();
164 });
165 
166 
167 //
168 
169 /* ]]> */
170 --></script>
171 <?
172  $script = ob_get_contents();
173  ob_end_clean();
174 
175  return $script;
176  }
177 
178  function writeHTML()
179  {
180 ?>
181  <div id="progress">
182  <div class="text"></div>
183  <div class="border"><div class="bar">&nbsp;</div><div id="progress_count"></div></div>
184  </div>
185 <table id="slideshow" cellpadding="0" cellspacing="0" style="width: <? echo $this->width ?>px;">
186  <tr>
187  <td colspan="3">
188  <div id="viewport" style="height: <?echo $this->height ?>px">
189  <div id="gallery" style="height: <?echo $this->height ?>px">
190  <div id="zoom_overlay" style="left: <? echo $this->width - 40 ?>px">
191  <table id="zoomer" cellpadding="0" cellspacing="0">
192  <tr>
193  <td id="zoom_in"></td>
194  </tr>
195  <tr>
196  <td id="zoom_slider">
197  <div id="zoom_scale">
198  <div id="zoom_thumb"><img src="/fakoli/slideshow/images/zoom_thumb.gif" width="24" height="12" alt="" style="display: block;"/></div>
199  </div>
200  </td>
201  </tr>
202  <tr>
203  <td id="zoom_out"></td>
204  </tr>
205  </table>
206  </div>
207  </div>
208  </div>
209  </td>
210  </tr>
211  <tr<? if (!$this->showControls) echo " style='display:none'"; ?>>
212  <td colspan="3" id="controlbar"><div id="play_button" class="play">&nbsp;</div><div id="info_button" class="info">&nbsp;</div><span id="caption">&nbsp;</span></td>
213  </tr>
214  <tr<? if (!$this->showControls) echo " style='display:none'"; ?>>
215  <td colspan="3" id="credit">&nbsp;<span id="creditText"></span></td>
216  </tr>
217 </table>
218 <table cellpadding="0" cellspacing="0">
219 <tr>
220 <td>
221 <table id="thumbnails" cellpadding="0" cellspacing="0" style="width:<? echo $this->width."px"; if (!$this->showThumbnails) echo "; display:none"; ?>">
222  <tr>
223  <td id="scroll_left"></td>
224  <td id="strip">
225  <div id="thumbnail_strip" style="width: <? echo $this->width - 46 ?>px">
226  <div id="thumbnail_scroll"><div id="thumbnail_highlight"></div></div>
227  </div>
228  </td>
229  <td id="scroll_right"></td>
230  </tr>
231 </table>
232 </td>
233 </tr>
234 </table>
235 <?
236  }
237 }?>
& nbsp
Definition: index.inc:49
$helpTree style
Definition: tree.inc:46
$helpTree width
Definition: tree.inc:45
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
The ImageManager class provides basic Image manipulation functions that are useful when working with ...
The Slideshow class provides a reusable user interface control that displays images from the database...
Definition: slideshow.inc:51
add($items)
Definition: slideshow.inc:81
writeScript()
Definition: slideshow.inc:93
Slideshow($items, $width=500, $height=400)
Definition: slideshow.inc:61
$desc height
Definition: event_edit.inc:64
$topicList colspan
Definition: group_form.inc:54
global $config
Definition: import.inc:4
$images
Definition: slideshow.inc:44
$script
Definition: slideshow.inc:48