i18n
This commit is contained in:
@@ -8,12 +8,18 @@ class Uploader extends UploadHandler
|
||||
*/
|
||||
private $oMedia;
|
||||
|
||||
/**
|
||||
* Languages
|
||||
* @var Translator
|
||||
*/
|
||||
private $oLang;
|
||||
|
||||
public $sBody;
|
||||
|
||||
function __construct(&$oMedia)
|
||||
function __construct(&$oMedia, &$oLang)
|
||||
{
|
||||
$this->error_messages['wrong_project_mode'] = 'Le projet n\'est pas en mode "blog".';
|
||||
$this->oMedia = &$oMedia;
|
||||
$this->oLang = &$oLang;
|
||||
$this->sBody = '';
|
||||
parent::__construct(array('image_versions'=>array(), 'accept_file_types'=>'/\.(gif|jpe?g|png|mov)$/i'));
|
||||
}
|
||||
@@ -23,7 +29,7 @@ class Uploader extends UploadHandler
|
||||
|
||||
//Check project mode
|
||||
if(!$this->oMedia->isProjectModeValid()) {
|
||||
$file->error = $this->get_error_message('wrong_project_mode');
|
||||
$file->error = $this->get_error_message('upload_wrong_mode', array($this->oMedia->getProjectCodeName()));
|
||||
$bResult = false;
|
||||
}
|
||||
|
||||
@@ -34,10 +40,8 @@ class Uploader extends UploadHandler
|
||||
$file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
|
||||
|
||||
if(empty($file->error)) {
|
||||
$sError = $this->oMedia->addMedia($file->name);
|
||||
if($sError!='') {
|
||||
$file->error = $this->get_error_message($sError);
|
||||
}
|
||||
$asResult = $this->oMedia->addMedia($file->name);
|
||||
if(!$asResult['result']) $file->error = $this->get_error_message($asResult['desc'], $asResult['data']);
|
||||
}
|
||||
|
||||
return $file;
|
||||
@@ -46,6 +50,13 @@ class Uploader extends UploadHandler
|
||||
protected function body($sBodyPart) {
|
||||
$this->sBody .= $sBodyPart;
|
||||
}
|
||||
|
||||
protected function get_error_message($sError, $asParams=array()) {
|
||||
$sTranslatedError = $this->oLang->getTranslation($sError, $asParams);
|
||||
if($sTranslatedError) return $sTranslatedError;
|
||||
elseif(array_key_exists($sError, $this->error_messages)) return $this->error_messages[$sError];
|
||||
else return $sError;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user