/[drupal]/contributions/modules/username_highlighter/username_highlighter.module
ViewVC logotype

Diff of /contributions/modules/username_highlighter/username_highlighter.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Jun 25 16:00:38 2008 UTC revision 1.2, Thu Jun 26 07:52:13 2008 UTC
# Line 49  function username_highlighter_filter($op Line 49  function username_highlighter_filter($op
49    }    }
50  }  }
51    
52    /**
53     * Implementation of hook_filter_tips().
54     */
55    function username_highlighter_filter_tips($delta, $format, $long = false) {
56      return t('User names will be highlighted.');
57    }
58    
59  /**  /**
60   * Administration form builder function.   * Administration form builder function.
# Line 60  function username_highlighter_admin() { Line 66  function username_highlighter_admin() {
66    $form['username_highlighter_color_saturation'] = array(    $form['username_highlighter_color_saturation'] = array(
67      '#type' => 'textfield',      '#type' => 'textfield',
68      '#title' => t('Color saturation'),      '#title' => t('Color saturation'),
69      '#default_value' => variable_get('username_highlighter_color_saturation', 75),      '#description' => t('The color saturation of the highlighting.'),
70        '#default_value' => variable_get('username_highlighter_color_saturation', 50),
71      '#size' => 4,      '#size' => 4,
72      '#maxlength' => 3,      '#maxlength' => 3,
73      '#field_suffix' => '%',      '#field_suffix' => '%',
# Line 69  function username_highlighter_admin() { Line 76  function username_highlighter_admin() {
76    $form['username_highlighter_color_value'] = array(    $form['username_highlighter_color_value'] = array(
77      '#type' => 'textfield',      '#type' => 'textfield',
78      '#title' => t('Color value'),      '#title' => t('Color value'),
79        '#description' => t('The color value of the highlighting, lower means darker.'),
80      '#default_value' => variable_get('username_highlighter_color_value', 100),      '#default_value' => variable_get('username_highlighter_color_value', 100),
81      '#size' => 4,      '#size' => 4,
82      '#maxlength' => 3,      '#maxlength' => 3,
# Line 82  function username_highlighter_admin() { Line 90  function username_highlighter_admin() {
90    // Add example of highlighting.    // Add example of highlighting.
91    $text = 'Lorem ipsum';    $text = 'Lorem ipsum';
92    $lorem_ipsum = explode(' ', 'lorem ipsum dolor sit amet consectetuer adipiscing elit integer viverra diam suspendisse aliquam ligula ut justo cras sodales tortor in');    $lorem_ipsum = explode(' ', 'lorem ipsum dolor sit amet consectetuer adipiscing elit integer viverra diam suspendisse aliquam ligula ut justo cras sodales tortor in');
93    $result = db_query('SELECT uid, name FROM {users} WHERE name != ""');    $result = db_query_range('SELECT uid, name FROM {users} WHERE name != "" ORDER BY RAND()', 0, 20);
94    while ($user = db_fetch_object($result)) {    while ($user = db_fetch_object($result)) {
95      $text .= ' ' . $user->name;      $text .= ' ' . $user->name;
96      foreach (array_rand($lorem_ipsum, rand(2, 5)) as $i) {      foreach (array_rand($lorem_ipsum, rand(2, 5)) as $i) {
# Line 119  function username_highlighter_admin_vali Line 127  function username_highlighter_admin_vali
127   * Helper function for mapping user id to a color.   * Helper function for mapping user id to a color.
128   */   */
129  function _username_highlighter_uid2color($uid) {  function _username_highlighter_uid2color($uid) {
130    $hue = ($uid * 23) % 360;    $hue = ($uid * 67) % 360;
131    $sat = 0.01 * (float)(variable_get('username_highlighter_color_saturation', 75));    $sat = 0.01 * (float)(variable_get('username_highlighter_color_saturation', 50));
132    $val = 0.01 * (float)(variable_get('username_highlighter_color_value', 100));    $val = 0.01 * (float)(variable_get('username_highlighter_color_value', 100));
133    return _username_highlighter_hsv2rgbhexcode($hue, $sat, $val);    return _username_highlighter_hsv2rgbhexcode($hue, $sat, $val);
134  }  }
135    
136    
137  /**  /**
138   * Helper function for fetching the user name replacements.   * Helper function for fetching the user name replacements.
139   */   */
140  function _username_highlighter_username_map() {  function _username_highlighter_username_map() {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2