Ignore:
Timestamp:
Jan 6, 2013, 1:53:17 AM (12 years ago)
Author:
julien1311
Message:

[file_uploader] lots of bug fixes

Location:
extensions/File_Uploader/admin
Files:
2 edited

Legend:

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

    r19835 r19875  
    33
    44include_once(PHPWG_ROOT_PATH . 'include/functions.inc.php');
     5include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
    56
    67global $template, $conf, $user, $page;
     
    1516                        $file_uploader_errors['file'] = $file_uploader_upload_file['errors'];
    1617        } else {
    17                 $file_uploader_errors['file']['no_file'] = 'Specify a file to upload';
     18                $file_uploader_errors['file']['no_file'] = l10n('Specify a file to upload');
    1819        }
    1920       
     
    3738
    3839function file_uploader_upload_file($file_uploader_file) {
    39         include_once(dirname(__FILE__).'/install/config_default.inc.php');
     40        require(FILE_UPLOADER_PATH.'install/config_default.inc.php');
     41        require_once(FILE_UPLOADER_PATH.'install/functions.inc.php');
    4042       
    4143        global $conf;
     
    4345       
    4446        $file_uploader_file_tmp = $file_uploader_file['tmp_name'];
     47        $file_uploader_file_title = substr($file_uploader_file['name'], 0, strrpos($file_uploader_file['name'], '.'));
    4548        $file_uploader_file_name = preg_replace('/[^a-zA-Z0-9s.]/', '_', $file_uploader_file['name']);
    4649        $file_uploader_file_name_wo_extension = substr($file_uploader_file_name, 0, strrpos($file_uploader_file_name, '.'));
     
    5861        $return = array();
    5962       
     63        $return['title'] = $file_uploader_file_title;
    6064        $return['name_wo_extension'] = $file_uploader_file_name_wo_extension;
    6165        $return['extension'] = $file_uploader_file_extension;
     
    6468        $return['size'] = $file_uploader_file_size;
    6569        $return['overwrite'] = false;
     70       
     71        //Check if the folder file_uploader exists
     72        file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir, $file_uploader_galleries_folder_name);
    6673       
    6774        //If the directory does not exist, we create it
     
    7481                        $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
    7582                        $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);');
     83                        $file_uploader_physical_category = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE dir = "'.$file_uploader_galleries_folder.'";'));
     84                        $insert = array(
     85                                'id' => $next_id,
     86                                'name' => $file_uploader_file_category,
     87                                'id_uppercat' => $file_uploader_physical_category['id'],
     88                                'comment' => 'Created by the File Uploader plugin',
     89                                'dir' => $file_uploader_file_category,
     90                                'rank' => $category_rank,
     91                                'status' => 'private',
     92                                'visible' => boolean_to_string($conf['newcat_default_visible']),
     93                                'uppercats' => $next_id.','.$file_uploader_physical_category['id'],
     94                                'global_rank' => $category_rank,
     95                                'site_id' => '1',
     96                        );
     97                        single_insert(CATEGORIES_TABLE, $insert);
    7898                }
    7999       
     
    117137
    118138function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension, $file_uploader_file_folder) {
    119         include_once(dirname(__FILE__).'/install/config_default.inc.php');
     139        require(FILE_UPLOADER_PATH.'install/config_default.inc.php');
    120140       
    121141        $file_uploader_thumbnail_tmp = $file_uploader_thumbnail['tmp_name'];
     
    179199        $insert = array(
    180200                'file' => substr(strrchr($file_path, '/'), 1),
    181                 'name' => pwg_db_real_escape_string($file_uploader_file_properties['title']),
     201                'name' => ($file_uploader_file_properties['title'] != '') ? pwg_db_real_escape_string($file_uploader_file_properties['title']) : $file_uploader_file['title'],
    182202                'comment' => pwg_db_real_escape_string($file_uploader_file_properties['description']),
    183203                'date_available' => $dbnow,
     
    199219        }
    200220       
     221        if (!is_array($image_id))
     222                $image_id = array($image_id);
     223       
    201224        if(isset($file_uploader_file_properties['category']) and count($file_uploader_file_properties['category']) > 0) {
    202225                associate_images_to_categories(
    203                         array($image_id),
     226                        $image_id,
    204227                        array($file_uploader_file_properties['category'], $physical_category_id['id'])
    205228                );
    206229        }
    207230       
    208         @fill_caddie(array($image_id));
     231        @fill_caddie($image_id);
    209232}
    210233
     
    214237display_select_cat_wrapper($query, array(), 'category_parent_options');
    215238
     239//Add parameters to template
     240$upload_max_filesize = min(get_ini_size('upload_max_filesize'), get_ini_size('post_max_size'));
     241if ($upload_max_filesize == get_ini_size('upload_max_filesize')) {
     242        $upload_max_filesize = get_ini_size('upload_max_filesize', true);
     243} else {
     244        $upload_max_filesize = get_ini_size('post_max_filesize', true);
     245}
     246$upload_max_filesize_display = round($upload_max_filesize/1024, 0, PHP_ROUND_HALF_DOWN);
     247
     248$template->assign(
     249    array(
     250                'upload_max_filesize' => $upload_max_filesize,
     251                'upload_max_filesize_display' => $upload_max_filesize_display,
     252    )
     253);
     254
    216255$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin_upload.tpl'));
    217256$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
  • extensions/File_Uploader/admin/admin_upload.tpl

    r19775 r19875  
    1515                                <input name="file_uploader_file" type="file" value=""{if isset($file_uploader_errors.file)} class="file_uploader_error"{/if}>
    1616                                {foreach from=$file_uploader_errors.file item=error_description}<span class="file_uploader_error_description" title="{$error_description}">!</span>{/foreach}
     17                                <input type="hidden" name="MAX_FILE_SIZE" value="{$upload_max_filesize}">
     18                        </p>
     19                        <p class="file_uploader_center">
     20                                {'file_uploader_upload_max_filesize'|@translate} {$upload_max_filesize_display} Kio.
    1721                        </p>
    1822                </fieldset>
Note: See TracChangeset for help on using the changeset viewer.