/** * @see Cardwall_OnTop_Config_Command::execute() */ public function execute(Codendi_Request $request) { if ($request->get('column')) { foreach ($request->get('column') as $id => $column_definition) { $column_label = $column_definition['label']; $column_bg_red = 255; $column_bg_green = 255; $column_bg_blue = 255; if (!empty($column_definition['bgcolor'])) { list($column_bg_red, $column_bg_green, $column_bg_blue) = ColorHelper::HexatoRGB($column_definition['bgcolor']); } if (!empty($column_label) && $this->dao->save($this->tracker->getId(), $id, $column_label, $column_bg_red, $column_bg_green, $column_bg_blue)) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_cardwall', 'on_top_column_changed', array($column_label))); } } } }
public function build(Cardwall_CardInCellPresenter $card, $column_id, $planning_id, PFUser $user) { $this->id = $planning_id . '_' . $card->getId(); $this->label = $card->getArtifact()->getTitle(); $this->uri = self::ROUTE . '/' . $this->id; $artifact = $card->getArtifact(); $this->project = $this->getProjectReference($artifact->getTracker()->getProject()); $this->artifact = $this->getArtifactReference($artifact); $this->planning_id = JsonCast::toInt($planning_id); $this->status = $this->getCardStatus($card); if ($card->getCardPresenter()->getAccentColor()) { $this->accent_color = ColorHelper::CssRGBToHexa($card->getCardPresenter()->getAccentColor()); } $this->column_id = JsonCast::toInt($column_id); if ($this->column_id) { $this->allowed_column_ids = array_map(function ($value) { return JsonCast::toInt($value); }, $card->getDropIntoIds()); } else { $this->allowed_column_ids = array(); } $this->values = $this->mapAndFilter($card->getCardPresenter()->getFields(), $this->getFieldsValuesFilter($user, $artifact->getLastChangeset())); }
/** * Saves a bind in the database * * @return void */ public function saveObject() { if (is_array($this->default_values)) { $t = array(); foreach ($this->default_values as $value) { $t[$value->getId()] = $value; } $this->default_values = $t; if (count($this->default_values)) { $this->getDefaultValueDao()->save($this->field->getId(), array_keys($this->default_values)); } } if (is_array($this->decorators) && !empty($this->decorators)) { $values = $this->getBindValues(); foreach ($this->decorators as $decorator) { $hexacolor = ColorHelper::RGBtoHexa($decorator->r, $decorator->g, $decorator->b); Tracker_FormElement_Field_List_BindDecorator::save($this->field->getId(), $values[$decorator->value_id]->getId(), $hexacolor); } } }
private function decorateEdit($column) { $id = 'column_' . $column->id . '_field'; $hexa = ColorHelper::CssRGBToHexa($column->bgcolor); $html = $this->fetchSquareColor('column_' . $column->id, $column->bgcolor, 'colorpicker'); $html .= '<input id="' . $id . '" type="text" size="6" autocomplete="off" name="column[' . $column->id . '][bgcolor]" value="' . $hexa . '" />'; return $html; }
/** * Process the request * * @param array $params the request parameters * @param bool $no_redirect true if we do not have to redirect the user * * @return void */ public function process($params, $no_redirect = false, $redirect = false) { $hp = Codendi_HTMLPurifier::instance(); $value_dao = $this->getValueDao(); foreach ($params as $key => $value) { switch ($key) { case 'is_rank_alpha': $is_rank_alpha = $value ? 1 : 0; if ($this->is_rank_alpha != $is_rank_alpha) { $this->getDao()->save($this->field->id, $is_rank_alpha); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_formelement_admin', 'alpha_ranking_updated')); } break; case 'delete': if (($row = $value_dao->searchById((int) $value)->getRow()) && $value_dao->delete((int) $value)) { $params['decorator'] = array((int) $value => null); $redirect = true; $GLOBALS['Response']->addFeedback('info', 'Value ' . $hp->purify($row['label'], CODENDI_PURIFIER_CONVERT_HTML) . ' deleted'); } break; case 'order': if (is_string($value) && $value != '') { $ids_in_right_order = explode(',', $value); $value_dao->reorder($ids_in_right_order); } break; case 'edit': foreach ($value as $value_id => $info) { if (isset($this->values[$value_id])) { $new_label = null; $new_description = null; $new_is_hidden = null; if (isset($info['label']) && trim($info['label']) != $this->values[$value_id]->getLabel()) { $new_label = trim($info['label']); } if (isset($info['description']) && trim($info['description']) != $this->values[$value_id]->getDescription()) { $new_description = trim($info['description']); } if (isset($info['is_hidden']) && trim($info['is_hidden']) != $this->values[$value_id]->isHidden()) { $new_is_hidden = trim($info['is_hidden']); } if ($new_label !== null || $new_description !== null || $new_is_hidden !== null) { //something has changed. we can save it $value_dao->save($value_id, $this->field->getId(), isset($new_label) ? $new_label : $this->values[$value_id]->getLabel(), isset($new_description) ? $new_description : $this->values[$value_id]->getDescription(), $this->values[$value_id]->getRank(), isset($new_is_hidden) ? $new_is_hidden : $this->values[$value_id]->isHidden()); unset($new_label, $new_description); } } } break; case 'add': $valueMapping = array(); foreach (explode("\n", $value) as $new_value) { $id = $this->addValue($new_value); if ($id) { $redirect = true; $this->values[$id] = $value_dao->searchById($id)->getRow(); $valueMapping[] = $id; } } if (isset($params['decorators'])) { $params['decorator'] = array(); foreach ($params['decorators'] as $key => $deco) { $params['decorator'][$valueMapping[$key]] = ColorHelper::RGBtoHexa($deco->r, $deco->g, $deco->b); } } break; default: break; } } return parent::process($params, $no_redirect, $redirect); }
/** @return string hexadecimal representation of the color */ private function getHexaColor($color) { return ColorHelper::RGBToHexa($color[0], $color[1], $color[2]); }
/** * Save a decorator */ public static function save($field_id, $value_id, $hexacolor) { $dao = new Tracker_FormElement_Field_List_BindDecoratorDao(); list($r, $g, $b) = ColorHelper::HexaToRGB($hexacolor); $dao->save($field_id, $value_id, $r, $g, $b); }
public function build(Cardwall_Column $column) { $this->id = JsonCast::toInt($column->getId()); $this->label = $column->getLabel(); $this->color = ColorHelper::CssRGBToHexa($column->getBgcolor()); }
function testHexaToRGB() { foreach ($this->colorSet as $hexa => $rgb) { $this->assertEqual(array($rgb[0], $rgb[1], $rgb[2]), ColorHelper::HexaToRGB($hexa)); } }