Dotclear

Changeset 237


Ignore:
Timestamp:
09/24/08 09:04:25 (15 years ago)
Author:
bruno
Message:

Onto 0.3 ...

Location:
plugins/gallery
Files:
33 added
9 edited

Legend:

Unmodified
Added
Removed
  • plugins/gallery/CHANGELOG

    r235 r237  
     1Gallery 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 
    16 
    27Gallery 0.2.16 
  • plugins/gallery/_define.php

    r235 r237  
    1515     /* Description*/         "Image Gallery for Dotclear2", 
    1616     /* Author */             "Bruno Hondelatte", 
    17      /* Version */            '0.2.16', 
     17     /* Version */            'SVN', 
    1818     /* Permissions */        'usage,contentadmin' 
    1919); 
  • plugins/gallery/_prepend.php

    r232 r237  
    2727     $core->url->register('galitem',$core->blog->settings->gallery_image_url_prefix,'^' 
    2828          .$core->blog->settings->gallery_image_url_prefix.'/(.+)$',array('urlGallery','image')); 
     29     $core->url->register('galtheme','gallerytheme','^gallerytheme/(.+/.+)$',array('urlGalleryProxy','galtheme')); 
    2930     /* RNot yes implemented 
    3031     $core->url->register('images','images','^images/(.+)$',array('urlGallery','images')); 
  • plugins/gallery/_public.php

    r217 r237  
    3636$core->tpl->addBlock('GalleryItemGallery',array('tplGallery','GalleryItemGallery')); 
    3737$core->tpl->addValue('GalleryItemFeedURL',array('tplGallery','GalleryItemFeedURL')); 
     38$core->tpl->addValue('GalleryItemMeta',array('tplGallery','GalleryItemMeta')); 
    3839 
    3940 
     
    4647$core->addBehavior('publicBeforeDocument',array('behaviorsGallery','addTplPath')); 
    4748 
     49 
     50 
    4851// Later on, some rest features :) 
    4952if (!empty($core->pubrest)) 
     
    5457  public static function addTplPath(&$core) 
    5558  { 
    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)); 
    5760  } 
    5861 
     
    6669          global $core; 
    6770          $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; 
    7077          $res = "\n<?php echo '<style type=\"text/css\" media=\"screen\">@import url(".$css.");</style>';\n?>"; 
    7178          return $res; 
     
    253260          $type = !empty($attr['type']) ? $attr['type'] : 'rss2'; 
    254261           
    255           if (!preg_match('#^(rss2|atom|mediarss)$#',$type)) { 
     262          if (!preg_match('#^(rss2|atom|mediarss|custom)$#',$type)) { 
    256263               $type = 'rss2'; 
    257264          } 
     
    259266          return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("gal")."/feed/'.$type.'"').'; ?>'; 
    260267           /*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; 
    261283     } 
    262284 
     
    277299          $lastn = 0; 
    278300          if (isset($attr['lastn'])) { 
    279                $lastn = abs((integer) $attr['lastn'])+0; 
     301               $lastn = (integer) $attr['lastn']; 
    280302          } 
    281303           
     
    285307          if ($lastn > 0) { 
    286308               $p .= "\$params['limit'] = ".$lastn.";\n"; 
    287           } else { 
     309          } else if ($lastn == 0) { 
    288310               $p .= "\$params['limit'] = \$core->blog->settings->gallery_nb_images_per_page;\n"; 
    289311          } 
    290            
     312          if ($lastn >= 0)     
    291313          $p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n"; 
    292314           
     
    691713class urlGallery extends dcUrlHandlers 
    692714{ 
     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     } 
    693725     public static function gallery($args) 
    694726     { 
    695727          $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); 
    698732               $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               } 
    700739               $mime = 'application/xml'; 
    701740               $params['post_id'] = $m[3]; 
     
    707746               $params['post_id'] = $m[3]; 
    708747          } 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; 
    711751               $mime='text/html'; 
     752               $theme=$GLOBALS['core']->blog->settings->gallery_default_theme; 
    712753          } else { 
    713754               self::p404(); 
     
    751792          $post_id = $GLOBALS['_ctx']->posts->post_id; 
    752793          $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          }  
    753798           
    754799           
     
    862907           
    863908          # The entry 
    864           self::serveDocument($page,$mime); 
     909          self::serveThemeDocument($theme,$page,$mime); 
    865910          exit; 
    866911     } 
     
    882927          $GLOBALS['core']->meta = new dcMeta($GLOBALS['core']);; 
    883928          $GLOBALS['core']->gallery = new dcGallery($GLOBALS['core']); 
    884           self::serveDocument($GLOBALS['core']->blog->settings->gallery_default_theme.'/galleries.html'); 
     929          self::serveThemeDocument($GLOBALS['core']->blog->settings->gallery_default_theme,'/galleries.html'); 
    885930          exit; 
    886931     } 
     
    895940               $params['post_id'] = $m[3]; 
    896941          } elseif ($args != '') { 
    897                $page=$GLOBALS['core']->blog->settings->gallery_default_theme.'/image.html'; 
     942               $page='image.html'; 
    898943               $params['post_url'] = $args; 
    899944               $mime='text/html'; 
     
    942987          $post_password = $GLOBALS['_ctx']->posts->post_password; 
    943988           
     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 
    9441001          # Password protected entry 
    9451002          if ($post_password != '') 
     
    10501107          } 
    10511108          //self::serveDocument('image.html'); 
    1052           self::serveDocument($page,$mime); 
     1109          self::serveThemeDocument($theme,$page,$mime); 
    10531110          exit; 
    10541111     } 
     
    11071164} 
    11081165 
     1166class 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} 
    11091193 
    11101194?> 
  • plugins/gallery/class.dc.gallery.php

    r236 r237  
    807807     } 
    808808 
     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 
    809824} 
    810825?> 
  • plugins/gallery/default-templates/default/galleries.html

    r179 r237  
    8989    </tpl:EntryIf> 
    9090    <tpl:EntryIf show_pings="1"> 
    91     <a href="{{tpl:EntryURL}}#pings" class="ping_count">{{tpl:EntryTrackbackCount}}</a></tpl:EntryIf> 
     91    <a href="{{tpl:EntryURL}}#pings" class="ping_count">{{tpl:EntryPingCount}}</a></tpl:EntryIf> 
    9292    </p> 
    9393    </div> 
  • plugins/gallery/default-templates/default/image.html

    r193 r237  
    8585    </tpl:EntryIf> 
    8686     
    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> 
    8895  </div> 
    8996   
  • plugins/gallery/gal.php

    r232 r237  
    11<?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. 
    37# 
    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 
    521# 
    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 ***** 
    1223if (!defined('DC_CONTEXT_ADMIN')) { exit; } 
    1324 
     
    4657$core->gallery = new dcGallery($core); 
    4758 
     59$themes = $core->gallery->getThemes(); 
    4860/* 
    4961$post_headlink = '<link rel="%s" title="%s" href="post.php?id=%s" />'; 
     
    5264$next_link = $prev_link = $next_headlink = $prev_headlink = null; 
    5365 
    54 $gal_headlink = '<link rel="%s" title="%s" href="plugin.php?p=gallery&amp;m=gal&amp;id=%s" />'; 
    55 $gal_link = '<a href="plugin.php?p=gallery&amp;m=gal&amp;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>'; 
    5668 
    5769 
     
    89101$f_media_dir = $f_tag = $f_user = $f_cat = null; 
    90102$f_orderby = $f_sortby = null; 
     103$f_theme = "default"; 
    91104 
    92105 
     
    157170               $gal_thumb = $gal_thumb[0]; 
    158171          } 
    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'; 
    161175 
    162176          /*$gal_meta=$core->meta->getMetaArray($post->post_meta); 
     
    240254     $f_orderby = !empty($_POST['f_orderby']) ? $_POST['f_orderby'] : null; 
    241255     $f_sortby = !empty($_POST['f_sortby']) ? $_POST['f_sortby'] : null; 
     256     $f_theme = !empty($_POST['f_theme']) ? $_POST['f_theme'] : 'default'; 
    242257 
    243258 
     
    296311               $core->meta->delPostMeta($post_id,"galorderby"); 
    297312               $core->meta->delPostMeta($post_id,"galsortby"); 
     313               $core->meta->delPostMeta($post_id,"galtheme"); 
    298314               if ($c_media_dir) { 
    299315                    $core->meta->setPostMeta($post_id,"galmediadir",$f_media_dir); 
     
    315331                    $core->meta->setPostMeta($post_id,"galsortby",$f_sortby); 
    316332               } 
     333               if (isset ($f_theme) && $f_theme != 'default') { 
     334                    $core->meta->setPostMeta($post_id,"galtheme",$f_theme); 
     335               } 
    317336               $core->gallery->refreshGallery($post_id); 
    318337 
    319                http::redirect('plugin.php?p=gallery&amp;m=gal&amp;id='.$post_id.'&upd=1'); 
     338               http::redirect('plugin.php?p=gallery&m=gal&id='.$post_id.'&upd=1'); 
    320339          } 
    321340          catch (Exception $e) 
     
    352371               $core->gallery->refreshGallery($return_id); 
    353372                
    354                http::redirect('plugin.php?p=gallery&amp;m=gal&amp;id='.$return_id.'&amp;crea=1'); 
     373               http::redirect('plugin.php?p=gallery&m=gal&id='.$return_id.'&crea=1'); 
    355374          } 
    356375          catch (Exception $e) 
     
    443462          '<div class="col">'. 
    444463          "<h3>".__('Presentation thumbnail')."</h3>"; 
    445      $change_thumb_url='plugin.php?p=gallery&amp;m=galthumb&amp;gal_id='.$post_id; 
     464     $change_thumb_url='plugin.php?p=gallery&m=galthumb&gal_id='.$post_id; 
    446465     if ($c_media_dir) 
    447           $change_thumb_url .= '&amp;d='.$f_media_dir; 
     466          $change_thumb_url .= '&d='.$f_media_dir; 
    448467 
    449468     if ($has_thumb) { 
     
    454473          echo '<li>'.$gal_thumb->media_dtstr.' - '. files::size($gal_thumb->size).' - '. 
    455474          '<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">'. 
    457476          '<input type="image" src="images/minus.png" alt="'.__('Remove').'" '. 
    458477          'title="'.__('Remove').'" /> '. 
     
    481500{ 
    482501 
    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">'; 
    484503     echo '<div id="entry-sidebar">'; 
    485504      
     
    552571     '<p><label class="classic">'.__('Order')." : ".form::combo('f_orderby',$orderby_combo,$f_orderby).'</label></p>'. 
    553572     '<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>'. 
    554575     '</div>'. 
    555576     '</div>'. 
     
    583604     echo '</fieldset></div>';          // End #entry-content 
    584605     echo '</form>'; 
    585      //echo '</div>'; 
    586606      
    587607     /*if ($post_id && $post->post_status == 1) { 
  • plugins/gallery/options.php

    r232 r237  
    6060$c_gal_prefix=defaultIfNotSet($core->blog->settings->gallery_gallery_url_prefix,'gallery'); 
    6161$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'); 
    6263 
    6364if (!empty($_POST['enable_plugin'])) { 
     
    9697     $c_gal_prefix = !empty($_POST['gallery_prefix'])?$_POST['gallery_prefix']:$c_gal_prefix; 
    9798     $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; 
    98100     $core->blog->settings->setNamespace('gallery'); 
    99101     $core->blog->settings->put('gallery_galleries_url_prefix',$c_gals_prefix,'string','Gallery lists URL prefix'); 
    100102     $core->blog->settings->put('gallery_gallery_url_prefix',$c_gal_prefix,'string','Galleries URL prefix'); 
    101103     $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'); 
    102105     $core->blog->triggerBlog(); 
    103106     http::redirect('plugin.php?p=gallery&amp;m=options&amp;upd=1'); 
     
    215218          form::field('images_prefix', 60, 255, $c_img_prefix). 
    216219          '</label></p>'. 
     220          '<p><label class=" classic">'. __('Gallery themes path').' : '. 
     221          form::field('themes_path', 60, 255, $c_gal_themes_path). 
     222          '</label></p>'. 
    217223          form::hidden('p','gallery'). 
    218224          form::hidden('m','options').$core->formNonce(). 
Note: See TracChangeset for help on using the changeset viewer.

Sites map