1<?php
2/**
3 * Simple helper class to query CSS color values and names.
4 *
5 * This is only a wrapper for csscolor in ODT/css/csscolors.php
6 * making the functions accessible as a helper plugin.
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     LarsDW223
10 */
11
12// must be run within Dokuwiki
13if (!defined('DOKU_INC')) die();
14
15require_once DOKU_PLUGIN . 'odt/ODT/css/csscolors.php';
16
17/**
18 * Class helper_plugin_odt_csscolors
19 *
20 * @package helper\csscolors
21 */
22class helper_plugin_odt_csscolors extends DokuWiki_Plugin {
23    /**
24     * Return list of implemented methods.
25     *
26     * @return    array
27     */
28    function getMethods() {
29        $result = array();
30        $result[] = array(
31                'name'   => 'getColorValue',
32                'desc'   => 'returns the color value for a given CSS color name. Returns "#000000" if the name is unknown',
33                'params' => array('name' => 'string'),
34                'return' => array('color value' => 'string'),
35                );
36        $result[] = array(
37                'name'   => 'getValueName',
38                'desc'   => 'returns the CSS color name for a given color value. Returns "Black" if the value is unknown',
39                'params' => array('value' => 'string'),
40                'return' => array('name' => 'string'),
41                );
42        return $result;
43    }
44
45    /**
46     * Return the color value for the color with $name.
47     *
48     * @param     string|null $name
49     * @return    string
50     */
51    public static function getColorValue ($name=NULL) {
52        return csscolors::getColorValue ($name);
53    }
54
55    /**
56     * Return the color name for the given color $value.
57     *
58     * @param     null   $value
59     * @return    string
60     */
61    public static function getValueName ($value=NULL) {
62        return csscolors::getValueName ($value);
63    }
64
65    /**
66     * Is the given $name a known CSS color name?
67     *
68     * @param     string  $name
69     * @return    boolean
70     */
71    public static function isKnownColorName ($name=NULL) {
72        return csscolors::isKnownColorName ($name);
73    }
74}
75