Indefero

Indefero Commit Details


Date:2011-12-06 13:39:15 (13 years 16 days ago)
Author:Thomas Keller
Branch:develop, release-1.3
Commit:63bc47e7b76f63ea0b645b3c7c775a503d690d37
Parents: 0d410605f90c01d70f1a8f66bf5c22507801959a
Message:Save / restore project labels for the forge.

Changes:

File differences

src/IDF/Forge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright (C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* A lightweight model for the singleton forge entity
*/
class IDF_Forge
{
public $_model = __CLASS__;
public $id = 1;
/**
* @var IDF_Gconf
*/
private $conf;
private function __construct() {
$this->conf = new IDF_Gconf();
$this->conf->setModel($this);
}
public static function instance() {
return new IDF_Forge();
}
public function getProjectLabels($default = '') {
return $this->conf->getVal('project_labels', $default);
}
public function setProjectLabels($labels) {
$this->conf->setVal('project_labels', $labels);
}
}
src/IDF/Form/Admin/LabelConf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of InDefero, an open source project management application.
# Copyright(C) 2008-2011 Céondo Ltd and contributors.
#
# InDefero is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
# InDefero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# ***** END LICENSE BLOCK ***** */
/**
* Configuration of forge labels.
*/
class IDF_Form_Admin_LabelConf extends Pluf_Form
{
const init_project_labels = 'UI:GUI = Applications with graphical user interfaces
UI:CLI = Applications with no graphical user interfaces
License:BSD = Applications with BSD license
License:GPL = Applications with GPL license
';
public function initFields($extra=array())
{
$this->fields['project_labels'] = new Pluf_Form_Field_Varchar(
array('required' => true,
'label' => __('Predefined project labels'),
'initial' => self::init_project_labels,
'widget_attrs' => array('rows' => 13,
'cols' => 75),
'widget' => 'Pluf_Form_Widget_TextareaInput',
));
}
}
src/IDF/Views/Admin.php
8282
8383
8484
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
85119
86120
87121
}
/**
* Administrate the labels of a project.
*/
public $projectLabels_precond = array('Pluf_Precondition::staffRequired');
public function projectLabels($request, $match)
{
$title = __('Project Labels');
$forge = IDF_Forge::instance();
if ($request->method == 'POST') {
$form = new IDF_Form_Admin_LabelConf($request->POST);
if ($form->isValid()) {
$forge->setProjectLabels($form->cleaned_data['project_labels']);
$request->user->setMessage(__('The label configuration has been saved.'));
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Admin::projectLabels');
return new Pluf_HTTP_Response_Redirect($url);
}
} else {
$params = array();
if (($labels = $forge->getProjectLabels(false)) !== false) {
$params['project_labels'] = $labels;
}
if (count($params) == 0) {
$params = null; //Nothing in the db, so new form.
}
$form = new IDF_Form_Admin_LabelConf($params);
}
return Pluf_Shortcuts_RenderToResponse('idf/gadmin/projects/labels.html',
array(
'page_title' => $title,
'form' => $form,
),
$request);
}
/**
* Edition of a project.
*
* One cannot switch from one source backend to another.
src/IDF/conf/urls.php
478478
479479
480480
481
482
483
484
485
481486
482487
483488
'model' => 'IDF_Views_Admin',
'method' => 'projectUpdate');
$ctl[] = array('regex' => '#^/admin/projects/labels/$#',
'base' => $base,
'model' => 'IDF_Views_Admin',
'method' => 'projectLabels');
$ctl[] = array('regex' => '#^/admin/projects/create/$#',
'base' => $base,
'model' => 'IDF_Views_Admin',
src/IDF/templates/idf/gadmin/projects/base.html
22
33
44
5
56
67
{block tabprojects} class="active"{/block}
{block subtabs}
<a {if $inIndex}class="active" {/if}href="{url 'IDF_Views_Admin::projects'}">{trans 'Project List'}</a> |
<a {if $inLabels}class="active" {/if}href="{url 'IDF_Views_Admin::projectLabels'}">{trans 'Project Labels'}</a> |
<a {if $inCreate}class="active" {/if}href="{url 'IDF_Views_Admin::projectCreate'}">{trans 'Create Project'}</a> {if $project} | <a href="{url 'IDF_Views_Project::admin', array($project.shortname)}">{trans 'Change Project Details'}</a>{/if}
{/block}
src/IDF/templates/idf/gadmin/projects/labels.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{extends "idf/gadmin/projects/base.html"}
{block docclass}yui-t3{assign $inLabels=true}{/block}
{block body}
<form method="post" action=".">
<table class="form" summary="">
<tr>
<td colspan="2"><strong>{$form.f.project_labels.labelTag}:</strong><br />
{if $form.f.project_labels.errors}{$form.f.project_labels.fieldErrors}{/if}
{$form.f.project_labels|unsafe}
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="{trans 'Save Changes'}" name="submit" />
</td>
</tr>
</table>
</form>
{/block}
{block context}
<div class="issue-submit-info">
{blocktrans}
<p><strong>Instructions:</strong></p>
<p>List one status value per line in desired sort-order.</p>
<p>Optionally, use an equals-sign to document the meaning of each status value.</p>
{/blocktrans}
</div>
{/block}

Archive Download the corresponding diff file

Page rendered in 0.09964s using 13 queries.