12345678910111213141516171819202122232425262728293031323334353637 |
- <?php namespace Kanboard\Plugin\OMIProjectBranding\Model;
- use Kanboard\Model\ColorModel;
- class CustomColorModel extends ColorModel {
- /**
- * CustomColorModel Model
- * Get all available colors.
- *
- * @access public
- * @param bool $prepend
- * @return array
- * @author Dwayne @ OMI NZ
- */
- public function getList($prepend = false) {
- $colors = parent::getList($prepend);
- $colorFile = DATA_DIR . DIRECTORY_SEPARATOR . "OMIProjectBrandingColours.txt";// Define the path to your color file
- if (! file_exists($colorFile)) {// Check if the file exists, if not create it
- $defaultContent = "Aqua=aqua\nBeige=beige\nBlack=black\nDark Blue=darkblue\nFuchsia=fuchsia\nGray=gray\nIndigo=indigo\nMaroon=maroon\nNavy=navy\nOlive=olive\nSlategrey=slategrey\nWhite=white\nWhitesmoke=whitesmoke";
- file_put_contents($colorFile, $defaultContent);
- }
- $handle = fopen($colorFile, "r");// read from $colorFile
- if ($handle) {
- while (($line = fgets($handle)) !== false) {
- $line = trim($line);
- if (!empty($line)) {
- list($name, $colorCode) = explode("=", $line, 2);// Split the line into name and color code
- $colors[trim($colorCode)] = t(trim($name));// Add the color to the list
- }
- }
- fclose($handle);
- }
- return $colors;
- }
- }
- #-
- #plugins/OMIProjectBranding/Model/CustomColorModel.php
|