|
|
<?php |
|
|
|
|
|
namespace Kanboard\Model; |
|
|
|
|
|
use Kanboard\Core\Base; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ColorModel extends Base |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $default_colors = array( |
|
|
'yellow' => array( |
|
|
'name' => 'Yellow', |
|
|
'background' => 'rgb(245, 247, 196)', |
|
|
'border' => 'rgb(223, 227, 45)', |
|
|
), |
|
|
'blue' => array( |
|
|
'name' => 'Blue', |
|
|
'background' => 'rgb(219, 235, 255)', |
|
|
'border' => 'rgb(168, 207, 255)', |
|
|
), |
|
|
'green' => array( |
|
|
'name' => 'Green', |
|
|
'background' => 'rgb(189, 244, 203)', |
|
|
'border' => 'rgb(74, 227, 113)', |
|
|
), |
|
|
'purple' => array( |
|
|
'name' => 'Purple', |
|
|
'background' => 'rgb(223, 176, 255)', |
|
|
'border' => 'rgb(205, 133, 254)', |
|
|
), |
|
|
'red' => array( |
|
|
'name' => 'Red', |
|
|
'background' => 'rgb(255, 187, 187)', |
|
|
'border' => 'rgb(255, 151, 151)', |
|
|
), |
|
|
'orange' => array( |
|
|
'name' => 'Orange', |
|
|
'background' => 'rgb(255, 215, 179)', |
|
|
'border' => 'rgb(255, 172, 98)', |
|
|
), |
|
|
'grey' => array( |
|
|
'name' => 'Grey', |
|
|
'background' => 'rgb(238, 238, 238)', |
|
|
'border' => 'rgb(204, 204, 204)', |
|
|
), |
|
|
'brown' => array( |
|
|
'name' => 'Brown', |
|
|
'background' => '#d7ccc8', |
|
|
'border' => '#4e342e', |
|
|
), |
|
|
'deep_orange' => array( |
|
|
'name' => 'Deep Orange', |
|
|
'background' => '#ffab91', |
|
|
'border' => '#e64a19', |
|
|
), |
|
|
'dark_grey' => array( |
|
|
'name' => 'Dark Grey', |
|
|
'background' => '#cfd8dc', |
|
|
'border' => '#455a64', |
|
|
), |
|
|
'pink' => array( |
|
|
'name' => 'Pink', |
|
|
'background' => '#f48fb1', |
|
|
'border' => '#d81b60', |
|
|
), |
|
|
'teal' => array( |
|
|
'name' => 'Teal', |
|
|
'background' => '#80cbc4', |
|
|
'border' => '#00695c', |
|
|
), |
|
|
'cyan' => array( |
|
|
'name' => 'Cyan', |
|
|
'background' => '#b2ebf2', |
|
|
'border' => '#00bcd4', |
|
|
), |
|
|
'lime' => array( |
|
|
'name' => 'Lime', |
|
|
'background' => '#e6ee9c', |
|
|
'border' => '#afb42b', |
|
|
), |
|
|
'light_green' => array( |
|
|
'name' => 'Light Green', |
|
|
'background' => '#dcedc8', |
|
|
'border' => '#689f38', |
|
|
), |
|
|
'amber' => array( |
|
|
'name' => 'Amber', |
|
|
'background' => '#ffe082', |
|
|
'border' => '#ffa000', |
|
|
), |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function find($color) |
|
|
{ |
|
|
$color = strtolower($color); |
|
|
|
|
|
foreach ($this->default_colors as $color_id => $params) { |
|
|
if ($color_id === $color) { |
|
|
return $color_id; |
|
|
} elseif ($color === strtolower($params['name'])) { |
|
|
return $color_id; |
|
|
} |
|
|
} |
|
|
|
|
|
return ''; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getColorProperties($color_id) |
|
|
{ |
|
|
if (isset($this->default_colors[$color_id])) { |
|
|
return $this->default_colors[$color_id]; |
|
|
} |
|
|
|
|
|
return $this->default_colors[$this->getDefaultColor()]; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getList($prepend = false) |
|
|
{ |
|
|
$listing = $prepend ? array('' => t('All colors')) : array(); |
|
|
|
|
|
foreach ($this->default_colors as $color_id => $color) { |
|
|
$listing[$color_id] = t($color['name']); |
|
|
} |
|
|
|
|
|
$this->hook->reference('model:color:get-list', $listing); |
|
|
|
|
|
return $listing; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDefaultColor() |
|
|
{ |
|
|
return $this->configModel->get('default_color', 'yellow'); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getDefaultColors() |
|
|
{ |
|
|
return $this->default_colors; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getBorderColor($color_id) |
|
|
{ |
|
|
$color = $this->getColorProperties($color_id); |
|
|
return $color['border']; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getBackgroundColor($color_id) |
|
|
{ |
|
|
$color = $this->getColorProperties($color_id); |
|
|
return $color['background']; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getCss() |
|
|
{ |
|
|
$buffer = ''; |
|
|
|
|
|
foreach ($this->default_colors as $color => $values) { |
|
|
$buffer .= '.task-board.color-'.$color.', .task-summary-container.color-'.$color.', .color-picker-square.color-'.$color.', .task-board-category.color-'.$color.', .table-list-category.color-'.$color.', .task-tag.color-'.$color.' {'; |
|
|
$buffer .= 'background-color: '.$values['background'].';'; |
|
|
$buffer .= 'border-color: '.$values['border']; |
|
|
$buffer .= '}'; |
|
|
$buffer .= 'td.color-'.$color.' { background-color: '.$values['background'].'}'; |
|
|
$buffer .= '.table-list-row.color-'.$color.' {border-left: 5px solid '.$values['border'].'}'; |
|
|
} |
|
|
|
|
|
return $buffer; |
|
|
} |
|
|
} |
|
|
|