Plugin Directory

Changeset 598768


Ignore:
Timestamp:
09/13/2012 09:45:27 PM (13 years ago)
Author:
fabifott
Message:

WP-Filebase 0.2.9.20

  • Improved template engine performance
  • New option Destroy session when downloading
  • jQuery [DataTables](http://datatables.net/) included. See the default data table template (you have to reset to default templates)
  • New default template for DataTables
  • Extended upload form in Editor Plugin
  • Fixed widget upload permissions
  • Fixed using file extensions as thumbnail extensions (petebocken)
  • Fixed category sorting in multi categories lists
  • Fixed display of attachments in post lists (njsitebuilder)
  • Fixed filemtime error when adding URLs (altafali)
  • Fixed default permissions settings
  • Fixed AJAX response issue that broke the file browser on some servers
  • Added mimetype application/notebook
  • Changed wp-load in Editor Plugin (might fix blank screen)
Location:
wp-filebase
Files:
1044 added
25 edited

Legend:

Unmodified
Added
Removed
  • wp-filebase/trunk/classes/Admin.php

    r590827 r598768  
    103103    'private_files'         => array('default' => false, 'title' => __('Private Files', WPFB), 'type' => 'checkbox', 'desc' => __('Access to files is only permitted to owner and administrators.', WPFB)),
    104104   
    105     'frontend_upload'       => array('default' => false, 'title' => __('Enabled front end uploads', WPFB), 'type' => 'checkbox', 'desc' => __('Global option to allow file uploads from widgets and embedded file forms', WPFB)), //  (Pro only)
     105    'frontend_upload'       => array('default' => false, 'title' => __('Enable front end uploads', WPFB), 'type' => 'checkbox', 'desc' => __('Global option to allow file uploads from widgets and embedded file forms', WPFB)), //  (Pro only)
    106106   
    107107   
    108108    'accept_empty_referers' => array('default' => true, 'title' => __('Accept empty referers', WPFB), 'type' => 'checkbox', 'desc' => __('If enabled, direct-link-protected files can be downloaded when the referer is empty (i.e. user entered file url in address bar or browser does not send referers)', WPFB)),   
    109109    'allowed_referers'      => array('default' => '', 'title' => __('Allowed referers', WPFB), 'type' => 'textarea', 'desc' => __('Sites with matching URLs can link to files directly.', WPFB).'<br />'.$multiple_line_desc),
     110   
     111    'dl_destroy_session'    => array('default' => true, 'title' => __('Destroy session when downloading', WPFB), 'type' => 'checkbox', 'desc' => __('Should be enabled to allow users to download multiple files at the same time. This does not interfere WordPress user sessions, but can cause trouble with other plugins using the global $_SESSION.', WPFB)), 
    110112   
    111113    'decimal_size_format'   => array('default' => false, 'title' => __('Decimal file size prefixes', WPFB), 'type' => 'checkbox', 'desc' => __('Enable this if you want decimal prefixes (1 MB = 1000 KB = 1 000 000 B) instead of binary (1 MiB = 1024 KiB = 1 048 576 B)', WPFB)),
     
    245247    'file_url_encoded'      => __('Download URL encoded for use in query strings', WPFB),
    246248   
    247     'file_icon_url'         => __('URL of the thumbnail or icon', WPFB),   
     249    'file_icon_url'         => __('URL of the thumbnail or icon', WPFB),
    248250   
    249251    'file_size'             => __('Formatted file size', WPFB),
     
    601603    if(!empty($data->file_date)) {
    602604        $file->file_date = $data->file_date;
    603     } elseif($add_existing || empty($file->file_date)) {
    604         $file->file_date = gmdate('Y-m-d H:i:s', filemtime($file->GetLocalPath()));
     605    } elseif($add_existing || empty($file->file_date)) {       
     606        $file->file_date = gmdate('Y-m-d H:i:s', file_exists($file->GetLocalPath()) ? filemtime($file->GetLocalPath()) : time());
    605607    }
    606608   
     
    10811083        $content = __('The File has been uploaded successfully.', WPFB);
    10821084        $file = WPFB_File::GetFile($result['file_id']);
    1083         $content .= $file->GenTpl();
     1085        $content .= $file->GenTpl2();
    10841086        $title = trim(__('File added.', WPFB),'.');
    10851087    }
     
    11061108        $content = _e('New Category created.',WPFB);
    11071109        $cat = WPFB_Category::GetCat($result['cat_id']);
    1108         $content .= $cat->GenTpl();
     1110        $content .= $cat->GenTpl2();
    11091111        $title = trim(__('Category added.', WPFB),'.');
    11101112    }
     
    11781180    $all_roles = $wp_roles->roles;
    11791181    if(empty($selected_roles)) $selected_roles = array();
     1182    elseif(!is_array($selected_roles)) $selected_roles = array($selected_roles);
    11801183    ?>
    11811184<div id="<?php echo $field_name; ?>-wrap" class="tabs-panel"><input value="" type="hidden" name="<?php echo $field_name; ?>[]" />
  • wp-filebase/trunk/classes/AdminGuiSettings.php

    r590827 r598768  
    5454                       
    5555                    case 'roles':
    56                         foreach(array_keys($post[$opt_tag]) as $i) {
    57                             if(empty($post[$opt_tag][$i])) unset($post[$opt_tag][$i]);
    58                         }
     56                        $post[$opt_tag] = array_values(array_filter($post[$opt_tag]));
     57                        break;
    5958                   
    6059                    case 'cat':
    6160                        $post[$opt_tag] = (empty($post[$opt_tag]) || is_null($cat = WPFB_Category::GetCat($post[$opt_tag]))) ? 0 : intval($post[$opt_tag]);
     61                        break;
    6262                }                       
    6363            }
     
    200200        __('Display', WPFB)                 => array('file_date_format','thumbnail_size','auto_attach_files', 'attach_loop','attach_pos', 'filelist_sorting', 'filelist_sorting_dir', 'filelist_num', /* TODO: remove? 'parse_tags_rss',*/ 'decimal_size_format'),
    201201        __('File Browser',WPFB)             => array('file_browser_post_id','file_browser_cat_sort_by','file_browser_cat_sort_dir','file_browser_file_sort_by','file_browser_file_sort_dir','file_browser_fbc', 'late_script_loading','disable_footer_credits','footer_credits_style'),
    202         __('Download', WPFB)                => array('disable_permalinks', 'download_base', 'force_download', 'range_download', 'http_nocache', 'ignore_admin_dls', 'accept_empty_referers','allowed_referers'),
     202        __('Download', WPFB)                => array(
     203                                                'disable_permalinks', 'download_base', 'force_download', 'range_download', 'http_nocache', 'ignore_admin_dls', 'accept_empty_referers','allowed_referers','dl_destroy_session'),
    203204        __('Form Presets', WPFB)            => array('default_author','default_roles', 'default_cat', 'languages', 'platforms', 'licenses', 'requirements', 'custom_fields'),
    204205        __('Limits', WPFB)                  => array('bitrate_unregistered', 'bitrate_registered', 'traffic_day', 'traffic_month', 'traffic_exceeded_msg', 'file_offline_msg', 'daily_user_limits', 'daily_limit_subscriber', 'daily_limit_contributor', 'daily_limit_author', 'daily_limit_editor', 'daily_limit_exceeded_msg'),
  • wp-filebase/trunk/classes/AdminGuiTpls.php

    r590827 r598768  
    44static $sample_file = null;
    55static $sample_cat = null;
    6 static $protected_tags = array('default','single','excerpt');
     6static $protected_tags = array('default','single','excerpt','filebrowser','filepage');
    77
    88static function InitClass() {
     
    334334    </p>
    335335    <?php } ?>
    336    
    337     <div class="entry-content wpfilebase-tpl-preview">
    338         <div id="<?php echo $code_id ?>_preview"><?php     
    339         if($list) echo $tpl->Sample(self::$sample_cat, self::$sample_file);
    340         else echo empty($tpl_code)?'<i>'.__('Preview').'</i>' : $item->GenTpl(WPFB_TplLib::Parse($tpl_code), 'sample');
    341         ?></div>
    342         <div style="height: 50px; float: left;"></div>
    343         <div class="clear"></div>
    344     </div>
    345336           
    346337    <p class="submit"><input type="submit" name="submit" class="button-primary" value="<?php echo esc_attr__($new?'Add Template':'Submit Template Changes', WPFB) ?>" /></p>
    347338</form>
     339
     340<div class="entry-content wpfilebase-tpl-preview">
     341    <div id="<?php echo $code_id ?>_preview"><?php     
     342    if($list) echo $tpl->Sample(self::$sample_cat, self::$sample_file);
     343    else echo empty($tpl_code)?'<i>'.__('Preview').'</i>' : $item->GenTpl(WPFB_TplLib::Parse($tpl_code), 'sample');
     344    ?></div>
     345    <div style="height: 50px; float: left;"></div>
     346    <div class="clear"></div>
     347</div>
    348348<?php
    349349}
  • wp-filebase/trunk/classes/AdminLite.php

    r590827 r598768  
    8989    $ver = wpfb_call('Core', 'GetOpt', 'version');
    9090    if($ver != WPFB_VERSION) {
    91         wpfilebase_activate();
    92         //echo '<!-- WPFilebase: version changed -->';
     91        wpfb_loadclass('Setup');
     92        WPFB_Setup::OnActivateOrVerChange($ver);
    9393    }
    9494}
  • wp-filebase/trunk/classes/Core.php

    r566139 r598768  
    33static $load_js = false;
    44static $file_browser_search = false;
     5static $file_browser_item = null;
    56//static $options = null;
    67
     
    2627    // for attachments and file browser
    2728    add_filter('the_content',   array(__CLASS__, 'ContentFilter'), 10); // must be lower than 11 (before do_shortcode) and after wpautop (>9)
     29    add_filter('the_title', array(__CLASS__, 'TitleFilter'), 10, 2);
    2830    add_filter('ext2type', array(__CLASS__, 'Ext2TypeFilter'));
    2931    add_filter('wp_get_attachment_url', array(__CLASS__, 'GetAttachmentUrlFilter'));
     
    3638    wp_register_script('jquery-treeview-async', WPFB_PLUGIN_URI.'extras/jquery/treeview/jquery.treeview.async.js', array('jquery-treeview-edit'), WPFB_VERSION);
    3739    wp_register_style('jquery-treeview', WPFB_PLUGIN_URI.'extras/jquery/treeview/jquery.treeview.css', array(), WPFB_VERSION);
    38        
     40   
     41    // DataTables
     42    wp_register_script('jquery-dataTables', WPFB_PLUGIN_URI.'extras/jquery/dataTables/js/jquery.dataTables.min.js', array('jquery'), WPFB_VERSION);
     43    wp_register_style('jquery-dataTables', WPFB_PLUGIN_URI.'extras/jquery/dataTables/css/jquery.dataTables.css', array(), WPFB_VERSION);
    3944
    4045    wp_register_script(WPFB, WPFB_PLUGIN_URI.'js/common.js', array('jquery'), WPFB_VERSION); // cond loading (see Footer)
     
    6873    self::DownloadRedirect();
    6974   
    70     if(current_user_can('upload_files'))
     75    if(WPFB_Core::GetOpt('frontend_upload') || current_user_can('upload_files'))
    7176    {
    7277        if(!empty($_GET['wpfb_upload_file']) || !empty($_GET['wpfb_add_cat'])) {
     
    7782
    7883static function Nothing() { return ''; }
     84
     85static function GetPostId($query = null)
     86{
     87    global $wp_query, $post;
     88   
     89    if(!empty($post->ID)) return $post->ID;
     90   
     91    if(empty($query)) $query =& $wp_query; 
     92    if(!empty($query->post->ID)) return $wp_query->post->ID;   
     93    if(!empty($query->queried_object_id)) return $query->queried_object_id;
     94    if(!empty($query->query['post_id'])) return $query->query['post_id'];
     95    if(!empty($query->query['page_id'])) return $query->query['page_id'];
     96   
     97    return 0;
     98}
    7999
    80100static function ParseQuery(&$query)
     
    87107        WPFB_Core::$file_browser_search = true;     
    88108    add_filter('the_excerpt',   array(__CLASS__, 'SearchExcerptFilter'), 10); // must be lower than 11 (before do_shortcode) and after wpautop (>9)
     109
     110   
     111    // check if current post is file browser
     112    if( ($id=self::GetPostId($query)) == WPFB_Core::GetOpt('file_browser_post_id'))
     113    {
     114        $url = (is_ssl()?'https':'http').'://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
     115        if( ($qs=strpos($url,'?')) !== false ) $url = substr($url,0,$qs); // remove query string   
     116        $path = trim(substr($url, strlen(WPFB_Core::GetPostUrl($id))), '/');
     117        if(!empty($path)) {
     118            wpfb_loadclass('File','Category');
     119            self::$file_browser_item = WPFB_Item::GetByPath(urldecode($path));
     120            if(is_null(self::$file_browser_item)) self::$file_browser_item = WPFB_Item::GetByPath($path);
     121        }
     122    }   
    89123}
    90124
     
    243277}
    244278
     279function TitleFilter($title, $id)
     280{
     281    return $title;
     282}
     283
     284
    245285static function ShortCode($atts, $content=null, $tag=null) {
    246286    wpfb_loadclass('Output');
  • wp-filebase/trunk/classes/Download.php

    r555757 r598768  
    240240        case 'thmx':    return 'application/vnd.ms-officetheme';
    241241       
     242        case 'notebook':    return 'application/notebook';
     243       
    242244        default:        return 'application/octet-stream';
    243245    }
     
    443445        header("Content-Range: bytes " . $begin . "-" . ($end-1) . "/" . $size);
    444446   
    445     @session_destroy();
     447    if(WPFB_Core::GetOpt('dl_destroy_session'))
     448        @session_destroy();
    446449   
    447450    // send the file!
  • wp-filebase/trunk/classes/File.php

    r590827 r598768  
    44class WPFB_File extends WPFB_Item {
    55   
    6     static $thumbnail_regex = '/^-([0-9]+)x([0-9]+)\.(jpg|jpeg|png|gif)$/i';
     6    const THUMB_REGEX = '/^-([0-9]+)x([0-9]+)\.(jpg|jpeg|png|gif)$/i';
    77
    88    var $file_id = 0;
     
    203203        if(empty($this->file_last_dl_time)) $this->file_last_dl_time = '0000-00-00 00:00:00';
    204204        $r = parent::DBSave();
    205         //$this->UpdateWPAttachment();
    206205        return $r;
    207206    }
     
    288287            if(is_wp_error($thumb) && max($src_size) <= $thumb_size) { // error occurs when image is smaller than thumb_size. in this case, just copy original
    289288                $name = wp_basename($src_image, ".$ext");
    290                 $thumb = dirname($src_image)."/{$name}-{$src_size[0]}x{$src_size[1]}.{$ext}";
     289                $thumb = dirname($src_image)."/{$name}-{$src_size[0]}x{$src_size[1]}.".strtolower(strrchr($src_image, '.'));
    291290                copy($src_image, $thumb);
    292291            }
     
    607606    }
    608607   
    609     // TODO:
    610     function UpdateWPAttachment($file_changed=false) {
    611         global $wpdb;       
    612        
    613         return 0; // beta!!
    614         /*
    615        
    616         if($this->locked > 0) $this->TriggerLockedError();
    617        
    618         $rel_path = $this->GetLocalPath();
    619        
    620        
    621         if(!($uploads = wp_upload_dir()) || $uploads['error'] || strpos($rel_path, $uploads['basedir'].'/') === false) {
    622             echo "Path error. Cannot create WP attachmet!";
    623             return false;
    624         }
    625        
    626         $rel_path = str_replace(WPFB_Core::UploadDir(), '/'.WPFB, $rel_path);
    627        
    628         $object = array(
    629         'post_author' => $this->file_added_by,
    630         'post_content' => '[wpfilebase tag=file id='.$this->GetId().' tpl=single]',
    631         'post_title' => $this->GetTitle(),
    632         'post_excerpt' => $this->GenTpl(WPFB_Core::GetParsedTpl('file','excerpt')),
    633         'post_status' => $this->file_offline ? 'private' : 'publish',
    634         'post_password' => '',
    635         'post_name' => $this->GetName(),
    636         'to_ping' =>  '', 'pinged' => '',
    637         'post_content_filtered' => '',
    638         'post_parent' => $this->file_offline ? 0 : (int)WPFB_Core::GetOpt('file_browser_post_id'), //$this->file_post_id,
    639         'guid' => $this->GetUrl(),
    640         'menu_order' => $this->file_attach_order,
    641         'post_type' => 'attachment',
    642         'post_mime_type' => 'application/octet-stream' //wpfb_call('Download', 'GetFileType', $this->file_name),
    643         //'import_id' => $this->GetId()
    644         );
    645        
    646        
    647         $object = sanitize_post($object, 'db');
    648        
    649         // export array as variables
    650         extract($object, EXTR_SKIP);
    651        
    652         //$post_category = array( get_option('default_category') );
    653         $post_category = array();
    654        
    655        
    656         $ID = $this->file_wpattach_id;
    657         // Are we updating or creating?
    658         if ( !empty($ID) ) {
    659             $update = true;
    660             $post_ID = (int) $ID;
    661         } else {
    662             $update = false;
    663             $post_ID = 0;
    664         }
    665        
    666         // Create a valid post name.
    667         if ( empty($post_name) ) $post_name = sanitize_title($post_title);
    668         else $post_name = sanitize_title($post_name);
    669        
    670         // expected_slashed ($post_name)
    671         $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    672        
    673         $post_modified = $post_date = gmdate('Y-m-d H:i:s', $this->GetModifiedTime());
    674         $post_modified_gmt = $post_date_gmt = gmdate('Y-m-d H:i:s', $this->GetModifiedTime(true));
    675    
    676        
    677         if ( empty($comment_status) ) {
    678             if ( $update ) $comment_status = 'closed';
    679             else $comment_status = get_option('default_comment_status');
    680         }
    681        
    682         if ( empty($ping_status) ) $ping_status = get_option('default_ping_status');       
    683         if ( isset($to_ping) ) $to_ping = preg_replace('|\s+|', "\n", $to_ping);
    684         else $to_ping = '';
    685        
    686         if ( isset($post_parent) ) $post_parent = (int) $post_parent;
    687         else $post_parent = 0;
    688        
    689         if ( isset($menu_order) ) $menu_order = (int) $menu_order;
    690         else $menu_order = 0;
    691        
    692         if ( !isset($post_password) ) $post_password = '';
    693        
    694         if ( ! isset($pinged) ) $pinged = '';
    695        
    696        
    697         // expected_slashed (everything!)
    698         $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) );
    699         $data = stripslashes_deep( $data );
    700        
    701         if ( $update ) {
    702             $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
    703         } else {
    704             // If there is a suggested ID, use it if not already present
    705             if ( !empty($import_id) ) {
    706                 $import_id = (int) $import_id;
    707                 if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
    708                     $data['ID'] = $import_id;
    709                 }
    710             }
    711        
    712             $wpdb->insert( $wpdb->posts, $data );
    713             $post_ID = (int) $wpdb->insert_id;
    714         }
    715        
    716         if ( empty($post_name) ) {
    717             $post_name = sanitize_title($post_title, $post_ID);
    718             $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
    719         }
    720        
    721         wp_set_post_categories($post_ID, $post_category);
    722        
    723         update_post_meta($post_ID, '_wp_attached_file',  $rel_path);
    724        
    725         clean_post_cache($post_ID);
    726        
    727         if ( isset($post_parent) && $post_parent < 0 )
    728         add_post_meta($post_ID, '_wp_attachment_temp_parent', $post_parent, true);
    729        
    730         if ( ! empty( $context ) )
    731         add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    732        
    733         if ( $update) {
    734             do_action('edit_attachment', $post_ID);
    735         } else {
    736             do_action('add_attachment', $post_ID);
    737         }
    738        
    739         if(!$update || $file_changed || true) {
    740             $metadata = array();
    741             $w = (int)$this->getInfoValue(array('video','resolution_x'));
    742             if($w > 0) {
    743                 $metadata['width'] = $w;
    744                 $metadata['height'] = $h = (int)$this->getInfoValue(array('video','resolution_y'));
    745                 $metadata['file'] = ''; //$rel_path; TODO invalid, must be relative to wp-content/upload
    746                 //  $metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
    747                
    748                 if(!empty($this->file_thumbnail)) {
    749                     // calc thumb size
    750                     $max_side = max(array($w,$h));
    751                     $thumb_size = (int)WPFB_Core::GetOpt('thumbnail_size');
    752                     if($max_side > $thumb_size) {
    753                         $w *= $thumb_size / $max_side;
    754                         $h *= $thumb_size / $max_side;
    755                     }
    756                    
    757                     $img_sizes = array('thumbnail','medium','post-thumbnail','large-feature','small-feature');                 
    758                     $metadata['sizes'] = array();
    759                     foreach($img_sizes as $is) {
    760                         $metadata['sizes'][$is] = array(
    761                             'file' => $this->file_thumbnail,
    762                             'width' => (int)round($w),
    763                             'height' => (int)round($h)
    764                         );
    765                     }
    766                 }
    767             }
    768             // $metadata['file'] = _wp_relative_upload_path($file);
    769             if(!empty($metadata))
    770                 wp_update_attachment_metadata($post_ID, $metadata);         
    771         }
    772        
    773         if($this->file_wpattach_id != $post_ID) {
    774             $this->file_wpattach_id = $post_ID;
    775             if($this->locked == 0) $this->DBSave();
    776         }                   
    777        
    778         return $post_ID;
    779         /**/
    780     }
    781 
    782    
    783608    function IsRemote() { return !empty($this->file_remote_uri); } 
    784609    function IsLocal() { return empty($this->file_remote_uri); }
  • wp-filebase/trunk/classes/Item.php

    r590827 r598768  
    8989            $desc = (trim($sort[1]) == "DESC");
    9090        }
    91         $on = preg_replace('/[^0-9a-z]/i', '', $on); //strip hacking
     91        $on = preg_replace('/[^0-9a-z_]/i', '', $on); //strip hacking
    9292        $comparer = $desc ? "return -strcmp(\$a->{$on},\$b->{$on});" : "return strcmp(\$a->{$on},\$b->{$on});";
    9393        usort($items, create_function('$a,$b', $comparer));
     
    214214    }
    215215   
    216     function GetUrl($rel=false)
    217     {
    218         $ps = WPFB_Core::GetOpt('disable_permalinks') ? null : get_option('permalink_structure');       
    219         if($this->is_file) {
    220             if(!empty($ps)) $url = home_url(str_replace('#','%23',WPFB_Core::GetOpt('download_base').'/'.$this->GetLocalPathRel()));
    221             else $url = home_url('?wpfb_dl='.$this->file_id);
    222         } else {
     216    function GetUrl($rel=false, $to_file_page=false)
     217    { // TODO: rawurlencode??
     218        $ps = WPFB_Core::GetOpt('disable_permalinks') ? null : get_option('permalink_structure');
     219        if($this->is_category || $to_file_page) {
    223220            $url = get_permalink(WPFB_Core::GetOpt('file_browser_post_id'));   
    224221            if(!empty($ps)) $url .= str_replace('#','%23',$this->GetLocalPathRel()).'/';
    225             elseif($this->cat_id > 0) $url = add_query_arg(array('wpfb_cat' => $this->cat_id), $url);
    226             $url .= "#wpfb-cat-$this->cat_id"; 
     222            elseif($this->GetId() > 0) $url = add_query_arg(array("wpfb_file" => $this->GetId()), $url);
     223            if($this->is_category) $url .= "#wpfb-cat-$this->cat_id";   
     224        } else {
     225            if(!empty($ps)) $url = home_url(str_replace('#','%23',WPFB_Core::GetOpt('download_base').'/'.$this->GetLocalPathRel()));
     226            else $url = home_url('?wpfb_dl='.$this->file_id);           
    227227        }
    228228        if($rel) {
     
    259259        $f =& $this;
    260260        return eval("return ($parsed_tpl);");
     261    }
     262   
     263    function GenTpl2($tpl_tag=null, $load_js=true)
     264    {
     265        static $tpl_funcs = array('file' => array(), 'cat' => array());
     266       
     267        if(empty($tpl_tag)) $tpl_tag = 'default';
     268        if($load_js) WPFB_Core::$load_js = true;   
     269           
     270        $type = $this->is_file ? 'file' : 'cat';
     271       
     272        if(empty($tpl_funcs[$type][$tpl_tag]))
     273        {
     274            $parsed_tpl = WPFB_Core::GetParsedTpl($this->is_file?'file':'cat', $tpl_tag);
     275            if(empty($parsed_tpl)) return "Template $type :: $tpl_tag does not exist!";
     276            $tpl_funcs[$type][$tpl_tag] = create_function('$f', "return ($parsed_tpl);");
     277        }
     278       
     279        self::$tpl_uid++;
     280           
     281        return $tpl_funcs[$type][$tpl_tag]($this);
    261282    }
    262283   
  • wp-filebase/trunk/classes/ListTpl.php

    r566139 r598768  
    4242    }
    4343   
    44     static function ParseHeaderFooter($str) {
     44    static function ParseHeaderFooter($str, $uid=null) {
    4545        global $wp_query;   
    46         $str = preg_replace('/%sortlink:([a-z0-9_]+)%/ie', __CLASS__.'::GenSortlink(\'$1\')', $str);
     46        $str = preg_replace('/%sort_?link:([a-z0-9_]+)%/ie', __CLASS__.'::GenSortlink(\'$1\')', $str);
    4747        if(strpos($str, '%search_form%') !== false) {
    4848            $searching = !empty($_GET['wpfb_s']);
     
    6767            $str = str_replace('%search_form%', $form, $str);
    6868        }
     69       
     70        $str = preg_replace('/%print_?script:([a-z0-9_-]+)%/ie', __CLASS__.'::PrintScriptOrStyle(\'$1\', false)', $str);
     71        $str = preg_replace('/%print_?style:([a-z0-9_-]+)%/ie', __CLASS__.'::PrintScriptOrStyle(\'$1\', true)', $str);
     72   
     73        if(empty($uid)) $uid = uniqid();
     74        $str = str_replace('%uid%', $uid, $str);
     75       
    6976        return $str;
     77    }
     78   
     79    static function PrintScriptOrStyle($script, $style=false)
     80    {
     81        ob_start();
     82        if($style) wp_print_styles($script);
     83        else  wp_print_scripts($script);
     84        return ob_get_clean();
    7085    }
    7186   
     
    8297    function Generate($categories, $show_cats, $file_order, $page_limit, $cat_order=null)
    8398    {
    84         $content = self::ParseHeaderFooter($this->header);
     99        $uid = uniqid();
     100        $content = self::ParseHeaderFooter($this->header, $uid);
    85101        $hia = WPFB_Core::GetOpt('hide_inaccessible');
    86102        $sort = WPFB_Core::GetFileListSortSql($file_order);
    87        
    88         if($show_cats) $cat_tpl = WPFB_Core::GetParsedTpl('cat', $this->cat_tpl_tag);
    89         $file_tpl = WPFB_Core::GetParsedTpl('file', $this->file_tpl_tag);
    90103       
    91104        if($page_limit > 0) { // pagination
     
    104117            $num_total_files = WPFB_File::GetNumFiles2($where, $hia);
    105118            foreach($files as $file)
    106                 $content .= $file->GenTpl($file_tpl);
     119                $content .= $file->GenTpl2($this->file_tpl_tag);
    107120        } else {
    108121            if(!empty($cat_order))
     
    112125            if(count($categories) == 1 && $cat->cat_num_files > 0) { // single cat
    113126                if(!$cat->CurUserCanAccess()) return '';
    114                 if($show_cats) $content .= $cat->GenTpl($cat_tpl);
     127                if($show_cats) $content .= $cat->GenTpl2($this->cat_tpl_tag);
    115128                $where = "($where) AND ".WPFB_File::GetSqlCatWhereStr($cat->cat_id);
    116129                $files = WPFB_File::GetFiles2($where, $hia, $sort, $page_limit, $start);
    117130                $num_total_files = WPFB_File::GetNumFiles2($where, $hia);
    118131                foreach($files as $file)
    119                     $content .= $file->GenTpl($file_tpl);   
     132                    $content .= $file->GenTpl2($this->file_tpl_tag);   
    120133            } else { // multi-cat
    121134                // TODO: multi-cat list pagination does not work properly yet
     
    140153                            $files = WPFB_File::GetFiles2("($where) AND ".WPFB_File::GetSqlCatWhereStr($cat->cat_id), $hia, $sort, $page_limit, $start);
    141154                            if($show_cats && count($files) > 0)
    142                                 $content .= $cat->GenTpl($cat_tpl); // check for file count again, due to pagination!
     155                                $content .= $cat->GenTpl2($this->cat_tpl_tag); // check for file count again, due to pagination!
    143156                               
    144157                            foreach($files as $file) {
    145                                 $content .= $file->GenTpl($file_tpl);
     158                                $content .= $file->GenTpl2($this->file_tpl_tag);
    146159                                $n++;
    147160                            }
     
    164177                    $last = min($start + $page_limit, $num_total_files);
    165178                    for($i = $start; $i < $last; $i++)
    166                         $content .= $all_files[$keys[$i]]->GenTpl($file_tpl);
     179                        $content .= $all_files[$keys[$i]]->GenTpl2($this->file_tpl_tag);
    167180                }
    168181            }
    169182        }
    170183       
    171         $footer = self::ParseHeaderFooter($this->footer);
     184        $footer = self::ParseHeaderFooter($this->footer, $uid);
    172185       
    173186        if($page_limit > 0 && $num_total_files > $page_limit) {
     
    203216   
    204217    function Sample($cat, $file) {
    205         $cat_tpl = WPFB_Core::GetParsedTpl('cat', $this->cat_tpl_tag);
    206         $file_tpl = WPFB_Core::GetParsedTpl('file', $this->file_tpl_tag);
     218        $uid = uniqid();
    207219        $footer = str_replace('%page_nav%', paginate_links(array(
    208220            'base' => add_query_arg( 'wpfb_list_page', '%#%' ), 'format' => '',
    209221            'total' => 3,
    210222            'current' => 1
    211         )), self::ParseHeaderFooter($this->footer));
    212         return self::ParseHeaderFooter($this->header) . $cat->GenTpl($cat_tpl) . $file->GenTpl($file_tpl) . $footer;       
     223        )), self::ParseHeaderFooter($this->footer, $uid));
     224        return self::ParseHeaderFooter($this->header, $uid) . $cat->GenTpl2($this->cat_tpl_tag) . $file->GenTpl2($this->file_tpl_tag) . $footer;       
    213225    }
    214226   
  • wp-filebase/trunk/classes/Output.php

    r590827 r598768  
    33static $page_title = '';
    44static $page_content = '';
    5 
    65static function ProcessShortCode($args, $content = null, $tag = null)
    76{
     
    1817            wpfb_loadclass('File','Category');
    1918            if($id > 0 && ($file = WPFB_File::GetFile($id)) != null && $file->CurUserCanAccess(true))
    20                 return do_shortcode($file->GenTpl(WPFB_Core::GetParsedTpl('file',$args['tpl'])));
     19                return do_shortcode($file->GenTpl2($args['tpl']));
    2120            else break;
    2221           
     
    3938
    4039private static function genFileList(&$files, $tpl_tag=null)
    41 {
    42     if(!empty($tpl_tag)) $tpl = self::GetParsedTpl($tpl_tag);
    43     else $tpl = null;   
    44        
     40{       
    4541    $content = '';
    4642    foreach(array_keys($files) as $i)
    47         $content .= $files[$i]->GenTpl($tpl);
     43        $content .= $files[$i]->GenTpl2($tpl_tag);
    4844    $content .= '<div style="clear:both;"></div>';
    4945
     
    5147}
    5248
    53 static function GetPostId()
    54 {
    55     global $id, $wp_query;
    56     if(!empty($id) && $id > 0) return $id;
    57     if(!empty($wp_query->post) && !empty($wp_query->post->ID) && $wp_query->post->ID > 0) return $wp_query->post->ID;
    58    
    59     return 0;   
    60 }
    61 
    6249static function PostAttachments($check_attached = false, $tpl_tag=null)
    6350{
    64     static $attached = false;
    65    
    66     wpfb_loadclass('File', 'Category');
    67    
    68     $pid = self::GetPostId();
    69    
    70    
    71     if($pid==0 || ($check_attached && $attached) || count($files = &WPFB_File::GetAttachedFiles($pid)) == 0)
     51    static $attached = array();
     52    wpfb_loadclass('File', 'Category');
     53    $pid = WPFB_Core::GetPostId(); 
     54   
     55    if($pid==0 || ($check_attached && !empty($attached[$pid])) || count($files = &WPFB_File::GetAttachedFiles($pid)) == 0)
    7256        return '';
    73 
    74     $attached = true;
     57    $attached[$pid] = true;
     58   
    7559    return self::genFileList($files, $tpl_tag);
    7660}
     
    117101        $root_cat = ($root_cat_id==0) ? null : WPFB_Category::GetCat($root_cat_id);
    118102       
    119         $cur_cat = null;
     103        $cur_item = WPFB_Core::$file_browser_item;     
    120104        if($cur_cat_id > 0) {
    121             $cur_cat = WPFB_Category::GetCat($cur_cat_id);
    122         } else {
     105            $cur_item = WPFB_Category::GetCat($cur_cat_id);
     106        }
     107       
     108        /*else {
    123109            $url = (is_ssl()?'https':'http').'://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
    124110            if( ($qs=strpos($url,'?')) !== false ) $url = substr($url,0,$qs); // remove query string   
    125             $path = trim(substr($url, strlen(WPFB_Core::GetPostUrl(self::GetPostId()))), '/');
    126             if(!empty($path))
    127                 $cur_cat = WPFB_Category::GetByPath($path);
    128         }
     111            $path = trim(substr($url, strlen(WPFB_Core::GetPostUrl(WPFB_Core::GetPostId()))), '/');
     112            echo $path;
     113            if(!empty($path)) {
     114                $cur_cat = WPFB_Item::GetByPath($path);
     115                if(!is_null($cur_cat) && $cur_cat->is_file) {
     116                    $file =& $cur_cat;
     117                    print_r($file);
     118                    return;
     119                }
     120            }
     121        }
     122        */
    129123       
    130124        // make sure cur cat is a child cat of parent
    131         if(!is_null($cur_cat) && !is_null($root_cat) && !$root_cat->IsAncestorOf($cur_cat))
    132             $cur_cat = null;
     125        if(!is_null($cur_item) && !is_null($root_cat) && !$root_cat->IsAncestorOf($cur_item))
     126            $cur_item = null;
    133127       
    134128        $el_id = "wpfb-filebrowser-$fb_id";
     
    139133   
    140134        $parents = array();
    141         if(!is_null($cur_cat)) {
    142             $p = $cur_cat;
     135        if(!is_null($cur_item)) {
     136            $p = $cur_item;
    143137            do { array_push($parents, $p); } while(!is_null($p = $p->GetParent()) && !$p->Equals($root_cat));
    144138        }
    145139       
    146         $cat_tpl = WPFB_Core::GetParsedTpl('cat', 'filebrowser');
    147         $file_tpl = WPFB_Core::GetParsedTpl('file', 'filebrowser');
    148        
    149         self::FileBrowserList($content, $parents, $cat_tpl, $file_tpl, $root_cat);
     140        self::FileBrowserList($content, $parents, $root_cat);
    150141           
    151142        $content .= '</ul><div style="clear:both;"></div>';
     
    153144}
    154145
    155 static function FileBrowserList(&$content, &$parents, $cat_tpl, $file_tpl, $root_cat=null)
     146static function FileBrowserList(&$content, &$parents, $root_cat=null)
    156147{
    157148    $cats = WPFB_Category::GetFileBrowserCats(is_null($root_cat) ? 0 : $root_cat->cat_id);
     
    162153    if($files_before_cats) {
    163154        foreach($files as $file)
    164             $content .= '<li id="wpfb-file-'.$file->file_id.'"><span>'.$file->GenTpl($file_tpl, 'ajax')."</span></li>\n";
     155            $content .= '<li id="wpfb-file-'.$file->file_id.'"><span>'.$file->GenTpl2('filebrowser', false)."</span></li>\n";
    165156    }   
    166157   
     
    173164       
    174165        $content .= '<li id="wpfb-cat-'.$cat->cat_id.'" class="'.$liclass.'">';
    175         $content .= '<span>'.$cat->GenTpl($cat_tpl, 'ajax').'</span>';
     166        $content .= '<span>'.$cat->GenTpl2('filebrowser', false).'</span>';
    176167
    177168        if($has_children) {
    178169            $content .= "<ul>\n";           
    179             if($open) self::FileBrowserList($content, $parents, $cat_tpl, $file_tpl, $cat);
     170            if($open) self::FileBrowserList($content, $parents, $cat);
    180171            else $content .= '<li><span class="placeholder">&nbsp;</span></li>'."\n";
    181172            $content .= "</ul>\n";
     
    187178    if(!$files_before_cats) {
    188179        foreach($files as $file)
    189             $content .= '<li id="wpfb-file-'.$file->file_id.'"><span>'.$file->GenTpl($file_tpl, 'ajax')."</span></li>\n";
     180            $content .= '<li id="wpfb-file-'.$file->file_id.'"><span>'.$file->GenTpl2('filebrowser', false)."</span></li>\n";
    190181    }
    191182}
  • wp-filebase/trunk/classes/Search.php

    r555298 r598768  
    126126    $files = WPFB_File::GetFiles2(self::SearchWhereSql(WPFB_Core::GetOpt('search_id3'), stripslashes($_GET['wpfb_s'])), WPFB_Core::GetOpt('hide_inaccessible'));   
    127127    foreach($files as $file)
    128         $ref_content .= $file->GenTpl();
     128        $ref_content .= $file->GenTpl2();
    129129}
    130130}
  • wp-filebase/trunk/classes/Setup.php

    r590827 r598768  
    22
    33class WPFB_Setup {
    4 const MANY_FILES = 2000;
     4const MANY_FILES = 500;
    55const MANY_CATEGORIES = 500;
    66
     
    5353   
    5454}
    55 static function AddTpls() {
    56     $tpls_file = array(
     55static function AddTpls($old_ver) {
     56    $def_tpls_file = array(
    5757        'filebrowser' => '%file_small_icon% <a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)',
    5858        'image_320' => '[caption id="file_%file_id%" align="alignnone" width="320" caption="<!-- IF %file_description% -->%file_description%<!-- ELSE -->%file_display_name%<!-- ENDIF -->"]<img class="size-full" title="%file_display_name%" src="%file_url%" alt="%file_display_name%" width="320" />[/caption]'."\n\n",
     
    8686  <embed src='%wpfb_url%extras/flvplayer/OSplayer.swf?movie=%file_url_encoded%&btncolor=0x333333&accentcolor=0x31b8e9&txtcolor=0xdddddd&volume=30&autoload=on&autoplay=off&vTitle=%file_display_name%&showTitle=yes' width='%file_info/video/resolution_x%' height='%file_info/video/resolution_y%' allowFullScreen='true' type='application/x-shockwave-flash' allowScriptAccess='always'>
    8787 </object>",
     88   
     89    'data-table' => '<tr><td><a href="%file_url%">%file_display_name%</a></td><td>%file_size%</td><td>%file_hits%</td></tr>',
    8890    );
    8991   
    90     $tpls_cat = array(
     92    $def_tpls_cat = array(
    9193        'filebrowser' => '%cat_small_icon% <a href="%cat_url%" onclick="return false;">%cat_name%</a>',
    9294        '3-col-row' => '<tr><td colspan="3" style="text-align:center;font-size:120%;">%cat_name%</td></tr>',
     95        'data-table' => '<!-- EMPTY: categories should not be listed in DataTables -->',
    9396    );
    9497   
    95     add_option(WPFB_OPT_NAME.'_tpls_file', $tpls_file, null, 'no'/*autoload*/);
    96     add_option(WPFB_OPT_NAME.'_tpls_cat', $tpls_cat, null, 'no'/*autoload*/);   
     98    add_option(WPFB_OPT_NAME.'_tpls_file', $def_tpls_file, null, 'no'/*autoload*/);
     99    add_option(WPFB_OPT_NAME.'_tpls_cat', $def_tpls_cat, null, 'no'/*autoload*/);   
    97100    add_option(WPFB_OPT_NAME.'_ptpls_file', array(), null, 'no'/*autoload*/);
    98101    add_option(WPFB_OPT_NAME.'_ptpls_cat', array(), null, 'no'/*autoload*/);
    99102   
    100     $list_tpls = array(
     103    $def_tpls_list = array(
    101104        'default' => array(
    102105            'header' => '',
     
    127130            'cat_tpl_tag' => 'default'
    128131        ),
     132       
     133        'data-table' => array(
     134            'header' =>
     135'%print_script:jquery-dataTables%
     136%print_style:jquery-dataTables%
     137<table id="wpfb-data-table-%uid%">
     138<thead>
     139    <tr><th scope="col">Name</th><th scope="col">Size</th><th scope="col">Hits</th></tr>
     140</thead>
     141<tbody>',
     142            'footer' =>
     143'</tbody>
     144</table>
     145<script type="text/javascript" charset="utf-8">
     146    jQuery(document).ready(function() {
     147        jQuery(\'#wpfb-data-table-%uid%\').dataTable();
     148    } );
     149</script>',
     150            'file_tpl_tag' => 'data-table',
     151            'cat_tpl_tag' => 'data-table'
     152       
     153        )
    129154    );     
    130     add_option(WPFB_OPT_NAME.'_list_tpls', $list_tpls, null, 'no'/*autoload*/);
     155    add_option(WPFB_OPT_NAME.'_list_tpls', $def_tpls_list, null, 'no'/*autoload*/);
    131156       
    132157    // delete old (<0.2.0) tpl options and copy to new
     
    138163        WPFB_Core::SetFileTpls($file_tpls);
    139164    }
     165   
     166    // add protected tpls
     167    $tpls_file = get_option(WPFB_OPT_NAME.'_tpls_file');
     168    $tpls_cat = get_option(WPFB_OPT_NAME.'_tpls_cat');
     169    $tpls_list = get_option(WPFB_OPT_NAME.'_list_tpls');
     170   
     171    wpfb_loadclass('AdminGuiTpls');
     172    $default_templates = WPFB_AdminGuiTpls::$protected_tags;
     173   
     174    // add new data table template
     175    if(!empty($old_ver)) {
     176        if(version_compare($old_ver, '0.2.9.20') < 0)
     177            $default_templates[] = 'data-table';
     178    }
     179   
     180    foreach($default_templates as $pt) {
     181        if(empty($tpls_file[$pt]) && !empty($def_tpls_file[$pt])) $tpls_file[$pt] = $def_tpls_file[$pt];
     182        if(empty($tpls_cat[$pt]) && !empty($def_tpls_cat[$pt])) $tpls_cat[$pt] = $def_tpls_cat[$pt];
     183        if(empty($tpls_list[$pt]) && !empty($def_tpls_list[$pt])) $tpls_list[$pt] = $def_tpls_list[$pt];
     184    }
     185   
     186    update_option(WPFB_OPT_NAME.'_tpls_file', $tpls_file);
     187    update_option(WPFB_OPT_NAME.'_tpls_cat', $tpls_cat);
     188    update_option(WPFB_OPT_NAME.'_tpls_list', $tpls_list);
    140189   
    141190    WPFB_Admin::ParseTpls();
     
    419468           
    420469            $converted[$tag_str] = $tag_content;
    421            
    422 
    423 /*
    424             switch($tag[0]) {
    425                 case 'filelist':
    426                     $tag_content = wpfilebase_filelist(isset($args['cat']) ? intval($args['cat']) : -1, !empty($args['tpl']) ? $args['tpl'] : null);
    427                     break;
    428 
    429                 case 'file':
    430                     if(isset($args['file']) && is_object($file = WPFB_File::GetFile($args['file'])) && $file->CurUserCanAccess(true)) {
    431                         if(empty($args['tpl']))
    432                             $tag_content = $file->GenTpl();
    433                         else
    434                             $tag_content = $file->GenTpl(self::GetParsedTpl($args['tpl']));
    435                     }
    436                     break;
    437                    
    438                 case 'fileurl':
    439                     if(isset($args['file']) && is_object($file = WPFB_File::GetFile($args['file'])))
    440                         $tag_content = $file->GetUrl();
    441                     break;
    442                    
    443                 case 'attachments':
    444                     self::PostAttachments($tag_content, false, !empty($args['tpl']) ? $args['tpl'] : null);
    445                     break;
    446             }
    447 */
    448470        }
    449471
     
    474496}
    475497
    476 static function OnActivateOrVerChange() {
    477     wpfb_loadclass('File','Category');
     498static function OnActivateOrVerChange($old_ver=null) {
     499    wpfb_loadclass('Admin','File','Category');
    478500    self::SetupDBTables();
    479501    $old_options = get_option(WPFB_OPT_NAME);
    480502    self::AddOptions();
    481     self::AddTpls();
     503    self::AddTpls($old_ver);
    482504    WPFB_Admin::SettingsUpdated($old_options, get_option(WPFB_OPT_NAME));
    483505    self::ProtectUploadPath();
    484506    WPFB_Admin::FlushRewriteRules();
    485507   
     508    WPFB_Admin::WPCacheRejectUri(WPFB_Core::GetOpt('download_base') . '/', $old_options['download_base'] . '/');
     509       
    486510    $ncats = WPFB_Category::GetNumCats();
    487511    $nfiles = WPFB_File::GetNumFiles();
  • wp-filebase/trunk/classes/Sync.php

    r590827 r598768  
    241241           
    242242            $matches = array();
    243             if(preg_match(WPFB_File::$thumbnail_regex, $suffix, $matches) && ($is = getimagesize($sync_data->new_files[$i-1])))
     243            if(preg_match(WPFB_File::THUMB_REGEX, $suffix, $matches) && ($is = getimagesize($sync_data->new_files[$i-1])))
    244244            {
    245245                if($is[0] == $matches[1] && $is[1] == $matches[2])
  • wp-filebase/trunk/editor_plugin.php

    r590827 r598768  
    55    define( 'IFRAME_REQUEST' , true );
    66
    7 //require_once(dirname(__FILE__).'/../../../wp-load.php');
    8 // disable error reporting
    9 //error_reporting(0);
    10 require_once(dirname(__FILE__).'/../../../wp-admin/admin.php');
    11 // enable error reporting again
    12 //wp_debug_mode();
     7require_once(dirname(dirname(dirname(dirname(__FILE__)))).'/wp-load.php');
     8require_once(ABSPATH . 'wp-admin/includes/admin.php'); 
     9
     10auth_redirect();
     11
     12wpfb_loadclass('Core', 'File', 'Category', 'AdminLite', 'Admin', 'ListTpl', 'Output');
     13
     14wp_enqueue_script( 'common' );
     15wp_enqueue_script( 'jquery-color' );
     16wp_enqueue_script('jquery-treeview-async');
     17wp_enqueue_script('postbox');
     18wp_enqueue_script('wpfb-editor-plugin', WPFB_PLUGIN_URI."js/editor-plugin.js", array(), WPFB_VERSION);
     19
     20wp_enqueue_style( 'global' );
     21wp_enqueue_style( 'wp-admin' );
     22wp_enqueue_style( 'colors' );
     23wp_enqueue_style( 'media' );
     24wp_enqueue_style( 'ie' );
     25wp_enqueue_style('jquery-treeview');
     26
     27do_action('admin_init');
    1328
    1429// anti hack
    1530if(!current_user_can('publish_posts') && !current_user_can('edit_posts') && !current_user_can('edit_pages'))
    1631    wp_die(__('Cheatin&#8217; uh?'));
    17 
    18 function wpfb_editor_plugin_scripts() {
    19     //wp_enqueue_script('tiny-mce-popup', site_url().'/'.WPINC.'/js/tinymce/tiny_mce_popup.js');
    20     wp_enqueue_script('jquery');
    21     wp_enqueue_script('jquery-treeview-async');
    22     wp_enqueue_script('postbox');
    23     wp_enqueue_script('wpfb-editor-plugin', WPFB_PLUGIN_URI."js/editor-plugin.js", array(), WPFB_VERSION);
    24 }
    25 add_action('admin_enqueue_scripts', 'wpfb_editor_plugin_scripts');
    2632   
    2733@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    28 
    29 wpfb_loadclass('File', 'Category', 'Admin', 'ListTpl', 'Output');
    3034
    3135$action = empty($_REQUEST['action']) ? '' : $_REQUEST['action'];
     
    6266        }
    6367    }
     68    break;
    6469}
    6570
     
    7378
    7479<?php
    75 wp_enqueue_style( 'global' );
    76 wp_enqueue_style( 'wp-admin' );
    77 wp_enqueue_style( 'colors' );
    78 wp_enqueue_style( 'media' );
    79 wp_enqueue_style( 'ie' );
    80 wp_enqueue_style('jquery-treeview');
    81 
    8280do_action('admin_enqueue_scripts', 'media-upload-popup');
    8381do_action('admin_print_styles-media-upload-popup');
     
    272270    <?php
    273271}
    274 WPFB_Admin::PrintForm('file', $file, array('in_editor'=>true, 'post_id'=>$post_id));
     272WPFB_Admin::PrintForm('file', $file, array('exform'=>!empty($_GET['exform']), 'in_editor'=>true, 'post_id'=>$post_id));
    275273?>
    276274<h3 class="media-title"><?php _e('Attach existing file', WPFB) ?></h3>
  • wp-filebase/trunk/languages/template.po

    r590827 r598768  
    11741174
    11751175Secondary Categories
     1176
     1177Enable front end uploads
     1178
     1179Global option to allow file uploads from widgets and embedded file forms
     1180
     1181Frontend upload is disabled in security settings!
     1182
     1183Attachments in post lists
     1184
     1185Attach files to posts in archives, index and search result.
     1186
     1187The maximum side of the image is scaled to this value.
     1188
     1189File Date Format
  • wp-filebase/trunk/languages/wpfb-de_DE.po

    r465363 r598768  
    10571057
    10581058msgid "Reset all Templates to default"
    1059 msgstr "Standardtemplates widerherstellen"
     1059msgstr "Standardtemplates wiederherstellen"
    10601060
    10611061msgid "These templates can be used for categories."
  • wp-filebase/trunk/lib/wpfb_form_file.php

    r590827 r598768  
    77
    88$update = $multi_edit ? !empty($item) : (isset($item) && is_object($item) && !empty($item->file_id));
    9 $exform = $update || (!$in_editor && !empty($exform));
     9$exform = $update || ( /*!$in_editor && */ !empty($exform));
    1010
    1111
     
    4848<form enctype="multipart/form-data" name="<?php echo $action ?>" id="<?php echo $action ?>" method="post" action="<?php echo $form_url ?>" class="validate">
    4949
    50 <?php if($in_editor && !$in_widget) { ?><h3 class="media-title"><?php echo $title ?></h3>
    51 <?php } elseif(!$in_widget) {?><h2><?php echo $title ?> <?php if(!$in_editor && !$update) { ?><a style="font-style:normal;" href="<?php echo remove_query_arg('exform') ?>&amp;exform=<?php echo ($exform ? '0' : '1') . '#'.$action; ?>" class="add-new-h2"><?php _e($exform ? 'Simple Form' : 'Extended Form', WPFB) ?></a><?php } ?>
    52 </h2><?php } ?>
     50<?php
     51if(!$in_widget) {
     52    if($in_editor) {
     53        ?><div style="float: right;"><a style="font-style:normal;" href="<?php echo add_query_arg('exform', ($exform ? '0' : '1')); ?>"><?php _e($exform ? 'Simple Form' : 'Extended Form', WPFB) ?></a></div><?php     
     54        ?><h3 class="media-title"><?php echo $title ?></h3><?php
     55    } else {
     56        echo "<h2>".$title;
     57        ?><a style="font-style:normal;" href="<?php echo add_query_arg('exform', ($exform ? '0' : '1')).'#'.$action; ?>" class="add-new-h2"><?php _e($exform ? 'Simple Form' : 'Extended Form', WPFB) ?></a><?php
     58        echo "</h2>";
     59    }
     60}
     61?>
    5362
    5463<script type="text/javascript">
  • wp-filebase/trunk/readme.txt

    r590827 r598768  
    44Tags: filebase, filemanager, file, files, manager, upload, download, downloads, downloadmanager, traffic, widget, filelist, list, thumb, thumbnail, attachment, attachments, category, categories, media, template, ftp, http, mp3, id3
    55Requires at least: 3.1
    6 Tested up to: 3.4.1
    7 Stable tag: 0.2.9.19
     6Tested up to: 3.4.2
     7Stable tag: 0.2.9.20
    88
    99Adds a powerful download manager supporting file categories, downloads counter, widgets, sorted file lists and more to your WordPress blog.
     
    2727
    2828*   Category / child category / file taxonomy
    29 *   Automatic thumbnail
     29*   Automatic thumbnails
    3030*   Built-in download counter
     31*   Drag and Drop file upload
    3132*   File List Widget
    3233*   Ajax file tree browser
     
    3536*   Insert flexible shortcodes with the Visual Editor Plugin
    3637*   Sortable paginated file lists
     38*   Supports [DataTables](http://datatables.net/)
    3739*   Associate files to posts and automatically attach them to the content
    3840*   User Role access restrictions, limit file access to certain user roles
     
    5456**Important:** Don't upgrade to 0.2.1 if you are still running old PHP 4! WP-Filebase 0.2.1 only runs on PHP 5 and later!
    5557
    56 **Note:** If you only want to limit traffic or bandwidth of media files you should take a look at my [Traffic Limiter Plugin](http://wordpress.org/extend/plugins/traffic-limiter/ "Traffic Limiter").
    57 
    5858== Installation ==
    5959
     
    9595
    9696== Screenshots ==
    97 
    98 1. Example of an embedded download box with the default template
    99 2. The WP-Filebase Widgets
    100 3. AJAX file tree view
     971. The form to upload files
     982. AJAX file tree view
     993. Example of an embedded download box with the default template
    1011004. The Editor Button to insert tags for filelists and download urls
     1015. The Editor Plugin to create shortcodes for files, categories and lists
     1026. The WP-Filebase Widgets
     103
    102104
    103105== Changelog ==
     106
     107= 0.2.9.20 =
     108* Improved template engine performance
     109* New option `Destroy session when downloading`
     110* jQuery [DataTables](http://datatables.net/) included. See the default data table template (you have to reset to default templates)
     111* New default template for DataTables
     112* Fixed widget upload permissions
     113* Fixed using file extensions as thumbnail extensions (petebocken)
     114* Fixed category sorting in multi categories lists
     115* Fixed display of attachments in post lists  (njsitebuilder)
     116* Fixed filemtime error when adding URLs (altafali)
     117* Fixed default permissions settings
     118* Fixed AJAX response issue that broke the file browser on some servers
     119* Added mimetype `application/notebook`
     120* Changed wp-load in Editor Plugin (might fix blank screen)
    104121
    105122= 0.2.9.19 =
     
    502519== Plugin Developers ==
    503520WP-Filebase currently offers the action `wpfilebase_sync`. This will run a fast filebase sync that adds new files.
     521
     522== Traffic Limiter ==
     523If you only want to limit traffic or bandwidth of media files you should take a look at my [Traffic Limiter Plugin](http://wordpress.org/extend/plugins/traffic-limiter/ "Traffic Limiter").
  • wp-filebase/trunk/todo.txt

    r590827 r598768  
    1 
    2 thumnails in safari broken?
    3 editor_plugin: if test is marked, wrap file links around!
    4 preview for file lists broken!
     1wp-search: Notice: Undefined index: wpfb_s in C:\xampp\htdocs\wpt\wp-content\plugins\wp-filebase-pro\classes\Search.php on line 126
     2dont re-scan pdf when editing file without upload!
     3bmp thumnails in  otuner broken??!?
     4drag & drop file widget
     5file details without permalinks
     6singe download page
    57
    68extended form in editor plugin
    79simpel form by default!
    8 
    9 Download.php line 445 session destroy??? (only one download at a time??)
    10 toggle destroy session
    1110
    1211filebrowser subpage links to parent??!? fix?!
     
    2423http://i.imgur.com/lljts.png
    2524
    26 late script loading
    27  
     25
    2826 
    2927 
     
    116114 wpfilebase:
    117115 - download page +2
    118 -batch syncing! http://wordpress.org/support/topic/plugin-wp-filebase-download-manager-synchronizing-filebase-with-ftp-uploaded-files-not-complete?replies=2
    119116-multi uploadh
    120 -quick edit
    121117-wigets
    122118-public upload (like inline upload)
     
    130126- Custom field for post edit screen http://wordpress.org/support/topic/plugin-wp-filebase-download-manager-custom-field-for-post-edit-screen?replies=1
    131127- drag & drop widget
    132 - better cronjobbing
    133 -pdf thumbs!
    134128- auto redirect dl page
    1351291. superuser - can upload files to any user and see files for any user
  • wp-filebase/trunk/wp-filebase-admin.css

    r590827 r598768  
    2626.wpfilebase-tpledit {
    2727    width: 98%;
    28     font-size: 9px;
     28    font-size: 10px;
    2929    font-family: Consolas, Monaco, Courier, monospace;
    3030}
  • wp-filebase/trunk/wp-filebase.php

    r590827 r598768  
    55Description: Adds a powerful downloads manager supporting file categories, download counter, widgets, sorted file lists and more to your WordPress blog.
    66Author: Fabian Schlieper
    7 Version: 0.2.9.19
     7Version: 0.2.9.20
    88Author URI: http://fabi.me/
    99*/
     
    1212{
    1313    define('WPFB', 'wpfb');
    14     define('WPFB_VERSION', '0.2.9.19');
     14    define('WPFB_VERSION', '0.2.9.20');
    1515    define('WPFB_PLUGIN_ROOT', str_replace('\\','/',dirname(__FILE__)).'/');
    1616    if(!defined('ABSPATH')) {
     
    8484    }
    8585   
    86     // called on activation AND version change/update!!
    8786    function wpfilebase_activate() {
    8887        wpfb_loadclass('Core','Admin', 'Setup');
    89         WPFB_Setup::OnActivateOrVerChange();
     88        WPFB_Setup::OnActivateOrVerChange(WPFB_Core::GetOpt('version'));
    9089    }
    9190   
  • wp-filebase/trunk/wpfb-ajax.php

    r590827 r598768  
    66
    77function wpfb_print_json($obj) {
    8     @ob_end_clean();
    98    if(!WP_DEBUG)
    109        @header('Content-Type: application/json; charset=' . get_option('blog_charset'));
    11     echo json_encode($obj);
    12     @ob_flush();
    13     @flush();
     10    $json = json_encode($obj);
     11    @header('Content-Length: '.strlen($json));
     12    echo $json;
    1413    exit;
    1514}
     
    3332        $type = $_REQUEST['type'];
    3433       
    35         wpfb_loadclass('File','Category','Output');
     34        wpfb_loadclass('Core','File','Category','Output');
    3635       
    3736        // fixed exploit, thanks to Miroslav Stampar http://unconciousmind.blogspot.com/
     
    5251        if($filesel || $catsel) $onselect = $_REQUEST['onselect'];
    5352       
    54         $files_before_cats = $browser && WPFB_Core::GetOpt('file_browser_fbc');
    55        
    56         $cat_tpl = WPFB_Core::GetParsedTpl('cat', 'filebrowser');
    57         $file_tpl = WPFB_Core::GetParsedTpl('file', 'filebrowser');
    58    
     53        $files_before_cats = $browser && WPFB_Core::GetOpt('file_browser_fbc');
    5954       
    6055        $cats = $browser ? WPFB_Category::GetFileBrowserCats($parent_id) : WPFB_Category::GetCats("WHERE cat_parent = $parent_id ORDER BY cat_name ASC");   
     
    7671                    'text'=> $catsel ?
    7772                                    ('<a href="javascript:'.sprintf($onselect,$c->cat_id,str_replace('\'','\\\'', htmlspecialchars(stripslashes($c->cat_name)))).'">'.esc_html($c->GetTitle(24)).'</a>')
    78                                    :($filesel ? (esc_html($c->cat_name)." ($c->cat_num_files / $c->cat_num_files_total)") : $c->GenTpl($cat_tpl, 'ajax')),
     73                                   :($filesel ? (esc_html($c->cat_name)." ($c->cat_num_files / $c->cat_num_files_total)") : $c->GenTpl2('filebrowser', false)),
    7974                    'hasChildren'=>($catsel?(count($c->GetChildCats())>0):($c->cat_num_files_total > 0)),
    8075                    'classes'=>($filesel||$catsel)?'folder':null);
     
    9186            );
    9287            foreach($files as $f)
    93                 $file_items[$i++] = array('id'=>sprintf($file_id_format, $f->file_id), 'text'=>$filesel?('<a href="javascript:'.sprintf($onselect,$f->file_id,str_replace('\'','\\\'',htmlspecialchars(stripslashes($f->file_display_name)))).'">'.esc_html($f->GetTitle(24)).'</a> <span style="font-size:75%;vertical-align:top;">'.esc_html($f->file_name).'</span>'):$f->GenTpl($file_tpl, 'ajax'), 'classes'=>$filesel?'file':null);
     88                $file_items[$i++] = array('id'=>sprintf($file_id_format, $f->file_id), 'text'=>$filesel?('<a href="javascript:'.sprintf($onselect,$f->file_id,str_replace('\'','\\\'',htmlspecialchars(stripslashes($f->file_display_name)))).'">'.esc_html($f->GetTitle(24)).'</a> <span style="font-size:75%;vertical-align:top;">'.esc_html($f->file_name).'</span>'):$f->GenTpl2('filebrowser', false), 'classes'=>$filesel?'file':null);
    9489        }
    9590       
Note: See TracChangeset for help on using the changeset viewer.