diff --git a/src/IDF/Forge.php b/src/IDF/Forge.php new file mode 100644 index 0000000..97ce9c1 --- /dev/null +++ b/src/IDF/Forge.php @@ -0,0 +1,54 @@ +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); + } +} \ No newline at end of file diff --git a/src/IDF/Form/Admin/LabelConf.php b/src/IDF/Form/Admin/LabelConf.php new file mode 100644 index 0000000..7c886e0 --- /dev/null +++ b/src/IDF/Form/Admin/LabelConf.php @@ -0,0 +1,47 @@ +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', + )); + } +} diff --git a/src/IDF/Views/Admin.php b/src/IDF/Views/Admin.php index 60b160e..9faae89 100644 --- a/src/IDF/Views/Admin.php +++ b/src/IDF/Views/Admin.php @@ -81,6 +81,40 @@ class IDF_Views_Admin $request); } + /** + * 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. * diff --git a/src/IDF/conf/urls.php b/src/IDF/conf/urls.php index 4550f32..16f1892 100644 --- a/src/IDF/conf/urls.php +++ b/src/IDF/conf/urls.php @@ -478,6 +478,11 @@ $ctl[] = array('regex' => '#^/admin/projects/(\d+)/$#', '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', diff --git a/src/IDF/templates/idf/gadmin/projects/base.html b/src/IDF/templates/idf/gadmin/projects/base.html index 01eb115..4910ae6 100644 --- a/src/IDF/templates/idf/gadmin/projects/base.html +++ b/src/IDF/templates/idf/gadmin/projects/base.html @@ -2,5 +2,6 @@ {block tabprojects} class="active"{/block} {block subtabs} {trans 'Project List'} | +{trans 'Project Labels'} | {trans 'Create Project'} {if $project} | {trans 'Change Project Details'}{/if} {/block} diff --git a/src/IDF/templates/idf/gadmin/projects/labels.html b/src/IDF/templates/idf/gadmin/projects/labels.html new file mode 100644 index 0000000..6b7c66e --- /dev/null +++ b/src/IDF/templates/idf/gadmin/projects/labels.html @@ -0,0 +1,31 @@ +{extends "idf/gadmin/projects/base.html"} + +{block docclass}yui-t3{assign $inLabels=true}{/block} + +{block body} +
+ + + + + + + +
{$form.f.project_labels.labelTag}:
+{if $form.f.project_labels.errors}{$form.f.project_labels.fieldErrors}{/if} +{$form.f.project_labels|unsafe} +
+ +
+
+{/block} + +{block context} +
+{blocktrans} +

Instructions:

+

List one status value per line in desired sort-order.

+

Optionally, use an equals-sign to document the meaning of each status value.

+{/blocktrans} +
+{/block}