public function displayAdmin(Tracker_SemanticManager $semantic_manager, TrackerManager $tracker_manager, Codendi_Request $request, PFUser $current_user) { $html_purifier = Codendi_HTMLPurifier::instance(); $semantic_manager->displaySemanticHeader($this, $tracker_manager); $html = ''; $fields = $this->getFields(); if (!count($fields)) { $html .= $GLOBALS['Language']->getText('plugin_cardwall', 'semantic_cardFields_no_fields_defined'); } else { $html .= $GLOBALS['Language']->getText('plugin_cardwall', 'semantic_cardFields_fields'); $html .= '<blockquote>'; $html .= '<table>'; foreach ($fields as $field) { $html .= '<tr><td>'; $html .= $html_purifier->purify($field->getLabel(), CODENDI_PURIFIER_CONVERT_HTML); $html .= '</td><td>'; $html .= '<a href="' . $this->getUrl() . '&remove=' . (int) $field->id . '" title="' . $GLOBALS['Language']->getText('plugin_cardwall', 'semantic_cardFields_fields') . '">'; $html .= $GLOBALS['HTML']->getimage('ic/cross.png', array('alt' => $GLOBALS['Language']->getText('plugin_cardwall', 'semantic_cardFields_fields'))); $html .= '</a>'; $html .= '</td></tr>'; } $html .= '</table>'; $html .= '</blockquote>'; } $options = ''; foreach ($this->tracker->getFormElements() as $formElement) { $options .= $formElement->fetchAddTooltip($fields); } if ($options) { $html .= '<form action="' . $this->getUrl() . '" method="POST">'; $html .= '<p>' . $GLOBALS['Language']->getText('plugin_cardwall', 'semantic_card_fields_add_field'); $html .= '<select name="field">'; $html .= $options; $html .= '</select>'; $html .= '<input type="submit" name="add" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; $html .= '</p>'; $html .= '</form>'; } else { $html .= '<em>' . $GLOBALS['Language']->getText('plugin_cardwall', 'semantic_card_fields_no_more_field') . '</em>'; } $html .= '<p><a href="' . TRACKER_BASE_URL . '/?tracker=' . $this->tracker->getId() . '&func=admin-semantic">« ' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'go_back_overview') . '</a></p>'; echo $html; $semantic_manager->displaySemanticFooter($this, $tracker_manager); }
/** * Display the form to let the admin change the semantic * * @param Tracker_SemanticManager $sm The semantic manager * @param TrackerManager $tracker_manager The tracker manager * @param Codendi_Request $request The request * @param User $current_user The user who made the request * * @return string html */ public function displayAdmin(Tracker_SemanticManager $sm, TrackerManager $tracker_manager, Codendi_Request $request, User $current_user) { $hp = Codendi_HTMLPurifier::instance(); $sm->displaySemanticHeader($this, $tracker_manager); $html = ''; if ($list_fields = Tracker_FormElementFactory::instance()->getUsedListFields($this->tracker)) { $html .= '<form method="POST" action="' . $this->geturl() . '">'; // field selectbox $field = null; $select = '<select name="field_id">'; $selected = ''; if (!$this->list_field) { $selected = 'selected="selected"'; } $select .= '<option value="-1" ' . $selected . '>' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'choose_a_field') . '</option>'; foreach ($list_fields as $list_field) { $selected = ''; if ($list_field->getId() == $this->getFieldId()) { $field = $list_field; $selected = ' selected="selected" '; } $select .= '<option value="' . $list_field->getId() . '" ' . $selected . '>' . $hp->purify($list_field->getLabel(), CODENDI_PURIFIER_CONVERT_HTML) . '</option>'; } $select .= '</select>'; // open values selectbox $params = ''; if ($field) { $params = 'name="open_values[' . $this->getFieldId() . '][]" multiple="multiple" size="7" style="vertical-align:top;"'; } $values = '<select ' . $params . '>'; if ($field) { //see above foreach ($field->getAllValues() as $v) { if (!$v->isHidden()) { $selected = ''; if (in_array($v->getId(), $this->open_values)) { $selected = ' selected="selected" '; } $values .= '<option value="' . $v->getId() . '" ' . $selected . '>' . $hp->purify($v->getLabel(), CODENDI_PURIFIER_CONVERT_HTML) . '</option>'; } } } $values .= '</select>'; // submit button $submit = '<input type="submit" name="update" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; if (!$this->getFieldId()) { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'status_no_field'); $html .= '<p>' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'choose_one_advice') . $select . ' ' . $submit . '</p>'; } else { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'status_long_desc', array($select)) . $values . ' ' . $submit; } $html .= '</form>'; } else { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'status_impossible'); } $html .= '<p><a href="' . TRACKER_BASE_URL . '/?tracker=' . $this->tracker->getId() . '&func=admin-semantic">« ' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'go_back_overview') . '</a></p>'; echo $html; $sm->displaySemanticFooter($this, $tracker_manager); }
protected function getTrackerSemantic(PFUser $user, Tracker $tracker) { $tracker_semantic_manager = new Tracker_SemanticManager($tracker); return $tracker_semantic_manager->exportToSOAP($user); }
/** * Display the form to let the admin change the semantic * * @param Tracker_SemanticManager $sm The semantic manager * @param TrackerManager $tracker_manager The tracker manager * @param Codendi_Request $request The request * @param PFUser $current_user The user who made the request * * @return string html */ public function displayAdmin(Tracker_SemanticManager $sm, TrackerManager $tracker_manager, Codendi_Request $request, PFUser $current_user) { $hp = Codendi_HTMLPurifier::instance(); $sm->displaySemanticHeader($this, $tracker_manager); $html = ''; if ($list_fields = Tracker_FormElementFactory::instance()->getUsedUserSbFields($this->tracker)) { $html .= '<form method="POST" action="' . $this->geturl() . '">'; $select = '<select name="list_field_id">'; $select .= '<option value="' . self::NO_VALUE . '" selected="selected">' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'choose_a_field') . '</option>'; foreach ($list_fields as $list_field) { if ($list_field->getId() == $this->getFieldId()) { $selected = ' selected="selected" '; } else { $selected = ''; } $select .= '<option value="' . $list_field->getId() . '" ' . $selected . '>' . $hp->purify($list_field->getLabel(), CODENDI_PURIFIER_CONVERT_HTML) . '</option>'; } $select .= '</select>'; $submit = '<input type="submit" name="update" value="' . $GLOBALS['Language']->getText('global', 'btn_submit') . '" />'; if (!$this->getFieldId()) { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'contributor_no_field'); $html .= '<p>' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'choose_one_advice') . $select . ' ' . $submit . '</p>'; } else { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'contributor_field', array($select)) . $submit; } $html .= '</form>'; } else { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'contributor_impossible'); } $html .= '<p><a href="' . TRACKER_BASE_URL . '/?tracker=' . $this->tracker->getId() . '&func=admin-semantic">« ' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'go_back_overview') . '</a></p>'; echo $html; $sm->displaySemanticFooter($this, $tracker_manager); }
/** * Is the field used in semantics? * * @return boolean returns true if the field is used in semantics, false otherwise */ public function isUsedInSemantics() { $sm = new Tracker_SemanticManager($this->getTracker()); return $sm->isUsedInSemantics($this); }
/** * Return true if this field is the semantic title field of the tracker, * false otherwise if not or if there is no title field defined. * * @return boolean true if the field is the 'title' of the tracker */ protected function isSemanticTitle() { $semantic_manager = new Tracker_SemanticManager($this->getTracker()); $semantics = $semantic_manager->getSemantics(); $field = $semantics['title']->getField(); return $field === $this; }
/** * Display the form to let the admin change the semantic * * @param Tracker_SemanticManager $sm The semantic manager * @param TrackerManager $tracker_manager The tracker manager * @param Codendi_Request $request The request * @param PFUser $current_user The user who made the request * * @return string html */ public function displayAdmin(Tracker_SemanticManager $sm, TrackerManager $tracker_manager, Codendi_Request $request, PFUser $current_user) { $hp = Codendi_HTMLPurifier::instance(); $sm->displaySemanticHeader($this, $tracker_manager); $html = ''; if ($text_fields = Tracker_FormElementFactory::instance()->getUsedTextFields($this->tracker)) { $html .= '<form method="POST" action="' . $this->geturl() . '">'; $select = '<select name="text_field_id">'; if (!$this->getFieldId()) { $select .= '<option value="-1" selected="selected">' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'choose_a_field') . '</option>'; } foreach ($text_fields as $text_field) { if ($text_field->getId() == $this->getFieldId()) { $selected = ' selected="selected" '; } else { $selected = ''; } $select .= '<option value="' . $text_field->getId() . '" ' . $selected . '>' . $hp->purify($text_field->getLabel(), CODENDI_PURIFIER_CONVERT_HTML) . '</option>'; } $select .= '</select>'; $unset_btn = '<button type="submit" class="btn btn-danger" name="delete">'; $unset_btn .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'unset') . '</button>'; $submit_btn = '<button type="submit" class="btn btn-primary" name="update">'; $submit_btn .= $GLOBALS['Language']->getText('global', 'save_change') . '</button>'; if (!$this->getFieldId()) { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'description_no_field'); $html .= '<p>' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'choose_one_advice') . ' '; $html .= $select . ' <br> ' . $submit_btn; $html .= '</p>'; } else { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'description_field', $select); $html .= $submit_btn . ' ' . $GLOBALS['Language']->getText('global', 'or') . ' ' . $unset_btn; } $html .= '</form>'; } else { $html .= $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'description_impossible'); } $html .= '<p><a href="' . TRACKER_BASE_URL . '/?tracker=' . $this->tracker->getId() . '&func=admin-semantic">« ' . $GLOBALS['Language']->getText('plugin_tracker_admin_semantic', 'go_back_overview') . '</a></p>'; echo $html; $sm->displaySemanticFooter($this, $tracker_manager); }