Mark two strings for translation.

This commit is contained in:
Thomas Keller 2011-05-06 14:04:08 +02:00
parent 9644784a79
commit be4774c95c

View File

@ -51,68 +51,68 @@ class IDF_Form_ProjectConf extends Pluf_Form
), ),
'widget' => 'Pluf_Form_Widget_TextareaInput', 'widget' => 'Pluf_Form_Widget_TextareaInput',
)); ));
// Logo part // Logo part
$upload_path = Pluf::f('upload_path', false); $upload_path = Pluf::f('upload_path', false);
if (false === $upload_path) { if (false === $upload_path) {
throw new Pluf_Exception_SettingError(__('The "upload_path" configuration variable was not set.')); throw new Pluf_Exception_SettingError(__('The "upload_path" configuration variable was not set.'));
} }
$upload_path .= '/' . $this->project->shortname; $upload_path .= '/' . $this->project->shortname;
$filename = '/%s'; $filename = '/%s';
$this->fields['logo'] = new Pluf_Form_Field_File(array('required' => false, $this->fields['logo'] = new Pluf_Form_Field_File(array('required' => false,
'label' => __('Update the logo'), 'label' => __('Update the logo'),
'initial' => '', 'initial' => '',
'help_text' => __('The logo must be a picture with a size of 32 by 32.'), 'help_text' => __('The logo must be a picture with a size of 32 by 32.'),
'max_size' => Pluf::f('max_upload_size', 5 * 1024), 'max_size' => Pluf::f('max_upload_size', 5 * 1024),
'move_function_params' => 'move_function_params' =>
array('upload_path' => $upload_path, array('upload_path' => $upload_path,
'upload_path_create' => true, 'upload_path_create' => true,
'file_name' => $filename, 'file_name' => $filename,
) )
)); ));
$this->fields['logo_remove'] = new Pluf_Form_Field_Boolean(array('required' => false, $this->fields['logo_remove'] = new Pluf_Form_Field_Boolean(array('required' => false,
'label' => __('Remove the current logo'), 'label' => __('Remove the current logo'),
'initial' => false, 'initial' => false,
'widget' => 'Pluf_Form_Widget_CheckboxInput', 'widget' => 'Pluf_Form_Widget_CheckboxInput',
)); ));
} }
/** /**
* If we have uploaded a file, but the form failed remove it. * If we have uploaded a file, but the form failed remove it.
* *
*/ */
function failed() function failed()
{ {
if (!empty($this->cleaned_data['logo']) if (!empty($this->cleaned_data['logo'])
&& file_exists(Pluf::f('upload_path').'/'.$this->cleaned_data['logo'])) { && file_exists(Pluf::f('upload_path').'/'.$this->cleaned_data['logo'])) {
unlink(Pluf::f('upload_path').'/'.$this->cleaned_data['logo']); unlink(Pluf::f('upload_path').'/'.$this->cleaned_data['logo']);
} }
} }
public function clean() public function clean()
{ {
if (!isset($this->cleaned_data['logo_remove'])) { if (!isset($this->cleaned_data['logo_remove'])) {
$this->cleaned_data['logo_remove'] = false; $this->cleaned_data['logo_remove'] = false;
} }
return $this->cleaned_data; return $this->cleaned_data;
} }
public function clean_logo() public function clean_logo()
{ {
if (empty($this->cleaned_data['logo'])) { if (empty($this->cleaned_data['logo'])) {
return ''; return '';
} }
$meta = getimagesize(Pluf::f('upload_path') . '/' . $this->project->shortname . $this->cleaned_data['logo']); $meta = getimagesize(Pluf::f('upload_path') . '/' . $this->project->shortname . $this->cleaned_data['logo']);
if ($meta === false) { if ($meta === false) {
throw new Pluf_Form_Invalid("Could not determine the size of the uploaded picture."); throw new Pluf_Form_Invalid(__('Could not determine the size of the uploaded picture.'));
} }
if ($meta[0] !== 32 || $meta[1] !== 32) { if ($meta[0] !== 32 || $meta[1] !== 32) {
throw new Pluf_Form_Invalid("The picture must have a size of 32 by 32."); throw new Pluf_Form_Invalid(__('The picture must have a size of 32 by 32.'));
} }
return $this->cleaned_data['logo']; return $this->cleaned_data['logo'];
@ -121,13 +121,13 @@ class IDF_Form_ProjectConf extends Pluf_Form
public function save($commit=true) public function save($commit=true)
{ {
$conf = $this->project->getConf(); $conf = $this->project->getConf();
// Basic part // Basic part
$this->project->name = $this->cleaned_data['name']; $this->project->name = $this->cleaned_data['name'];
$this->project->shortdesc = $this->cleaned_data['shortdesc']; $this->project->shortdesc = $this->cleaned_data['shortdesc'];
$this->project->description = $this->cleaned_data['description']; $this->project->description = $this->cleaned_data['description'];
$this->project->update(); $this->project->update();
// Logo part // Logo part
if ($this->cleaned_data['logo'] !== "") { if ($this->cleaned_data['logo'] !== "") {
$conf->setVal('logo', $this->cleaned_data['logo']); $conf->setVal('logo', $this->cleaned_data['logo']);