Plugin Directory

Changeset 722195


Ignore:
Timestamp:
06/03/2013 05:52:33 PM (13 years ago)
Author:
fabifott
Message:

WP-Filebase 0.2.9.37

  • Fixed Batch Uploader
  • Further memory optimizations
  • Updated DataTables to 1.9.4
  • Fixed monthly/daily traffic limit
  • Fixed download range header handling (thanks to mrogaski)
  • Minified DataTables init JS to prevent auto <p>
  • Added wpfilebase_file_downloaded hook for download logging
  • Fixed HTML escaping for some file template vars
Location:
wp-filebase
Files:
296 added
28 edited

Legend:

Unmodified
Added
Removed
  • wp-filebase/trunk

    • Property svn:ignore set to
      .git
  • wp-filebase/trunk/classes/Admin.php

    r702142 r722195  
    1818}
    1919
    20 static function SettingsSchema()
    21 {
    22     $multiple_entries_desc = __("One entry per line. Seperate the title and a short tag (not longer than 8 characters) with '|'.<br />All lines beginning with '*' are selected by default.", WPFB);
    23     $multiple_line_desc = __('One entry per line.', WPFB);
    24     $bitrate_desc = __('Limits the maximum tranfer rate for downloads. 0 = unlimited', WPFB);
    25     $traffic_desc = __('Limits the maximum data traffic. 0 = unlimited', WPFB);
    26     $dls_per_day = __('downloads per day', WPFB);
    27     $daily_limit_for = __('Daily limit for %s', WPFB);
    28    
    29     $upload_path_base = str_replace(ABSPATH, '', get_option('upload_path'));
    30     if($upload_path_base == '' || $upload_path_base == '/')
    31         $upload_path_base = 'wp-content/uploads';
    32        
    33     $last_sync_time = intval(get_option(WPFB_OPT_NAME.'_cron_sync_time'));
    34     $last_sync_time = ($last_sync_time > 0) ? (" (".sprintf( __('Last cron sync on %1$s at %2$s.',WPFB), date_i18n( get_option( 'date_format'), $last_sync_time ), date_i18n( get_option( 'time_format'), $last_sync_time ) ).")") : '';
    35        
    36    
    37     $list_tpls = array_keys(wpfb_call('ListTpl','GetAll'));
    38     $list_tpls = empty($list_tpls) ? array() : array_combine($list_tpls, $list_tpls);
    39    
    40    
    41     return
    42     (
    43    
    44     array (
    45    
    46     // common
    47     'upload_path'           => array('default' => $upload_path_base . '/filebase', 'title' => __('Upload Path', WPFB), 'desc' => __('Path where all files are stored. Relative to WordPress\' root directory.', WPFB), 'type' => 'text', 'class' => 'code', 'size' => 65),
    48     'thumbnail_size'        => array('default' => 120, 'title' => __('Thumbnail size'), 'desc' => __('The maximum side of the image is scaled to this value.', WPFB), 'type' => 'number', 'class' => 'num', 'size' => 8),
    49     'thumbnail_path'        => array('default' => '', 'title' => __('Thumbnail Path',WPFB), 'desc' => __('Thumbnails can be stored at a different path than the actual files. Leave empty to use the default upload path.', WPFB), 'type' => 'text', 'class' => 'code', 'size' => 65),
    50    
    51     'base_auto_thumb'       => array('default' => true, 'title' => __('Auto-detect thumbnails',WPFB), 'type' => 'checkbox', 'desc' => __('Images are considered as thumbnails for files with the same name when syncing. (e.g `file.jpg` &lt;=&gt; `file.zip`)', WPFB)),
    52    
    53     'fext_blacklist'        => array('default' => 'db,tmp', 'title' => __('Extension Blacklist', WPFB), 'desc' => __('Files with an extension in this list are skipped while synchronisation. (seperate with comma)', WPFB), 'type' => 'text', 'class' => 'code', 'size' => 100),
    54 
    55     'attach_pos'            => array('default' => 1, 'title' => __('Attachment Position', WPFB), 'desc' => __('', WPFB), 'type' => 'select', 'options' => array(__('Before the Content',WPFB),__('After the Content',WPFB))),
    56    
    57     'attach_loop'           => array('default' => false,'title' => __('Attachments in post lists', WPFB), 'type' => 'checkbox', 'desc' => __('Attach files to posts in archives, index and search result.', WPFB)),
    58    
    59     // display
    60     'auto_attach_files'     => array('default' => true,'title' => __('Show attached files', WPFB), 'type' => 'checkbox', 'desc' => __('If enabled, all associated files are listed below an article', WPFB)),
    61     'filelist_sorting'      => array('default' => 'file_display_name', 'title' => __('Default sorting', WPFB), 'type' => 'select', 'desc' => __('The file property lists are sorted by', WPFB), 'options' => self::FileSortFields()),
    62     'filelist_sorting_dir'  => array('default' => 0, 'title' => __('Sort Order:'/*def*/), 'type' => 'select', 'desc' => __('The sorting direction of file lists', WPFB), 'options' => array(0 => __('Ascending'), 1 => __('Descending'))),
    63     'filelist_num'          => array('default' => 0, 'title' => __('Number of files per page', WPFB), 'type' => 'number', 'desc' => __('Length of the file list per page. Set to 0 to disable the limit.', WPFB)),
    64    
    65     'file_date_format'      => array('default' => get_option('date_format'), 'title' => __('File Date Format', WPFB), 'desc' => __('Date/Time formatting for files.',WPFB).' '.__('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.'), 'type' => 'text', 'class' => 'small-text'),
    66    
    67    
    68    
    69     // limits
    70     'bitrate_unregistered'  => array('default' => 0, 'title' => __('Bit rate limit for guests', WPFB), 'type' => 'number', 'unit' => 'KiB/Sec', 'desc' => &$bitrate_desc),
    71     'bitrate_registered'    => array('default' => 0, 'title' => __('Bit rate limit for registered users', WPFB), 'type' => 'number', 'unit' => 'KiB/Sec', 'desc' => &$bitrate_desc),   
    72     'traffic_day'           => array('default' => 0, 'title' => __('Daily traffic limit', WPFB), 'type' => 'number', 'unit' => 'MiB', 'desc' => &$traffic_desc),
    73     'traffic_month'         => array('default' => 0, 'title' => __('Monthly traffic limit', WPFB), 'type' => 'number', 'unit' => 'GiB', 'desc' => &$traffic_desc),
    74     'traffic_exceeded_msg'  => array('default' => __('Traffic limit exceeded! Please try again later.', WPFB), 'title' => __('Traffic exceeded message', WPFB), 'type' => 'text', 'size' => 65),
    75     'file_offline_msg'      => array('default' => __('This file is currently offline.', WPFB), 'title' => __('File offline message', WPFB), 'type' => 'text', 'size' => 65),
    76        
    77     'daily_user_limits'     => array('default' => false, 'title' => __('Daily user download limits', WPFB), 'type' => 'checkbox', 'desc' => __('If enabled, unregistered users cannot download any files. You can set different limits for each user role below.', WPFB)),
    78    
    79     'daily_limit_subscriber'    => array('default' => 5, 'title' => sprintf($daily_limit_for, _x('Subscriber', 'User role')), 'type' => 'number', 'unit' => &$dls_per_day),
    80     'daily_limit_contributor'   => array('default' => 10, 'title' => sprintf($daily_limit_for, _x('Contributor', 'User role')), 'type' => 'number', 'unit' => &$dls_per_day),
    81     'daily_limit_author'        => array('default' => 15, 'title' => sprintf($daily_limit_for, _x('Author', 'User role')), 'type' => 'number', 'unit' => &$dls_per_day),
    82     'daily_limit_editor'        => array('default' => 20, 'title' => sprintf($daily_limit_for, _x('Editor', 'User role')), 'type' => 'number', 'unit' => &$dls_per_day),
    83          
    84     'daily_limit_exceeded_msg'  => array('default' => __('You can only download %d files per day.', WPFB), 'title' => __('Daily limit exceeded message', WPFB), 'type' => 'text', 'size' => 65),
    85    
    86     // download
    87     'disable_permalinks'    => array('default' => false, 'title' => __('Disable download permalinks', WPFB), 'type' => 'checkbox', 'desc' => __('Enable this if you have problems with permalinks.', WPFB)),
    88     'download_base'         => array('default' => 'download', 'title' => __('Download URL base', WPFB), 'type' => 'text', 'desc' => sprintf(__('The url prefix for file download links. Example: <code>%s</code> (Only used when Permalinks are enabled.)', WPFB), get_option('home').'/%value%/category/file.zip')),
    89    
    90     'file_browser_post_id'      => array('default' => '', 'title' => __('Post ID of the file browser', WPFB), 'type' => 'number', 'unit' => '<span id="file_browser_post_title">'.(($fbid=WPFB_Core::GetOpt('file_browser_post_id'))?('<a href="'.get_permalink($fbid).'">'.get_the_title($fbid).'</a>'):'').'</span> <a href="javascript:;" class="button" onclick="WPFB_PostBrowser(\'file_browser_post_id\',\'file_browser_post_title\')">' . __('Select') . '</a>', 'desc' => __('Specify the ID of the post or page where the file browser should be placed. If you want to disable this feature leave the field blank.', WPFB).' '.__('Note that the selected page should <b>not have any sub-pages</b>!')),
    91    
    92     'file_browser_cat_sort_by'      => array('default' => 'cat_name', 'title' => __('File browser category sorting', WPFB), 'type' => 'select', 'desc' => __('The category property categories in the file browser are sorted by', WPFB), 'options' => self::CatSortFields()),
    93     'file_browser_cat_sort_dir' => array('default' => 0, 'title' => __('Sort Order:'/*def*/), 'type' => 'select', 'desc' => '', 'options' => array(0 => __('Ascending'), 1 => __('Descending'))),
    94    
    95     'file_browser_file_sort_by'     => array('default' => 'file_display_name', 'title' => __('File browser file sorting', WPFB), 'type' => 'select', 'desc' => __('The file property files in the file browser are sorted by', WPFB), 'options' => self::FileSortFields()),
    96     'file_browser_file_sort_dir'    => array('default' => 0, 'title' => __('Sort Order:'/*def*/), 'type' => 'select', 'desc' => '', 'options' => array(0 => __('Ascending'), 1 => __('Descending'))),
    97    
    98     'file_browser_fbc'      => array('default' => false, 'title' => __('Files before Categories', WPFB), 'type' => 'checkbox', 'desc' => __('Files will appear above categories in the file browser.', WPFB)),
    99    
    100     'small_icon_size'       => array('default' => 32, 'title' => __('Small Icon Size'), 'desc' => __('Icon size (height) for categories and files. Set to 0 to show icons in full size.', WPFB), 'type' => 'number', 'class' => 'num', 'size' => 8),
    101            
    102    
    103     'cat_drop_down'         => array('default' => false, 'title' => __('Category drop down list', WPFB), 'type' => 'checkbox', 'desc' => __('Use category drop down list in the file browser instead of listing like files.', WPFB)),
    104 
    105     'force_download'        => array('default' => false, 'title' => __('Always force download', WPFB), 'type' => 'checkbox', 'desc' => __('If enabled files that can be viewed in the browser (like images, PDF documents or videos) can only be downloaded (no streaming).', WPFB)),
    106     'range_download'        => array('default' => true, 'title' => __('Send HTTP-Range header', WPFB), 'type' => 'checkbox', 'desc' => __('Allows users to pause downloads and continue later. In addition download managers can use multiple connections at the same time.', WPFB)),
    107     'hide_links'            => array('default' => false, 'title' => __('Hide download links', WPFB), 'type' => 'checkbox', 'desc' => sprintf(__('File download links wont be displayed in the browser\'s status bar. You should enable \'%s\' to make it even harder to find out the URL.', WPFB), __('Always force download', WPFB))),
    108     'ignore_admin_dls'      => array('default' => true, 'title' => __('Ignore downloads by admins', WPFB), 'type' => 'checkbox'),
    109     'hide_inaccessible'     => array('default' => true, 'title' => __('Hide inaccessible files and categories', WPFB), 'type' => 'checkbox', 'desc' => __('If enabled files tagged <i>For members only</i> will not be listed for guests or users whith insufficient rights.', WPFB)),
    110     'inaccessible_msg'      => array('default' => __('You are not allowed to access this file!', WPFB), 'title' => __('Inaccessible file message', WPFB), 'type' => 'text', 'size' => 65, 'desc' => (__('This message will be displayed if users try to download a file they cannot access', WPFB).'. '.__('You can enter a URL to redirect users.', WPFB))),
    111     'inaccessible_redirect' => array('default' => false, 'title' => __('Redirect to login', WPFB), 'type' => 'checkbox', 'desc' => __('Guests trying to download inaccessible files are redirected to the login page if this option is enabled.', WPFB)),
    112     'cat_inaccessible_msg'  => array('default' => __('Access to category denied!', WPFB), 'title' => __('Inaccessible category message', WPFB), 'type' => 'text', 'size' => 65, 'desc' => (__('This message will be displayed if users try to access a category without permission.', WPFB))),
    113     'login_redirect_src'    => array('default' => false, 'title' => __('Redirect to referring page after login', WPFB), 'type' => 'checkbox', 'desc' => __('Users are redirected to the page where they clicked on the download link after logging in.', WPFB)),
    114    
    115     'http_nocache'          => array('default' => false, 'title' => __('Disable HTTP Caching', WPFB), 'type' => 'checkbox', 'desc' => __('Enable this if you have problems with downloads while using Wordpress with a cache plugin.', WPFB)),
    116    
    117     'parse_tags_rss'        => array('default' => true, 'title' => __('Parse template tags in RSS feeds', WPFB), 'type' => 'checkbox', 'desc' => __('If enabled WP-Filebase content tags are parsed in RSS feeds.', WPFB)),
    118    
    119     'allow_srv_script_upload'   => array('default' => false, 'title' => __('Allow script upload', WPFB), 'type' => 'checkbox', 'desc' => __('If you enable this, scripts like PHP or CGI can be uploaded. <b>WARNING:</b> Enabling script uploads is a <b>security risk</b>!', WPFB)),
    120     'protect_upload_path'   => array('default' => true, 'title' => __('Protect upload path', WPFB), 'type' => 'checkbox', 'desc' => __('This prevents direct access to files in the upload directory.', WPFB)),
    121 
    122          
    123     'private_files'         => array('default' => false, 'title' => __('Private Files', WPFB), 'type' => 'checkbox', 'desc' => __('Access to files is only permitted to owner and administrators.', WPFB)),
    124    
    125     '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)
    126    
    127    
    128     '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)),   
    129     '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),
    130    
    131     //'dl_destroy_session'  => array('default' => false, '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)),
    132     'use_fpassthru'         => array('default' => false, 'title' => __('Use fpassthru', WPFB), 'type' => 'checkbox', 'desc' => __('Downloads will be serverd using the native PHP function fpassthru. Enable this when you are experiencing trouble with large files. Note that bandwidth throttle is not available for this method.', WPFB)),
    133    
    134     '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)),
    135    
    136     'admin_bar' => array('default' => true, 'title' => __('Add WP-Filebase to admin menu bar', WPFB), 'type' => 'checkbox', 'desc' => __('Display some quick actions for file management in the admin menu bar.', WPFB)),
    137     //'file_context_menu'   => array('default' => true, 'title' => '', 'type' => 'checkbox', 'desc' => ''),
    138    
    139     'cron_sync' => array('default' => false, 'title' => __('Automatic Sync', WPFB), 'type' => 'checkbox', 'desc' => __('Schedules a cronjob to hourly synchronize the filesystem and the database.', WPFB).$last_sync_time),
    140    
    141     'remove_missing_files'  => array('default' => false, 'title' => __('Remove Missing Files', WPFB), 'type' => 'checkbox', 'desc' => __('Missing files are removed from the database during sync', WPFB)),
    142    
    143            
    144    
    145     'search_integration' =>  array('default' => true, 'title' => __('Search Integration', WPFB), 'type' => 'checkbox', 'desc' => __('Searches in attached files and lists the associated posts and pages when searching the site.', WPFB)),
    146    
    147     'search_result_tpl' =>  array('default' => 'default', 'title' => __('Search Result Template', WPFB), 'type' => 'select', 'options' => $list_tpls, 'desc' => __('Set the List Template used for Search Results when using the Search Widget', WPFB)),
    148 
    149          
    150     'disable_id3' =>  array('default' => false, 'title' => __('Disable ID3 tag detection', WPFB), 'type' => 'checkbox', 'desc' => __('This disables all meta file info reading. Use this option if you have issues adding large files.', WPFB)),
    151     'search_id3' =>  array('default' => true, 'title' => __('Search ID3 Tags', WPFB), 'type' => 'checkbox', 'desc' => __('Search in file meta data, like ID3 for MP3 files, EXIF for JPEG... (this option does not increase significantly server load since all data is cached in a MySQL table)', WPFB)),
    152     'use_path_tags' => array('default' => false, 'title' => __('Use path instead of ID in Shortcode', WPFB), 'type' => 'checkbox', 'desc' => __('Files and Categories are identified by paths and not by their IDs in the generated Shortcodes', WPFB)),
    153     'no_name_formatting'  => array('default' => false, 'title' => __('Disable Name Formatting', WPFB), 'type' => 'checkbox', 'desc' => __('This will disable automatic formatting/uppercasing file names when they are used as title (e.g. when syncing)', WPFB)),
    154    
    155     // file browser
    156     'disable_footer_credits'  => array('default' => true, 'title' => __('Remove WP-Filebase Footer credits', WPFB), 'type' => 'checkbox', 'desc' => sprintf(__('This disables the footer credits only displayed on <a href="%s">File Browser Page</a>. Why should you keep the credits? Every backlink helps WP-Filebase to get more popular, popularity motivates the developer to continue work on the plugin.', WPFB), get_permalink(WPFB_Core::GetOpt('file_browser_post_id')).'#wpfb-credits')),
    157     'footer_credits_style'  => array('default' => 'margin:0 auto 2px auto; text-align:center; font-size:11px;', 'title' => __('Footer credits Style', WPFB), 'type' => 'text', 'class' => 'code', 'desc' => __('Set custom CSS style for WP-Filebase footer credits',WPFB),'size'=>80),
    158     'late_script_loading'   => array('default' => false, 'title' => __('Late script loading', WPFB), 'type' => 'checkbox', 'desc' => __('Scripts will be included in content, not in header. Enable if your AJAX tree view does not work properly.', WPFB)),
    159    
    160     'default_author' => array('default' => '', 'title' => __('Default Author', WPFB), 'desc' => __('This author will be used as form default and when adding files with FTP', WPFB), 'type' => 'text', 'size' => 65),
    161     'default_roles' => array('default' => array(), 'title' => __('Default User Roles', WPFB), 'desc' => __('These roles are selected by default and will be used for files added with FTP', WPFB), 'type' => 'roles'),
    162    
    163     'default_cat' => array('default' => 0, 'title' => __('Default Category', WPFB), 'desc' => __('Preset Category in the file form', WPFB), 'type' => 'cat'),
    164        
    165     'languages'             => array('default' => "English|en\nDeutsch|de", 'title' => __('Languages'), 'type' => 'textarea', 'desc' => &$multiple_entries_desc),
    166     'platforms'             => array('default' => "Windows 95|win95\n*Windows 98|win98\n*Windows 2000|win2k\n*Windows XP|winxp\n*Windows Vista|vista\n*Windows 7|win7\nLinux|linux\nMac OS X|mac", 'title' => __('Platforms', WPFB), 'type' => 'textarea', 'desc' => &$multiple_entries_desc, 'nowrap' => true),   
    167     'licenses'              => array('default' =>
    168 "*Freeware|free\nShareware|share\nGNU General Public License|gpl|http://www.gnu.org/copyleft/gpl.html\nGNU Lesser General Public License|lgpl\nGNU Affero General Public License|agpl\nCC Attribution-NonCommercial-ShareAlike|ccbyncsa|http://creativecommons.org/licenses/by-nc-sa/3.0/", 'title' => __('Licenses', WPFB), 'type' => 'textarea', 'desc' => &$multiple_entries_desc, 'nowrap' => true),
    169     'requirements'          => array('default' =>
    170 "PDF Reader|pdfread|http://www.foxitsoftware.com/pdf/reader/addons.php
    171 Java|java|http://www.java.com/download/
    172 Flash|flash|http://get.adobe.com/flashplayer/
    173 Open Office|ooffice|http://www.openoffice.org/download/index.html
    174 .NET Framework 3.5|.net35|http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6",
    175     'title' => __('Requirements', WPFB), 'type' => 'textarea', 'desc' => $multiple_entries_desc . ' ' . __('You can optionally add |<i>URL</i> to each line to link to the required software/file.', WPFB), 'nowrap' => true),
    176    
    177     'default_direct_linking'    => array('default' => 1, 'title' => __('Default File Direct Linking'), 'type' => 'select', 'desc' => __('', WPFB), 'options' => array(1 => __('Allow direct linking', WPFB), 0 => __('Redirect to post', WPFB) )),   
    178          
    179     'custom_fields'         => array('default' => "Custom Field 1|cf1\nCustom Field 2|cf2", 'title' => __('Custom Fields'), 'type' => 'textarea', 'desc' =>
    180     __('With custom fields you can add even more file properties.',WPFB).' '.$multiple_entries_desc),
    181    
    182    
    183    
    184    
    185    
    186     'template_file'         => array('default' =>
    187 <<<TPLFILE
    188 <div class="wpfilebase-file-default" onclick="if('undefined' == typeof event.target.href) document.getElementById('wpfb-file-link-%uid%').click();">
    189   <div class="icon"><a href="%file_url%" target="_blank" title="Download %file_display_name%"><img align="middle" src="%file_icon_url%" alt="%file_display_name%" /></a></div>
    190   <div class="filetitle">
    191     <a href="%file_url%" title="Download %file_display_name%" target="_blank" id="wpfb-file-link-%uid%">%file_display_name%</a>
    192     <!-- IF %file_post_id% AND %post_id% != %file_post_id% --><a href="%file_post_url%" class="postlink">&raquo; %'Post'%</a><!-- ENDIF -->
    193     <br />
    194     %file_name%<br />
    195     <!-- IF %file_version% -->%'Version:'% %file_version%<br /><!-- ENDIF -->
    196   </div>
    197   <div class="info">
    198     %file_size%<br />
    199     %file_hits% %'Downloads'%<br />
    200     <a href="#" onclick="return wpfilebase_filedetails(%uid%);">%'Details'%</a>
    201   </div>
    202   <div class="details" id="wpfilebase-filedetails%uid%" style="display: none;">
    203   <!-- IF %file_description% --><p>%file_description%</p><!-- ENDIF -->
    204   <table border="0">
    205    <!-- IF %file_languages% --><tr><td><strong>%'Languages'%:</strong></td><td>%file_languages%</td></tr><!-- ENDIF -->
    206    <!-- IF %file_author% --><tr><td><strong>%'Author'%:</strong></td><td>%file_author%</td></tr><!-- ENDIF -->
    207    <!-- IF %file_platforms% --><tr><td><strong>%'Platforms'%:</strong></td><td>%file_platforms%</td></tr><!-- ENDIF -->
    208    <!-- IF %file_requirements% --><tr><td><strong>%'Requirements'%:</strong></td><td>%file_requirements%</td></tr><!-- ENDIF -->
    209    <!-- IF %file_category% --><tr><td><strong>%'Category:'%</strong></td><td>%file_category%</td></tr><!-- ENDIF -->
    210    <!-- IF %file_license% --><tr><td><strong>%'License'%:</strong></td><td>%file_license%</td></tr><!-- ENDIF -->
    211    <tr><td><strong>%'Date'%:</strong></td><td>%file_date%</td></tr>
    212   </table>
    213   </div>
    214  <div style="clear: both;"></div>
    215 </div>
    216 TPLFILE
    217     , 'title' => __('Default File Template', WPFB), 'type' => 'textarea', 'desc' => (self::TplFieldsSelect('template_file') . '<br />' . __('The template for attachments', WPFB)), 'class' => 'code'),
    218 
    219     'template_cat'          => array('default' =>
    220 <<<TPLCAT
    221 <div class="wpfilebase-cat-default">
    222   <h3>
    223     <!-- IF %cat_has_icon% || true -->%cat_small_icon%<!-- ENDIF -->
    224     <a href="%cat_url%" title="Go to category %cat_name%">%cat_name%</a>
    225     <span>%cat_num_files% <!-- IF %cat_num_files% == 1 -->file<!-- ELSE -->files<!-- ENDIF --></span>
    226   </h3>
    227 </div>
    228 TPLCAT
    229     , 'title' => __('Category Template', WPFB), 'type' => 'textarea', 'desc' => (self::TplFieldsSelect('template_cat', false, true) . '<br />' . __('The template for category lists (used in the file browser)', WPFB)), 'class' => 'code'),
    230 
    231     'dlclick_js'            => array('default' =>
    232 <<<JS
    233 if(typeof pageTracker == 'object') {
    234     pageTracker._trackPageview(file_url); // new google analytics tracker
    235 } else if(typeof urchinTracker == 'function') {
    236     urchinTracker(file_url); // old google analytics tracker
    237 }
    238 JS
    239     , 'title' => __('Download JavaScript', WPFB), 'type' => 'textarea', 'desc' => __('Here you can enter JavaScript Code which is executed when a user clicks on file download link. The following variables can be used: <i>file_id</i>: the ID of the file, <i>file_url</i>: the clicked download url', WPFB), 'class' => 'code'),
    240 
    241     //'max_dls_per_ip'          => array('default' => 10, 'title' => __('Maximum downloads', WPFB), 'type' => 'number', 'unit' => 'per file, per IP Address', 'desc' => 'Maximum number of downloads of a file allowed for an IP Address. 0 = unlimited'),
    242     //'archive_lister'          => array('default' => false, 'title' => __('Archive lister', WPFB), 'type' => 'checkbox', 'desc' => __('Uploaded files are scanned for archives', WPFB)),
    243     //'enable_ratings'          => array('default' => false, 'title' => __('Ratings'), 'type' => 'checkbox', 'desc' => ''),
    244     )
    245              
    246     );
    247 }
    248 
    249 static function TplVarsDesc($for_cat=false)
    250 {
    251     if($for_cat) return array( 
    252     'cat_name'              => __('The category name', WPFB),
    253     'cat_description'       => __('Short description', WPFB),
    254    
    255     'cat_url'               => __('The category URL', WPFB),
    256     'cat_path'              => __('Category path (e.g cat1/cat2/)', WPFB),
    257     'cat_folder'            => __('Just the category folder name, not the path', WPFB),
    258    
    259     'cat_icon_url'          => __('URL of the thumbnail or icon', WPFB),
    260     'cat_small_icon'        => sprintf(__('HTML image tag for a small icon (height %d)'), 32),
    261     'cat_has_icon'          => __('Wether the category has a custom icon (boolean 0/1)'),
    262 
    263    
    264     'cat_parent_name'       => __('Name of the parent categories (empty if none)', WPFB),
    265     'cat_num_files'         => __('Number of files in the category', WPFB),
    266     'cat_num_files_total'           => __('Number of files in the category and all child categories', WPFB),
    267    
    268     //'cat_required_level'  => __('The minimum user level to view this category (-1 = guest, 0 = Subscriber ...)', WPFB),
    269     'cat_user_can_access'   => sprintf(__('Variable to check if the %s is accessible (boolean 0/1)', WPFB),__('Category')),
    270    
    271     'cat_id'                => __('The category ID', WPFB),
    272     'uid'                   => __('A unique ID number to identify elements within a template', WPFB),
    273     );
    274     else return array_merge(array( 
    275     'file_display_name'     => __('Title', WPFB),
    276     'file_name'             => __('Name of the file', WPFB),
    277    
    278     'file_url'              => __('Download URL', WPFB),
    279     'file_url_encoded'      => __('Download URL encoded for use in query strings', WPFB),
    280    
    281     'file_icon_url'         => __('URL of the thumbnail or icon', WPFB),
    282    
    283    
    284     'file_size'             => __('Formatted file size', WPFB),
    285     'file_date'             => __('Formatted file date', WPFB),
    286     'file_version'          => __('File version', WPFB),   
    287     'file_author'           => __('Author'),
    288     'file_tags'             => __('Tags'),
    289     'file_description'      => __('Short description', WPFB),   
    290     'file_languages'        => __('Supported languages', WPFB),
    291     'file_platforms'        => __('Supported platforms (operating systems)', WPFB),
    292     'file_requirements'     => __('Requirements to use this file', WPFB),
    293     'file_license'          => __('License', WPFB),
    294    
    295     'file_category'         => __('The category name', WPFB),
    296    
    297    
    298     'file_thumbnail'        => __('Name of the thumbnail file', WPFB), 
    299     'cat_icon_url'          => __('URL of the category icon (if any)', WPFB),
    300     'cat_small_icon'        => __('Category').': '.sprintf(__('HTML image tag for a small icon (height %d)'), 32),
    301    
    302 
    303    
    304     //'file_required_level' => __('The minimum user level to download this file (-1 = guest, 0 = Subscriber ...)', WPFB),
    305     'file_user_can_access'  => sprintf(__('Variable to check if the %s is accessible (boolean 0/1)', WPFB),__('File',WPFB)),
    306    
    307     'file_offline'          => __('1 if file is offline, otherwise 0', WPFB),
    308     'file_direct_linking'   => __('1 if direct linking is allowed, otherwise 0', WPFB),
    309    
    310     //'file_update_of'      =>
    311     'file_post_id'          => __('ID of the post/page this file belongs to', WPFB),
    312     'file_added_by'         => __('User Name of the owner', WPFB),
    313     'file_hits'             => __('How many times this file has been downloaded.', WPFB),
    314     //'file_ratings'            =>
    315     //'file_rating_sum'     =>
    316     'file_last_dl_ip'       => __('IP Address of the last downloader', WPFB),
    317     'file_last_dl_time'     => __('Time of the last download', WPFB),
    318    
    319     'file_extension'        => sprintf(__('Lowercase file extension (e.g. \'%s\')', WPFB), 'pdf'),
    320     'file_type'             => sprintf(__('File content type (e.g. \'%s\')', WPFB), 'image/png'),
    321    
    322 
    323     'file_post_url'         => __('URL of the post/page this file belongs to', WPFB),
    324    
    325     'file_path'             => __('Category path and file name (e.g cat1/cat2/file.ext)', WPFB),
    326    
    327     'file_id'               => __('The file ID', WPFB),
    328    
    329     'uid'                   => __('A unique ID number to identify elements within a template', WPFB),
    330     'post_id'               => __('ID of the current post or page', WPFB),
    331     'wpfb_url'              => sprintf(__('Plugin root URL (%s)',WPFB), WPFB_PLUGIN_URI)
    332     ), WPFB_Core::GetCustomFields(true));
    333 }
    334 
    335 static function FileSortFields()
    336 {
    337     return array_merge(array(
    338     'file_display_name'     => __('Title', WPFB),
    339     'file_name'             => __('Name of the file', WPFB),
    340     'file_version'          => __('File version', WPFB),
    341    
    342     'file_hits'             => __('How many times this file has been downloaded.', WPFB),
    343     'file_size'             => __('Formatted file size', WPFB),
    344     'file_date'             => __('Formatted file date', WPFB),
    345     'file_last_dl_time'     => __('Time of the last download', WPFB),
    346    
    347     'file_path'             => __('Relative path of the file'),
    348     'file_id'               => __('File ID'),
    349    
    350     'file_category_name'    => __('Category Name', WPFB),
    351     'file_category'         => __('Category ID', WPFB),
    352    
    353     'file_description'      => __('Short description', WPFB),   
    354     'file_author'           => __('Author', WPFB),
    355     'file_license'          => __('License', WPFB),
    356    
    357     'file_post_id'          => __('ID of the post/page this file belongs to', WPFB),
    358     'file_added_by'         => __('User Name of the owner', WPFB),
    359    
    360     //'file_offline'            => __('Offline &gt; Online', WPFB),
    361     //'file_direct_linking' => __('Direct linking &gt; redirect to post', WPFB),
    362    
    363     ), WPFB_Core::GetCustomFields(true));
    364 }
    365 
    366 static function CatSortFields()
    367 {
    368     return array(
    369     'cat_name'          => __('Category Name', WPFB),
    370     'cat_folder'        => __('Name of the Category folder', WPFB),
    371     'cat_description'   => __('Short description', WPFB),   
    372    
    373     'cat_path'          => __('Relative path of the category folder', WPFB),
    374     'cat_id'            => __('Category ID', WPFB),
    375     'cat_parent'        => __('Parent Category ID', WPFB),
    376    
    377     'cat_num_files'     => __('Number of files directly in the category', WPFB),
    378     'cat_num_files_total' => __('Number of all files in the category and all sub-categories', WPFB),
    379    
    380     'cat_order'         => __('Custom Category Order', WPFB)
    381    
    382     //'cat_required_level' => __('The minimum user level to access (-1 = guest, 0 = Subscriber ...)', WPFB)
    383     );
    384 }
    385 
    386 static function TplFieldsSelect($input, $short=false, $for_cat=false)
    387 {
    388     $out = __('Add template variable:', WPFB) . ' <select name="_wpfb_tpl_fields" onchange="WPFB_AddTplVar(this, \'' . $input . '\')"><option value="">'.__('Select').'</option>'; 
    389     foreach(self::TplVarsDesc($for_cat) as $tag => $desc)
    390         $out .= '<option value="'.$tag.'" title="'.$desc.'">'.$tag.($short ? '' : ' ('.$desc.')').'</option>';
    391     $out .= '</select>';
    392     $out .= '<small>('.__('For some files there are more tags available. You find a list of all tags below the form when editing a file.',WPFB).'</small>';
    393     return $out;
    394 }
    395 
    396 // copy of wp's copy_dir, but moves everything
    397 static function MoveDir($from, $to)
    398 {
    399     require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
    400     require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php');
    401    
    402     $wp_filesystem = new WP_Filesystem_Direct(null);
    403    
    404     $dirlist = $wp_filesystem->dirlist($from);
    405 
    406     $from = trailingslashit($from);
    407     $to = trailingslashit($to);
    408 
    409     foreach ( (array) $dirlist as $filename => $fileinfo ) {
    410         if ( 'f' == $fileinfo['type'] ) {
    411             if ( ! $wp_filesystem->move($from . $filename, $to . $filename, true) )
    412                 return false;
    413             $wp_filesystem->chmod($to . $filename, octdec(WPFB_PERM_FILE));
    414         } elseif ( 'd' == $fileinfo['type'] ) {
    415             if ( !$wp_filesystem->mkdir($to . $filename, octdec(WPFB_PERM_DIR)) )
    416                 return false;
    417             if(!self::MoveDir($from . $filename, $to . $filename))
    418                 return false;
    419         }
    420     }
    421    
    422     // finally delete the from dir
    423     @rmdir($from);
    424    
    425     return true;
    426 }
     20static function SettingsSchema() { return wpfb_call('Settings','Schema'); }
    42721
    42822static function InsertCategory($catarr)
     
    657251    if(!($update && $remote_redirect) && is_file($file->GetLocalPath()) && empty($data->no_scan))
    658252    {
    659         $file->file_size = WPFB_FileUtils::GetFileSize($file->GetLocalPath());
     253        $file->file_size = isset($data->file_size) ? $data->file_size : WPFB_FileUtils::GetFileSize($file->GetLocalPath());
    660254        $file->file_mtime = filemtime($file->GetLocalPath());
    661255        $old_hash = $file->file_hash;
     
    774368
    775369
    776 
    777 
    778370static function ParseFileNameVersion($file_name, $file_version) {
    779371    $fnwv = substr($file_name, 0, strrpos($file_name, '.'));// remove extension
     
    1125717<?php
    1126718}
    1127 
    1128 
    1129719// this is used for post filter
    1130720public function ProcessWidgetUpload(){ 
     
    1139729        // nonce/referer check (security)
    1140730        if(!wp_verify_nonce($_POST['wpfb-file-nonce'],$nonce_action) || !check_admin_referer($nonce_action,'wpfb-file-nonce'))
    1141             wp_die(__('Cheatin&#8217; uh?') . ' (nonce)');
     731            wp_die(__('Cheatin&#8217; uh?') . ' (security)');
    1142732    }
    1143733       
     
    1191781   
    1192782    $cols = $wpdb->get_col("SHOW COLUMNS FROM $wpdb->wpfilebase_files LIKE 'file_custom_%'");
     783   
    1193784   
    1194785    $custom_fields = WPFB_Core::GetCustomFields();
  • wp-filebase/trunk/classes/AdminGuiSettings.php

    r702142 r722195  
    227227        __('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','small_icon_size',
    228228        'disable_footer_credits','footer_credits_style',
    229         ),
     229                    ),
    230230        __('Download', WPFB)                => array('hide_links', 'disable_permalinks', 'download_base', 'force_download', 'range_download', 'http_nocache', 'ignore_admin_dls', 'accept_empty_referers','allowed_referers' /*,'dl_destroy_session'*/,'use_fpassthru'),
    231231        __('Form Presets', WPFB)            => array('default_author','default_roles', 'default_cat', 'default_direct_linking','languages', 'platforms', 'licenses', 'requirements', 'custom_fields'),
  • wp-filebase/trunk/classes/AdminGuiTpls.php

    r702142 r722195  
    260260        <th scope="row" class="check-column"><input type="checkbox" name="tpl[]" value="<?php echo esc_attr($tpl_tag) ?>" /></th>
    261261        <td class="column-title">
    262             <strong><a class="row-title" href="<?php echo $edit_link ?>" title="<?php printf(__('Edit &#8220;%s&#8221;'), $tpl_tag) ?>"><?php echo self::TplTitle($tpl_tag); ?></a></strong>
     262            <strong><a class="row-title" href="<?php echo $edit_link ?>" title="<?php printf(__('Edit &#8220;%s&#8221;'), $tpl_tag) ?>"><?php echo self::TplTitle($tpl_tag); ?></a></strong><br />
     263            <code>tag=<?php echo $tpl_tag; ?></code>
    263264            <div class="row-actions"><span class='edit'><a href="<?php echo $edit_link ?>" title="<?php _e('Edit this item') ?>"><?php _e('Edit') ?></a></span>
    264265            <?php if(!in_array($tpl_tag, self::$protected_tags)){ ?><span class='trash'>| <a class='submitdelete' title='<?php _e('Delete this item permanently') ?>' href='<?php echo add_query_arg(array('action'=>'del','type'=>$type,'tpl'=>$tpl_tag)).'#'.$type ?>'><?php _e('Delete') ?></a></span><?php } ?>
     
    345346        <?php _e('Template Code:', WPFB) ?><br />
    346347        <textarea id="<?php echo $code_id ?>" cols="70" rows="<?php echo (max(2, count(explode("\n",$tpl_code)))+3); ?>" wrap="off" name="tplcode" class="codepress html wpfilebase-tpledit" onkeyup="WPFB_PreviewTpl(this, '<?php echo $type ?>')" onchange="WPFB_PreviewTpl(this, '<?php echo $type ?>')"><?php echo htmlspecialchars($tpl_code) ?></textarea><br />
    347         <?php echo WPFB_Admin::TplFieldsSelect($code_id, false, $cat) ?>
     348        <?php wpfb_loadclass('Models'); echo WPFB_Models::TplFieldsSelect($code_id, false, $cat) ?>
    348349    </p>
    349350    <?php } ?>
  • wp-filebase/trunk/classes/AdvUploader.php

    r660375 r722195  
    3838    {
    3939        $this->Scripts($prefix);
    40         ?>
    4140       
    42 <script type="text/javascript">
    43 //<![CDATA[
    44 //jQuery(document).ready(function($){   
     41        $minify = true;
     42       
     43        if($minify) ob_start();
     44        ?><script type="text/javascript">
     45/* <![CDATA[ */
     46
     47
    4548function fileQueued(fileObj) {
    4649    jQuery('#file-upload-progress').show().html('<div class="progress"><div class="percent">0%</div><div class="bar" style="width: 30px"></div></div><div class="filename original"> ' + fileObj.name + '</div>');
     
    5558    jQuery('#cancel-upload').show().prop('disabled', false);
    5659
    57      // delete already uploaded temp file   
     60     /* delete already uploaded temp file */
    5861    if(jQuery('#file_flash_upload').val() != '0') {
    5962        jQuery.ajax({type: 'POST', async: true, url:"<?php echo esc_attr( WPFB_PLUGIN_URI.'wpfb-async-upload.php' ); ?>",
     
    7881
    7982function uploadSuccess(fileObj, serverData) {
    80     // if async-upload returned an error message, place it in the media item div and return
     83    /* if async-upload returned an error message, place it in the media item div and return */
    8184    if ( serverData.match('media-upload-error') || serverData.match('error-div') ) {
    8285        wpFileError(fileObj, serverData);
     
    117120}
    118121
    119 //]]>
     122   
     123/* ]]> */
    120124</script>
    121         <?php
     125<?php
     126       
     127        if($minify) { // todo: remove // comments!!
     128            echo str_replace(array(" /* <![CDATA[ */ "," /* ]]> */ "), array("\r\n/* <![CDATA[ */\r\n","\r\n/* ]]> */\r\n"),
     129                      str_replace(array("\r\n", "\n"), " ", ob_get_clean())
     130            );
     131        }
    122132    }
    123133   
  • wp-filebase/trunk/classes/BatchUploader.php

    r702142 r722195  
    143143        batchUploaderSetPresetsMore(pm);
    144144    });
    145     batchUploaderSetPresetsMore(parseInt(getUserSetting('wpfb_batch_presets_more')));
     145    batchUploaderSetPresetsMore(getUserSetting('wpfb_batch_presets_more') ? parseInt(getUserSetting('wpfb_batch_presets_more')) : 0);
    146146});
    147147
    148148function batchUploaderSetPresetsMore(m)
    149149{
     150    if(isNaN(m)) m = 0;
    150151    var form = jQuery('#wpfb-batch-uploader-presets').find('form');
    151152    var s = (m+morePresets);
  • wp-filebase/trunk/classes/Core.php

    r702142 r722195  
    256256        'pagenav' => 1,
    257257        'linktext' => null,
    258    
     258           
    259259    ), $atts), $content, $tag);
    260260}
     
    330330   
    331331    $conf = array(
    332         'ql'=>1, // querylinks with jQuery
     332        'ql'=>!is_admin(), // querylinks with jQuery
    333333        'hl'=> (int)self::GetOpt('hide_links'), // hide links
    334334        'pl'=>(self::GetOpt('disable_permalinks') ? 0 : (int)!!get_option('permalink_structure')), // permlinks
     
    406406static function GetMaxUlSize() {    return wpfb_call('Misc','ParseIniFileSize', ini_get('upload_max_filesize')); }
    407407
    408 public static function GetCustomFields($full_field_names=false) {
     408public static function GetCustomFields($full_field_names=false, &$default_values=null) {
    409409    $custom_fields = isset(WPFB_Core::$settings->custom_fields)?explode("\n",WPFB_Core::$settings->custom_fields):array();
    410410    $arr = array();
     411    $default_values = array();
    411412    if(empty($custom_fields[0])) return array();
    412413    foreach($custom_fields as $cf) {
    413414        $cfa = explode("|", $cf);
    414         $arr[$full_field_names?('file_custom_'.trim($cfa[1])):trim($cfa[1])] = $cfa[0];
     415        $arr[$k = $full_field_names?('file_custom_'.trim($cfa[1])):trim($cfa[1])] = $cfa[0];
     416        $default_values[$k] = empty($cfa[2]) ? '' : $cfa[2];
    415417    }
    416418    return $arr;
  • wp-filebase/trunk/classes/Download.php

    r702142 r722195  
    4343    $traffic = wpfb_call('Misc','GetTraffic');
    4444   
    45     $limit_month = (WPFB_Core::GetOpt('traffic_month') * 1048576);
    46     $limit_day = (WPFB_Core::GetOpt('traffic_day') * 1073741824);
     45    $limit_month = (WPFB_Core::GetOpt('traffic_month') * 1073741824); //GiB
     46    $limit_day = (WPFB_Core::GetOpt('traffic_day') * 1048576); // MiB
    4747   
    4848    return ( ($limit_month == 0 || ($traffic['month'] + $file_size) < $limit_month) && ($limit_day == 0 || ($traffic['today'] + $file_size) < $limit_day) );
     
    417417       
    418418    $begin = 0;
    419     $end = $size;
     419    $end = $size-1;
    420420
    421421    $http_range = isset($_SERVER['HTTP_RANGE']) ? $_SERVER['HTTP_RANGE'] : '';
    422422    if(!empty($http_range) && strpos($http_range, 'bytes=') !== false && strpos($http_range, ',') === false) // multi-range not supported (yet)!
    423423    {
    424         $range = explode('-', trim(substr($http_range, 6)));
    425         $begin = 0 + trim($range[0]);
    426         if(!empty($range[1]))
    427             $end = 0 + trim($range[1]);
     424        $range = array_map('trim',explode('-', trim(substr($http_range, 6))));
     425        if(is_numeric($range[0])) {
     426            $begin = 0 + $range[0];
     427            if(is_numeric($range[1])) $end = 0 + $range[1];
     428        } else {
     429            $begin = $size - $range[1]; // format "-x": last x bytes
     430        }
    428431    } else
    429432        $http_range = '';
    430433   
    431     if($begin > 0 || $end < $size)
     434    if($begin > 0 || $end < ($size-1))
    432435        header('HTTP/1.0 206 Partial Content');
    433436    else
    434437        header('HTTP/1.0 200 OK');
    435438       
    436     $length = ($end-$begin);
     439    $length = ($end-$begin+1);
    437440    WPFB_Download::AddTraffic($length);
    438441   
     
    448451    header("Content-Length: " . $length);
    449452    if(!empty($http_range))
    450         header("Content-Range: bytes " . $begin . "-" . ($end-1) . "/" . $size);
     453        header("Content-Range: bytes $begin-$end/$size");
    451454   
    452455    // clean up things that are not needed for download
     
    484487        $cur = $begin;
    485488       
    486         while(!@feof($fh) && $cur < $end && @connection_status() == 0)
     489        while(!@feof($fh) && $cur <= $end && @connection_status() == 0)
    487490        {       
    488             $nbytes = min($buffer_size, $end-$cur);
     491            $nbytes = min($buffer_size, $end-$cur+1);
    489492            $ts = microtime(true);
    490493
  • wp-filebase/trunk/classes/File.php

    r702142 r722195  
    400400           
    401401            case 'file_description':    return nl2br($this->file_description);
    402             case 'file_tags':           return str_replace(',',', ',trim($this->file_tags,','));
     402            case 'file_tags':           return esc_html(str_replace(',',', ',trim($this->file_tags,',')));
    403403           
    404404            case 'file_date':
     
    419419        {
    420420            $path = explode('/',substr($name, 10));
    421             return htmlspecialchars($this->getInfoValue($path));
     421            return esc_html($this->getInfoValue($path));
    422422        } elseif(strpos($name, 'file_custom') === 0) // dont esc custom
    423423            return isset($this->$name) ? $this->$name : '';
     
    432432        }
    433433       
    434         return isset($this->$name) ? htmlspecialchars($this->$name) : '';
     434        return isset($this->$name) ? esc_html($this->$name) : '';
    435435    }
    436436   
     
    519519                $wpdb->query("UPDATE " . $wpdb->wpfilebase_files . " SET file_hits = file_hits + 1, file_last_dl_ip = '" . $downloader_ip . "', file_last_dl_time = '" . current_time('mysql') . "' WHERE file_id = " . (int)$this->file_id);
    520520        }
     521       
     522        // external hooks
     523        do_action( 'wpfilebase_file_downloaded', $this->file_id );
    521524       
    522525        // download or redirect
  • wp-filebase/trunk/classes/FileUtils.php

    r702142 r722195  
    9191    $name = strtolower(substr($name, strrpos($name, '.') + 1));
    9292    return ($name == 'png' || $name == 'gif' || $name == 'jpg' || $name == 'jpeg' || $name == 'bmp' || $name == 'tif' || $name == 'tiff');
    93 }   
    9493}
     94
     95
     96// copy of wp's copy_dir, but moves everything
     97static function MoveDir($from, $to)
     98{
     99    require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
     100    require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php');
     101   
     102    $wp_filesystem = new WP_Filesystem_Direct(null);
     103   
     104    $dirlist = $wp_filesystem->dirlist($from);
     105
     106    $from = trailingslashit($from);
     107    $to = trailingslashit($to);
     108
     109    foreach ( (array) $dirlist as $filename => $fileinfo ) {
     110        if ( 'f' == $fileinfo['type'] ) {
     111            if ( ! $wp_filesystem->move($from . $filename, $to . $filename, true) )
     112                return false;
     113            $wp_filesystem->chmod($to . $filename, octdec(WPFB_PERM_FILE));
     114        } elseif ( 'd' == $fileinfo['type'] ) {
     115            if ( !$wp_filesystem->mkdir($to . $filename, octdec(WPFB_PERM_DIR)) )
     116                return false;
     117            if(!self::MoveDir($from . $filename, $to . $filename))
     118                return false;
     119        }
     120    }
     121   
     122    // finally delete the from dir
     123    @rmdir($from);
     124   
     125    return true;
     126}
     127
     128}
  • wp-filebase/trunk/classes/Item.php

    r702142 r722195  
    489489                } else {
    490490                    if(!@is_dir($new_path)) wp_mkdir_p($new_path);
    491                     if(!@WPFB_Admin::MoveDir($old_path, $new_path))
     491                    wpfb_loadclass('FileUtils');
     492                    if(!@WPFB_FileUtils::MoveDir($old_path, $new_path))
    492493                        return array( 'error' => sprintf('Could not move folder %s to %s', $old_path, $new_path));
    493494                }
  • wp-filebase/trunk/classes/ListTpl.php

    r702142 r722195  
    6161       
    6262        $count = 0;
    63         $str = preg_replace("/jQuery\((.+?)\)\.dataTable\s*\((.*?)\)\s*;/", 'jQuery($1).dataTable(wpfb_DataTableOptionsFilter'.$uid.'($2));'." /*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/", $str, -1, $count);
     63        $str = preg_replace("/jQuery\((.+?)\)\.dataTable\s*\((.*?)\)\s*;/", 'jQuery($1).dataTable((function(options){/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/})($2));', $str, -1, $count);
    6464        if($count > 0)
    6565        {
     
    7979           
    8080            $str = str_replace('/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/',
    81 " function wpfb_DataTableOptionsFilter{$uid}(options){ ".
    8281    " var wpfbOptions = ".json_encode($dataTableOptions)."; ".
    8382    " if('object' == typeof(options)) { for (var v in options) { wpfbOptions[v] = options[v]; } }".
    84     " return wpfbOptions; ".
    85 "}"
     83    " return wpfbOptions; "
    8684, $str);
    8785        }   
     
    140138       
    141139            $cat = reset($categories); // get first category
    142             if(count($categories) == 1 && $cat->cat_num_files > 0) { // single cat
     140            // here we check if single category and cat has at least one file (also secondary cat files!)
     141            if(count($categories) == 1 && ($cat->cat_num_files > 0 )) { // single cat
    143142                if(!$cat->CurUserCanAccess()) return '';
    144143               
  • wp-filebase/trunk/classes/Output.php

    r702142 r722195  
    3232        case 'browser':
    3333                $content = '';
    34                 self::FileBrowser($content, $id, 0 ); // by ref
     34                self::FileBrowser($content, $id, 0  ); // by ref
    3535                return $content;
    3636    }   
     
    119119}
    120120
    121 static function FileBrowser(&$content, $root_cat_id=0, $cur_cat_id=0)
     121static function FileBrowser(&$content, $root_cat_id=0, $cur_cat_id=0 )
    122122{
    123123    static $fb_id = 0;
     
    154154        }
    155155       
    156         self::FileBrowserList($content, $parents, $root_cat);
     156        self::FileBrowserList($content, $root_cat, array(
     157             'open_cats' => $parents
     158                                ));
    157159           
    158160        $content .= '</ul><div style="clear:both;"></div>';
     
    160162}
    161163
    162 static function FileBrowserList(&$content, &$parents, $root_cat=null)
     164// args[open_cats] private
     165private static function FileBrowserList(&$content, $root_cat=null, $args=array())
    163166{
    164167    if(!is_null($root_cat) && !$root_cat->CurUserCanAccess()) {
     
    166169        return;
    167170    }
    168        
    169     $cats = WPFB_Category::GetFileBrowserCats(is_null($root_cat) ? 0 : $root_cat->cat_id);
    170     $open_cat = array_pop($parents);
     171   
     172    $root_id = empty($root_cat) ? 0 : $root_cat->cat_id;
     173       
     174    $cats = WPFB_Category::GetFileBrowserCats($root_id);
     175    $open_cat = empty($args['open_cats']) ? null : array_pop($args['open_cats']);
    171176    $files_before_cats = WPFB_Core::GetOpt('file_browser_fbc');
    172177   
    173     $files =  WPFB_File::GetFiles2(array('file_category' => $root_cat ? $root_cat->GetId() : 0),  WPFB_Core::GetOpt('hide_inaccessible'), WPFB_Core::GetFileListSortSql((WPFB_Core::GetOpt('file_browser_file_sort_dir')?'>':'<').WPFB_Core::GetOpt('file_browser_file_sort_by')));
     178    $files =  WPFB_File::GetFiles2(array('file_category' => $root_id),  WPFB_Core::GetOpt('hide_inaccessible'), WPFB_Core::GetFileListSortSql((WPFB_Core::GetOpt('file_browser_file_sort_dir')?'>':'<').WPFB_Core::GetOpt('file_browser_file_sort_by')));
    174179   
    175180    if($files_before_cats) {
     
    182187       
    183188        $liclass = '';
    184         if($has_children = $cat->HasChildren()) $liclass .= 'hasChildren';
    185         if($open = $cat->Equals($open_cat)) $liclass .= ' open';
     189        if( ($has_children = $cat->HasChildren()) ) $liclass .= 'hasChildren';
     190        if( ($open = $cat->Equals($open_cat) ) ) $liclass .= ' open';
    186191       
    187192        $content .= '<li id="wpfb-cat-'.$cat->cat_id.'" class="'.$liclass.'">';
     
    190195        if($has_children) {
    191196            $content .= "<ul>\n";           
    192             if($open) self::FileBrowserList($content, $parents, $cat );
     197            if($open) self::FileBrowserList($content, $cat, $args);
    193198            else $content .= '<li><span class="placeholder">&nbsp;</span></li>'."\n";
    194199            $content .= "</ul>\n";
     
    303308                $out .= self::CatSelTree(null, $c->cat_id, 0); 
    304309        }
     310        // TODO
     311        //$out .= '<option value="0" style="font-style:italic;" onchoose="alert(\'asdf\');">'.__('+ Add New Category').'</option>';
    305312    } else {
    306313        $cat = &WPFB_Category::GetCat($root_cat_id);   
  • wp-filebase/trunk/classes/PLUploader.php

    r702142 r722195  
    6060    $max_upload_size = WPFB_Core::GetMaxUlSize();
    6161   
    62     wp_print_scripts('plupload-all');
     62    wp_print_scripts('plupload-all');
     63    wp_print_scripts('wp-plupload');
     64   
    6365   
    6466$plupload_init = array(
  • wp-filebase/trunk/classes/Search.php

    r702142 r722195  
    8888    wpfb_loadclass('File');
    8989   
     90    $is_wp_search = !empty($_GET['s']) && empty($_GET['wpfb_s']);
     91   
    9092    $search_id3 = WPFB_Core::GetOpt('search_id3');
    9193    $no_matches = false;   
     
    9597   
    9698    // check if there are matching files, if there are, include the filebrowser page/post in the resulst!
     99    // if we have file pages, only include the file browser if file search widget was used!
    97100    $file_browser_id = intval(WPFB_Core::GetOpt('file_browser_post_id'));
    98     if($file_browser_id > 0 && WPFB_File::GetNumFiles2($where, true) > 0) {
     101    if($file_browser_id > 0 && WPFB_File::GetNumFiles2($where, true) > 0 ) {   
    99102        $where = "($where OR ({$wpdb->posts}.ID = $file_browser_id))"; // TODO!
    100103        wpfb_loadclass('Output');
  • wp-filebase/trunk/classes/Sync.php

    r702142 r722195  
    459459       
    460460        if(is_dir($cat->GetLocalPath()))
    461             chmod ($cat->GetLocalPath(), octdec(WPFB_PERM_DIR));
     461            @chmod ($cat->GetLocalPath(), octdec(WPFB_PERM_DIR));
    462462    }
    463463   
     
    473473   
    474474    // chmod
    475     chmod ($upload_dir, octdec(WPFB_PERM_DIR));
     475    @chmod ($upload_dir, octdec(WPFB_PERM_DIR));
    476476    for($i = 0; $i < count($files); $i++)
    477477    {
     
    543543    if(!empty($_GET['debug']))
    544544    {
     545        wpfb_loadclass('Output');
    545546        $ms = self::GetMemStats();
    546547        echo "<!-- [$tag] (MEM: ". WPFB_Output::FormatFilesize($ms['used'])." / $ms[limit]) BACKTRACE:\n";
  • wp-filebase/trunk/classes/Widget.php

    r702142 r722195  
    182182        WPFB_Category::GetCats();
    183183   
    184         $cats = WPFB_Category::GetCats(($tree ? 'WHERE cat_parent = 0 ' : '') . 'ORDER BY '.$instance['sort-by'].' '.($instance['sort-asc']?'ASC':'DESC') /* . $options['catlist_order_by'] . ($options['catlist_asc'] ? ' ASC' : ' DESC') /*. ' LIMIT ' . (int)$options['catlist_limit']*/);
     184        $cats = WPFB_Category::GetCats(($tree ? 'WHERE cat_parent = '.(empty($instance['root-cat'])?0:(int)$instance['root-cat']) : '') . 'ORDER BY '.$instance['sort-by'].' '.($instance['sort-asc']?'ASC':'DESC') /* . $options['catlist_order_by'] . ($options['catlist_asc'] ? ' ASC' : ' DESC') /*. ' LIMIT ' . (int)$options['catlist_limit']*/);
    185185   
    186186        echo '<ul>';
     
    196196
    197197    function update( $new_instance, $old_instance ) {
    198         wpfb_loadclass('Admin');
     198        wpfb_loadclass('Models');
    199199       
    200200        $instance = $old_instance;
     
    202202        $instance['hierarchical'] = !empty($new_instance['hierarchical']);
    203203        $instance['sort-by'] = strip_tags($new_instance['sort-by']);
    204         if(!in_array($instance['sort-by'], array_keys(WPFB_Admin::CatSortFields())))
     204        // TODO root-cat
     205        if(!in_array($instance['sort-by'], array_keys(WPFB_Models::CatSortFields())))
    205206            $instance['sort-by'] = 'cat_name';
    206207        $instance['sort-asc'] = !empty($new_instance['sort-asc']);
     
    255256
    256257    function update( $new_instance, $old_instance ) {
    257         wpfb_loadclass('Admin','TplLib', 'Output');
     258        wpfb_loadclass('Models','TplLib', 'Output');
    258259       
    259260        $instance = $old_instance;
     
    262263        $instance['limit'] = max(1, intval($new_instance['limit']));
    263264        $instance['sort-by'] = strip_tags($new_instance['sort-by']);
    264         if(!in_array($instance['sort-by'], array_keys(WPFB_Admin::FileSortFields())))
     265        if(!in_array($instance['sort-by'], array_keys(WPFB_Models::FileSortFields())))
    265266            $instance['sort-by'] = 'cat_name';
    266267        $instance['sort-asc'] = !empty($new_instance['sort-asc']);
  • wp-filebase/trunk/classes/WidgetForms.php

    r702142 r722195  
    3535        $instance['sort-asc'] = !empty($instance['sort-asc']);
    3636       
    37         wpfb_loadclass('Admin');
     37        wpfb_loadclass('Models');
    3838    ?>
    3939    <div>
     
    5050            <select id="<?php echo $obj->get_field_id('sort-by'); ?>" name="<?php echo $obj->get_field_name('sort-by'); ?>">
    5151            <?php
    52                 $sort_vars = WPFB_Admin::CatSortFields();
     52                $sort_vars = WPFB_Models::CatSortFields();
    5353                foreach($sort_vars as $tag => $name)
    5454                {
     
    8181            if(!isset($instance[$prop])) $instance[$prop] = $val;
    8282       
    83         wpfb_loadclass('Admin','Output');
     83        wpfb_loadclass('Admin','Models','Output');
    8484    ?>
    8585    <div>
     
    103103            <select id="<?php echo $obj->get_field_id('sort-by'); ?>" name="<?php echo $obj->get_field_name('sort-by'); ?>">
    104104            <?php
    105                 $sort_vars = WPFB_Admin::FileSortFields();
     105                $sort_vars = WPFB_Models::FileSortFields();
    106106                foreach($sort_vars as $tag => $name)
    107107                {
     
    120120        <p><label for="<?php echo $obj->get_field_id('tpl'); ?>"><?php _e('Template:', WPFB); ?>
    121121            <input class="widefat" type="text" id="<?php echo $obj->get_field_id('id'); ?>" name="<?php echo $obj->get_field_name('tpl'); ?>" value="<?php echo esc_attr($instance['tpl']); ?>" /></label>
    122             <br /><?php echo WPFB_Admin::TplFieldsSelect($obj->get_field_id('id'), true); ?>
     122            <br /><?php echo WPFB_Models::TplFieldsSelect($obj->get_field_id('id'), true); ?>
    123123        </p>
    124124    </div>
  • wp-filebase/trunk/editor_plugin.php

    r702142 r722195  
    2929auth_redirect();
    3030
    31 wpfb_loadclass('Core', 'File', 'Category', 'AdminLite', 'Admin', 'ListTpl', 'Output');
     31wpfb_loadclass('Core', 'File', 'Category', 'AdminLite', 'Admin', 'ListTpl', 'Output', 'Models');
    3232
    3333wp_enqueue_script( 'common' );
     
    338338    <select name="list-sort-by" id="list-sort-by" style="width:100%">
    339339        <option value=""><?php _e('Default'); echo ' ('.WPFB_Core::GetOpt('filelist_sorting').')'; ?></option>
    340         <?php $opts = WPFB_Admin::FileSortFields();
     340        <?php $opts = WPFB_Models::FileSortFields();
    341341        foreach($opts as $tag => $name) echo '<option value="'.$tag.'">'.$tag.' - '.$name.'</option>'; ?>
    342342    </select>   
     
    360360    <select name="list-cat-sort-by" id="list-cat-sort-by" style="width:100%">
    361361        <option value=""><?php _e('None (order of IDs in shortcode)', WPFB); ?></option>
    362         <?php $opts = WPFB_Admin::CatSortFields();
     362        <?php $opts = WPFB_Models::CatSortFields();
    363363        foreach($opts as $tag => $name) echo '<option value="'.$tag.'">'.$tag.' - '.$name.'</option>'; ?>
    364364    </select>   
  • wp-filebase/trunk/extras/jquery/dataTables/src/DataTables.js

    r598768 r722195  
    22 * @summary     DataTables
    33 * @description Paginate, search and sort HTML tables
    4  * @version     1.9.3
     4 * @version     1.9.4
    55 * @file        jquery.dataTables.js
    66 * @author      Allan Jardine (www.sprymedia.co.uk)
     
    2222
    2323/*jslint evil: true, undef: true, browser: true */
    24 /*globals $, jQuery,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/
    25 
    26 (/** @lends <global> */function($, window, document, undefined) {
     24/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/
     25
     26(/** @lends <global> */function( window, document, undefined ) {
     27
     28(function( factory ) {
     29    "use strict";
     30
     31    // Define as an AMD module if possible
     32    if ( typeof define === 'function' && define.amd )
     33    {
     34        define( ['jquery'], factory );
     35    }
     36    /* Define using browser globals otherwise
     37     * Prevent multiple instantiations if the script is loaded twice
     38     */
     39    else if ( jQuery && !jQuery.fn.dataTable )
     40    {
     41        factory( jQuery );
     42    }
     43}
     44(/** @lends <global> */function( $ ) {
     45    "use strict";
    2746    /**
    2847     * DataTables is a plug-in for the jQuery Javascript library. It is a
     
    7998       
    8099        var _that = this;
    81         return this.each(function() {
     100        this.each(function() {
    82101            require('core.constructor.js');
    83102        } );
     103        _that = null;
     104        return this;
    84105    };
    85106
     
    94115     *  @default Version number
    95116     */
    96     DataTable.version = "1.9.3";
     117    DataTable.version = "1.9.4";
    97118
    98119    /**
     
    258279     *  @param {object} o DataTables settings object {@link DataTable.models.oSettings}
    259280     */
    260 }(jQuery, window, document, undefined));
     281}));
     282
     283}(window, document));
     284
  • wp-filebase/trunk/extras/jquery/dataTables/src/api/api.methods.js

    r702142 r722195  
    1 
    21/**
    32 * Perform a jQuery selector action on the table's TR elements (from the tbody) and
     
    474473    var i, iLen;
    475474
    476     bRemove = (bRemove===undefined) ? false : true;
     475    bRemove = (bRemove===undefined) ? false : bRemove;
    477476   
    478477    /* Flag to note that the table is currently being destroyed - no action should be taken */
     
    481480    /* Fire off the destroy callbacks for plug-ins etc */
    482481    _fnCallbackFire( oSettings, "aoDestroyCallback", "destroy", [oSettings] );
    483    
    484     /* Restore hidden columns */
    485     for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
    486     {
    487         if ( oSettings.aoColumns[i].bVisible === false )
    488         {
    489             this.fnSetColumnVis( i, true );
     482
     483    /* If the table is not being removed, restore the hidden columns */
     484    if ( !bRemove )
     485    {
     486        for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
     487        {
     488            if ( oSettings.aoColumns[i].bVisible === false )
     489            {
     490                this.fnSetColumnVis( i, true );
     491            }
    490492        }
    491493    }
     
    563565    }
    564566   
    565     /* If the were originally odd/even type classes - then we add them back here. Note
    566      * this is not fool proof (for example if not all rows as odd/even classes - but
     567    /* If the were originally stripe classes - then we add them back here. Note
     568     * this is not fool proof (for example if not all rows had stripe classes - but
    567569     * it's a good effort without getting carried away
    568570     */
    569     $(nBody).children('tr:even').addClass( oSettings.asDestroyStripes[0] );
    570     $(nBody).children('tr:odd').addClass( oSettings.asDestroyStripes[1] );
     571    iLen = oSettings.asDestroyStripes.length;
     572    if (iLen)
     573    {
     574        var anRows = $(nBody).children('tr');
     575        for ( i=0 ; i<iLen ; i++ )
     576        {
     577            anRows.filter(':nth-child(' + iLen + 'n + ' + i + ')').addClass( oSettings.asDestroyStripes[i] );
     578        }
     579    }
    571580   
    572581    /* Remove the settings object from the settings array */
     
    581590    /* End it all */
    582591    oSettings = null;
     592    oInit = null;
    583593};
    584594
     
    674684            for ( var i=0, iLen=n.length ; i<iLen ; i++ )
    675685            {
    676                 $(n[i]._DT_Input).val( sInput );
     686                // IE9 throws an 'unknown error' if document.activeElement is used
     687                // inside an iframe or frame...
     688                try {
     689                    if ( n[i]._DT_Input != document.activeElement )
     690                    {
     691                        $(n[i]._DT_Input).val( sInput );
     692                    }
     693                }
     694                catch ( e ) {
     695                    $(n[i]._DT_Input).val( sInput );
     696                }
    677697            }
    678698        }
     
    794814 *  @param {node} nNode this can either be a TR, TD or TH in the table's body
    795815 *  @returns {int} If nNode is given as a TR, then a single index is returned, or
    796  *    if given as a cell, an array of [row index, column index (visible)] is given.
     816 *    if given as a cell, an array of [row index, column index (visible),
     817 *    column index (all)] is given.
    797818 *  @dtopt API
    798819 *
  • wp-filebase/trunk/extras/jquery/dataTables/src/ext/ext.paging.js

    r702142 r722195  
    7373            var oClasses = oSettings.oClasses;
    7474            var an = oSettings.aanFeatures.p;
     75            var nNode;
    7576
    7677            /* Loop over each instance of the pager */
    7778            for ( var i=0, iLen=an.length ; i<iLen ; i++ )
    7879            {
    79                 if ( an[i].childNodes.length !== 0 )
    80                 {
    81                     an[i].childNodes[0].className = ( oSettings._iDisplayStart === 0 ) ?
    82                         oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
    83                    
    84                     an[i].childNodes[1].className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
    85                         oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
     80                nNode = an[i].firstChild;
     81                if ( nNode )
     82                {
     83                    /* Previous page */
     84                    nNode.className = ( oSettings._iDisplayStart === 0 ) ?
     85                        oClasses.sPagePrevDisabled : oClasses.sPagePrevEnabled;
     86                       
     87                    /* Next page */
     88                    nNode = nNode.nextSibling;
     89                    nNode.className = ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
     90                        oClasses.sPageNextDisabled : oClasses.sPageNextEnabled;
    8691                }
    8792            }
     
    172177            var iStartButton, iEndButton, i, iLen;
    173178            var oClasses = oSettings.oClasses;
    174             var anButtons, anStatic, nPaginateList;
     179            var anButtons, anStatic, nPaginateList, nNode;
    175180            var an = oSettings.aanFeatures.p;
    176181            var fnBind = function (j) {
     
    223228            for ( i=0, iLen=an.length ; i<iLen ; i++ )
    224229            {
    225                 if ( an[i].childNodes.length === 0 )
     230                nNode = an[i];
     231                if ( !nNode.hasChildNodes() )
    226232                {
    227233                    continue;
     
    229235               
    230236                /* Build up the dynamic list first - html and listeners */
    231                 $('span:eq(0)', an[i])
     237                $('span:eq(0)', nNode)
    232238                    .html( sList )
    233239                    .children('a').each( fnBind );
    234240               
    235241                /* Update the permanent button's classes */
    236                 anButtons = an[i].getElementsByTagName('a');
     242                anButtons = nNode.getElementsByTagName('a');
    237243                anStatic = [
    238244                    anButtons[0], anButtons[1],
  • wp-filebase/trunk/extras/jquery/dataTables/src/model/model.column.js

    r702142 r722195  
    4848   
    4949    /**
    50      * When using fnRender, you have two options for what to do with the data,
    51      * and this property serves as the switch. Firstly, you can have the sorting
    52      * and filtering use the rendered value (true - default), or you can have
    53      * the sorting and filtering us the original value (false).
    54      * 
    55      * *NOTE* It is it is advisable now to use mData as a function and make
    56      * use of the 'type' that it gives, allowing (potentially) different data to
    57      * be used for sorting, filtering, display and type detection.
     50     * <code>Deprecated</code> When using fnRender, you have two options for what
     51     * to do with the data, and this property serves as the switch. Firstly, you
     52     * can have the sorting and filtering use the rendered value (true - default),
     53     * or you can have the sorting and filtering us the original value (false).
     54     *
     55     * Please note that this option has now been deprecated and will be removed
     56     * in the next version of DataTables. Please use mRender / mData rather than
     57     * fnRender.
    5858     *  @type boolean
    5959     *  @deprecated
     
    7878    /**
    7979     * Developer definable function that is called whenever a cell is created (Ajax source,
    80      * etc) or processed for input (DOM source). This can be used as a compliment to fnRender
     80     * etc) or processed for input (DOM source). This can be used as a compliment to mRender
    8181     * allowing you to modify the DOM element (add background colour for example) when the
    82      * element is available (since it is not when fnRender is called).
     82     * element is available.
    8383     *  @type function
    8484     *  @param {element} nTd The TD node that has been created
     
    107107   
    108108    /**
    109      * Custom display function that will be called for the display of each cell
    110      * in this column.
     109     * <code>Deprecated</code> Custom display function that will be called for the
     110     * display of each cell in this column.
     111     *
     112     * Please note that this option has now been deprecated and will be removed
     113     * in the next version of DataTables. Please use mRender / mData rather than
     114     * fnRender.
    111115     *  @type function
    112116     *  @param {object} o Object with the following parameters:
     
    117121     *  @returns {string} The string you which to use in the display
    118122     *  @default null
     123     *  @deprecated
    119124     */
    120125    "fnRender": null,
  • wp-filebase/trunk/extras/jquery/dataTables/src/model/model.defaults.columns.js

    r702142 r722195  
    142142
    143143    /**
    144      * When using fnRender() for a column, you may wish to use the original data
    145      * (before rendering) for sorting and filtering (the default is to used the
    146      * rendered data that the user can see). This may be useful for dates etc.
    147      *
    148      * *NOTE* This property is now deprecated, and it is suggested that you use
    149      * mData and / or mRender to render data for the DataTable.
     144     * <code>Deprecated</code> When using fnRender() for a column, you may wish
     145     * to use the original data (before rendering) for sorting and filtering
     146     * (the default is to used the rendered data that the user can see). This
     147     * may be useful for dates etc.
     148     *
     149     * Please note that this option has now been deprecated and will be removed
     150     * in the next version of DataTables. Please use mRender / mData rather than
     151     * fnRender.
    150152     *  @type boolean
    151153     *  @default true
    152154     *  @dtopt Columns
    153155     *  @deprecated
    154      *
    155      *  @example
    156      *    // Using aoColumnDefs
    157      *    $(document).ready( function() {
    158      *      $('#example').dataTable( {
    159      *        "aoColumnDefs": [
    160      *          {
    161      *            "fnRender": function ( oObj ) {
    162      *              return oObj.aData[0] +' '+ oObj.aData[3];
    163      *            },
    164      *            "bUseRendered": false,
    165      *            "aTargets": [ 0 ]
    166      *          }
    167      *        ]
    168      *      } );
    169      *    } );
    170      *   
    171      *  @example
    172      *    // Using aoColumns
    173      *    $(document).ready( function() {
    174      *      $('#example').dataTable( {
    175      *        "aoColumns": [
    176      *          {
    177      *            "fnRender": function ( oObj ) {
    178      *              return oObj.aData[0] +' '+ oObj.aData[3];
    179      *            },
    180      *            "bUseRendered": false
    181      *          },
    182      *          null,
    183      *          null,
    184      *          null,
    185      *          null
    186      *        ]
    187      *      } );
    188      *    } );
    189156     */
    190157    "bUseRendered": true,
     
    224191    /**
    225192     * Developer definable function that is called whenever a cell is created (Ajax source,
    226      * etc) or processed for input (DOM source). This can be used as a compliment to fnRender
     193     * etc) or processed for input (DOM source). This can be used as a compliment to mRender
    227194     * allowing you to modify the DOM element (add background colour for example) when the
    228      * element is available (since it is not when fnRender is called).
     195     * element is available.
    229196     *  @type function
    230197     *  @param {element} nTd The TD node that has been created
     
    253220
    254221    /**
    255      * Custom display function that will be called for the display of each cell in
    256      * this column.
     222     * <code>Deprecated</code> Custom display function that will be called for the
     223     * display of each cell in this column.
     224     *
     225     * Please note that this option has now been deprecated and will be removed
     226     * in the next version of DataTables. Please use mRender / mData rather than
     227     * fnRender.
    257228     *  @type function
    258229     *  @param {object} o Object with the following parameters:
     
    265236     *  @returns {string} The string you which to use in the display
    266237     *  @dtopt Columns
    267      *
    268      *  @example
    269      *    // Using aoColumnDefs
    270      *    $(document).ready( function() {
    271      *      $('#example').dataTable( {
    272      *        "aoColumnDefs": [
    273      *          {
    274      *            "fnRender": function ( o, val ) {
    275      *              return o.aData[0] +' '+ o.aData[3];
    276      *            },
    277      *            "aTargets": [ 0 ]
    278      *          }
    279      *        ]
    280      *      } );
    281      *    } );
    282      *   
    283      *  @example
    284      *    // Using aoColumns
    285      *    $(document).ready( function() {
    286      *      $('#example').dataTable( {
    287      *        "aoColumns": [
    288      *          { "fnRender": function ( o, val ) {
    289      *            return o.aData[0] +' '+ o.aData[3];
    290      *          } },
    291      *          null,
    292      *          null,
    293      *          null,
    294      *          null
    295      *        ]
    296      *      } );
    297      *    } );
     238     *  @deprecated
    298239     */
    299240    "fnRender": null,
  • wp-filebase/trunk/extras/jquery/dataTables/src/model/model.defaults.js

    r702142 r722195  
    13841384       
    13851385            /**
    1386              * Text to use when using the 'full_numbers' type of pagination for the
    1387              * button to take the user to the next page.
     1386             * Text to use for the 'next' pagination button (to take the user to the
     1387             * next page).
    13881388             *  @type string
    13891389             *  @default Next
     
    14051405       
    14061406            /**
    1407              * Text to use when using the 'full_numbers' type of pagination for the
    1408              * button to take the user to the previous page.
     1407             * Text to use for the 'previous' pagination button (to take the user to 
     1408             * the previous page).
    14091409             *  @type string
    14101410             *  @default Previous
  • wp-filebase/trunk/lib/wpfb_form_file.php

    r702142 r722195  
    357357    </tr>
    358358    <?php }
    359     $custom_fields = WPFB_Core::GetCustomFields();
     359    $custom_fields = WPFB_Core::GetCustomFields(false, $custom_defaults);
    360360    foreach($custom_fields as $ct => $cn) {
    361361        $hid = 'file_custom_'.esc_attr($ct);
     
    363363    <tr class="form-field">
    364364        <th scope="row" valign="top"><label for="<?php echo $hid; ?>"><?php echo esc_html($cn) ?></label></th>
    365         <td colspan="3"><textarea name="<?php echo $hid; ?>" id="<?php echo $hid; ?>" rows="2" cols="50" style="width: 97%;"><?php echo empty($file->$hid) ? '' : esc_html($file->$hid); ?></textarea></td>
     365        <td colspan="3"><textarea name="<?php echo $hid; ?>" id="<?php echo $hid; ?>" rows="2" cols="50" style="width: 97%;"><?php echo empty($file->$hid) ? $custom_defaults[$ct] : esc_html($file->$hid); ?></textarea></td>
    366366    </tr> <?php
    367367    }
  • wp-filebase/trunk/readme.txt

    r702142 r722195  
    55Requires at least: 3.1
    66Tested up to: 3.5.1
    7 Stable tag: 0.2.9.36
     7Stable tag: 0.2.9.37
    88
    99Adds a powerful download manager including file categories, downloads counter, widgets, sorted file lists and more to your WordPress blog.
     
    113113
    114114== Changelog ==
     115
     116= 0.2.9.37 =
     117* Fixed Batch Uploader
     118* Further memory optimizations
     119* Updated DataTables to 1.9.4
     120* Fixed monthly/daily traffic limit
     121* Fixed download range header handling (thanks to mrogaski)
     122* Minified DataTables init JS to prevent auto <p>
     123* Added `wpfilebase_file_downloaded` hook for download logging
     124* Fixed HTML escaping for some file template vars
     125
    115126
    116127= 0.2.9.36 =
     
    655666WP-Filebase currently offers the action `wpfilebase_sync`. This will run a fast filebase sync that adds new files.
    656667
     668The hook `wpfilebase_file_downloaded` with file_id as parameter can be used for download logging.
     669
     670
    657671== WP-Filebase Pro ==
    658672[WP-Filebase Pro](http://wpfilebase.com/) is the commercial version of WP-Filebase with an extended range of functions. It supports secondary categories, extended permissions, embedded upload forms. Furthermore it can generate PDF thumbnails, sync with Dropbox or FTP and includes an improved file sync algorithm.
  • wp-filebase/trunk/wp-filebase.php

    r702142 r722195  
    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.36
     7Version: 0.2.9.37
    88Author URI: http://wpfilebase.com/
    99*/
     
    1212{
    1313    define('WPFB', 'wpfb');
    14     define('WPFB_VERSION', '0.2.9.36');
     14    define('WPFB_VERSION', '0.2.9.37');
    1515    define('WPFB_PLUGIN_ROOT', str_replace('\\','/',dirname(__FILE__)).'/');
    1616    if(!defined('ABSPATH')) {
Note: See TracChangeset for help on using the changeset viewer.