Changeset 237
- Timestamp:
- 09/24/08 09:04:25 (15 years ago)
- Location:
- plugins/gallery
- Files:
-
- 33 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/gallery/CHANGELOG
r235 r237 1 Gallery 0.3 2 * Added new gallery themes (imported from DS Gallery) 3 * New urlhandlers for static gallery files 4 * Gallery themes can be externalized through gallery_themes_path option 5 1 6 2 7 Gallery 0.2.16 -
plugins/gallery/_define.php
r235 r237 15 15 /* Description*/ "Image Gallery for Dotclear2", 16 16 /* Author */ "Bruno Hondelatte", 17 /* Version */ ' 0.2.16',17 /* Version */ 'SVN', 18 18 /* Permissions */ 'usage,contentadmin' 19 19 ); -
plugins/gallery/_prepend.php
r232 r237 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')); 29 30 /* RNot yes implemented 30 31 $core->url->register('images','images','^images/(.+)$',array('urlGallery','images')); -
plugins/gallery/_public.php
r217 r237 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')); 38 39 39 40 … … 46 47 $core->addBehavior('publicBeforeDocument',array('behaviorsGallery','addTplPath')); 47 48 49 50 48 51 // Later on, some rest features :) 49 52 if (!empty($core->pubrest)) … … 54 57 public static function addTplPath(&$core) 55 58 { 56 $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates');59 $core->tpl->setPath($core->tpl->getPath(),path::fullFromRoot($core->blog->settings->gallery_themes_path,DC_ROOT)); 57 60 } 58 61 … … 66 69 global $core; 67 70 $f = $GLOBALS['core']->tpl->getFilters($attr); 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'; 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; 70 77 $res = "\n<?php echo '<style type=\"text/css\" media=\"screen\">@import url(".$css.");</style>';\n?>"; 71 78 return $res; … … 253 260 $type = !empty($attr['type']) ? $attr['type'] : 'rss2'; 254 261 255 if (!preg_match('#^(rss2|atom|mediarss )$#',$type)) {262 if (!preg_match('#^(rss2|atom|mediarss|custom)$#',$type)) { 256 263 $type = 'rss2'; 257 264 } … … 259 266 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("gal")."/feed/'.$type.'"').'; ?>'; 260 267 /*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; 261 283 } 262 284 … … 277 299 $lastn = 0; 278 300 if (isset($attr['lastn'])) { 279 $lastn = abs((integer) $attr['lastn'])+0;301 $lastn = (integer) $attr['lastn']; 280 302 } 281 303 … … 285 307 if ($lastn > 0) { 286 308 $p .= "\$params['limit'] = ".$lastn.";\n"; 287 } else {309 } else if ($lastn == 0) { 288 310 $p .= "\$params['limit'] = \$core->blog->settings->gallery_nb_images_per_page;\n"; 289 311 } 290 312 if ($lastn >= 0) 291 313 $p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n"; 292 314 … … 691 713 class urlGallery extends dcUrlHandlers 692 714 { 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 else 722 self::serveDocument($core->blog->settings->gallery_default_theme.'/'.$page,$content_type,$http_cache,$http_etag); 723 724 } 693 725 public static function gallery($args) 694 726 { 695 727 $n = self::getPageNumber($args); 696 if (preg_match('%(^|/)feed/(mediarss|rss2|atom)/([0-9]+)$%',$args,$m)){ 697 $args = preg_replace('#(^|/)feed/(mediarss|rss2|atom)/([0-9]+)$#','',$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); 698 732 $type = $m[2]; 699 $page = "feed/img-".$type.".xml"; 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 } 700 739 $mime = 'application/xml'; 701 740 $params['post_id'] = $m[3]; … … 707 746 $params['post_id'] = $m[3]; 708 747 } elseif ($args != '') { 709 $page=$GLOBALS['core']->blog->settings->gallery_default_theme.'/gallery.html'; 710 $params['post_url'] = $args; 748 //$page=$GLOBALS['core']->blog->settings->gallery_default_theme.'/gallery.html'; 749 $page='gallery.html'; 750 $params['post_url'] = $args; 711 751 $mime='text/html'; 752 $theme=$GLOBALS['core']->blog->settings->gallery_default_theme; 712 753 } else { 713 754 self::p404(); … … 751 792 $post_id = $GLOBALS['_ctx']->posts->post_id; 752 793 $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 } 753 798 754 799 … … 862 907 863 908 # The entry 864 self::serve Document($page,$mime);909 self::serveThemeDocument($theme,$page,$mime); 865 910 exit; 866 911 } … … 882 927 $GLOBALS['core']->meta = new dcMeta($GLOBALS['core']);; 883 928 $GLOBALS['core']->gallery = new dcGallery($GLOBALS['core']); 884 self::serve Document($GLOBALS['core']->blog->settings->gallery_default_theme.'/galleries.html');929 self::serveThemeDocument($GLOBALS['core']->blog->settings->gallery_default_theme,'/galleries.html'); 885 930 exit; 886 931 } … … 895 940 $params['post_id'] = $m[3]; 896 941 } elseif ($args != '') { 897 $page= $GLOBALS['core']->blog->settings->gallery_default_theme.'/image.html';942 $page='image.html'; 898 943 $params['post_url'] = $args; 899 944 $mime='text/html'; … … 942 987 $post_password = $GLOBALS['_ctx']->posts->post_password; 943 988 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 944 1001 # Password protected entry 945 1002 if ($post_password != '') … … 1050 1107 } 1051 1108 //self::serveDocument('image.html'); 1052 self::serve Document($page,$mime);1109 self::serveThemeDocument($theme,$page,$mime); 1053 1110 exit; 1054 1111 } … … 1107 1164 } 1108 1165 1166 class urlGalleryProxy extends dcUrlHandlers 1167 { 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 } 1109 1193 1110 1194 ?> -
plugins/gallery/class.dc.gallery.php
r236 r237 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 809 824 } 810 825 ?> -
plugins/gallery/default-templates/default/galleries.html
r179 r237 89 89 </tpl:EntryIf> 90 90 <tpl:EntryIf show_pings="1"> 91 <a href="{{tpl:EntryURL}}#pings" class="ping_count">{{tpl:Entry TrackbackCount}}</a></tpl:EntryIf>91 <a href="{{tpl:EntryURL}}#pings" class="ping_count">{{tpl:EntryPingCount}}</a></tpl:EntryIf> 92 92 </p> 93 93 </div> -
plugins/gallery/default-templates/default/image.html
r193 r237 85 85 </tpl:EntryIf> 86 86 87 <div class="post-content">{{tpl:EntryContent}}</div> 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> 88 95 </div> 89 96 -
plugins/gallery/gal.php
r232 r237 1 1 <?php 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 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. 3 7 # 4 # This file is part of Dotclear 2 Gallery plugin. 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 5 21 # 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 ------------------------------------ 22 # ***** END LICENSE BLOCK ***** 12 23 if (!defined('DC_CONTEXT_ADMIN')) { exit; } 13 24 … … 46 57 $core->gallery = new dcGallery($core); 47 58 59 $themes = $core->gallery->getThemes(); 48 60 /* 49 61 $post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />'; … … 52 64 $next_link = $prev_link = $next_headlink = $prev_headlink = null; 53 65 54 $gal_headlink = '<link rel="%s" title="%s" href="plugin.php?p=gallery& amp;m=gal&id=%s" />';55 $gal_link = '<a href="plugin.php?p=gallery& amp;m=gal&id=%s" title="%s">%s</a>';66 $gal_headlink = '<link rel="%s" title="%s" href="plugin.php?p=gallery&m=gal&id=%s" />'; 67 $gal_link = '<a href="plugin.php?p=gallery&m=gal&id=%s" title="%s">%s</a>'; 56 68 57 69 … … 89 101 $f_media_dir = $f_tag = $f_user = $f_cat = null; 90 102 $f_orderby = $f_sortby = null; 103 $f_theme = "default"; 91 104 92 105 … … 157 170 $gal_thumb = $gal_thumb[0]; 158 171 } 159 $image_ids = $core->meta->getMetaArray($post->post_meta); 160 $gal_nb_img = isset($image_ids['galitem'])?sizeof($image_ids['galitem']):0; 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'; 161 175 162 176 /*$gal_meta=$core->meta->getMetaArray($post->post_meta); … … 240 254 $f_orderby = !empty($_POST['f_orderby']) ? $_POST['f_orderby'] : null; 241 255 $f_sortby = !empty($_POST['f_sortby']) ? $_POST['f_sortby'] : null; 256 $f_theme = !empty($_POST['f_theme']) ? $_POST['f_theme'] : 'default'; 242 257 243 258 … … 296 311 $core->meta->delPostMeta($post_id,"galorderby"); 297 312 $core->meta->delPostMeta($post_id,"galsortby"); 313 $core->meta->delPostMeta($post_id,"galtheme"); 298 314 if ($c_media_dir) { 299 315 $core->meta->setPostMeta($post_id,"galmediadir",$f_media_dir); … … 315 331 $core->meta->setPostMeta($post_id,"galsortby",$f_sortby); 316 332 } 333 if (isset ($f_theme) && $f_theme != 'default') { 334 $core->meta->setPostMeta($post_id,"galtheme",$f_theme); 335 } 317 336 $core->gallery->refreshGallery($post_id); 318 337 319 http::redirect('plugin.php?p=gallery& amp;m=gal&id='.$post_id.'&upd=1');338 http::redirect('plugin.php?p=gallery&m=gal&id='.$post_id.'&upd=1'); 320 339 } 321 340 catch (Exception $e) … … 352 371 $core->gallery->refreshGallery($return_id); 353 372 354 http::redirect('plugin.php?p=gallery& amp;m=gal&id='.$return_id.'&crea=1');373 http::redirect('plugin.php?p=gallery&m=gal&id='.$return_id.'&crea=1'); 355 374 } 356 375 catch (Exception $e) … … 443 462 '<div class="col">'. 444 463 "<h3>".__('Presentation thumbnail')."</h3>"; 445 $change_thumb_url='plugin.php?p=gallery& amp;m=galthumb&gal_id='.$post_id;464 $change_thumb_url='plugin.php?p=gallery&m=galthumb&gal_id='.$post_id; 446 465 if ($c_media_dir) 447 $change_thumb_url .= '& amp;d='.$f_media_dir;466 $change_thumb_url .= '&d='.$f_media_dir; 448 467 449 468 if ($has_thumb) { … … 454 473 echo '<li>'.$gal_thumb->media_dtstr.' - '. files::size($gal_thumb->size).' - '. 455 474 '<a href="'.$change_thumb_url.'">'.__('Change').'</a>'.'</li></ul>'; 456 echo '<li class="media-action"><form action="plugin.php?p=gallery& amp;m=galthumb" method="post">'.475 echo '<li class="media-action"><form action="plugin.php?p=gallery&m=galthumb" method="post">'. 457 476 '<input type="image" src="images/minus.png" alt="'.__('Remove').'" '. 458 477 'title="'.__('Remove').'" /> '. … … 481 500 { 482 501 483 echo '<form action="plugin.php?p=gallery& amp;m=gal" method="post" id="entry-form">';502 echo '<form action="plugin.php?p=gallery&m=gal" method="post" id="entry-form">'; 484 503 echo '<div id="entry-sidebar">'; 485 504 … … 552 571 '<p><label class="classic">'.__('Order')." : ".form::combo('f_orderby',$orderby_combo,$f_orderby).'</label></p>'. 553 572 '<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>'. 554 575 '</div>'. 555 576 '</div>'. … … 583 604 echo '</fieldset></div>'; // End #entry-content 584 605 echo '</form>'; 585 //echo '</div>';586 606 587 607 /*if ($post_id && $post->post_status == 1) { -
plugins/gallery/options.php
r232 r237 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'); 62 63 63 64 if (!empty($_POST['enable_plugin'])) { … … 96 97 $c_gal_prefix = !empty($_POST['gallery_prefix'])?$_POST['gallery_prefix']:$c_gal_prefix; 97 98 $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; 98 100 $core->blog->settings->setNamespace('gallery'); 99 101 $core->blog->settings->put('gallery_galleries_url_prefix',$c_gals_prefix,'string','Gallery lists URL prefix'); 100 102 $core->blog->settings->put('gallery_gallery_url_prefix',$c_gal_prefix,'string','Galleries URL prefix'); 101 103 $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'); 102 105 $core->blog->triggerBlog(); 103 106 http::redirect('plugin.php?p=gallery&m=options&upd=1'); … … 215 218 form::field('images_prefix', 60, 255, $c_img_prefix). 216 219 '</label></p>'. 220 '<p><label class=" classic">'. __('Gallery themes path').' : '. 221 form::field('themes_path', 60, 255, $c_gal_themes_path). 222 '</label></p>'. 217 223 form::hidden('p','gallery'). 218 224 form::hidden('m','options').$core->formNonce().
Note: See TracChangeset
for help on using the changeset viewer.