Dotclear

Changeset 520


Ignore:
Timestamp:
10/13/08 03:05:14 (15 years ago)
Author:
Moe
google:author:
appears
Message:

Public Media 1.1.2 :

  • fixed bugs with settings' namespace (definitely)
  • fixed bug with BreadCrumb? when a page root is defined
  • added test before downloading file, the file must be in the root directory or its subdirectories
  • added compatibility with myUrlHandlers plugin
Location:
plugins/publicMedia
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/publicMedia/_admin.php

    r517 r520  
    4343          global $core; 
    4444 
    45           $settings->setNameSpace('publicmedia_page'); 
     45          $settings->setNameSpace('publicmedia'); 
    4646          $settings->put('publicmedia_page_active',!empty($_POST['publicmedia_page_active']), 
    4747               'boolean','Activate Media Page'); 
     
    5454               (!empty($_POST['publicmedia_page_root']) ? $_POST['publicmedia_page_root'] : ''), 
    5555               'string', 'root directory'); 
    56           $settings->put('publicmedia_count_dl', 
     56          /*$settings->put('publicmedia_count_dl', 
    5757               (!empty($_POST['publicmedia_count_dl']) ? $_POST['publicmedia_count_dl'] : serialize(array())), 
    58                'string', 'Download counter'); 
     58               'string', 'Download counter');*/ 
    5959          # inspirated from lightbox/admin.php 
    6060          $settings->setNameSpace('system'); 
  • plugins/publicMedia/_define.php

    r519 r520  
    2626     /* Description*/                "Display media on a public page or in a widget", 
    2727     /* Author */                    "Moe (http://gniark.net/), Osku and Tomtom (http://blog.zenstyle.fr)", 
    28      /* Version */                   '1.1.1', 
     28     /* Version */                   '1.1.2', 
    2929     /* Permissions */               'admin' 
    3030); 
  • plugins/publicMedia/_install.php

    r515 r520  
    3838$cur = $core->con->openCursor($core->prefix.'setting'); 
    3939$cur->setting_ns = 'publicmedia'; 
    40 $cur->update('WHERE (setting_id LIKE \'publicmedia_page%\') '. 
     40$cur->update('WHERE (setting_id LIKE \'publicmedia_%\') '. 
    4141     'AND setting_ns = \'system\';'); 
    4242 
  • plugins/publicMedia/_public.php

    r519 r520  
    7575                    $dirs = explode('/',$_ctx->mediaPage_currentDir); 
    7676                    $path = ''; 
     77                    //die('<pre>'.print_r($dirs,true).'</pre>'); 
    7778                    foreach ($dirs as $dir) 
    7879                    { 
    79                          $path = (($path == '') ? $dir : $path.'/'.$dir);  
    80                          $breadCrumb[$dir] = $base_url.$path; 
     80                         $dir = trim($dir); 
     81                         if (!empty($dir)) 
     82                         { 
     83                              $path = (($path == '') ? $dir : $path.'/'.$dir);  
     84                              $breadCrumb[$dir] = $base_url.$path; 
     85                         } 
    8186                    } 
    8287               } 
     
    130135                         $item->relname = 
    131136                              substr($item->relname,$page_root_len); 
     137                         # parent directory 
    132138                         if ($item->file == $parent_dir_full_path) 
    133139                         { 
     
    171177               $core->media = new dcMedia($core); 
    172178          } 
    173            
    174           $core->media->chdir($core->blog->settings->publicmedia_page_root); 
    175           // we need to test if the file is in a subdirectory of -^ 
    176           $core->media->getDir(); 
    177            
    178           $items = $core->media->dir['files']; 
    179            
    180           # initialize $file 
    181           $file = ''; 
    182            
    183           foreach ($items as $media_item) { 
    184                if ($media_item->media_id == $args) { 
    185                     $file_id = $media_item->media_id; 
    186                     $file_ext = $media_item->extension; 
    187                     $file_mime = $media_item->type; 
    188                     $file_name = $media_item->media_title; 
    189                     $file = $media_item->file; 
    190                     break; 
     179 
     180          $file = $core->media->getFile($args); 
     181           
     182          $page_root = $core->blog->settings->publicmedia_page_root; 
     183           
     184          if (!empty($page_root)) 
     185          { 
     186               if (strpos($file->relname,$page_root) !== 0) 
     187               { 
     188                    self::p404(); 
    191189               } 
    192           } 
    193           unset($items); 
     190          }          
    194191             
    195           if ($file && is_readable($file)) { 
     192          if ($file->file && is_readable($file->file)) { 
    196193               $count = unserialize($core->blog->settings->publicmedia_count_dl); 
    197                $count[$file_id] = array_key_exists($file_id,$count) ? $count[$file_id]+1 : 1; 
    198                // if (!is_object($core->settings)) ? 
    199                $settings = new dcSettings($core,$core->blog->id); 
    200                $settings->setNamespace('system'); 
     194               $count[$file->media_id] = array_key_exists($file->media_id,$count) ? $count[$file->media_id]+1 : 1; 
     195               if (!is_object($core->blog->settings)) 
     196               { 
     197                    $settings = new dcSettings($core,$core->blog->id); 
     198               } 
     199               else 
     200               { 
     201                    $settings =& $core->blog->settings; 
     202               } 
     203               $settings->setNamespace('publicmedia'); 
    201204               $settings->put('publicmedia_count_dl',serialize($count),'string','Download counter'); 
    202205               //$core->callBehavior('publicDownloadedFile',(integer)$args); 
    203                header('Content-type: '.$file_mime); 
    204                header('Content-Disposition: attachment; filename="'.$file_name.'"'); 
    205                readfile($file); 
     206               header('Content-type: '.$file->type); 
     207               header('Content-Disposition: attachment; filename="'.$file->basename.'"'); 
     208               readfile($file->file); 
    206209               exit; 
    207210          } 
     
    587590          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    588591 
    589           return('<?php echo($core->blog->url.\'download/\'.'.sprintf($f,'$_ctx->media_item->media_id').'); ?>'); 
     592          return('<?php echo($core->blog->url.$core->url->getBase(\'download\').\'/\'.'.sprintf($f,'$_ctx->media_item->media_id').'); ?>'); 
    590593     }          
    591594     /** 
Note: See TracChangeset for help on using the changeset viewer.

Sites map