Page 1 of 1

About "multiple upload" allow

Posted: 09 Oct 2013, 16:05
by ibanson
Hello there,

I think I found a little problem.
@ component params, we can find following :

Code: Select all

<field name="enable_multiple_upload_admin" type="list" default="0" label="COM_PHOCADOWNLOAD_FIELD_ENABLE_MU_ADMIN_LABEL" description="COM_PHOCADOWNLOAD_FIELD_ENABLE_MU_ADMIN_DESC">
	<option value="1">COM_PHOCADOWNLOAD_YES</option>
	<option value="0">COM_PHOCADOWNLOAD_NO</option>
</field>
So, I check 0 -> No, I do not want to use Multiple upload.

Let's check to the file, then upload, the tab is enabled anyway...

I modified this way :

\administrator\components\com_phocadownload\views\phocadownloadmanager\view.html.php

Replace this :

Code: Select all

$this->tmpl['multipleuploadmethod'] = $params->get( 'multiple_upload_method', 1 );
With :

Code: Select all

$this->tmpl['multipleuploadmethod'] = $params->get('enable_multiple_upload_admin',0);
And the params works fine now.

-------------------

Another thing, the FileMakeSafe fonction of Joomla do not remove blank spaces, so I've created my own function to do this, if it can help somebody :

\administrator\components\com_phocadownload\helpers\fileupload.php

Add

Code: Select all

public static function AudioFileMakeSafe($File) {
                    
                   $date = Jfactory::getDate()->toFormat('%d-%m-%Y'); //Just If you want to display Date in the filename...  
            
                   $AllowedExt = array('mp3','wav','ogg','mp4'); 
                   $FileExt = strtolower(Jfile::getExt($File)); // Force lowercase for extension file...
                    
                   if (empty($FileExt))
                           return false;

                   if((in_array($FileExt, $AllowedExt) == true)) {

                           $AudioFileName = Jfile::stripExt($File);
                           $AudioSafeName = Jfile::makeSafe($AudioFileName);

                           //replace - by _
                           $AudioSafeName = str_replace('-', '_', $AudioSafeName);

                           // remplace spaces by _
                           $AudioSafeName = str_replace(' ', '_', $AudioSafeName);

                           $AudioSafeFile = $date .'_'. $AudioSafeName .'.'. $FileExt;

                           return $AudioSafeFile;

                   } else 
                           return false;
        }
then call your new function @ line ~373

Code: Select all

if (isset($file['name'])) {
        $file['name'] = self::AudioFileMakeSafe($file['name']);
}
Any suggestions are welcome.

Laurent.

Re: About "multiple upload" allow

Posted: 13 Oct 2013, 22:41
by Jan
Hi, thank you for this guide:
Replace this :

Code: Select all
$this->tmpl['multipleuploadmethod'] = $params->get( 'multiple_upload_method', 1 );

With :

Code: Select all
$this->tmpl['multipleuploadmethod'] = $params->get('enable_multiple_upload_admin',0);
Did you mean:

FROM:

Code: Select all

$this->t['enablemultiple'] 		= $params->get( 'enable_multiple', 0 );
TO:

Code: Select all

$this->t['enablemultiple'] 		= $params->get('enable_multiple_upload_admin',0);
means from: enable_multiple' to: enable_multiple_upload_admin.

I see there are some missing parameters, I willl fix them in next version. And I will take a look at the safe function. Thank you for the guide.

Jan