[Fusionforge-commits] FusionForge branch master updated. 6.0.4-451-g442f463
Franck Villaume
nerville at libremir.placard.fr.eu.org
Sun May 22 19:34:23 CEST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, master has been updated
via 442f4639d7431faf43478b7b02b8396dcfb8c09a (commit)
via ebf064ce09092d41504d4f124699c9c91a1e2b2b (commit)
from 270b74de901d50acdd6b7bfbb10d4cf8b33c6837 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=442f4639d7431faf43478b7b02b8396dcfb8c09a
commit 442f4639d7431faf43478b7b02b8396dcfb8c09a
Author: Stéphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date: Sun May 22 18:17:29 2016 +0200
Tracker: Add description (help text) for custom fields
diff --git a/src/common/tracker/ArtifactExtraField.class.php b/src/common/tracker/ArtifactExtraField.class.php
index 54bfa02..3a44197 100644
--- a/src/common/tracker/ArtifactExtraField.class.php
+++ b/src/common/tracker/ArtifactExtraField.class.php
@@ -5,6 +5,7 @@
* Copyright 2004, Anthony J. Pugliese
* Copyright 2009, Roland Mas
* Copyright 2014, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
@@ -102,7 +103,7 @@ class ArtifactExtraField extends FFError {
* @param string $show100label The label used for the 100 value if displayed
* @return bool true on success / false on failure.
*/
- function create($name, $field_type, $attribute1, $attribute2, $is_required = 0, $alias = '', $show100 = true, $show100label = 'none') {
+ function create($name, $field_type, $attribute1, $attribute2, $is_required = 0, $alias = '', $show100 = true, $show100label = 'none', $description = '') {
//
// data validation
//
@@ -155,17 +156,18 @@ class ArtifactExtraField extends FFError {
}
db_begin();
- $result = db_query_params ('INSERT INTO artifact_extra_field_list (group_artifact_id, field_name, field_type, attribute1, attribute2, is_required, alias, show100, show100label)
- VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)',
+ $result = db_query_params ('INSERT INTO artifact_extra_field_list (group_artifact_id, field_name, field_type, attribute1, attribute2, is_required, alias, show100, show100label, description)
+ VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)',
array ($this->ArtifactType->getID(),
- htmlspecialchars($name),
- $field_type,
- $attribute1,
- $attribute2,
- $is_required,
- $alias,
- $show100,
- $show100label));
+ htmlspecialchars($name),
+ $field_type,
+ $attribute1,
+ $attribute2,
+ $is_required,
+ $alias,
+ $show100,
+ $show100label,
+ $description));
if ($result && db_affected_rows($result) > 0) {
$this->clearError();
@@ -275,6 +277,15 @@ class ArtifactExtraField extends FFError {
}
/**
+ * getDescription - get the description.
+ *
+ * @return string The description.
+ */
+ function getDescription() {
+ return $this->data_array['description'];
+ }
+
+ /**
* getAttribute1 - get the attribute1 field.
*
* @return int The first attribute.
@@ -395,7 +406,7 @@ class ArtifactExtraField extends FFError {
* @param string $show100label The label used for the 100 value if displayed
* @return bool success.
*/
- function update($name, $attribute1, $attribute2, $is_required = 0, $alias = "", $show100 = true, $show100label = 'none') {
+ function update($name, $attribute1, $attribute2, $is_required = 0, $alias = "", $show100 = true, $show100label = 'none', $description = '') {
if (!forge_check_perm ('tracker_admin', $this->ArtifactType->Group->getID())) {
$this->setPermissionDeniedError();
return false;
@@ -428,23 +439,25 @@ class ArtifactExtraField extends FFError {
$result = db_query_params ('UPDATE artifact_extra_field_list
SET field_name = $1,
- attribute1 = $2,
- attribute2 = $3,
- is_required = $4,
- alias = $5,
- show100 = $6,
- show100label = $7
- WHERE extra_field_id = $8
- AND group_artifact_id = $9',
+ description = $2,
+ attribute1 = $3,
+ attribute2 = $4,
+ is_required = $5,
+ alias = $6,
+ show100 = $7,
+ show100label = $8
+ WHERE extra_field_id = $9
+ AND group_artifact_id = $10',
array (htmlspecialchars($name),
- $attribute1,
- $attribute2,
- $is_required,
- $alias,
- $show100,
- $show100label,
- $this->getID(),
- $this->ArtifactType->getID())) ;
+ $description,
+ $attribute1,
+ $attribute2,
+ $is_required,
+ $alias,
+ $show100,
+ $show100label,
+ $this->getID(),
+ $this->ArtifactType->getID())) ;
if ($result && db_affected_rows($result) > 0) {
return true;
} else {
diff --git a/src/common/tracker/ArtifactType.class.php b/src/common/tracker/ArtifactType.class.php
index 5b10f5c..2069db2 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -659,7 +659,7 @@ class ArtifactType extends FFError {
$current_ef_todelete->delete(true,true);
}
}
- if (!$nef->create(util_unconvert_htmlspecialchars($ef['field_name']), $ef['field_type'], $ef['attribute1'], $ef['attribute2'], $ef['is_required'], $ef['alias'])) {
+ if (!$nef->create(util_unconvert_htmlspecialchars($ef['field_name']), $ef['field_type'], $ef['attribute1'], $ef['attribute2'], $ef['is_required'], $ef['alias'], $ef['description'])) {
$this->setError('Error Creating New Extra Field: '.$nef->getErrorMessage());
db_rollback();
return false;
diff --git a/src/common/tracker/actions/admin-updates.php b/src/common/tracker/actions/admin-updates.php
index 99f84e8..cd65668 100644
--- a/src/common/tracker/actions/admin-updates.php
+++ b/src/common/tracker/actions/admin-updates.php
@@ -5,6 +5,7 @@
* Copyright 2010 (c) FusionForge Team
* Copyright 2010 (c) Franck Villaume - Capgemini
* Copyright 2012-2014, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -34,6 +35,7 @@ global $atid;
//
if (getStringFromRequest('add_extrafield')) {
$name = getStringFromRequest('name');
+ $description = getStringFromRequest('description');
$field_type = getStringFromRequest('field_type');
$attribute1 = getStringFromRequest('attribute1');
$attribute2 = getStringFromRequest('attribute2');
@@ -54,7 +56,7 @@ if (getStringFromRequest('add_extrafield')) {
} else {
$show100 = 1;
}
- if (!$ab->create($name, $field_type, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label)) {
+ if (!$ab->create($name, $field_type, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label, $description)) {
$error_msg .= _('Error inserting a custom field')._(': ').$ab->getErrorMessage();
$ab->clearError();
} else {
@@ -227,6 +229,7 @@ if (getStringFromRequest('add_extrafield')) {
} elseif (getStringFromRequest('update_box')) {
$id = getStringFromRequest('id');
$name = getStringFromRequest('name');
+ $description = getStringFromRequest('description');
$attribute1 = getStringFromRequest('attribute1');
$attribute2 = getStringFromRequest('attribute2');
$is_required = getStringFromRequest('is_required');
@@ -245,7 +248,7 @@ if (getStringFromRequest('add_extrafield')) {
} else {
$show100 = 1;
}
- if (!$ac->update($name, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label)) {
+ if (!$ac->update($name, $attribute1, $attribute2, $is_required, $alias, $show100, $show100label, $description)) {
$error_msg .= _('Update failed')._(': ').$ac->getErrorMessage();
$ac->clearError();
} else {
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php b/src/common/tracker/include/ArtifactTypeHtml.class.php
index eec2e68..aea1696 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -236,6 +236,14 @@ class ArtifactTypeHtml extends ArtifactType {
$i = $keys[$k];
$post_name = '';
+ $attrs = array();
+ if (!empty($efarr[$i]['description'])) {
+ $attrs['title'] = $efarr[$i]['description'];
+ }
+ if ($efarr[$i]['is_required'] == 1) {
+ $attrs['required'] = 'required';
+ }
+
if (!isset($selected[$efarr[$i]['extra_field_id']]))
$selected[$efarr[$i]['extra_field_id']] = '';
@@ -244,41 +252,41 @@ class ArtifactTypeHtml extends ArtifactType {
}
if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
- $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any);
+ $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
- $str = $this->renderCheckbox($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label']);
+ $str = $this->renderCheckbox($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'], $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
- $str = $this->renderRadio($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any);
+ $str = $this->renderRadio($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
- $str = $this->renderTextField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
+ $str = $this->renderTextField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
if ($mode == 'QUERY') {
$post_name = ' <i>'._('(%% for wildcards)').'</i> ';
}
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
- $str = $this->renderTextArea($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
+ $str = $this->renderTextArea($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
if ($mode == 'QUERY') {
$post_name = ' <i>'._('(%% for wildcards)').'</i>';
}
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
- $str = $this->renderMultiSelectBox ($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label']);
+ $str = $this->renderMultiSelectBox ($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'], $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
// Get the allowed values from the workflow.
$atw = new ArtifactWorkflow($this, $efarr[$i]['extra_field_id']);
- // Special treatement for the initial step (Submit).
+ // Special treatment for the initial step (Submit).
// In this case, the initial value is the first value.
if ($selected === true) {
$selected_node = 100;
@@ -290,11 +298,11 @@ class ArtifactTypeHtml extends ArtifactType {
$allowed = $atw->getNextNodes($selected_node);
$allowed[] = $selected_node;
- $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected_node,$status_show_100,$text_100,$show_any,$text_any, $allowed);
+ $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected_node,$status_show_100,$text_100,$show_any,$text_any, $allowed, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
- $str = $this->renderRelationField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
+ $str = $this->renderRelationField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
if ($mode == 'UPDATE') {
$post_name = html_image('ic/forum_edit.gif','37','15',array('title'=>"Click to edit", 'alt'=>"Click to edit", 'onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
}
@@ -545,9 +553,10 @@ class ArtifactTypeHtml extends ArtifactType {
* @param bool $show_any
* @param string $text_any
* @param bool $allowed
+ * @param array $attrs
* @return string HTML code for the box and choices
*/
- function renderSelect ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false) {
+ function renderSelect ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false, $attrs = array ()) {
if ($text_100 == 'none'){
$text_100=_('None');
}
@@ -558,7 +567,7 @@ class ArtifactTypeHtml extends ArtifactType {
$keys[$i]=$arr[$i]['element_id'];
$vals[$i]=$arr[$i]['element_name'];
}
- return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed);
+ return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed, $attrs);
}
/**
@@ -570,9 +579,10 @@ class ArtifactTypeHtml extends ArtifactType {
* @param string $text_100 What $string to call the '100 row'
* @param bool $show_any
* @param string $text_any
+ * @param array $attrs Array of other attributes
* @return string HTML code using radio buttons
*/
- function renderRadio ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any') {
+ function renderRadio ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $attrs = array()) {
$arr = $this->getExtraFieldElements($extra_field_id);
$keys = array();
$vals = array();
@@ -580,7 +590,7 @@ class ArtifactTypeHtml extends ArtifactType {
$keys[$i]=$arr[$i]['element_id'];
$vals[$i]=$arr[$i]['element_name'];
}
- return html_build_radio_buttons_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any);
+ return html_build_radio_buttons_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any,$attrs);
}
/**
@@ -590,26 +600,38 @@ class ArtifactTypeHtml extends ArtifactType {
* @param array $checked The items that should be checked
* @param bool|string $show_100 Whether to show the '100 row'
* @param string $text_100 What to call the '100 row'
+ * @param array $attrs Array of other attributes
* @return string radio buttons
*/
- function renderCheckbox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
+ function renderCheckbox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none', $attrs = array()) {
if ($text_100 == 'none'){
$text_100=_('None');
}
if (!$checked || !is_array($checked)) {
$checked=array();
}
+ if (!empty($attrs['title'])) {
+ $attrs['title'] = util_html_secure($attrs['title']);
+ }
$arr = $this->getExtraFieldElements($extra_field_id);
$return = '';
if ($show_100) {
- $return .= '
- <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="100" '.
- ((in_array(100,$checked)) ? 'checked="checked"' : '').'/> '.$text_100.'<br />';
+ $chk_attrs = array('type'=>'checkbox', 'name'=>'extra_fields['.$extra_field_id.'][]', 'id'=>'extra_fields100', 'value'=>'100');
+ if (in_array('100', $checked)) {
+ $chk_attrs['checked']='checked';
+ }
+ $return .= html_e('input', array_merge($attrs,$chk_attrs));
+ $return .= html_e('label', array_merge(array('for'=>'extra_fields100'), (empty($attrs['title']) ? array() : array('title'=>$attrs['title']))), $text_100);
+ $return .= html_e('br');
}
for ($i=0; $i<count($arr); $i++) {
- $return .= '
- <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="'.$arr[$i]['element_id'].'" '.
- ((in_array($arr[$i]['element_id'],$checked)) ? 'checked="checked"' : '').'/> '.$arr[$i]['element_name'].'<br />';
+ $chk_attrs = array('type'=>'checkbox', 'name'=>'extra_fields['.$extra_field_id.'][]', 'id'=>'extra_fields'.$arr[$i]['element_id'], 'value'=>$arr[$i]['element_id']);
+ if (in_array($arr[$i]['element_id'],$checked)) {
+ $chk_attrs['checked']='checked';
+ }
+ $return .= html_e('input', array_merge($attrs,$chk_attrs));
+ $return .= html_e('label', array_merge(array('for'=>'extra_fields'.$arr[$i]['element_id']), (empty($attrs['title']) ? array() : array('title'=>$attrs['title']))), $arr[$i]['element_name']);
+ $return .= html_e('br');
}
return $return;
}
@@ -621,9 +643,10 @@ class ArtifactTypeHtml extends ArtifactType {
* @param array $checked The items that should be checked
* @param bool|string $show_100 Whether to show the '100 row'
* @param string $text_100 What to call the '100 row'
+ * @param array $attrs Array of other attributes
* @return string radio multiselectbox
*/
- function renderMultiSelectBox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
+ function renderMultiSelectBox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none', $attrs = array()) {
if (!$checked) {
$checked=array();
}
@@ -638,7 +661,7 @@ class ArtifactTypeHtml extends ArtifactType {
$vals[]=$arr[$i]['element_name'];
}
$size = min( count($arr)+1, 15);
- return html_build_multiple_select_box_from_arrays($keys,$vals,"extra_fields[$extra_field_id][]",$checked,$size,$show_100,$text_100);
+ return html_build_multiple_select_box_from_arrays($keys,$vals,"extra_fields[$extra_field_id][]",$checked,$size,$show_100,$text_100, $attrs);
}
/**
@@ -648,23 +671,24 @@ class ArtifactTypeHtml extends ArtifactType {
* @param string $contents The data for this field.
* @param string $size
* @param string $maxlength
+ * @param array $attrs Array of other attributes
* @return string HTML code of corresponding input tag.
*/
- function renderTextField ($extra_field_id, $contents, $size, $maxlength) {
- return '
- <input type="text" name="extra_fields['.$extra_field_id.']" value="'.$contents.'" size="'.$size.'" maxlength="'.$maxlength.'"/>';
+ function renderTextField ($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+ return html_e('input', array_merge(array( 'type'=>'text', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$contents, 'size'=>$size, 'maxlength'=>$maxlength)));
}
- /**
+ /**()
* renderRelationField - this function builds a relation field.
*
* @param int $extra_field_id The ID of this field.
* @param string $contents The data for this field.
* @param string $size
* @param string $maxlength
+ * @param array $attrs Array of other attributes
* @return string text area and data.
*/
- function renderRelationField ($extra_field_id,$contents,$size,$maxlength) {
+ function renderRelationField ($extra_field_id,$contents,$size,$maxlength, $attrs = array()) {
$arr = $this->getExtraFieldElements($extra_field_id);
for ($i=0; $i<count($arr); $i++) {
$keys[$i]=$arr[$i]['element_id'];
@@ -673,9 +697,9 @@ class ArtifactTypeHtml extends ArtifactType {
// Convert artifact id to links.
$html_contents = preg_replace_callback('/\b(\d+)\b/', create_function('$matches', 'return _artifactid2url($matches[1], \'title\');'), $contents);
$edit_contents = $this->renderTextField ($extra_field_id,$contents,$size,$maxlength);
- return '
- <div id="edit'.$extra_field_id.'" style="display: none;" title="'._('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)').'" >'.$edit_contents.'</div>
- <div id="show'.$extra_field_id.'" style="display: block;">'.$html_contents.'</div>';
+ $return = html_e('div',array_merge(array( 'id'=>'edit'.$extra_field_id, 'style'=>'display: none', 'title'=>_('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)')), $attrs), $edit_contents);
+ $return .=html_e('div',array_merge(array( 'id'=>'show'.$extra_field_id, 'style'=>'display: block'), $attrs), $html_contents);
+ return $return;
}
/**
@@ -685,11 +709,11 @@ class ArtifactTypeHtml extends ArtifactType {
* @param string $contents The data for this field.
* @param string $rows
* @param string $cols
+ * @param array $attrs Array of other attributes
* @return string text area and data.
*/
- function renderTextArea ($extra_field_id,$contents,$rows,$cols) {
- return '
- <textarea name="extra_fields['.$extra_field_id.']" rows="'.$rows.'" cols="'.$cols.'">'.$contents.'</textarea>';
+ function renderTextArea ($extra_field_id,$contents,$rows,$cols, $attrs = array()) {
+ return html_e('textarea', array_merge(array('name'=>'extra_fields['.$extra_field_id.']', 'rows'=>$rows, 'cols'=>$cols), $attrs), $contents);
}
function technicianBox ($name='assigned_to[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
diff --git a/src/common/tracker/views/form-addextrafield.php b/src/common/tracker/views/form-addextrafield.php
index 6db5f28..1d97446 100644
--- a/src/common/tracker/views/form-addextrafield.php
+++ b/src/common/tracker/views/form-addextrafield.php
@@ -4,6 +4,7 @@
*
* Copyright 2010 (c) FusionForge Team
* Copyright 2014-2015, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -96,55 +97,71 @@ if ($rows > 0) {
echo "<h2>"._('Add New Custom Field')."</h2>";
echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID(), 'method' => 'post'));
-?>
-<p>
-<input type="hidden" name="add_extrafield" value="y" />
-<strong><?php echo _('Custom Field Name').utils_requiredField()._(':'); ?></strong><br />
-<input type="text" name="name" value="" size="15" maxlength="30" required="required" />
-</p>
-<p>
-<strong><?php echo _('Field alias')._(':'); ?></strong><br />
-<input type="text" name="alias" value="" size="15" maxlength="30" />
-</p>
-
-<p>
-<strong><?php echo _('Type of custom field')._(':'); ?></strong><br />
-<input type="radio" name="field_type" value="1" required="required" /> <?php echo _('Select Box'); ?><br />
-<input type="radio" name="field_type" value="2" /> <?php echo _('Check Box'); ?><br />
-<input type="radio" name="field_type" value="3" /> <?php echo _('Radio Buttons'); ?><br />
-<input type="radio" name="field_type" value="4" /> <?php echo _('Text Field'); ?><br />
-<input type="radio" name="field_type" value="5" /> <?php echo _('Multi-Select Box'); ?><br />
-<input type="radio" name="field_type" value="6" /> <?php echo _('Text Area'); ?><br />
-<?php if (!$ath->usesCustomStatuses()) { ?>
-<input type="radio" name="field_type" value="7" /> <?php echo _('Status'); ?><br />
-<?php } ?>
-<!--<input type="radio" name="field_type" value="8" /> <?php echo _('Box type technician'); ?><br />-->
-<input type="radio" name="field_type" value="9" /> <?php echo _('Relation between artifacts'); ?><br />
-<p>
-<?php echo _('Text Fields and Text Areas need to have Size/Maxlength and Rows/Cols defined, respectively.'); ?><br />
-<?php echo _('Text Field Size/Text Area Rows'); ?>
- <input type="text" name="attribute1" value="20" size="2" maxlength="2" /><br />
-<?php echo _('Text Field Maxlength/Text Area Columns'); ?>
- <input type="text" name="attribute2" value="80" size="2" maxlength="2" /><br />
-<?php echo _('Hide the default none value'); ?>
- <input type="checkbox" name="hide100" /><br />
-<?php echo _('Label for the none value'); ?>
- <input type="text" name="show100label" size="30" value="<?php echo _('none') ?>" /><br />
-</p>
-<?php
+echo html_ao('p');
+echo html_e('input', array('type'=>'hidden', 'name'=>'add_extrafield', 'value'=>'y'));
+
+echo html_e('strong', array(), _('Custom Field Name').utils_requiredField()._(':')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'name', 'value'=>'', size=>'15', 'maxlength'=>'30', 'required'=>'required'));
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
+echo html_e('strong', array(), _('Field alias')._(':')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'alias', 'value'=>'', size=>'15', 'maxlength'=>'30'));
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
+echo html_e('strong', array(), _('Description')._(':')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'description', 'value'=>'', size=>'50', 'maxlength'=>'255'));
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
+echo html_e('strong', array(), _('Type of custom field').utils_requiredField()._(':')).html_e('br');
+
+$vals = array(ARTIFACT_EXTRAFIELDTYPE_SELECT , ARTIFACT_EXTRAFIELDTYPE_CHECKBOX, ARTIFACT_EXTRAFIELDTYPE_RADIO, ARTIFACT_EXTRAFIELDTYPE_TEXT, ARTIFACT_EXTRAFIELDTYPE_MULTISELECT, ARTIFACT_EXTRAFIELDTYPE_TEXTAREA, ARTIFACT_EXTRAFIELDTYPE_STATUS, 8, ARTIFACT_EXTRAFIELDTYPE_RELATION);
+// 8 = ARTIFACT_EXTRAFIELDTYPE_ASSIGNEE
+// ARTIFACT_EXTRAFIELDTYPE_INTEGER, ARTIFACT_EXTRAFIELDTYPE_FORMULA, ARTIFACT_EXTRAFIELDTYPE_DATETIME, ARTIFACT_EXTRAFIELDTYPE_USER
+$texts = array( _('Select Box'), _('Check Box'), _('Radio Buttons'), _('Text Field'), _('Multi-Select Box'), _('Text Area'), _('Status'), _('Box type technician'), _('Relation between artifacts'));
+
+// ARTIFACT_EXTRAFIELDTYPE_ASSIGNEE not used
+unset($vals[7]);
+unset($texts[7]);
+
+if ($ath->usesCustomStatuses()) {
+ unset($vals[ARTIFACT_EXTRAFIELDTYPE_STATUS-1]);
+ unset($texts[ARTIFACT_EXTRAFIELDTYPE_STATUS-1]);
+}
+// re-index
+$vals = array_values($vals);
+$texts = array_values($texts);
+
+echo html_build_radio_buttons_from_arrays( $vals, $texts, 'field_type', '', false, '', false ,'', array('required'=>'required') );
+echo html_ac(html_ap() - 1);
+
+echo html_ao('p');
+echo _('Text Fields and Text Areas need to have Size/Maxlength and Rows/Cols defined, respectively.').html_e('br');
+echo _('Text Field Size/Text Area Rows');
+echo html_e('input', array('type'=>'text', 'name'=>'attribute1', 'value'=>'20', size=>'2', 'maxlength'=>'2')).html_e('br');
+echo _('Text Field Maxlength/Text Area Columns');
+echo html_e('input', array('type'=>'text', 'name'=>'attribute2', 'value'=>'80', size=>'2', 'maxlength'=>'2')).html_e('br');
+echo _('Hide the default none value');
+echo html_build_checkbox('hide100','',false).html_e('br');
+echo _('Label for the none value');
+echo html_e('input', array('type'=>'text', 'name'=>'show100label', 'value'=>_('none'), size=>'30')).html_e('br');
+echo html_ac(html_ap() - 1);
+
echo $HTML->warning_msg(_('Warning: this add new custom field'));
-?>
-<p>
-<input type="submit" name="post_changes" value="<?php echo _('Add Custom Field') ?>" />
-</p>
-<?php
+
+echo html_ao('p');
+echo html_e('input', array('type'=>'submit', 'name'=>'post_changes', 'value'=>_('Add Custom Field')));
+echo html_ac(html_ap() - 1);
+
echo $HTML->closeForm();
-echo "<h2>"._('Custom Field Rendering Template')."</h2>";
-echo "<p>";
-echo util_make_link('/tracker/admin/?edittemplate=1&group_id='.$group_id.'&atid='.$ath->getID(), _('Edit template')).'<br />';
+echo html_e('h2', array(), _('Custom Field Rendering Template'));
+echo html_ao('p');
+echo util_make_link('/tracker/admin/?edittemplate=1&group_id='.$group_id.'&atid='.$ath->getID(), _('Edit template')).html_e('br');
echo util_make_link('/tracker/admin/?deletetemplate=1&group_id='.$group_id.'&atid='.$ath->getID(), _('Delete template'));
-echo "</p>";
+echo html_ac(html_ap() - 1);
$ath->footer();
diff --git a/src/common/tracker/views/form-updateextrafield.php b/src/common/tracker/views/form-updateextrafield.php
index ee000da..94550fd 100644
--- a/src/common/tracker/views/form-updateextrafield.php
+++ b/src/common/tracker/views/form-updateextrafield.php
@@ -40,76 +40,66 @@ if (!$ac || !is_object($ac)) {
} elseif ($ac->isError()) {
$error_msg .= $ac->getErrorMessage();
} else {
- ?>
- <p>
- <strong><?php echo _('Type of custom field')._(': ').$ac->getTypeName(); ?></strong></p>
- <?php
+ echo html_ao('p');
+ echo html_e('strong', array(), _('Type of custom field')._(': ').$ac->getTypeName());
+ echo html_ac(html_ap() - 1);
echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&id='.$id.'&atid='.$ath->getID(), 'method' => 'post'));
- ?>
- <input type="hidden" name="update_box" value="y" />
- <input type="hidden" name="id" value="<?php echo $ac->getID(); ?>" />
- <p>
- <label for="name">
- <strong><?php echo _('Custom Field Name')._(':'); ?></strong><br />
- </label>
- <input id="name" type="text" name="name" value="<?php echo $ac->getName(); ?>" required="required" />
- </p>
- <p>
- <?php if ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) { ?>
- <label for="attribute1">
- <b><?php echo _('Text Area Rows'); ?></b><br />
- </label>
- <input id="attribute1" type="text" name="attribute1" value="<?php echo $ac->getAttribute1(); ?>" size="2" maxlength="2" />
- </p>
- <p>
- <label for="attribute2">
- <b><?php echo _('Text Area Columns'); ?></b><br />
- </label>
- <input id="attribute2" type="text" name="attribute2" value="<?php echo $ac->getAttribute2(); ?>" size="2" maxlength="2" />
- <?php } elseif ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
- $ac->getType() == ARTIFACT_EXTRAFIELDTYPE_RELATION) {?>
- <label for="attribute1">
- <b><?php echo _('Text Field Size'); ?></b><br />
- </label>
- <input id="attribute1" type="text" name="attribute1" value="<?php echo $ac->getAttribute1(); ?>" size="2" maxlength="2" />
- </p>
- <p>
- <label for="attribute2">
- <b><?php echo _('Text Field Maxlength'); ?></b><br />
- <input id="attribute2" type="text" name="attribute2" value="<?php echo $ac->getAttribute2(); ?>" size="2" maxlength="2" />
- <?php } else { ?>
- <input type="hidden" name="attribute1" value="0" />
- <input type="hidden" name="attribute2" value="0" />
- <label for="hide100">
- <b><?php echo _('Hide the default none value'); ?></b><br />
- </label>
- <input type="checkbox" name="hide100" <?php if (!$ac->getShow100()) { echo 'checked="checked" '; } ?>/>
- </p>
- <p>
- <label for="show100label">
- <b><?php echo _('Label for the none value'); ?></b><br />
- <input type="text" name="show100label" size="30" value="<?php $ac->getShow100label() ?>" />
- </p>
- <?php } ?>
- </p>
- <p>
- <label for="alias">
- <strong><?php echo _('Field alias')._(':'); ?></strong><br />
- </label>
- <input id="alias" type="text" name="alias" value="<?php echo $ac->getAlias(); ?>" />
- </p>
- <p><input id="is_required" type="checkbox" name="is_required" <?php if ($ac->isRequired()) echo 'checked="checked"'; ?> />
- <?php echo _('Field is mandatory')?></p>
- <label for="is_required">
- <?php
+
+ echo html_e('input', array('type'=>'hidden', 'name'=>'update_box', 'value'=>'y'));
+ echo html_e('input', array('type'=>'hidden', 'name'=>'id', 'value'=> $ac->getID()));
+
+ echo html_ao('p');
+ echo html_e('label', array('for'=>'name'), html_e('strong', array(), _('Custom Field Name')._(':')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'id'=>'name', 'name'=>'name', 'value'=>$ac->getName(), size=>'15', 'maxlength'=>'30', 'required'=>'required'));
+ echo html_ac(html_ap() - 1);
+
+ echo html_ao('p');
+ echo html_e('label', array('for'=>'description'), html_e('strong', array(), _('Description')._(':')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'name'=>'description', 'value'=>$ac->getDescription(), size=>'50', 'maxlength'=>'255'));
+ echo html_ac(html_ap() - 1);
+
+ echo html_ao('p');
+ if ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
+ echo html_e('label', array('for'=>'attribute1'), html_e('b', array(), _('Text Area Columns')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'id'=>'attribute1', 'name'=>'attribute1', 'value'=>$ac->getAttribute1(), size=>'2', 'maxlength'=>'2'));
+ echo html_ac(html_ap() - 1);
+ echo html_ao('p');
+ echo html_e('label', array('for'=>'attribute2'), html_e('b', array(), _('Text Area Columns')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'id'=>'attribute2', 'name'=>'attribute2', 'value'=>$ac->getAttribute2(), size=>'2', 'maxlength'=>'2'));
+ } elseif ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_TEXT || $ac->getType() == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
+ echo html_e('label', array('for'=>'attribute1'), html_e('b', array(), _('Text Field Size')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'id'=>'attribute1', 'name'=>'attribute1', 'value'=>$ac->getAttribute1(), size=>'2', 'maxlength'=>'2'));
+ echo html_ac(html_ap() - 1);
+ echo html_ao('p');
+ echo html_e('label', array('for'=>'attribute2'), html_e('b', array(), _('Text Field Maxlength')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'id'=>'attribute2', 'name'=>'attribute2', 'value'=>$ac->getAttribute2(), size=>'2', 'maxlength'=>'2'));
+ } else {
+ echo html_e('input', array('type'=>'hidden', 'name'=>'attribute1', 'value'=>'0'));
+ echo html_e('input', array('type'=>'hidden', 'name'=>'attribute2', 'value'=>'0'));
+ echo html_e('label', array('for'=>'hide100'), html_e('b', array(), _('Hide the default none value')).html_e('br'));
+ echo html_build_checkbox('hide100','',!$ac->getShow100());
+ echo html_ac(html_ap() - 1);
+ echo html_ao('p');
+ echo html_e('label', array('for'=>'show100label'), html_e('b', array(), _('Label for the none value')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'name'=>'show100label', 'value'=>$ac->getShow100label(), size=>'30'));
+ }
+ echo html_ac(html_ap() - 1);
+
+ echo html_ao('p');
+ echo html_e('label', array('for'=>'alias'), html_e('strong', array(), _('Field alias')._(':')).html_e('br'));
+ echo html_e('input', array('type'=>'text', 'id'=>'alias', 'name'=>'alias', 'value'=>$ac->getAlias(), size=>'15', 'maxlength'=>'30'));
+ echo html_ac(html_ap() - 1);
+
+ echo html_ao('p');
+ echo html_build_checkbox('is_required','',$ac->isRequired());
+ echo html_e('label', array('for'=>'is_required'), _('Field is mandatory'));
+ echo html_ac(html_ap() - 1);
+
echo $HTML->warning_msg(_('It is not recommended that you change the custom field name because other things are dependent upon it. When you change the custom field name, all related items will be changed to the new name.'));
- ?>
- </label>
- </p>
- <p>
- <input type="submit" name="post_changes" value="<?php echo _('Submit') ?>" />
- </p>
- <?php
+
+ echo html_ao('p');
+ echo html_e('input', array('type'=>'submit', 'name'=>'post_changes', 'value'=>_('Submit')));
+ echo html_ac(html_ap() - 1);
echo $HTML->closeForm();
}
diff --git a/src/db/20160519-artifact_extra_field_list-description.sql b/src/db/20160519-artifact_extra_field_list-description.sql
new file mode 100644
index 0000000..5dbded8
--- /dev/null
+++ b/src/db/20160519-artifact_extra_field_list-description.sql
@@ -0,0 +1,2 @@
+ALTER TABLE artifact_extra_field_list
+ ADD COLUMN description text NOT NULL DEFAULT '';
\ No newline at end of file
diff --git a/src/www/tracker/admin/index.php b/src/www/tracker/admin/index.php
index 144f90a..63addd6 100644
--- a/src/www/tracker/admin/index.php
+++ b/src/www/tracker/admin/index.php
@@ -6,6 +6,7 @@
* Copyright 2010, FusionForge Team
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
* Copyright 2013-2014, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -24,6 +25,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+
+
require_once '../../env.inc.php';
require_once $gfcommon.'include/pre.php';
require_once $gfcommon.'tracker/Artifact.class.php';
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=ebf064ce09092d41504d4f124699c9c91a1e2b2b
commit ebf064ce09092d41504d4f124699c9c91a1e2b2b
Author: Stéphane-Eymeric Bredthauer <sebredthauer at gmail.com>
Date: Sun May 22 17:59:34 2016 +0200
html utils: Add 'extra attributs' parameter to all html_build_ functions
diff --git a/src/www/include/html.php b/src/www/include/html.php
index fb8b07c..acfcd1b 100644
--- a/src/www/include/html.php
+++ b/src/www/include/html.php
@@ -9,6 +9,7 @@
* Copyright 2011-2016, Franck Villaume - TrivialDev
* Copyright © 2011, 2012
* Thorsten “mirabilos” Glaser <t.glaser at tarent.de>
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivalDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
@@ -240,19 +241,19 @@ function html_get_timezone_popup($title = 'timezone', $selected = 'xzxz') {
/**
* html_build_select_box_from_assoc() - Takes one assoc array and returns a pop-up box.
*
- * @param array $arr An array of items to use.
+ * @param array $arr An array of items to use.
* @param string $select_name The name you want assigned to this form element.
* @param string $checked_val The value of the item that should be checked.
- * @param bool $swap Whether we should swap the keys / names.
- * @param bool $show_100 Whether or not to show the '100 row'.
- * @param string $text_100 What to call the '100 row' defaults to none.
- * @param bool $show_any Whether or not to show the 'Any row'.
- * @param string $text_any What to call the 'Any row' defaults to any.
- * @param bool|array $allowed Array of all allowed values from the full list.
- * @param array $html_params Array of other html param for an element.
+ * @param bool $swap Whether we should swap the keys / names.
+ * @param bool $show_100 Whether or not to show the '100 row'.
+ * @param string $text_100 What to call the '100 row' defaults to none.
+ * @param bool $show_any Whether or not to show the 'Any row'.
+ * @param string $text_any What to call the 'Any row' defaults to any.
+ * @param bool|array $allowed Array of all allowed values from the full list.
+ * @param array $attrs Array of other attributes for this select element.
* @return string
*/
-function html_build_select_box_from_assoc($arr, $select_name, $checked_val = 'xzxz', $swap = false, $show_100 = false, $text_100 = 'None', $show_any = false, $text_any = 'any', $allowed = false, $html_params = array()) {
+function html_build_select_box_from_assoc($arr, $select_name, $checked_val = 'xzxz', $swap = false, $show_100 = false, $text_100 = 'None', $show_any = false, $text_any = 'any', $allowed = false, $attrs = array()) {
if ($swap) {
$keys = array_values($arr);
$vals = array_keys($arr);
@@ -260,43 +261,31 @@ function html_build_select_box_from_assoc($arr, $select_name, $checked_val = 'xz
$vals = array_values($arr);
$keys = array_keys($arr);
}
- return html_build_select_box_from_arrays($keys, $vals, $select_name, $checked_val, $show_100, $text_100, $show_any, $text_any, $allowed, $html_params);
+ return html_build_select_box_from_arrays($keys, $vals, $select_name, $checked_val, $show_100, $text_100, $show_any, $text_any, $allowed, $attrs);
}
/**
* html_build_select_box_from_array() - Takes one array, with the first array being the "id"
* or value and the array being the text you want displayed.
*
- * @param array $vals An array of items to use.
+ * @param array $vals An array of items to use.
* @param string $select_name The name you want assigned to this form element.
* @param string $checked_val The value of the item that should be checked.
- * @param int $samevals
+ * @param int $samevals
+ * @param array $attrs Array of other attributes for this select element.
* @return string
*/
-function html_build_select_box_from_array($vals, $select_name, $checked_val = 'xzxz', $samevals = 0) {
- $return = '
- <select name="'.$select_name.'">';
+function html_build_select_box_from_array($vals, $select_name, $checked_val = 'xzxz', $samevals = 0, $attrs = array()) {
- $rows = count($vals);
-
- for ($i = 0; $i < $rows; $i++) {
- if ($samevals) {
- $return .= "\n\t\t<option value=\"".$vals[$i]."\"";
- if ($vals[$i] == $checked_val) {
- $return .= ' selected="selected"';
- }
- } else {
- $return .= "\n\t\t<option value=\"".$i.'"';
- if ($i == $checked_val) {
- $return .= ' selected="selected"';
- }
- }
- $return .= '>'.htmlspecialchars($vals[$i]).'</option>';
+ if ($samevals) {
+ $values = array_values($vals);
+ $texts = array_values($vals);
+ } else {
+ $values = array_keys($vals);
+ $texts = array_values($vals);
}
- $return .= '
- </select>';
- return $return;
+ return html_build_select_box_from_arrays($values, $texts, $select_name, $checked_val, false, '', false, '', false, $attrs);
}
/**
@@ -316,10 +305,16 @@ function html_build_select_box_from_array($vals, $select_name, $checked_val = 'x
* @param string $text_100 What to call the '100 row' defaults to none
* @param bool $show_any Whether or not to show the 'Any row'
* @param string $text_any What to call the 'Any row' defaults to any
+ * @param array $attrs Array of other attributes
* @return string
*/
function html_build_radio_buttons_from_arrays($vals, $texts, $select_name, $checked_val = 'xzxz',
- $show_100 = true, $text_100 = 'none', $show_any = false, $text_any = 'any') {
+ $show_100 = true, $text_100 = 'none', $show_any = false,
+ $text_any = 'any', $attrs = array()) {
+
+ $attrs['type'] = 'radio';
+ $attrs['name'] = $select_name;
+
if ($text_100 == 'none') {
$text_100 = _('None');
}
@@ -332,13 +327,23 @@ function html_build_radio_buttons_from_arrays($vals, $texts, $select_name, $chec
//we don't always want the default Any row shown
if ($show_any) {
- $return .= '
- <input type="radio" name="'.$select_name.'" value=""'.(($checked_val == '')? ' checked="checked"' : '').' /> '.$text_any.'<br />';
+ $radio_attrs = $attrs;
+ $radio_attrs['value'] = '';
+ $radio_attrs['id'] = $select_name.'_any';
+ if ($checked_val == '') {
+ $radio_attrs ['checked'] = 'checked';
+ }
+ $return .= html_e('input', $radio_attrs).html_e('label',array('for'=>$select_name.'_any'), $text_any).html_e('br');
}
//we don't always want the default 100 row shown
if ($show_100) {
- $return .= '
- <input type="radio" name="'.$select_name.'" value="100"'.(($checked_val == 100)? ' checked="checked"' : '').' /> '.$text_100.'<br />';
+ $radio_attrs = $attrs;
+ $radio_attrs['value'] = '100';
+ $radio_attrs['id'] = $select_name.'_100';
+ if ($checked_val == '100') {
+ $radio_attrs ['checked'] = 'checked';
+ }
+ $return .= html_e('input', $radio_attrs).html_e('label',array('for'=>$select_name.'_100'), $text_100).html_e('br');
}
$checked_found = false;
@@ -347,13 +352,15 @@ function html_build_radio_buttons_from_arrays($vals, $texts, $select_name, $chec
// uggh - sorry - don't show the 100 row
// if it was shown above, otherwise do show it
if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
- $return .= '
- <input type="radio" id="'.$select_name.'_'.$vals[$i].'" name="'.$select_name.'" value="'.$vals[$i].'"';
+ $radio_attrs = $attrs;
+ $radio_attrs['value'] = $vals[$i];
+ $radio_attrs['id'] = $select_name.'_'.$vals[$i];
if ((string)$vals[$i] == (string)$checked_val) {
$checked_found = true;
- $return .= ' checked="checked"';
+ //$return .= ' checked="checked"';
+ $radio_attrs ['checked'] = 'checked';
}
- $return .= ' /> '.htmlspecialchars($texts[$i]).'<br />';
+ $return .= html_e('input', $radio_attrs).html_e('label',array('for'=>$select_name.'_'.$vals[$i]), htmlspecialchars($texts[$i])).html_e('br');
}
}
//
@@ -361,8 +368,11 @@ function html_build_radio_buttons_from_arrays($vals, $texts, $select_name, $chec
// we want to preserve that value UNLESS that value was 'xzxz', the default value
//
if (!$checked_found && $checked_val != 'xzxz' && $checked_val && $checked_val != 100) {
- $return .= '
- <input type="radio" value="'.$checked_val.'" checked="checked" /> '._('No Change').'<br />';
+ $radio_attrs = $attrs;
+ $radio_attrs['value'] = $checked_val;
+ $radio_attrs['id'] = $select_name.'_no_change';
+ $radio_attrs ['checked'] = 'checked';
+ $return .= html_e('input', $radio_attrs).html_e('label',array('for'=>$select_name.'_no_change'), _('No Change')).html_e('br');
}
return $return;
@@ -537,21 +547,25 @@ function html_use_jquerybrowser() {
* row is 100, so almost every pop-up box has 100 as the default
* Most tables in the database should therefore have a row with an id of 100 in it so that joins are successful
*
- * @param array $vals The ID or value
- * @param array $texts Text to be displayed
+ * @param array $vals The ID or value
+ * @param array $texts Text to be displayed
* @param string $select_name Name to assign to this form element
* @param string $checked_val The item that should be checked
- * @param bool $show_100 Whether or not to show the '100 row'
- * @param string $text_100 What to call the '100 row' defaults to none
- * @param bool $show_any Whether or not to show the 'Any row'
- * @param string $text_any What to call the 'Any row' defaults to any
- * @param bool|array $allowed Array of all allowed values from the full list.
- * @param array $html_params Array of other html param for an element
+ * @param bool $show_100 Whether or not to show the '100 row'
+ * @param string $text_100 What to call the '100 row' defaults to none
+ * @param bool $show_any Whether or not to show the 'Any row'
+ * @param string $text_any What to call the 'Any row' defaults to any
+ * @param bool|array $allowed Array of all allowed values from the full list.
+ * @param array $attrs Array of other attributes for this select element
* @return string
*/
function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked_val = 'xzxz',
- $show_100 = true, $text_100 = 'none',
- $show_any = false, $text_any = 'any', $allowed = false, $html_params = array()) {
+ $show_100 = true, $text_100 = 'none',
+ $show_any = false, $text_any = 'any',
+ $allowed = false, $attrs = array()) {
+ if ($text_100 == 'none') {
+ $text_100 = _('None');
+ }
$have_a_subelement = false;
$return = '';
@@ -560,28 +574,32 @@ function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked
$return .= _('Error: uneven row counts');
}
- //TODO: remove this ugly ack to get something more generic...
- $title = html_get_tooltip_description($select_name);
- if (isset($html_params['id'])) {
- $id = $html_params['id'];
+ if (!is_array($attrs)) {
+ $attrs = array();
+ }
+
+ if (empty($attrs['title'])) {
+ //TODO: remove this ugly ack to get something more generic...
+ $attrs['title'] = util_html_secure(html_get_tooltip_description($select_name));
} else {
- $id = '';
+ $attrs['title'] = util_html_secure($attrs['title']);
}
- if ($title) {
- $id = 'tracker-'.$select_name.'"';
- if (preg_match('/\[\]/', $id)) {
- $id = '';
+
+ if (!empty($attrs['title'])) {
+ $attrs['id'] = 'tracker-'.$select_name.'"';
+ if (preg_match('/\[\]/', $attrs['id'])) {
+ unset($attrs['id']);
}
}
-
- $return .= html_ao('select', array('id' => $id, 'name' => $select_name, 'title' => util_html_secure($title)));
+ $attrs['name'] = $select_name;
+ $return .= html_ao('select', $attrs);
//we don't always want the default Any row shown
if ($show_any) {
- $attrs = array('value' => '');
+ $opt_attrs = array('value' => '');
if ($checked_val)
- $attrs['selected'] = 'selected';
- $return .= html_e('option', $attrs, util_html_secure($text_any), false);
+ $opt_attrs['selected'] = 'selected';
+ $return .= html_e('option', $opt_attrs, util_html_secure($text_any), false);
$have_a_subelement = true;
}
//we don't always want the default 100 row shown
@@ -589,10 +607,10 @@ function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked
if ($text_100 == 'none') {
$text_100 = _('None');
}
- $attrs = array('value' => 100);
+ $opt_attrs = array('value' => 100);
if ($checked_val)
- $attrs['selected'] = 'selected';
- $return .= html_e('option', $attrs, util_html_secure($text_100), false);
+ $opt_attrs['selected'] = 'selected';
+ $return .= html_e('option', $opt_attrs, util_html_secure($text_100), false);
$have_a_subelement = true;
}
@@ -602,17 +620,17 @@ function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked
// uggh - sorry - don't show the 100 row
// if it was shown above, otherwise do show it
if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
- $attrs = array();
- $attrs['value'] = util_html_secure($vals[$i]);
+ $opt_attrs = array();
+ $opt_attrs['value'] = util_html_secure($vals[$i]);
if ((string)$vals[$i] == (string)$checked_val) {
$checked_found = true;
- $attrs['selected'] = 'selected';
+ $opt_attrs['selected'] = 'selected';
}
if (is_array($allowed) && !in_array($vals[$i], $allowed)) {
- $attrs['disabled'] = 'disabled';
- $attrs['class'] = 'option_disabled';
+ $opt_attrs['disabled'] = 'disabled';
+ $opt_attrs['class'] = 'option_disabled';
}
- $return .= html_e('option', $attrs, util_html_secure($texts[$i]));
+ $return .= html_e('option', $opt_attrs, util_html_secure($texts[$i]));
$have_a_subelement = true;
}
}
@@ -650,7 +668,7 @@ function html_build_select_box_from_arrays($vals, $texts, $select_name, $checked
* @return string
*/
function html_build_select_box($result, $name, $checked_val = "xzxz", $show_100 = true, $text_100 = 'none',
- $show_any = false, $text_any = 'Select One', $allowed = false) {
+ $show_any = false, $text_any = 'Select One', $allowed = false, $attrs = array()) {
if ($text_100 == 'none') {
$text_100 = _('None');
}
@@ -659,7 +677,8 @@ function html_build_select_box($result, $name, $checked_val = "xzxz", $show_100
}
return html_build_select_box_from_arrays(util_result_column_to_array($result, 0),
util_result_column_to_array($result, 1),
- $name, $checked_val, $show_100, $text_100, $show_any, $text_any);
+ $name, $checked_val, $show_100, $text_100,
+ $show_any, $text_any, $allowed, $attrs);
}
/**
@@ -673,14 +692,20 @@ function html_build_select_box($result, $name, $checked_val = "xzxz", $show_100
* @param string $text_100 What to call the '100 row'. Defaults to none.
* @return string
*/
-function html_build_select_box_sorted($result, $name, $checked_val = "xzxz", $show_100 = true, $text_100 = 'none') {
+function html_build_select_box_sorted($result, $name, $checked_val = "xzxz", $show_100 = true, $text_100 = 'none',
+ $show_any = false, $text_any = 'Select One', $allowed = false, $attrs = array()) {
if ($text_100 == 'none') {
$text_100 = _('None');
}
+ if ($text_any == 'Select One') {
+ $text_any = _('Select One');
+ }
+
$vals = util_result_column_to_array($result, 0);
$texts = util_result_column_to_array($result, 1);
array_multisort($texts, SORT_ASC, SORT_STRING, $vals);
- return html_build_select_box_from_arrays ($vals, $texts, $name, $checked_val, $show_100, $text_100);
+ return html_build_select_box_from_arrays ($vals, $texts, $name, $checked_val, $show_100, $text_100,
+ $show_any, $text_any, $allowed, $attrs);
}
/**
@@ -690,49 +715,21 @@ function html_build_select_box_sorted($result, $name, $checked_val = "xzxz", $sh
* @param resource $result The result set
* @param string $name Text to be displayed
* @param string $checked_array The item that should be checked
- * @param int $size The size of this box
+ * @param int $size The size of this box
* @param bool $show_100 Whether or not to show the '100 row'
* @param string $text_100 The displayed text of the '100 row'
+ * @param array $attrs Array of other attributes for this select element
* @return string
*/
-function html_build_multiple_select_box($result, $name, $checked_array, $size = 8, $show_100 = true, $text_100 = 'none') {
- $checked_count = count($checked_array);
- $return = html_ao('select', array('name' => $name, 'multiple' => 'multiple', 'size' => $size));
- if ($show_100) {
- if ($text_100 == 'none') {
- $text_100 = _('None');
- }
- /*
- Put in the default NONE box
- */
- $attrs = array('value' => 100);
- for ($j = 0; $j < $checked_count; $j++) {
- if ($checked_array[$j] == '100') {
- $attrs['selected'] = 'selected';
- }
- }
- $return .= html_e('option', $attrs, $text_100, false);
- }
-
+function html_build_multiple_select_box($result, $name, $checked_array, $size = 8, $show_100 = true, $text_100 = 'none', $attrs = array()) {
+ $vals = array();
+ $texts = array();
$rows = db_numrows($result);
for ($i = 0; $i < $rows; $i++) {
- if ((db_result($result, $i, 0) != '100') || (db_result($result, $i, 0) == '100' && !$show_100)) {
- $attrs = array();
- $attrs = array('value' => db_result($result, $i, 0));
- /*
- Determine if it's checked
- */
- $val = db_result($result, $i, 0);
- for ($j = 0; $j < $checked_count; $j++) {
- if ($val == $checked_array[$j]) {
- $attrs['selected'] = 'selected';
- }
- }
- $return .= html_e('option', $attrs, substr(db_result($result, $i, 1), 0, 35), false);
- }
+ $vals = db_result($result, $i, 0);
+ $texts = substr(db_result($result, $i, 1), 0, 35);
}
- $return .= html_ac(html_ap() -1);
- return $return;
+ return html_build_multiple_select_box_from_arrays($vals, $texts, $name, $checked_array, $size, $show_100, $text_100, $attrs);
}
/**
@@ -745,9 +742,10 @@ function html_build_multiple_select_box($result, $name, $checked_array, $size =
* @param int $size The size of this box
* @param bool $show_100 Whether or not to show the '100 row'
* @param string $text_100 What to call the '100 row' defaults to none.
+ * @param array $attrs Array of other attributes for this select element
* @return string
*/
-function html_build_multiple_select_box_from_arrays($ids, $texts, $name, $checked_array, $size = 8, $show_100 = true, $text_100 = 'none') {
+function html_build_multiple_select_box_from_arrays($vals, $texts, $name, $checked_array, $size = 8, $show_100 = true, $text_100 = 'none', $attrs = array()) {
$checked_count = count($checked_array);
$return = html_ao('select', array('name' => $name, 'multiple' => 'multiple', 'size' => $size));
if ($show_100) {
@@ -757,30 +755,30 @@ function html_build_multiple_select_box_from_arrays($ids, $texts, $name, $checke
/*
Put in the default NONE box
*/
- $attrs = array('value' => 100);
+ $opt_attrs = array('value' => 100);
for ($j = 0; $j < $checked_count; $j++) {
if ($checked_array[$j] == '100') {
- $attrs['selected'] = 'selected';
+ $opt_attrs['selected'] = 'selected';
}
}
- $return .= html_e('option', $attrs, $text_100, false);
+ $return .= html_e('option', $opt_attrs, $text_100, false);
}
- $rows = count($ids);
+ $rows = count($vals);
for ($i = 0; $i < $rows; $i++) {
- if (($ids[$i] != '100') || ($ids[$i] == '100' && !$show_100)) {
- $attrs = array();
- $attrs = array('value' => $ids[$i]);
+ if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
+ $opt_attrs = array();
+ $opt_attrs = array('value' => $vals[$i]);
/*
Determine if it's checked
*/
- $val = $ids[$i];
+ $val = $vals[$i];
for ($j = 0; $j < $checked_count; $j++) {
if ($val == $checked_array[$j]) {
- $attrs['selected'] = 'selected';
+ $opt_attrs['selected'] = 'selected';
}
}
- $return .= html_e('option', $attrs, $texts[$i], false);
+ $return .= html_e('option', $opt_attrs, $texts[$i], false);
}
}
$return .= html_ac(html_ap() -1);
@@ -793,10 +791,11 @@ function html_build_multiple_select_box_from_arrays($ids, $texts, $name, $checke
* @param string $name name of control
* @param string $value value of control
* @param bool $checked true if control should be checked
+ * @param array $attrs Array of other attributes for this element
* @return html code for checkbox control
*/
-function html_build_checkbox($name, $value, $checked) {
- $attrs = array('id' => $name, 'name' => $name, 'value' => $value, 'type' => 'checkbox');
+function html_build_checkbox($name, $value, $checked, $attrs=array()) {
+ $attrs = array_merge(array('id' => $name, 'name' => $name, 'value' => $value, 'type' => 'checkbox'), $attrs);
if ($checked) {
$attrs['checked'] = 'checked';
}
@@ -808,8 +807,8 @@ function html_build_checkbox($name, $value, $checked) {
*
* @see html_build_priority_select_box()
*/
-function build_priority_select_box($name = 'priority', $checked_val = '3', $nochange = false) {
- echo html_build_priority_select_box($name, $checked_val, $nochange);
+function build_priority_select_box($name = 'priority', $checked_val = '3', $nochange = false, $attrs = array()) {
+ echo html_build_priority_select_box($name, $checked_val, $nochange, $attrs);
}
/**
@@ -819,23 +818,26 @@ function build_priority_select_box($name = 'priority', $checked_val = '3', $noch
* @param string $name Name of the select box
* @param string $checked_val The value to be checked
* @param bool $nochange Whether to make 'No Change' selected.
+ * @param bool|array $attrs Array of other attributes for this select element
* @return string
*/
-function html_build_priority_select_box($name = 'priority', $checked_val = '3', $nochange = false) {
- $html = '<select id="tracker-'.$name.'" name="'.$name.'" title="'.util_html_secure(html_get_tooltip_description($name)).'">';
- if ($nochange) {
- $html .= '<option value="100" selected="selected" >'._('No Change').'</option>';
+function html_build_priority_select_box($name = 'priority', $checked_val = '3', $nochange = false, $attrs = array()) {
+ if (empty($attrs['title'])) {
+ $attrs['title'] = util_html_secure(html_get_tooltip_description($name));
+ } else {
+ $attrs['title'] = util_html_secure($attrs['title']);
}
- $labelOption = array('1 - '._('Lowest'), '2', '3', '4', '5 - '._('Highest'));
- for ($i = 1; $i <= 5; $i++) {
- $html .= '<option value="'.$i.'" ';
- if ($checked_val == $i) {
- $html .= 'selected="selected" ';
- }
- $html .= '>'.$labelOption[$i -1].'</option>';
+ $vals = array('1', '2', '3', '4', '5');
+ $texts = array('1 - '._('Lowest'), '2', '3', '4', '5 - '._('Highest'));
+ if ($nochange) {
+ $show_100 = true;
+ $text_100 = _('No Change');
+ $checked_val = 100;
+ } else {
+ $show_100 = false;
+ $text_100 = '';
}
- $html .= '</select>';
- return $html;
+ return html_build_select_box_from_arrays($vals, $texts, $name, $checked_val, $show_100, $text_100, false, '', false, $attrs);
}
/**
-----------------------------------------------------------------------
Summary of changes:
src/common/tracker/ArtifactExtraField.class.php | 69 +++--
src/common/tracker/ArtifactType.class.php | 2 +-
src/common/tracker/actions/admin-updates.php | 7 +-
.../tracker/include/ArtifactTypeHtml.class.php | 90 ++++---
src/common/tracker/views/form-addextrafield.php | 107 ++++----
src/common/tracker/views/form-updateextrafield.php | 126 ++++-----
...60519-artifact_extra_field_list-description.sql | 2 +
src/www/include/html.php | 292 +++++++++++----------
src/www/tracker/admin/index.php | 3 +
9 files changed, 376 insertions(+), 322 deletions(-)
create mode 100644 src/db/20160519-artifact_extra_field_list-description.sql
hooks/post-receive
--
FusionForge
More information about the Fusionforge-commits
mailing list