Dotclear

Changeset 552


Ignore:
Timestamp:
11/09/08 16:31:25 (15 years ago)
Author:
Moe
google:author:
appears
Message:

DL Manager 1.0-RC5 :

  • fixed bugs with <tpl:DLMIfNoItem> and {{tpl:MediaURL}}
  • added facebox.css (thanks to Tomtom)
  • added format="" parameter for {{tpl:DLMItemMTime}} (thanks to Tomtom)
  • improved viewfile() function
  • added Home in <title> when viewing the Home directory
  • renamed dlmanager_hide setting to dlmanager_hide_urls
Location:
plugins/dlManager
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • plugins/dlManager/_define.php

    r551 r552  
    2828     /* Description*/                "Download manager with a public page and a widget", 
    2929     /* Author */                    "Moe (http://gniark.net/), Osku and Tomtom (http://blog.zenstyle.fr)", 
    30      /* Version */                   '1.0-RC4', 
     30     /* Version */                   '1.0-RC5', 
    3131     /* Permissions */               'admin' 
    3232); 
  • plugins/dlManager/_prepend.php

    r551 r552  
    3131          '^mediaplayer/([0-9]+)$',array('dlManagerPageDocument','player')); 
    3232$core->url->register('download','download', 
    33           '^download/([0-9]+)$',array('dlManagerPageDocument','wrapper')); 
     33          '^download/([0-9]+)$',array('dlManagerPageDocument','download')); 
    3434$core->url->register('viewfile','viewfile', 
    3535          '^viewfile/(.+)$',array('dlManagerPageDocument','viewfile')); 
  • plugins/dlManager/_public.php

    r551 r552  
    3232     private static function check() 
    3333     { 
     34           
    3435          global $core; 
    3536           
     
    7071               $page_dir = $page_root; 
    7172 
    72                $_ctx->dlManager_currentDir = '/'; 
     73               $dir = '/'; 
     74               $_ctx->dlManager_currentDir = __('Home'); 
     75                
    7376               $root = true; 
    7477                
     
    7780               { 
    7881                    $_ctx->dlManager_currentDir = substr($args,1); 
    79                     $page_dir = $page_root.'/'.$_ctx->dlManager_currentDir; 
     82                    $dir = substr($args,1); 
     83                    $page_dir = $page_root.'/'.$dir; 
    8084                    $root = false; 
    8185               } 
    8286                
    8387               # BreadCrumb 
    84                $_ctx->dlManager_BreadCrumb = dlManager::breadCrumb($_ctx->dlManager_currentDir); 
     88               $_ctx->dlManager_BreadCrumb = dlManager::breadCrumb($dir); 
    8589               # /BreadCrumb 
    8690                
     
    215219           
    216220          try 
    217           { 
    218                # exit if the public_path (and Media root) doesn't exist 
    219                if (!is_dir($core->blog->public_path)) {self::p404();} 
    220                 
     221          {               
    221222               $file = $core->media->getFile($args); 
    222223                
     
    227228                
    228229               # file_url for mp3 and flv players 
    229                $_ctx->file_url = $core->blog->url.$core->url->getBase('viewfile').'/'. 
    230                     $file->media_id; 
     230               if ($core->blog->settings->dlmanager_hide_urls) 
     231               { 
     232                    $_ctx->file_url = $core->blog->url.$core->url->getBase('viewfile'). 
     233                    '/'.$file->media_id; 
     234               } 
     235               else 
     236               { 
     237                    $_ctx->file_url = $file->file_url; 
     238               } 
    231239                
    232240               # define root of DL Manager 
     
    283291     @param    count     <b>boolean</b> Count download 
    284292     */ 
    285      public static function wrapper($args,$count=true) 
     293     public static function download($args) 
    286294     { 
    287295          global $core; 
     
    289297          self::check(); 
    290298           
    291           if (empty($args)) {self::p404();} 
     299          if (!preg_match('/^[0-9]+$/',$args)) {self::p404();} 
    292300           
    293301          try 
     
    299307                    self::p404(); 
    300308               } 
    301                 
    302                $page_root = $core->blog->settings->dlmanager_root; 
    303309                
    304310               if (!dlManager::inJail($file->relname)) {self::p404();} 
     
    306312               if (is_readable($file->file)) 
    307313               { 
    308                     if ($count && $core->blog->settings->dlmanager_counter) 
     314                    if ($core->blog->settings->dlmanager_counter) 
    309315                    { 
    310316                         $count = unserialize($core->blog->settings->dlmanager_count_dl); 
     
    327333                    readfile($file->file); 
    328334                    exit; 
    329                     /*header('Location:'.$file->file_url); 
    330                     exit;*/ 
     335                    # header('Location:'.$file->file_url); 
     336                    exit; 
    331337               } 
    332338          } 
     
    345351          global $core; 
    346352           
    347           if (!$GLOBALS['core']->blog->settings->dlmanager_hide 
     353          if (!$GLOBALS['core']->blog->settings->dlmanager_hide_urls 
    348354          || empty($args) || !$core->blog->settings->dlmanager_active) 
    349355          { 
     
    352358           
    353359          try 
    354           { 
    355                $elements = explode('/',$args); 
    356                 
     360          {               
    357361               # standard file 
    358                if (count($elements) == 1) 
    359                { 
    360                     self::wrapper($elements[0],false); 
    361                } 
    362                # image file 
    363                elseif (count($elements) == 2) 
    364                { 
    365                     $file_id = $elements[0]; 
    366                     $size = $elements[1]; 
     362               if (preg_match('/^[0-9]+$/',$args,$matches)) 
     363               { 
     364                    $file = $core->media->getFile($matches[0]); 
    367365                     
    368                     $file = $core->media->getFile($args); 
     366                    if (empty($file->file) || ($file->type != 'audio/mpeg3' 
     367                         && $file->type != 'video/x-flv' && $file->media_type != 'image')) 
     368                    { 
     369                         self::p404(); 
     370                    } 
     371                     
     372                    $file_path = $file->file; 
     373               } 
     374               # image thumbnail 
     375               # \see http://fr.php.net/preg_match 
     376               elseif (preg_match('@^([0-9]+)/(m|s|t|sq)$@',$args,$matches)) 
     377               { 
     378                    $file_id = $matches[1]; 
     379                    $size = $matches[2]; 
     380                     
     381                    $file = $core->media->getFile($file_id); 
    369382                     
    370383                    # check that the file is an image and the requested size is valid 
     
    378391                    { 
    379392                         # get the directory of the file and the filename of the thumbnail 
    380                          $image = dirname($file->file).'/'.basename($file->media_thumb[$size]); 
     393                         $file_path = dirname($file->file).'/'.basename($file->media_thumb[$size]); 
    381394                    } else 
    382395                    { 
    383                          $image = $file->file; 
     396                         $file_path = $file->file; 
    384397                    } 
    385                      
    386                     http::$cache_max_age = 36000; 
    387                     http::cache(array_merge(array($image),get_included_files())); 
    388                     header('Content-type: '.$file->type); 
    389                     header('Content-Length: '.filesize($image)); 
    390                     readfile($image); 
    391                     exit; 
    392                } 
     398               } 
     399               else 
     400               { 
     401                    self::p404(); 
     402               } 
     403                
     404               if ((!dlManager::inJail($file->relname)) || (!is_readable($file_path))) 
     405               { 
     406                    self::p404(); 
     407               } 
     408                
     409               http::$cache_max_age = 36000; 
     410               http::cache(array_merge(array($file_path),get_included_files())); 
     411               header('Content-type: '.$file->type); 
     412               header('Content-Length: '.filesize($file_path)); 
     413               readfile($file_path); 
     414               exit; 
    393415          } 
    394416          catch (Exception $e) 
     
    615637          $type = ($attr['type'] == 'dirs') ? 'dirs' : 'files'; 
    616638 
    617           return('<?php if (count($_ctx->{\'dlManager_'.$type.'\'}) == 0) : ?>'. 
     639          return('<?php if ($_ctx->{\'dlManager_'.$type.'\'}->count() == 0) : ?>'. 
    618640          $content. 
    619641          '<?php endif; ?>'); 
     
    799821          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    800822           
    801           if ($GLOBALS['core']->blog->settings->dlmanager_hide) 
     823          if ($GLOBALS['core']->blog->settings->dlmanager_hide_urls) 
    802824          { 
    803825               return('<?php echo($core->blog->url.'. 
     
    889911     public static function itemMTime($attr) 
    890912     { 
    891           $f = $GLOBALS['core']->tpl->getFilters($attr); 
    892            
    893           return('<?php echo '.sprintf($f,'$_ctx->items->media_dtstr').'; ?>'); 
     913          global $core; 
     914           
     915          $f = $GLOBALS['core']->tpl->getFilters($attr); 
     916           
     917          $str = '$_ctx->items->media_dtstr'; 
     918           
     919          if (isset($attr['format'])) 
     920          { 
     921               if ($attr['format'] == 'date_format') 
     922               { 
     923                    $format = $GLOBALS['core']->blog->settings->date_format; 
     924               } 
     925               elseif ($attr['format'] == 'time_format') 
     926               { 
     927                    $format = $GLOBALS['core']->blog->settings->time_format; 
     928               } 
     929               else 
     930               { 
     931                    $format = $attr['format']; 
     932               } 
     933                
     934               $str = 'dt::dt2str(\''.$format.'\','.$str.')'; 
     935          } 
     936           
     937          return('<?php echo '.sprintf($f,$str).'; ?>'); 
    894938     } 
    895939      
     
    934978          {$size = $attr['size'];} 
    935979           
    936           if ($GLOBALS['core']->blog->settings->dlmanager_hide) 
     980          if ($GLOBALS['core']->blog->settings->dlmanager_hide_urls) 
    937981          { 
    938982               return('<?php '. 
     
    11661210                    $mediaplayer = 
    11671211                         '<a href="'.$core->blog->url.$core->url->getBase('mediaplayer').'/'. 
    1168                          $item->media_id.'" title="'.__('Preview :').' '.$item->media_title.'">'. 
     1212                         $item->media_id.'" title="'.__('Preview:').' '.$item->media_title.'">'. 
    11691213                         '<img src="'.$core->blog->getQmarkURL(). 
    11701214                         'pf=dlManager/images/'.$icon.'" alt="'.__('Preview').'" />'. 
  • plugins/dlManager/default-templates/media.html

    r551 r552  
    177177                    </td> 
    178178                    <td class="size">{{tpl:DLMItemSize format="1"}}</td> 
    179                     <!-- #<td>{{tpl:DLMItemType}}</td> 
    180                          return "text/plain" --> 
    181                     <!-- #<td>{{tpl:DLMItemMediaType}}</td> 
    182                          return "text" --> 
    183                     <!-- #<td>{{tpl:DLMItemExtension}}</td> 
    184                          return "txt" --> 
    185                     <td>{{tpl:DLMItemMTime}}</td> 
     179                    <!-- #<td>{{tpl:DLMItemType}}</td>           return "text/plain" --> 
     180                    <!-- #<td>{{tpl:DLMItemMediaType}}</td> return "text" --> 
     181                    <!-- #<td>{{tpl:DLMItemExtension}}</td> return "txt" --> 
     182                    <!-- # date_format and time_format use blog settings, 
     183                         see http://php.net/strftime for other syntax --> 
     184                    <td>{{tpl:DLMItemMTime format="date_format"}} {{tpl:DLMItemMTime format="time_format"}}</td> 
    186185                    <tpl:DLMIfDownloadCounter> 
    187186                         <td class="number">{{tpl:DLMItemDlCount}}</td> 
  • plugins/dlManager/default-templates/media_player.html

    r551 r552  
    109109                    <dd>{{tpl:DLMItemSize format="1"}}</dd> 
    110110                    <dt>{{tpl:lang Modification time}}</dt> 
    111                     <dd>{{tpl:DLMItemMTime}}</dd> 
     111                    <!-- # date_format and time_format use blog settings, 
     112                         see http://php.net/strftime for other syntax --> 
     113                    <dd>{{tpl:DLMItemMTime format="date_format"}} {{tpl:DLMItemMTime format="time_format"}}</dd> 
    112114                    <tpl:DLMIfDownloadCounter> 
    113115                         <dt>{{tpl:lang Download number}}</dt> 
  • plugins/dlManager/index.php

    r551 r552  
    3333          $settings->put('dlmanager_active',!empty($_POST['dlmanager_active']), 
    3434               'boolean','Enable DL Manager'); 
    35           $settings->put('dlmanager_hide',!empty($_POST['dlmanager_hide']), 
     35          $settings->put('dlmanager_hide_urls',!empty($_POST['dlmanager_hide_urls']), 
    3636               'boolean','Hide files URLs'); 
    3737          $settings->put('dlmanager_counter',!empty($_POST['dlmanager_counter']), 
     
    101101               </p> 
    102102               <p> 
    103                     <?php echo form::checkbox('dlmanager_hide',1, 
    104                          $core->blog->settings->dlmanager_hide); ?> 
    105                     <label class="classic" for="dlmanager_hide"> 
    106                          <?php echo __('Hide files URLs'); ?> 
    107                     </label> 
    108                </p> 
    109                <p class="form-note"> 
    110                     <?php echo __('The files will be served without revealing their URLs.'); 
     103                    <?php echo form::checkbox('dlmanager_hide_urls',1, 
     104                         $core->blog->settings->dlmanager_hide_urls); ?> 
     105                    <label class="classic" for="dlmanager_hide_urls"> 
     106                         <?php echo __('Hide URLs of images, mp3 and flv files'); ?> 
     107                    </label> 
     108               </p> 
     109               <p class="form-note"> 
     110                    <?php echo __('The images, mp3 and flv files will be served without revealing their URLs.'); 
    111111                    echo ' '; 
    112112                    printf(__('The public directory (or its subdirectories) can be in a restricted area or protected by a %1$s file containing %2$s.'), 
  • plugins/dlManager/lib.dlManager.php

    r551 r552  
    123123          { 
    124124               $dir = trim($dir); 
    125                 
    126                # check 
    127                if (($dir == '.') OR ($dir == '..')) {self::p404();} 
    128125                
    129126               if (!empty($dir)) 
  • plugins/dlManager/locales/fr/main.po

    r551 r552  
    33"Project-Id-Version: DL Manager\n" 
    44"Report-Msgid-Bugs-To: \n" 
    5 "POT-Creation-Date: 2008-11-08 01:42+0100\n" 
    6 "PO-Revision-Date: 2008-11-08 01:42+0100\n" 
     5"POT-Creation-Date: 2008-11-09 04:14+0100\n" 
     6"PO-Revision-Date: 2008-11-09 04:14+0100\n" 
    77"Last-Translator: Moe <poedit@gniark.net>\n" 
    88"Language-Team: Moe <poedit@gniark.net>\n" 
     
    1717"X-Poedit-SearchPath-0: .\n" 
    1818 
    19 #: _public.php:142 
     19#: _public.php:74 
     20#: public_l10n.php:14 
     21msgid "Home" 
     22msgstr "" 
     23 
     24#: _public.php:146 
    2025msgid "parent directory" 
    2126msgstr "répertoire parent" 
    2227 
    23 #: _public.php:161 
     28#: _public.php:165 
    2429msgid "previous" 
    2530msgstr "précédente" 
    2631 
    27 #: _public.php:162 
     32#: _public.php:166 
    2833msgid "next" 
    2934msgstr "suivante" 
    3035 
    31 #: _public.php:1168 
     36#: _public.php:1213 
    3237#: public_l10n.php:22 
    33 msgid "Preview :" 
    34 msgstr "" 
    35  
    36 #: _public.php:1170 
     38msgid "Preview:" 
     39msgstr "" 
     40 
     41#: _public.php:1215 
    3742#: public_l10n.php:23 
    3843msgid "Preview" 
     
    179184msgstr "Revenir au répertoire" 
    180185 
    181 #: public_l10n.php:14 
    182 msgid "Home" 
    183 msgstr "" 
    184  
    185186#: public_l10n.php:15 
    186187msgid "Image meta" 
     
    238239 
    239240#: index.php:106 
    240 msgid "Hide files URLs" 
    241 msgstr "Cacher les URLs des fichiers" 
     241msgid "Hide URLs of images, mp3 and flv files" 
     242msgstr "Cacher les URLs des images et des fichiers mp3 et flv" 
    242243 
    243244#: index.php:110 
    244 msgid "The files will be served without revealing their URLs." 
    245 msgstr "Les fichiers seront servis sans révéler leurs URLs." 
     245msgid "The images, mp3 and flv files will be served without revealing their URLs." 
     246msgstr "Les images et les fichiers mp3 et flv seront servis sans révéler leurs URLs." 
    246247 
    247248#: index.php:112 
     
    320321msgstr "Enregistrer la configuration" 
    321322 
     323#~ msgid "Hide files URLs" 
     324#~ msgstr "Cacher les URLs des fichiers" 
     325 
  • plugins/dlManager/public_l10n.php

    r550 r552  
    2020__("No file."); 
    2121__("Page(s):"); 
    22 __("Preview :"); 
     22__("Preview:"); 
    2323__("Preview"); 
    2424__("Size"); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map