Plugin Directory


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)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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); }
Note: See TracChangeset for help on using the changeset viewer.