<commit_before><?php
/**
 * NOVIUS OS - Web OS for digital communication
 *
 * @copyright  2011 Novius
 * @license    GNU Affero General Public License v3 or (at your option) any later version
 *             http://www.gnu.org/licenses/agpl-3.0.html
 * @link http://www.novius-os.org
 */

namespace Sdrdis\Color;

class Renderer_Picker extends \Fieldset_Field
{
    protected static $DEFAULT_RENDERER_OPTIONS = array(
        'colorpicker' => array(
	        'showOn'            => 'both',
            'buttonColorize'    => true,
            'buttonImage'       => 'static/apps/sdrdis_color/plugins/colorpicker/images/ui-colorpicker.png'
        ),
    );

    /**
     * Standalone build of the media renderer.
     *
     * @param  array  $renderer Renderer definition (attributes + renderer_options)
     * @return string The <input> tag + JavaScript to initialise it
     */
    public static function renderer($renderer = array())
    {
        list($attributes, $renderer_options) = static::parse_options($renderer);
        $attributes['data-colorpicker-options'] = htmlspecialchars(\Format::forge()->to_json($renderer_options['colorpicker']));

        return '<input '.array_to_attr($attributes).' />'.static::js_init($attributes['id'], $renderer_options);
    }

    protected $options = array();

    public function __construct($name, $label = '', array $renderer = array(), array $rules = array(), \Fuel\Core\Fieldset $fieldset = null)
    {
        list($attributes, $this->options) = static::parse_options($renderer);
        parent::__construct($name, $label, $attributes, $rules, $fieldset);
    }

    /**
     * How to display the field
     * @return type
     */
    public function build()
    {
        parent::build();
        $this->fieldset()->append(static::js_init($this->get_attribute('id'), $this->options));
        $colorpicker_options = $this->options['colorpicker'];
        $this->set_attribute('data-colorpicker-options', htmlspecialchars(\Format::forge()->to_json($colorpicker_options)));

        return (string) parent::build();
    }

    /**
     * Parse the renderer array to get attributes and the renderer options<commit_msg>added default color<commit_after><?php
/**
 * NOVIUS OS - Web OS for digital communication
 *
 * @copyright  2011 Novius
 * @license    GNU Affero General Public License v3 or (at your option) any later version
 *             http://www.gnu.org/licenses/agpl-3.0.html
 * @link http://www.novius-os.org
 */

namespace Sdrdis\Color;

class Renderer_Picker extends \Fieldset_Field
{
    protected static $DEFAULT_RENDERER_OPTIONS = array(
        'colorpicker' => array(
	        'showOn'            => 'both',
            'buttonColorize'    => true,
            'buttonImage'       => 'static/apps/sdrdis_color/plugins/colorpicker/images/ui-colorpicker.png'
        ),
        'default' => '000000',
    );

    /**
     * Standalone build of the media renderer.
     *
     * @param  array  $renderer Renderer definition (attributes + renderer_options)
     * @return string The <input> tag + JavaScript to initialise it
     */
    public static function renderer($renderer = array())
    {
        list($attributes, $renderer_options) = static::parse_options($renderer);
        $attributes['data-colorpicker-options'] = htmlspecialchars(\Format::forge()->to_json($renderer_options['colorpicker']));

        return '<input '.array_to_attr($attributes).' />'.static::js_init($attributes['id'], $renderer_options);
    }

    protected $options = array();

    public function __construct($name, $label = '', array $renderer = array(), array $rules = array(), \Fuel\Core\Fieldset $fieldset = null)
    {
        list($attributes, $this->options) = static::parse_options($renderer);
        parent::__construct($name, $label, $attributes, $rules, $fieldset);
    }

    /**
     * How to display the field
     * @return type
     */
    public function build()
    {
        parent::build();
        $this->fieldset()->append(static::js_init($this->get_attribute('id'), $this->options));

        if (empty($this->value)) {
            $this->value = $this->options['default'];
        }

        $colorpicker_options = $this->options['colorpicker'];
        $this->set_attribute('data-colorpicker-options', htmlspecialchars(\Format::forge()->to_json($colorpicker_options)));

        return (string) parent::build();
    }

    /**
     * Parse the renderer array to get attributes and the renderer options
{'fraction_non_alphanumeric': 0.14649397052255472, 'fraction_numerical': 0.0044662795891022775, 'mean_word_length': 3.035135135135135, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857894', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1270, 'n_words': 283}