CMS  Version 3.9
video_list_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 $id;
42  var $videos;
44  var $spacing = 0;
45  var $styles;
46  var $titleFormat = "{title}";
47  var $onClick;
48 
49  function VideoListView($videos, $linkFormat, $id = "videos", $titleFormat = "", $onClick = "")
50  {
51  $this->id = $id;
52  $this->videos = $videos;
53  $this->linkFormat = $linkFormat;
54  $this->titleFormat = ($titleFormat) ? $titleFormat : "{title}";
55  $this->onClick = $onClick;
56  }
57 
58  function writeScript()
59  {
60  global $script;
61  $script .= <<<ENDSCRIPT
62  <script type="text/javascript">
63  window.addEvent('domready', function()
64  {
65  $$(".videoGrid a").each(function(elt)
66  {
67  elt.addEvents(
68  {
69  'mouseover': function()
70  {
71  this.morph({'background-color': '#A9CDED', 'border-color': '#666666'});
72  }.bind(elt),
73  'mouseout': function()
74  {
75  this.morph({'background-color': '#eeeeff', 'border-color': '#cccccc'});
76  }.bind(elt)
77  });
78  });
79  });
80  </script>
81 ENDSCRIPT;
82 
83  return $script;
84  }
85 
86  function drawGrid()
87  {
88  $imgMgr = new VideoManager();
89 
90  $this->writeScript();
91 ?>
92  <ul class="videoGrid" id="<?echo $this->id?>"<?if ($this->styles) echo " style='{$this->styles}'";?>>
93  <?
94 
95  foreach($this->videos as $video)
96  {
97  $thumb = $imgMgr->thumbnailLink($video->get("video_id"), 125);
98  $link = $video->format($this->linkFormat);
99  $onClick = $video->format($this->onClick);
100 
101  if (is_callable($this->titleFormat))
102  $caption = call_user_func($this->titleFormat, $video);
103  else
104  $caption = $video->format($this->titleFormat);
105 
106  ?>
107  <li><div class="videoLink"<?if ($this->spacing) echo " style='margin: {$this->spacing}'";?>><a href="<?echo $link?>"<? if ($onClick) echo " onClick=\"$onClick\""; ?>>
108  <span class="wrapVideo"><img src="<?echo $thumb ?> " alt="Small version of video"/></span>
109  <span class="caption"><?echo $caption ?></span></a>
110  </div></li>
111  <?
112  }
113  ?>
114  </ul>
115  <?
116  }
117 
118  static function writeResizeScript()
119  {
120 
121  $script .= <<<ENDSCRIPT
122 <script type="text/javascript">
123 window.addEvent('domready', function() { document.id('videos_box').resizable(); });
124 </script>
125 ENDSCRIPT;
126 
127  return $script;
128  }
129 
130 }
131 
132 
133 
135 {
136  var $table;
137  var $link;
138 
139  function VideoGalleryListView($gallery, $link = "video_form?video_id={video_id}")
140  {
141  $videos = $gallery->Videos("ORDER BY title");
142  $this->link = $link;
143 
144  $this->table = $this->buildTable($videos);
145  }
146 
147  function buildTable($videos)
148  {
149 
150  $table = new DataListView($videos, "videos");
151  $table->column("Title", "<a href='{$this->link}'>{title}</a>", true, "width: 50%")
152  ->column("Video File", "{video_file}", true, "width: 50%");
153  $table->emptyMessage = "No videos have been added to this gallery";
154  $table->pageSize = 20;
155  $table->sortable = true;
156  $table->filter = true;
157 
158  return $table;
159  }
160 
161  function writeScript()
162  {
163  return $this->table->writeScript();
164  }
165 
166  function drawView()
167  {
168  $this->table->drawView();
169  }
170 }
171 ?>
static writeResizeScript()
VideoListView($videos, $linkFormat, $id="videos", $titleFormat="", $onClick="")
$view styles
$view spacing
$video
Definition: video_form.inc:42
$videos
Definition: videos.inc:40