Changeset 240
- Timestamp:
- 09/26/08 08:50:55 (15 years ago)
- Location:
- plugins/gallery
- Files:
-
- 5 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/gallery/CHANGELOG
r237 r240 1 Gallery 0.32 * Added new gallery themes (imported from DS Gallery)3 * New urlhandlers for static gallery files4 * Gallery themes can be externalized through gallery_themes_path option5 6 1 7 2 Gallery 0.2.16 -
plugins/gallery/_define.php
r237 r240 15 15 /* Description*/ "Image Gallery for Dotclear2", 16 16 /* Author */ "Bruno Hondelatte", 17 /* Version */ ' SVN',17 /* Version */ '0.2.16', 18 18 /* Permissions */ 'usage,contentadmin' 19 19 ); -
plugins/gallery/_prepend.php
r237 r240 27 27 $core->url->register('galitem',$core->blog->settings->gallery_image_url_prefix,'^' 28 28 .$core->blog->settings->gallery_image_url_prefix.'/(.+)$',array('urlGallery','image')); 29 $core->url->register('galtheme','gallerytheme','^gallerytheme/(.+/.+)$',array('urlGalleryProxy','galtheme'));30 29 /* RNot yes implemented 31 30 $core->url->register('images','images','^images/(.+)$',array('urlGallery','images')); -
plugins/gallery/_public.php
r237 r240 36 36 $core->tpl->addBlock('GalleryItemGallery',array('tplGallery','GalleryItemGallery')); 37 37 $core->tpl->addValue('GalleryItemFeedURL',array('tplGallery','GalleryItemFeedURL')); 38 $core->tpl->addValue('GalleryItemMeta',array('tplGallery','GalleryItemMeta'));39 38 40 39 … … 47 46 $core->addBehavior('publicBeforeDocument',array('behaviorsGallery','addTplPath')); 48 47 49 50 51 48 // Later on, some rest features :) 52 49 if (!empty($core->pubrest)) … … 57 54 public static function addTplPath(&$core) 58 55 { 59 $core->tpl->setPath($core->tpl->getPath(), path::fullFromRoot($core->blog->settings->gallery_themes_path,DC_ROOT));56 $core->tpl->setPath($core->tpl->getPath(),dirname(__FILE__).'/default-templates'); 60 57 } 61 58 … … 69 66 global $core; 70 67 $f = $GLOBALS['core']->tpl->getFilters($attr); 71 $css_relname = $core->blog->settings->gallery_default_theme.'/gallery.css'; 72 if (file_exists(path::real($core->blog->settings->themes_path.'/'.$core->blog->settings->theme).'/tpl/'.$css_relname)) 73 $css = $core->blog->settings->themes_url.'/'.$core->blog->settings->theme.'/tpl/'.$css_relname; 74 else 75 $css = $core->blog->url.(($core->blog->settings->url_scan == 'path_info')?'?':'').'pf=gallery/default-templates/' 76 .$css_relname; 68 $css = $core->blog->url.(($core->blog->settings->url_scan == 'path_info')?'?':'').'pf=gallery/default-templates/' 69 .$core->blog->settings->gallery_default_theme.'/gallery.css'; 77 70 $res = "\n<?php echo '<style type=\"text/css\" media=\"screen\">@import url(".$css.");</style>';\n?>"; 78 71 return $res; … … 260 253 $type = !empty($attr['type']) ? $attr['type'] : 'rss2'; 261 254 262 if (!preg_match('#^(rss2|atom|mediarss |custom)$#',$type)) {255 if (!preg_match('#^(rss2|atom|mediarss)$#',$type)) { 263 256 $type = 'rss2'; 264 257 } … … 266 259 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("gal")."/feed/'.$type.'"').'; ?>'; 267 260 /*return '<?php echo '.sprintf($f,'$_ctx->posts->getURL()."/feed/'.$type.'"').'; ?>';*/ 268 }269 270 public static function GalleryItemMeta($attr)271 {272 if (empty($attr['name']))273 return '';274 $value = addslashes($attr['name']);275 276 277 $p = '<?php if ($_ctx->media->type == "image/jpeg") {'."\n".278 'if (isset($_ctx->media->media_meta))'."\n".279 'echo $_ctx->media->media_meta->{\''.$value."'};\n".280 "}\n".281 '?>';282 return $p;283 261 } 284 262 … … 299 277 $lastn = 0; 300 278 if (isset($attr['lastn'])) { 301 $lastn = (integer) $attr['lastn'];279 $lastn = abs((integer) $attr['lastn'])+0; 302 280 } 303 281 … … 307 285 if ($lastn > 0) { 308 286 $p .= "\$params['limit'] = ".$lastn.";\n"; 309 } else if ($lastn == 0){287 } else { 310 288 $p .= "\$params['limit'] = \$core->blog->settings->gallery_nb_images_per_page;\n"; 311 289 } 312 if ($lastn >= 0)290 313 291 $p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n"; 314 292 … … 713 691 class urlGallery extends dcUrlHandlers 714 692 { 715 public static function serveThemeDocument($theme,$page,$content_type='text/html',$http_cache=true,$http_etag=true) {716 global $core;717 if ($theme == '')718 self::serveDocument($page,$content_type,$http_cache,$http_etag);719 elseif ($GLOBALS['core']->tpl->getFilePath($theme.'/'.$page) !== false)720 self::serveDocument($theme.'/'.$page,$content_type,$http_cache,$http_etag);721 else722 self::serveDocument($core->blog->settings->gallery_default_theme.'/'.$page,$content_type,$http_cache,$http_etag);723 724 }725 693 public static function gallery($args) 726 694 { 727 695 $n = self::getPageNumber($args); 728 $theme=''; 729 $type=''; 730 if (preg_match('%(^|/)feed/(mediarss|rss2|atom|custom)/([0-9]+)$%',$args,$m)){ 731 $args = preg_replace('#(^|/)feed/(mediarss|rss2|atom|custom)/([0-9]+)$#','',$args); 696 if (preg_match('%(^|/)feed/(mediarss|rss2|atom)/([0-9]+)$%',$args,$m)){ 697 $args = preg_replace('#(^|/)feed/(mediarss|rss2|atom)/([0-9]+)$#','',$args); 732 698 $type = $m[2]; 733 if ($type == 'custom') { 734 $theme=$GLOBALS['core']->blog->settings->gallery_default_theme; 735 $page = "image_feed.xml"; 736 } else { 737 $page = "feed/img-".$type.".xml"; 738 } 699 $page = "feed/img-".$type.".xml"; 739 700 $mime = 'application/xml'; 740 701 $params['post_id'] = $m[3]; … … 746 707 $params['post_id'] = $m[3]; 747 708 } elseif ($args != '') { 748 //$page=$GLOBALS['core']->blog->settings->gallery_default_theme.'/gallery.html'; 749 $page='gallery.html'; 750 $params['post_url'] = $args; 709 $page=$GLOBALS['core']->blog->settings->gallery_default_theme.'/gallery.html'; 710 $params['post_url'] = $args; 751 711 $mime='text/html'; 752 $theme=$GLOBALS['core']->blog->settings->gallery_default_theme;753 712 } else { 754 713 self::p404(); … … 792 751 $post_id = $GLOBALS['_ctx']->posts->post_id; 793 752 $post_password = $GLOBALS['_ctx']->posts->post_password; 794 $meta = $GLOBALS['core']->meta->getMetaArray($GLOBALS['_ctx']->posts->post_meta);795 if ($theme != '' && isset($meta['galtheme'])) {796 $theme = $meta['galtheme'][0];797 }798 753 799 754 … … 907 862 908 863 # The entry 909 self::serve ThemeDocument($theme,$page,$mime);864 self::serveDocument($page,$mime); 910 865 exit; 911 866 } … … 927 882 $GLOBALS['core']->meta = new dcMeta($GLOBALS['core']);; 928 883 $GLOBALS['core']->gallery = new dcGallery($GLOBALS['core']); 929 self::serve ThemeDocument($GLOBALS['core']->blog->settings->gallery_default_theme,'/galleries.html');884 self::serveDocument($GLOBALS['core']->blog->settings->gallery_default_theme.'/galleries.html'); 930 885 exit; 931 886 } … … 940 895 $params['post_id'] = $m[3]; 941 896 } elseif ($args != '') { 942 $page= 'image.html';897 $page=$GLOBALS['core']->blog->settings->gallery_default_theme.'/image.html'; 943 898 $params['post_url'] = $args; 944 899 $mime='text/html'; … … 987 942 $post_password = $GLOBALS['_ctx']->posts->post_password; 988 943 989 if ($GLOBALS['_ctx']->gallery_url != null) {990 $galtemp = $GLOBALS['core']->gallery->getGalleries(array('post_url'=>$GLOBALS['_ctx']->gallery_url));991 $meta = $GLOBALS['core']->meta->getMetaArray($galtemp->post_meta);992 if (isset($meta['galtheme'])) {993 $theme = $meta['galtheme'][0];994 } else {995 $theme=$GLOBALS['core']->blog->settings->gallery_default_theme;996 }997 } else {998 $theme=$GLOBALS['core']->blog->settings->gallery_default_theme;999 }1000 1001 944 # Password protected entry 1002 945 if ($post_password != '') … … 1107 1050 } 1108 1051 //self::serveDocument('image.html'); 1109 self::serve ThemeDocument($theme,$page,$mime);1052 self::serveDocument($page,$mime); 1110 1053 exit; 1111 1054 } … … 1164 1107 } 1165 1108 1166 class urlGalleryProxy extends dcUrlHandlers1167 {1168 public static function galtheme($args) {1169 if (preg_match('#([^/]+)/(.+)$#',$args,$m)) {1170 $theme = $m[1];1171 $res = $m[2];1172 $full_path = path::real($GLOBALS['core']->blog->settings->gallery_themes_path.'/'.$theme.'/'.$res);1173 if ($full_path == null)1174 $full_path = path::real($GLOBALS['core']->blog->settings->gallery_themes_path.'/default/'.$res);1175 1176 $allowed_types = array('png','jpg','jpeg','gif','css','js','swf');1177 if (!in_array(files::getExtension($full_path),$allowed_types)) {1178 self::p404();1179 exit;1180 }1181 http::cache(array_merge(array($full_path),get_included_files()));1182 header('Content-Type: '.files::getMimeType($full_path));1183 header('Content-Length: '.filesize($full_path));1184 readfile($full_path);1185 exit;1186 1187 } else {1188 self::p404();1189 }1190 1191 }1192 }1193 1109 1194 1110 ?> -
plugins/gallery/class.dc.gallery.php
r237 r240 807 807 } 808 808 809 810 /* Themes functions */811 public function getThemes() {812 $themes = array();813 $themes['default']='default';814 if ($dh = opendir(path::fullFromRoot($this->core->blog->settings->gallery_themes_path,DC_ROOT))) {815 while (($file = readdir($dh)) !== false) {816 if((substr($file,0,1) != '.' ) && ($file !== 'feed')) {817 $themes[$file]=$file;818 }819 }820 }821 return $themes;822 }823 824 809 } 825 810 ?> -
plugins/gallery/default-templates/default/galleries.html
r237 r240 89 89 </tpl:EntryIf> 90 90 <tpl:EntryIf show_pings="1"> 91 <a href="{{tpl:EntryURL}}#pings" class="ping_count">{{tpl:Entry PingCount}}</a></tpl:EntryIf>91 <a href="{{tpl:EntryURL}}#pings" class="ping_count">{{tpl:EntryTrackbackCount}}</a></tpl:EntryIf> 92 92 </p> 93 93 </div> -
plugins/gallery/default-templates/default/image.html
r237 r240 85 85 </tpl:EntryIf> 86 86 87 <div class="post-content"> 88 <p>EXIF :</p> 89 <ul> 90 <li>Make : {{tpl:GalleryItemMeta name="Make"}}</li> 91 <li>Exposure : {{tpl:GalleryItemMeta name="Exposure"}}</li> 92 </ul> 93 94 {{tpl:EntryContent}}</div> 87 <div class="post-content">{{tpl:EntryContent}}</div> 95 88 </div> 96 89 -
plugins/gallery/gal.php
r239 r240 1 1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear Gallery plugin. 4 # Copyright (c) 2007 Bruno Hondelatte, and contributors. 5 # Many, many thanks to Olivier Meunier and the Dotclear Team. 6 # All rights reserved. 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 7 3 # 8 # Gallery plugin for DC2 is free sofwtare; you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation; either version 2 of the License, or 11 # (at your option) any later version. 12 # 13 # DotClear is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with DotClear; if not, write to the Free Software 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 4 # This file is part of Dotclear 2 Gallery plugin. 21 5 # 22 # ***** END LICENSE BLOCK ***** 6 # Copyright (c) 2003-2008 Olivier Meunier and contributors 7 # Licensed under the GPL version 2.0 license. 8 # See LICENSE file or 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 10 # 11 # -- END LICENSE BLOCK ------------------------------------ 23 12 if (!defined('DC_CONTEXT_ADMIN')) { exit; } 24 13 … … 57 46 $core->gallery = new dcGallery($core); 58 47 59 $themes = $core->gallery->getThemes();60 48 /* 61 49 $post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />'; … … 101 89 $f_media_dir = $f_tag = $f_user = $f_cat = null; 102 90 $f_orderby = $f_sortby = null; 103 $f_theme = "default";104 91 105 92 … … 170 157 $gal_thumb = $gal_thumb[0]; 171 158 } 172 $meta_list = $core->meta->getMetaArray($post->post_meta); 173 $gal_nb_img = isset($meta_list['galitem'])?sizeof($meta_list['galitem']):0; 174 $f_theme = isset($meta_list['galtheme'])?$meta_list['galtheme'][0]:'default'; 159 $image_ids = $core->meta->getMetaArray($post->post_meta); 160 $gal_nb_img = isset($image_ids['galitem'])?sizeof($image_ids['galitem']):0; 175 161 176 162 /*$gal_meta=$core->meta->getMetaArray($post->post_meta); … … 254 240 $f_orderby = !empty($_POST['f_orderby']) ? $_POST['f_orderby'] : null; 255 241 $f_sortby = !empty($_POST['f_sortby']) ? $_POST['f_sortby'] : null; 256 $f_theme = !empty($_POST['f_theme']) ? $_POST['f_theme'] : 'default';257 242 258 243 … … 311 296 $core->meta->delPostMeta($post_id,"galorderby"); 312 297 $core->meta->delPostMeta($post_id,"galsortby"); 313 $core->meta->delPostMeta($post_id,"galtheme");314 298 if ($c_media_dir) { 315 299 $core->meta->setPostMeta($post_id,"galmediadir",$f_media_dir); … … 331 315 $core->meta->setPostMeta($post_id,"galsortby",$f_sortby); 332 316 } 333 if (isset ($f_theme) && $f_theme != 'default') {334 $core->meta->setPostMeta($post_id,"galtheme",$f_theme);335 }336 317 $core->gallery->refreshGallery($post_id); 337 318 338 http::redirect('plugin.php?p=gallery&m=gal& id='.$post_id.'&upd=1');319 http::redirect('plugin.php?p=gallery&m=gal&id='.$post_id.'&upd=1'); 339 320 } 340 321 catch (Exception $e) … … 571 552 '<p><label class="classic">'.__('Order')." : ".form::combo('f_orderby',$orderby_combo,$f_orderby).'</label></p>'. 572 553 '<p><label class="classic">'.__('Sort')." : ".form::combo('f_sortby',$sortby_combo,$f_sortby).'</label></p>'. 573 "<h3>".__('Theme')."</h3>".574 '<p><label class="classic">'.__('Gallery theme')." : ".form::combo('f_theme',$themes,$f_theme).'</label></p>'.575 554 '</div>'. 576 555 '</div>'. … … 604 583 echo '</fieldset></div>'; // End #entry-content 605 584 echo '</form>'; 585 //echo '</div>'; 606 586 607 587 /*if ($post_id && $post->post_status == 1) { -
plugins/gallery/options.php
r237 r240 60 60 $c_gal_prefix=defaultIfNotSet($core->blog->settings->gallery_gallery_url_prefix,'gallery'); 61 61 $c_img_prefix=defaultIfNotSet($core->blog->settings->gallery_image_url_prefix,'image'); 62 $c_gal_themes_path=defaultIfNotSet($core->blog->settings->gallery_themes_path,'plugins/gallery/default-templates');63 62 64 63 if (!empty($_POST['enable_plugin'])) { … … 97 96 $c_gal_prefix = !empty($_POST['gallery_prefix'])?$_POST['gallery_prefix']:$c_gal_prefix; 98 97 $c_img_prefix = !empty($_POST['images_prefix'])?$_POST['images_prefix']:$c_img_prefix; 99 $c_gal_themes_path = !empty($_POST['themes_path'])?$_POST['themes_path']:$c_img_prefix;100 98 $core->blog->settings->setNamespace('gallery'); 101 99 $core->blog->settings->put('gallery_galleries_url_prefix',$c_gals_prefix,'string','Gallery lists URL prefix'); 102 100 $core->blog->settings->put('gallery_gallery_url_prefix',$c_gal_prefix,'string','Galleries URL prefix'); 103 101 $core->blog->settings->put('gallery_image_url_prefix',$c_img_prefix,'string','Images URL prefix'); 104 $core->blog->settings->put('gallery_themes_path',$c_gal_themes_path,'string','Gallery Themes path');105 102 $core->blog->triggerBlog(); 106 103 http::redirect('plugin.php?p=gallery&m=options&upd=1'); … … 218 215 form::field('images_prefix', 60, 255, $c_img_prefix). 219 216 '</label></p>'. 220 '<p><label class=" classic">'. __('Gallery themes path').' : '.221 form::field('themes_path', 60, 255, $c_gal_themes_path).222 '</label></p>'.223 217 form::hidden('p','gallery'). 224 218 form::hidden('m','options').$core->formNonce().
Note: See TracChangeset
for help on using the changeset viewer.