CMS  Version 3.9
image_gallery.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 class ImageGallery extends DataItem
40 {
41  // Fields
42 
43  var $fields = array("gallery_id" => Number,
44  "gallery_name" => String,
45  "identifier" => String,
46  "description" => HTML,
47  "keywords" => String,
48  "thumbnail_size" => Number,
49  "thumbnail_format" => String,
50  "image_link_mode" => String,
51  "fix_orientation" => Boolean,
52  "randomize_filenames" => Boolean,
53  "hidden" => Boolean,
54  "owner_id" => Number,
55  "read_access" => String,
56  "write_access" => String,
57  "published" => Boolean,
58  "last_modified" => Timestamp);
59 
60  // Relations
61 
62  var $relations = array( "Images" => ImageRecord,
63  "Owner" => "");
64 
65  static $imageLinkModes = array("None" => "No Resource Link",
66  "Thumbnail" => "Link from Thumbnail",
67  "Lightbox" => "Link from Lightbox");
68 
69  static $thumbnailFormats = array("" => "Use Default",
70  "png" => "PNG",
71  "jpg" => "JPEG");
72 
73  function Images($constraint = "")
74  {
75  return $this->getRelatedList(ImageRecord, "", $constraint);
76  }
77 
78  function Owner()
79  {
80  $mgr = new UserManager();
81  return $mgr->getUser($this->owner_id);
82  }
83 
84  function getOwnerName()
85  {
86  return $this->Owner()->getFullName();
87  }
88 
89  function getThumbnailFormat()
90  {
91  return ($this->thumbnail_format) ? $this->thumbnail_format : Settings::getValue("image", "thumbnail_format");
92  }
93 
94  function countImages($constraint = "")
95  {
96  if ($constraint)
97  {
98  $constraint .= " AND ";
99  }
100  else
101  {
102  $constraint = "WHERE ";
103  }
104  $constraint .= "gallery_id={$this->gallery_id}";
105  return queryValue(ImageRecord, "COUNT(1)", $constraint);
106  }
107 
109  {
110  global $config;
111 
112  return $config['uploadbase'] . DIRECTORY_SEPARATOR . "gallery_{$this->gallery_id}";
113  }
114 
115  static function findByIdentifier($identifier)
116  {
117  $match = Query::create(ImageGallery, "WHERE identifier=:id")
118  ->bind(":id", $identifier)
119  ->executeSingle();
120 
121  return $match;
122  }
123 
124  function ImageGallery()
125  {
126  $this->primary_key = "gallery_id";
127  $this->table = "image_gallery";
128 
129  // Patch in the user class, since this can be overridden by the application
130  $mgr = new UserManager();
131  $this->relations["Owner"] = $mgr->getUserClass();
132 
133  $this->default_format = "{gallery_name}";
134 
135  $this->DataItem(func_get_args());
136  }
137 }
138 ?>
$constraint
$calendar owner_id
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
Provides the interface to the user model for the application.
global $config
Definition: import.inc:4
$identifier
Definition: rss.inc:37