| 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. |
| 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' => '%', |
| 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, |
| 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) { |
| 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() { |