Indefero

Indefero Commit Details


Date:2011-05-06 07:04:08 (13 years 7 months ago)
Author:Thomas Keller
Branch:develop, feature-issue_links, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:be4774c95cee73f69c783a64dec0a97733ebd993
Parents: 9644784a792f78d4da85cbd045a9009261113323
Message:Mark two strings for translation.

Changes:

File differences

src/IDF/Form/ProjectConf.php
5151
5252
5353
54
54
5555
5656
5757
5858
5959
6060
61
61
6262
6363
6464
6565
6666
67
67
6868
6969
7070
7171
7272
73
73
7474
7575
7676
7777
7878
7979
80
80
8181
8282
8383
8484
8585
8686
87
87
8888
8989
9090
9191
92
92
9393
9494
9595
9696
9797
98
98
9999
100100
101
101
102102
103103
104104
105105
106106
107
107
108108
109
109
110110
111
111
112112
113
113
114114
115
115
116116
117117
118118
......
121121
122122
123123
124
124
125125
126126
127127
128128
129129
130
130
131131
132132
133133
),
'widget' => 'Pluf_Form_Widget_TextareaInput',
));
// Logo part
$upload_path = Pluf::f('upload_path', false);
if (false === $upload_path) {
throw new Pluf_Exception_SettingError(__('The "upload_path" configuration variable was not set.'));
}
$upload_path .= '/' . $this->project->shortname;
$filename = '/%s';
$filename = '/%s';
$this->fields['logo'] = new Pluf_Form_Field_File(array('required' => false,
'label' => __('Update the logo'),
'initial' => '',
'help_text' => __('The logo must be a picture with a size of 32 by 32.'),
'max_size' => Pluf::f('max_upload_size', 5 * 1024),
'move_function_params' =>
'move_function_params' =>
array('upload_path' => $upload_path,
'upload_path_create' => true,
'file_name' => $filename,
)
));
$this->fields['logo_remove'] = new Pluf_Form_Field_Boolean(array('required' => false,
'label' => __('Remove the current logo'),
'initial' => false,
'widget' => 'Pluf_Form_Widget_CheckboxInput',
));
}
/**
* If we have uploaded a file, but the form failed remove it.
*
*/
function failed()
{
if (!empty($this->cleaned_data['logo'])
if (!empty($this->cleaned_data['logo'])
&& file_exists(Pluf::f('upload_path').'/'.$this->cleaned_data['logo'])) {
unlink(Pluf::f('upload_path').'/'.$this->cleaned_data['logo']);
}
}
public function clean()
{
if (!isset($this->cleaned_data['logo_remove'])) {
$this->cleaned_data['logo_remove'] = false;
}
return $this->cleaned_data;
}
public function clean_logo()
{
if (empty($this->cleaned_data['logo'])) {
return '';
}
$meta = getimagesize(Pluf::f('upload_path') . '/' . $this->project->shortname . $this->cleaned_data['logo']);
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) {
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'];
public function save($commit=true)
{
$conf = $this->project->getConf();
// Basic part
$this->project->name = $this->cleaned_data['name'];
$this->project->shortdesc = $this->cleaned_data['shortdesc'];
$this->project->description = $this->cleaned_data['description'];
$this->project->update();
// Logo part
if ($this->cleaned_data['logo'] !== "") {
$conf->setVal('logo', $this->cleaned_data['logo']);

Archive Download the corresponding diff file

Page rendered in 0.08540s using 13 queries.