CMS  Version 3.9
video_gallery_view.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 
40 {
41  var $listView;
42  var $id;
43 
44  var $videos;
46  var $spacing = 0;
47  var $styles;
48  var $onClick;
49 
51  {
52  $this->id = $id;
53  $this->listView = new VideoListView($videos, $linkFormat, $id . "_listView", "", $onClick);
54  }
55 
56  function drawGallery()
57  {
58  global $script;
59 
60  $script .= <<<ENDSCRIPT
61  <script type="text/javascript" src="/components/video/js/video_gallery.js"></script>
62  <script type="text/javascript">
63  var gallery;
64  window.addEvent('domready', function()
65  {
66  gallery = new VideoGallery('$this->id');
67  });
68  </script>
69 ENDSCRIPT;
70 
71  $width = intval((count($this->listView->videos) / 2) + 1) * 185;
72  $this->listView->styles="position: absolute; width: {$width}px";
73  $this->listView->spacing = $this->spacing;
74 
75 ?>
76 <div>
77 <div id="<?echo $this->id?>_left" style="width: 32px; float: left;<?echo $this->styles?>"><img id="<?echo $this->id?>_scroll_left" src="/components/video/images/scroll_left.png" style="margin-top: 160px"/>&nbsp;</div>
78 <div id="<?echo $this->id?>" style="width: 560px; height: 450px; position: relative; overflow: hidden; float: left">
79 <?
80  $this->listView->drawGrid();
81 ?>
82 </div>
83 <div id="<?echo $this->id?>_right" style="width: 32px; float: left"><img id="<?echo $this->id?>_scroll_right" src="/components/video/images/scroll_right.png" style="margin-top: 160px"/>&nbsp;</div>
84 </div>
85 <?
86  }
87 }
88 
89 
91 {
94  var $id;
96 
97  function VideoGalleryList($galleries, $linkFormat, $id = "galleries")
98  {
99  $this->galleries = $galleries;
100  $this->linkFormat = $linkFormat;
101 
102  $this->id = $id;
103  $this->galleryView = new VideoGalleryView($this->collateVideos(), $this->linkFormat, $this->id);
104  $this->galleryView->listView->titleFormat = "{Gallery.gallery_name}";
105  }
106 
107  function collateVideos()
108  {
109  $this->videos = array();
110 
111  if (count($this->galleries) == 0) return;
112 
113  $ids = formatItems($this->galleries, "{gallery_id}", ", ");
114  $groupedVideos = GroupedQuery::create(Video, "WHERE gallery_id IN (". $ids .") AND published=1", "gallery_id")
115  ->execute();
116 
117  foreach($groupedVideos as $gallery_id => $videos)
118  {
119  $this->videos[] = $videos[0];
120  }
121 
122  return $this->videos;
123  }
124 
125  function drawGallery()
126  {
127  if (count($this->videos) == 0)
128  {
129  echo "<p>No videos have been published on this site.</p>";
130  return;
131  }
132 
133  $this->galleryView->drawGallery();
134  }
135 
136  function drawList()
137  {
138  if (count($this->videos) == 0)
139  {
140  echo "<p>No videos have been published on this site.</p>";
141  return;
142  }
143 
144  $this->galleryView->listView->drawGrid();
145  }
146 }
147  ?>
& nbsp
Definition: index.inc:49
$helpTree style
Definition: tree.inc:46
$gallery_id
Definition: image_form.inc:42
Definition: video.inc:42
$width
Definition: cover.inc:37
$videos
Definition: videos.inc:40