public function __construct($label, $name, $value, $with_none = false, $onchange = "", $desc = "") { parent::__construct($label, $name, $value, $with_none, $onchange, $desc); foreach (array('day', 'week', 'month', 'year') as $scale) { $selected = $this->value == $scale; $this->addOption(new HTML_Element_Option($GLOBALS['Language']->getText('plugin_graphontrackers_date_scale', $scale), $scale, $selected)); } }
/** * @param $label String the label of the field * @param $name String the name of the input * @param $value mixed the current value of the field * @param $id int The item id * @param $siblings array the sibling of the item array('id' => 123, 'name' => 'Item display name', 'rank' => 4) */ public function __construct($label, $name, $value, $id, $siblings) { parent::__construct($label, $name, $value); $this->addOption(new HTML_Element_Option($GLOBALS['Language']->getText('global', 'at_the_beginning'), 'beginning', false)); $this->addOption(new HTML_Element_Option($GLOBALS['Language']->getText('global', 'at_the_end'), 'end', false)); $this->addOption(new HTML_Element_Option('--', '--', false)); foreach ($siblings as $i => $item) { if ($item['id'] != $id) { $this->addOption(new HTML_Element_Option($GLOBALS['Language']->getText('global', 'after', $item['name']), $item['rank'] + 1, isset($siblings[$i + 1]) && $siblings[$i + 1]['id'] == $id)); } } }
public function __construct($tracker, $label, $name, $value, $with_none = false, $onchange = "", $desc = "") { parent::__construct($label, $name, $value, $with_none, $onchange, $desc); require_once TRACKER_BASE_DIR . '/Tracker/FormElement/Tracker_FormElementFactory.class.php'; $aff = Tracker_FormElementFactory::instance(); foreach ($aff->getUsedDateFields($tracker) as $field) { if ($field->userCanRead()) { $selected = $this->value == $field->id; $this->addOption(new HTML_Element_Option($field->getLabel(), $field->id, $selected)); } } }
public function __construct($label, $name, $value, $with_none = false, $onchange = "", $desc = "") { parent::__construct($label, $name, $value, $with_none, $onchange, $desc); require_once 'common/tracker/ArtifactFieldFactory.class.php'; require_once 'common/tracker/ArtifactType.class.php'; $at = new ArtifactType($GLOBALS['ath']->Group, $GLOBALS['ath']->getID(), false); $aff = new ArtifactFieldFactory($at); foreach ($aff->getAllUsedFields() as $field) { if ($field->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { if ($field->isdateField()) { $selected = $this->value == $field->getName(); $this->addOption(new HTML_Element_Option($field->getLabel(), $field->getName(), $selected)); } } } }
/** * @return array of HTML_Element for properties */ public function getProperties() { $scaleSelect = new HTML_Element_Selectbox($GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_scale'), 'chart[scale]', 'value'); $scaleSelect->addMultipleOptions(array(GraphOnTrackersV5_Chart_CumulativeFlow::SCALE_DAY => $GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_day'), GraphOnTrackersV5_Chart_CumulativeFlow::SCALE_WEEK => $GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_week'), GraphOnTrackersV5_Chart_CumulativeFlow::SCALE_MONTH => $GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_month')), $this->getScale()); return array_merge(parent::getProperties(), array('field_id' => new HTML_Element_Selectbox_TrackerFields_SelectboxesV5($this->getTracker(), $GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_field'), 'chart[field_id]', $this->getFieldId()), 'start_date' => new HTML_Element_Input_Date($GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_start_date'), 'chart[start_date]', $this->getStartDate()), 'scale' => $scaleSelect, 'stop_date' => new HTML_Element_Input_Date($GLOBALS['Language']->getText('plugin_graphontrackersv5_cumulative_flow', 'cumulative_flow_property_stop_date'), 'chart[stop_date]', $this->getStopDate()))); }
/** * Nicely html-formatted output of this group's audit trail * * @param Integer $group_id Id of the project * @param Integer $offset Offset used for pagination * @param Integer $limit Number of events by page * @param String $event Events category used to filter results * @param String $subEventsBox Event used to filter results * @param String $value Value used to filter results * @param Integer $startDate Start date used to filter results * @param Integer $endDate End date used to filter results * @param String $by User name used to filter results * * @return void */ function show_grouphistory($group_id, $offset, $limit, $event = null, $subEventsBox = null, $value = null, $startDate = null, $endDate = null, $by = null) { /* show the group_history rows that are relevant to this group_id */ global $Language; $dao = new ProjectHistoryDao(CodendiDataAccess::instance()); $history_filter = build_grouphistory_filter($event, $subEventsBox, $value, $startDate, $endDate, $by); $history_rows = $dao->groupGetHistory($offset, $limit, $group_id, $history_filter); if (isset($subEventsBox)) { $subEventsString = implode(",", array_keys($subEventsBox)); $forwardSubEvents = '&event=' . $event . '&subEventsBox=' . $subEventsString; } else { $forwardSubEvents = '&event=' . $event; } $renderer = TemplateRendererFactory::build()->getRenderer(ForgeConfig::get('codendi_dir') . '/src/templates/project/'); //Event select Box $events = array('any' => $GLOBALS["Language"]->getText('global', 'any'), 'event_permission' => $GLOBALS["Language"]->getText("project_admin_utils", "event_permission"), 'event_project' => $GLOBALS["Language"]->getText("project_admin_utils", "event_project"), 'event_user' => $GLOBALS["Language"]->getText("project_admin_utils", "event_user"), 'event_ug' => $GLOBALS["Language"]->getText("project_admin_utils", "event_ug"), 'event_others' => $GLOBALS["Language"]->getText("project_admin_utils", "event_others")); $select = new HTML_Element_Selectbox('', 'events_box', ''); $select->setId('events_box'); $select->addMultipleOptions($events, $event); $title_arr = array(); $title_arr[] = $Language->getText('project_admin_utils', 'event'); $title_arr[] = $Language->getText('project_admin_utils', 'val'); $title_arr[] = $Language->getText('project_admin_utils', 'date'); $title_arr[] = $Language->getText('global', 'by'); $index = 1; $presenter = new ProjectHistoryPresenter($group_id, $select->renderValue(), $value, $startDate, $endDate, $by, $history_rows, $title_arr, $index, $offset, $limit, $forwardSubEvents); echo $renderer->renderToString('project_history', $presenter); $translatedEvents = convert_project_history_events(get_history_entries(), false); if (isset($subEventsString)) { $selectedSubEvents = explode(",", $subEventsString); foreach ($selectedSubEvents as $element) { $subEventsBox[] = $element; } } $translatedSelectedEvents = convert_project_history_events($subEventsBox, true); $js = "options = new Array();\n options['defaultValueActsAsHint'] = false;\n new UserAutoCompleter('by', '" . util_get_dir_image_theme() . "', true, options);\n new ProjectHistory(" . $translatedEvents . ", " . $translatedSelectedEvents . ");"; $GLOBALS['HTML']->includeFooterJavascriptFile('/scripts/codendi/ProjectHistory.js'); $GLOBALS['Response']->includeFooterJavascriptSnippet($js); }
/** * Nicely html-formatted output of this group's audit trail * * @param Integer $group_id Id of the project * @param Integer $offset Offset used for pagination * @param Integer $limit Number of events by page * @param String $event Events category used to filter results * @param String $subEventsBox Event used to filter results * @param String $value Value used to filter results * @param Integer $startDate Start date used to filter results * @param Integer $endDate End date used to filter results * @param String $by User name used to filter results * * @return void */ function show_grouphistory($group_id, $offset, $limit, $event = null, $subEventsBox = null, $value = null, $startDate = null, $endDate = null, $by = null) { /* show the group_history rows that are relevant to this group_id */ global $Language; $dao = new ProjectHistoryDao(CodendiDataAccess::instance()); $history_filter = build_grouphistory_filter($event, $subEventsBox, $value, $startDate, $endDate, $by); $res = $dao->groupGetHistory($offset, $limit, $group_id, $history_filter); if (isset($subEventsBox)) { $subEventsString = implode(",", array_keys($subEventsBox)); $forwardSubEvents = '&event=' . $event . '&subEventsBox=' . $subEventsString; } else { $forwardSubEvents = '&event=' . $event; } echo ' <H2>' . $Language->getText('project_admin_utils', 'g_change_history') . '</H2>'; echo '<FORM METHOD="POST" ACTION="?group_id=' . $group_id . '" id="project_history_form" name="project_history_form">'; echo '<div>'; echo '<SPAN title="' . $Language->getText('project_admin_utils', 'toggle_search') . '" id="history_search_title" class="' . Toggler::getClassname('history_search_title') . '"><B>' . $Language->getText('project_admin_utils', 'history_search_title') . '</B></SPAN>'; echo '<TABLE ID="project_history_search">'; echo '<TH colspan="2" style="text-align:left">' . $Language->getText('project_admin_utils', 'event') . '</TH> <TH style="text-align:left">' . $Language->getText('project_admin_utils', 'val') . '</TH> <TH style="text-align:left">' . $Language->getText('project_admin_utils', 'from') . '</TH> <TH style="text-align:left">' . $Language->getText('project_admin_utils', 'to') . '</TH> <TH style="text-align:left">' . $Language->getText('global', 'by') . '</TH> <TR VALIGN="TOP"><TD>'; //Event select Box $events = array('any' => $GLOBALS["Language"]->getText('global', 'any'), 'event_permission' => $GLOBALS["Language"]->getText("project_admin_utils", "event_permission"), 'event_project' => $GLOBALS["Language"]->getText("project_admin_utils", "event_project"), 'event_user' => $GLOBALS["Language"]->getText("project_admin_utils", "event_user"), 'event_ug' => $GLOBALS["Language"]->getText("project_admin_utils", "event_ug"), 'event_others' => $GLOBALS["Language"]->getText("project_admin_utils", "event_others")); $select = new HTML_Element_Selectbox('', 'events_box', ''); $select->setId('events_box'); $select->addMultipleOptions($events, $event); echo $select->renderValue(); //SubEvent select Box echo '</TD><TD><select id="sub_events_box" name="sub_events_box[]" multiple> <Option value="choose_event" disabled="disabled">' . $GLOBALS['Language']->getText('project_admin_utils', 'choose_event') . '</Option> </select>'; echo '</TD><TD><input type="text" name="value" value="' . $value . '"></TD> <TD>'; echo html_field_date('start', $startDate, false, 10, 10, 'project_history_form', false); echo '</TD> <TD>'; echo html_field_date('end', $endDate, false, 10, 10, 'project_history_form', false); echo '</TD> <TD><input type="text" name="by" id="by" value="' . $by . '"></TD> </TR>'; echo '<TR><TD id="events_array"></TD></TR>'; echo '<TR><TD><input type="submit" name="filter"></TD></TR> </TABLE>'; echo '</div>'; echo '<P>'; if ($res['numrows'] > 0) { $title_arr = array(); $title_arr[] = $Language->getText('project_admin_utils', 'event'); $title_arr[] = $Language->getText('project_admin_utils', 'val'); $title_arr[] = $Language->getText('project_admin_utils', 'date'); $title_arr[] = $Language->getText('global', 'by'); echo html_build_list_table_top($title_arr); $i = 1; displayProjectHistoryResults($group_id, $res, false, $i); echo '</TABLE>'; echo '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; if ($offset > 0) { echo '<a href="?group_id=' . $group_id . '&offset=' . ($offset - $limit) . $forwardSubEvents . '&value=' . $value . '&start=' . $startDate . '&end=' . $endDate . '&by=' . $by . '">[ ' . $Language->getText('project_admin_utils', 'previous') . ' ]</a>'; echo ' '; } if ($offset + $limit < $res['numrows']) { echo ' '; echo '<a href="?group_id=' . $group_id . '&offset=' . ($offset + $limit) . $forwardSubEvents . '&value=' . $value . '&start=' . $startDate . '&end=' . $endDate . '&by=' . $by . '">[ ' . $Language->getText('project_admin_utils', 'next') . ' ]</a>'; } echo '</div>'; echo '<div style="text-align:center" class="' . util_get_alt_row_color($i++) . '">'; echo $offset + $i - 3 . '/' . $res['numrows']; echo '</div>'; echo '<BR><TABLE align="left"><TR><TD> <input type="submit" name="export" value="' . $GLOBALS['Language']->getText('project_admin_utils', 'export_history') . '"> </TD></TR></TABLE></FORM><BR><P>'; } else { echo '<H3>' . $Language->getText('project_admin_utils', 'no_g_change') . '</H3>'; } $translatedEvents = convert_project_history_events(get_history_entries(), false); if (isset($subEventsString)) { $selectedSubEvents = explode(",", $subEventsString); foreach ($selectedSubEvents as $element) { $subEventsBox[] = $element; } } $translatedSelectedEvents = convert_project_history_events($subEventsBox, true); $js = "options = new Array();\n options['defaultValueActsAsHint'] = false;\n new UserAutoCompleter('by', '" . util_get_dir_image_theme() . "', true, options);\n new ProjectHistory(" . $translatedEvents . ", " . $translatedSelectedEvents . ");"; $GLOBALS['HTML']->includeFooterJavascriptFile('/scripts/codendi/ProjectHistory.js'); $GLOBALS['Response']->includeFooterJavascriptSnippet($js); }
function testAddMultipleOptions() { $selectbox = new HTML_Element_Selectbox('label', 'name', 'value', false); $selectbox->addMultipleOptions(array('one' => '1', 'two' => '2'), 'two'); $this->assertEqual('<select id="customfield_3" name="name" ><option value="one" >1</option><option value="two" selected="selected">2</option></select>', $selectbox->renderValue()); }