CMS  Version 3.9
image.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 
40 class ImageRecord extends DataItem
41 {
42  // Fields
43  var $fields = array("image_id" => Number,
44  "title" => String,
45  "image_file" => String,
46  "ALT_tag" => String,
47  "date_taken" => Date,
48  "credits" => String,
49  "caption" => String,
50  "keywords" => String,
51  "related_resource" => String,
52  "published" => Boolean,
53  "include_in_slideshow" => Boolean,
54  "sort_order" => Number,
55  "image_type" => String,
56  "gallery_id" => Number,
57  "owner_id" => Number
58  );
59 
60  // Relations
61 
62  var $relations = array(
63  "Gallery" => ImageGallery,
64  "Owner" => "",
65  );
66 
67  function Gallery()
68  {
69  return $this->getRelated(ImageGallery);
70  }
71 
72  function ImageRecord()
73  {
74  $this->table = "image";
75  $this->primary_key = "image_id";
76 
77  $this->default_format = "{title}";
78  $this->pretty_class_name = "Image";
79 
80  $this->DataItem(func_get_args());
81  }
82 
83  function formatThumbnail($width = 75, $height = 0)
84  {
85  $thumbnail = $this->getThumbnail();
86  $text = "<img src='$thumbnail' alt='".htmlSafe($this->title)."' border='0'";
87  if($width > 0)
88  {
89  $text .= " width='$width'";
90  }
91 
92  if ($height > 0)
93  {
94  $text .= " height='$height'";
95  }
96 
97  $text .= "/>";
98 
99  return $text;
100  }
101 
102  static function findByFileName($filename)
103  {
104  $images = Query::create(ImageRecord, "WHERE image_file=:f")
105  ->bind(":f", $filename)
106  ->execute();
107 
108  return (count($images) > 0) ? $images[0] : null;
109  }
110 
111  function getImage()
112  {
113  global $config;
114 
115  if ($img == "blank" || $img == "")
116  {
117  $img = "/fakoli/images/blank.gif";
118  }
119  else
120  {
121  $img = "/action/image/show?image_id={$this->image_id}";
122  }
123 
124  return $img;
125  }
126 
127  function isSVG()
128  {
129  return endsWith($this->image_file, ".svg");
130  }
131 
132  function getThumbnail($size = 0, $iconize = false)
133  {
134  $mgr = new ImageManager();
135  return $mgr->thumbnailLink($this->image_id, $size, $iconize);
136  }
137 
138  function getCaption()
139  {
140  return $this->title;
141  }
142 
143  function getShortCredit()
144  {
145  //this is used to create the correct citation for a library item
146  return $this->credits;
147  }
148 
149  function Owner()
150  {
151  $mgr = new UserManager();
152  return $mgr->getUser($this->owner_id);
153  }
154 
155  function isOwner()
156  {
157  global $user;
158  $owner = $this->Owner();
159 
160  return ($owner->user_id == $user->user_id) ? true : false;
161  }
162 
163 }?>
$calendar owner_id
$images
Definition: images.inc:46
$size
Definition: download.inc:47
$bookmark title
The ImageManager class provides basic Image manipulation functions that are useful when working with ...
Gallery()
Definition: image.inc:67
ImageRecord()
Definition: image.inc:72
getShortCredit()
Definition: image.inc:143
getCaption()
Definition: image.inc:138
formatThumbnail($width=75, $height=0)
Definition: image.inc:83
getThumbnail($size=0, $iconize=false)
Definition: image.inc:132
static findByFileName($filename)
Definition: image.inc:102
getImage()
Definition: image.inc:111
Provides the interface to the user model for the application.
global $user
$height
Definition: cover.inc:38
$width
Definition: cover.inc:37
global $config
Definition: import.inc:4
$table column("Redirect From", "<a href='redirect_form?redirect_id={redirect_id}'>{redirect_from}</a>", true, "width: 30%") -> column("Redirect To", "<a href='{redirect_to}' target='_blank'>{redirect_to}</a>", true, "width: 30%") ->column("Last Modified", "{last_modified}", true, "width: 20%; text-align: center") ->column("Override", "{ override true
Definition: redirects.inc:9
if(!Settings::getValue("debug", "enable_trace_file_downloads")) $filename
Definition: trace.inc:42