Changeset 19775


Ignore:
Timestamp:
01/04/13 00:31:23 (7 years ago)
Author:
julien1311
Message:

some bug fixes/improvements
still buggy

Location:
extensions/File_Uploader
Files:
1 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/File_Uploader/admin/admin_upload.php

    r19735 r19775  
    3737 
    3838function file_uploader_upload_file($file_uploader_file) { 
    39         include('static.inc.php'); 
     39        include_once(dirname(__FILE__).'/install/config_default.inc.php'); 
    4040         
    4141        global $conf; 
     
    6969                if(!mkdir($file_uploader_file_directory_full)) 
    7070                        $file_uploader_errors['upload_error'] = l10n('Unable to create folder ').$file_uploader_file_directory_full; 
    71         //If the physical category si not in database, we add it 
    72         if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file_category.'";')) == 0){ 
    73                 $next_id = pwg_db_nextval('id', CATEGORIES_TABLE); 
    74                 $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';')); 
    75                 $category_rank = $category_rank['MAX(rank)'] + 1; 
    76                 pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, dir, rank, status, visible, uppercats, global_rank) VALUES ('.$next_id.', "'.$file_uploader_file_category.'", "'.$file_uploader_file_category.'", '.$category_rank.', "'.$conf['newcat_default_status'].'", "'.boolean_to_string($conf['newcat_default_visible']).'", "'.$next_id.'", '.$category_rank.');'); 
    77         } 
     71                //If the physical category si not in database, we add it 
     72                else if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file_category.'";')) == 0){ 
     73                        $next_id = pwg_db_nextval('id', CATEGORIES_TABLE); 
     74                        $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';')); 
     75                        $category_rank = $category_rank['MAX(rank)'] + 1; 
     76                        $file_uploader_physical_category_id = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_galleries_folder.'";')); 
     77                        pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, dir, rank, status, visible, uppercats, global_rank, site_id) VALUES ('.$next_id.', "'.$file_uploader_file_category.'", "'.$file_uploader_file_category.'", '.$category_rank.', "private", "'.boolean_to_string($conf['newcat_default_visible']).'", "'.$file_uploader_physical_category_id.'", '.$category_rank.', 1);'); 
     78                } 
    7879         
    7980        if ($file_uploader_file['error'] !== UPLOAD_ERR_OK) { 
     
    116117 
    117118function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension, $file_uploader_file_folder) { 
    118         include('static.inc.php'); 
     119        include_once(dirname(__FILE__).'/install/config_default.inc.php'); 
    119120         
    120121        $file_uploader_thumbnail_tmp = $file_uploader_thumbnail['tmp_name']; 
     
    175176        //Database registration 
    176177        $file_path = pwg_db_real_escape_string($file_uploader_file['destination']); 
     178        $physical_category_id = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file['folder'].'";')); 
    177179        $insert = array( 
    178180                'file' => substr(strrchr($file_path, '/'), 1), 
     
    183185                'representative_ext' => $file_uploader_thumbnail['extension'], 
    184186                'filesize' => $file_uploader_file['size'], 
     187                'storage_category_id' => $physical_category_id, 
    185188                'md5sum' => md5_file($file_path), 
    186189                'added_by' => $user['id'], 
     
    195198                $image_id = pwg_db_insert_id(IMAGES_TABLE); 
    196199        } 
    197  
    198         $physical_category_id = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file['folder'].'";')); 
    199200         
    200201        if(isset($file_uploader_file_properties['category']) and count($file_uploader_file_properties['category']) > 0) { 
  • extensions/File_Uploader/admin/admin_upload.tpl

    r19472 r19775  
    5050                                        <span class="property">{'Album:'|@translate}</span> 
    5151                                </label> 
    52                                 <select style="width:400px" name="file_uploader[category]" id="file_uploader_album_select" size="1"> 
     52                                <select style="width:400px" name="file_uploader[category]" id="albumSelect" size="1"> 
    5353                                        {html_options options=$category_parent_options selected=$file_uploader.category} 
    5454                                </select> 
  • extensions/File_Uploader/install/config_default.inc.php

    r19677 r19775  
    11<?php 
     2$file_uploader_galleries_folder = 'file_uploader'; 
     3$file_uploader_galleries_dir = PHPWG_ROOT_PATH.'galleries/'.$file_uploader_galleries_folder.'/'; 
     4 
     5$file_uploader_allowed_thumbnail_extension = array('jpg', 'jpeg', 'gif', 'png'); 
     6         
     7$file_uploader_destination_folder = array( 
     8        'pdf' => 'pdf', 
     9        'doc' => 'documents', 
     10        'docx' => 'documents', 
     11        'odt' => 'documents', 
     12        'xls' => 'spreadsheets', 
     13        'xlsx' => 'spreadsheets', 
     14        'ods' => 'spreadsheets', 
     15        'ppt' => 'presentations', 
     16        'pptx' => 'presentations', 
     17        'odp' => 'presentations', 
     18        'webm' => 'videos', 
     19        'webmv' => 'videos', 
     20        'ogv' => 'videos', 
     21        'm4v' => 'videos', 
     22        'mp4' => 'videos', 
     23        'flv' => 'videos', 
     24        'mp3' => 'musics', 
     25        'ogg' => 'musics', 
     26        'oga' => 'musics', 
     27        'm4a' => 'musics', 
     28        'webma' => 'musics', 
     29        'fla' => 'musics', 
     30        'wav' => 'musics', 
     31        'others' => 'others', 
     32); 
    233 
    334$config_default = array( 
  • extensions/File_Uploader/maintain.inc.php

    r19676 r19775  
    33 
    44function plugin_install() { 
    5         include(dirname(__FILE__).'/install/config_default.inc.php'); 
     5        include_once(dirname(__FILE__).'/install/config_default.inc.php'); 
     6        include_once(dirname(__FILE__).'/install/functions.inc.php'); 
    67 
    78        $query = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("file_uploader" ,"'.pwg_db_real_escape_string(serialize($config_default)).'", "File Uploader plugin parameters");'; 
    89        pwg_query($query); 
     10         
     11        file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir); 
    912} 
    1013 
    1114function plugin_activate() { 
    12  
     15        include_once(dirname(__FILE__).'/install/config_default.inc.php'); 
     16        include_once(dirname(__FILE__).'/install/functions.inc.php'); 
     17         
     18        file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir); 
    1319} 
    1420 
Note: See TracChangeset for help on using the changeset viewer.