| [ PHPXref.com ] | [ Generated: Thu Aug 19 03:40:16 2010 ] | [ singapore 0.10.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Singapore gallery item class. 5 * 6 * @author Tamlyn Rhodes <tam at zenology dot co dot uk> 7 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License 8 * @copyright (c)2005-6 Tamlyn Rhodes 9 * @version $Id: item.class.php,v 1.10 2006/09/08 15:29:22 tamlyn Exp $ 10 */ 11 12 //permissions bit flags 13 define("SG_GRP_READ", 1); 14 define("SG_GRP_EDIT", 2); 15 define("SG_GRP_ADD", 4); 16 define("SG_GRP_DELETE", 8); 17 define("SG_WLD_READ", 16); 18 define("SG_WLD_EDIT", 32); 19 define("SG_WLD_ADD", 64); 20 define("SG_WLD_DELETE", 128); 21 define("SG_IHR_READ", 17); 22 define("SG_IHR_EDIT", 34); 23 define("SG_IHR_ADD", 68); 24 define("SG_IHR_DELETE", 136); 25 26 /** 27 * Abstract class from which sgImage and sgGallery are derived. 28 * 29 * @abstract 30 * @package singapore 31 * @author Tamlyn Rhodes <tam at zenology dot co dot uk> 32 * @copyright (c)2005-6 Tamlyn Rhodes 33 */ 34 class sgItem 35 { 36 /** 37 * The id of the item. In the case of galleries this is the path to the 38 * gallery from root and must be unique. For images it is the image file 39 * name (or URL for remote images). 40 * @var string 41 */ 42 var $id; 43 44 /** 45 * Username of the user to which the item belongs 46 * @var string 47 */ 48 var $owner = "__nobody__"; 49 50 /** 51 * Space-separated list of groups to which the item belongs 52 * @var string 53 */ 54 var $groups = ""; 55 56 /** 57 * Bit-field of permissions 58 * Default is to inherit everything. 59 * @var int 60 */ 61 var $permissions = 255; 62 63 /** 64 * Space-separated list of categories to which the item belongs (not used) 65 * @var string 66 */ 67 var $categories = ""; 68 69 /** 70 * The name or title of the item 71 * @var string 72 */ 73 var $name = ""; 74 75 /** 76 * The name of the original item creator (or anyone else) 77 * @var string 78 */ 79 var $artist = ""; 80 81 /** 82 * Email of the original item creator (or anyone else) 83 * @var string 84 */ 85 var $email = ""; 86 87 /** 88 * Optional copyright information 89 * @var string 90 */ 91 var $copyright = ""; 92 93 /** 94 * Multiline description of the item 95 * @var string 96 */ 97 var $desc = ""; 98 99 /** 100 * Date associated with item 101 * @var string 102 */ 103 var $date = ""; 104 105 var $location = ""; 106 107 /** 108 * Number of times item has been viewed 109 * @var int 110 */ 111 var $hits = 0; 112 113 /** 114 * Unix timestamp of last time item was viewed 115 * @var int 116 */ 117 var $lasthit = 0; 118 119 /** 120 * Pointer to the parent sgItem 121 * @var sgItem 122 */ 123 var $parent; 124 125 126 /** 127 * Reference to the current config object 128 * @var sgConfig 129 */ 130 var $config; 131 132 /** 133 * Reference to the current translator object 134 * @var Translator 135 */ 136 var $translator; 137 138 /** 139 * Array in which the various sized thumbnails representing this item are stored 140 * @var array 141 */ 142 var $thumbnails = array(); 143 144 /** Accessor methods */ 145 function name() { return $this->name; } 146 function artist() { return $this->artist; } 147 function date() { return $this->date; } 148 function location() { return $this->location; } 149 function description() { return $this->desc; } 150 151 function canEdit() { return false; } 152 153 function idEntities() { return htmlspecialchars($this->id); } 154 155 /** 156 * Removes script-generated HTML (BRs and URLs) but leaves any other HTML 157 * @return string the description of the item 158 */ 159 function descriptionStripped() 160 { 161 $ret = str_replace("<br />","\n",$this->description()); 162 163 if($this->config->enable_clickable_urls) { 164 //strip off html from autodetected URLs 165 $ret = preg_replace('{<a href="('.SG_REGEXP_PROTOCOLURL.')\">\1</a>}', '\1', $ret); 166 $ret = preg_replace('{<a href="http://('.SG_REGEXP_WWWURL.')">\1</a>}', '\1', $ret); 167 $ret = preg_replace('{<a href="mailto:('.SG_REGEXP_EMAILURL.')">\1</a>}', '\1', $ret); 168 } 169 170 return $ret; 171 } 172 173 /** 174 * If the current item has an artist specified, returns " by " followed 175 * by the artist's name. Otherwise returns an empty string. 176 * @return string 177 */ 178 function byArtistText() 179 { 180 if(empty($this->artist)) 181 return ""; 182 else 183 return " ".$this->translator->_g("artist name|by %s",$this->artist); 184 } 185 186 /** 187 * Obfuscates the given email address by replacing "." with "dot" and "@" with "at" 188 * @param boolean override the obfuscate_email config setting (optional) 189 * @return string obfuscated email address or HTML mailto link 190 */ 191 function emailLink($forceObfuscate = false) 192 { 193 if($this->config->obfuscate_email || $forceObfuscate) 194 return strtr($this->email,array("@" => ' <b>'.$this->translator->_g("email|at").'</b> ', "." => ' <b>'.$this->translator->_g("email|dot").'</b> ')); 195 else 196 return "<a href=\"mailto:".$this->email."\">".$this->email."</a>"; 197 } 198 199 function nameLink($action = null) 200 { 201 return '<a href="'.$this->URL(0, $action).'">'.$this->nameForce().'</a>'; 202 } 203 204 function parentURL($action = null) 205 { 206 $perpage = $this->parent->isAlbum() ? $this->config->thumb_number_album : $this->config->thumb_number_gallery; 207 return $this->parent->URL(floor($this->index() / $perpage) * $perpage, $action); 208 } 209 210 function parentLink($action = null) 211 { 212 return '<a href="'.$this->parentURL($action).'">'.$this->parentText().'</a>'; 213 } 214 215 function parentText() 216 { 217 return $this->translator->_g("gallery|Up"); 218 } 219 220 /** 221 * @return array associative array of item properties in the form "name" => "value" 222 */ 223 function detailsArray() 224 { 225 $ret = array(); 226 227 //generic properties 228 if(!empty($this->date)) $ret[$this->translator->_g("Date")] = $this->date; 229 if(!empty($this->location)) $ret[$this->translator->_g("Location")] = $this->location; 230 if(!empty($this->desc)) $ret[$this->translator->_g("Description")] = $this->desc; 231 if(!empty($this->email)) $ret[$this->translator->_g("Email")] = $this->emailLink(); 232 233 //image properties 234 if(!empty($this->camera)) $ret[$this->translator->_g("Camera")] = $this->camera; 235 if(!empty($this->lens)) $ret[$this->translator->_g("Lens")] = $this->lens; 236 if(!empty($this->film)) $ret[$this->translator->_g("Film")] = $this->film; 237 if(!empty($this->darkroom)) $ret[$this->translator->_g("Darkroom manipulation")] = $this->darkroom; 238 if(!empty($this->digital)) $ret[$this->translator->_g("Digital manipulation")] = $this->digital; 239 240 //special properties 241 if(!empty($this->copyright)) $ret[$this->translator->_g("Copyright")] = $this->copyright; 242 elseif(!empty($this->artist))$ret[$this->translator->_g("Copyright")] = $this->artist; 243 if($this->config->show_views) 244 $ret[$this->translator->_g("Viewed")] = $this->translator->_ng("viewed|%s time", "viewed|%s times",$this->hits); 245 246 return $ret; 247 } 248 249 function isAlbum() { return false; } 250 function isGallery() { return false; } 251 function isImage() { return false; } 252 253 /** 254 * Returns a link to the image or gallery with the correct formatting and path 255 * 256 * @param int page offset (optional) 257 * @param string action to perform (optional) 258 * @return string formatted URL 259 */ 260 function URL($startat = null, $action = null) 261 { 262 $query = array(); 263 if($this->config->use_mod_rewrite) { //format url for use with mod_rewrite 264 $ret = $this->config->base_url; 265 $ret .= $this->isImage() ? $this->parent->idEncoded() : $this->idEncoded(); 266 if($startat) $ret .= ','.$startat; 267 $ret .= '/'; 268 if($this->isImage()) $ret .= $this->idEncoded(); 269 270 if($action) $query[] = $this->config->url_action."=".$action; 271 if($this->translator->language != $this->config->default_language) $query[] = $this->config->url_lang.'='.$this->translator->language; 272 if($GLOBALS["sg"]->template != $this->config->default_template) $query[] = $this->config->url_template.'='.$GLOBALS["sg"]->template; 273 274 if(!empty($query)) 275 $ret .= '?'.implode(ini_get('arg_separator.output'), $query); 276 277 } else { //format plain url 278 279 $query[] = $this->config->url_gallery."=".($this->isImage() ? $this->parent->idEncoded() : $this->idEncoded()); 280 if($this->isImage()) $query[] = $this->config->url_image."=".$this->idEncoded(); 281 if($startat) $query[] = $this->config->url_startat."=".$startat; 282 if($action) $query[] = $this->config->url_action."=".$action; 283 if($this->translator->language != $this->config->default_language) 284 $query[] = $this->config->url_lang.'='.$this->translator->language; 285 if(isset($GLOBALS["sg"]->template) && $GLOBALS["sg"]->template != $this->config->default_template) 286 $query[] = $this->config->url_template.'='.$GLOBALS["sg"]->template; 287 288 $ret = $this->config->index_file_url.implode(ini_get('arg_separator.output'), $query); 289 } 290 291 return $ret; 292 } 293 294 } 295 296 297 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |