Index: pjirc.admin.inc.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/pjirc/Attic/pjirc.admin.inc.php,v retrieving revision 1.1.2.3 diff -u -r1.1.2.3 pjirc.admin.inc.php --- pjirc.admin.inc.php 26 Sep 2009 12:30:15 -0000 1.1.2.3 +++ pjirc.admin.inc.php 18 Oct 2009 17:18:02 -0000 @@ -11,6 +11,7 @@ * Menu callback. Shows PJIRC module settigns. */ function pjirc_admin() { + $form['pjirc_connection_settings'] = array( '#type' => 'fieldset', '#title' => t('IRC connection settings'), @@ -66,11 +67,54 @@ '#maxlength' => 255, '#description' => t('The IRC room you want to join initially. Should start with a # (eg: #myroom).'), ); + + //************************************************** + + // Add Farbtastic color picker. + drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE); + drupal_add_js('misc/farbtastic/farbtastic.js'); + drupal_add_css(drupal_get_path('module', 'pjirc') .'/css/pjirc-admin.css', 'module', 'all', FALSE); + drupal_add_js(drupal_get_path('module', 'pjirc') .'/js/pjirc-color.js'); + + $form['pjirc_color_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Colors'), + '#weight' => -3, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + + $form['pjirc_color_settings']['pjirc_color_selector'] = array ( + '#type' => 'markup', + '#value' => '
', + ); + $form['pjirc_color_settings']['pjirc_colors_container'] = array ( + '#type' => 'fieldset', + '#attributes' => array('id' => 'colors-container'), + ); + + $colorsdef = _pjirc_get_colorsdef_admin(); + + foreach ($colorsdef as $colorname => $colordef) { + $variablename = 'pjirc_'. $colorname; + $form['pjirc_color_settings']['pjirc_colors_container'][$variablename] = array ( + '#type' => 'textfield', + '#title' => t($colordef['title']), + '#default_value' => variable_get($variablename, $colordef['defvalue']), + '#size' => 8, + '#maxlength' => 128, + '#description' => t($colordef['description']), + '#attributes' => array('class' => 'color_fieldset'), + ); + } + + + //************************************************** $form['pjirc_pixx_settings'] = array( '#type' => 'fieldset', '#title' => t('pixx GUI settings'), - '#weight' => -3, + '#weight' => -2, '#collapsible' => TRUE, '#collapsed' => TRUE, ); @@ -125,4 +169,9 @@ ); return system_settings_form($form); +} + +function _pjirc_get_colorsdef_admin() { + require_once('pjirc.functions.inc.php'); + return _pjirc_get_colorsdef(); } \ No newline at end of file Index: pjirc.page.inc.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/pjirc/Attic/pjirc.page.inc.php,v retrieving revision 1.1.2.2 diff -u -r1.1.2.2 pjirc.page.inc.php --- pjirc.page.inc.php 26 Sep 2009 12:30:15 -0000 1.1.2.2 +++ pjirc.page.inc.php 19 Oct 2009 19:52:12 -0000 @@ -67,6 +67,7 @@ $output .= "\n"; $output .= "\n"; } + $output .= _pjirc_output_colors_params(); $output .= "\n"; $output .= "\n"; $output .= "\n"; @@ -92,6 +93,40 @@ function _pjirc_sanitize_nick($username) { $unallowed_chars = array(' '); $username = str_replace($unallowed_chars, '', $username); - + return $username; -} \ No newline at end of file +} + +function _pjirc_filter_conf_array_callback($var) { + return preg_match('/^pjirc_color(\d)+$/', $var); +} + +function _pjirc_output_colors_params() { + global $conf; + + require_once('pjirc.functions.inc.php'); + + $output = ''; + // obtain default colors + $colorsdef = _pjirc_get_colorsdef(); + + // obtain the keys in conf that are about pjirc color, then convert values to + // keys + $colorkeys = array_flip(array_filter(array_keys($conf), '_pjirc_filter_conf_array_callback')); + //obtain elements of $conf[] that are for pjirc colors + $colorsset = array_intersect_key($conf, $colorkeys); + // check if we have found color variables in conf[] + if (!empty($colorsset) && count($colorsset)) { + // check if there are difference between $conf color variables and default + // colors, and print only params for non-default colors + foreach ($colorsset as $colorset => $colorsetvalue) { + $colorname = str_replace('pjirc_', '', $colorset); + if ($colorsdef[$colorname]['defvalue'] != $colorsetvalue) { + $colorsetvalue = str_replace('#', '', $colorsetvalue); + $output .= "\n"; + } + } + } + + return $output; +} --- css/pjirc-admin.css +++ css/pjirc-admin.css @@ -0,0 +1,11 @@ +/* $Id$ */ + +#pickerholder { + float: left; +} +#colors-container { + float: left; +} +#colors-container input { + text-align: center; +} --- js/pjirc-color.js +++ js/pjirc-color.js @@ -0,0 +1,13 @@ +// $Id$ + +if (Drupal.jsEnabled) { + $(document).ready(function () { + // initiate farbtastic colorpicker + var f = $.farbtastic('#pickerholder'); + $('.color_fieldset') + .each(function () { f.linkTo(this); }) + .focus(function() { + f.linkTo(this); + }); + }); +} --- pjirc.functions.inc.php +++ pjirc.functions.inc.php @@ -0,0 +1,31 @@ + array ('title' => 'Color 0', 'description' => 'Button Highlight / Popup & Close Button Text & Higlight / Scrollbar Highlight (Black)', 'defvalue' => '#000', ), + 'color1' => array ('title' => 'Color 1', 'description' => 'Button Border & Text : ScrollBar Border & arrow : Popup & Close button Border : User List border & Text & icons (Default Black)', 'defvalue' => '#000', ), + 'color2' => array ('title' => 'Color 2', 'description' => 'Popup & Close button shadow (Default Dark Grey)', 'defvalue' => '#a9a9a9', ), + 'color3' => array ('title' => 'Color 3', 'description' => 'Scrollbar shadow (Default Dark Grey)', 'defvalue' => '#a9a9a9', ), + 'color4' => array ('title' => 'Color 4', 'description' => 'Scrollbar de-light (3D Dim colour (Default Light Grey))', 'defvalue' => '#a8a8a8', ), + 'color5' => array ('title' => 'Color 5', 'description' => 'foreground : Buttons Face : Scrollbar Face (Default Light Blue)', 'defvalue' => '#c0d9d9', ), + 'color6' => array ('title' => 'Color 6', 'description' => 'background : Header : Scrollbar Track : Footer background (Default Blue)', 'defvalue' => '#00f', ), + 'color7' => array ('title' => 'Color 7', 'description' => 'selection : Status & Window button active colour (Default Red)', 'defvalue' => '#f00', ), + 'color8' => array ('title' => 'Color 8', 'description' => 'event Color (Default Red)', 'defvalue' => '#f00', ), + 'color9' => array ('title' => 'Color 9', 'description' => 'close button', 'defvalue' => '#', ), + /*'color10' => array ('title' => 'Color 10', 'description' => 'voice icon', 'defvalue' => '', ), + 'color11' => array ('title' => 'Color 11', 'description' => 'operator icon', 'defvalue' => '', ), + 'color12' => array ('title' => 'Color 12', 'description' => 'halfoperator icon', 'defvalue' => '', ), + 'color13' => array ('title' => 'Color 13', 'description' => 'male ASL', 'defvalue' => '', ), + 'color14' => array ('title' => 'Color 14', 'description' => 'female ASL', 'defvalue' => '', ), + 'color15' => array ('title' => 'Color 15', 'description' => 'unknown ASL', 'defvalue' => '', ),*/ + ); + + return $colorsdef; +}