Changeset 759 for branches/1.1dev/lib
- Timestamp:
- Feb 10, 2022 1:48:35 AM (2 years ago)
- Location:
- branches/1.1dev/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/lib/Email.inc.php
r735 r759 209 209 // Apply regex pattern to search elements. 210 210 $search = array_keys($replacements); 211 array_walk($search, create_function('&$v', '$v = "{" . mb_strtoupper($v) . "}";')); 211 array_walk($search, function (&$v) { 212 $v = sprintf('{%s}', mb_strtoupper($v)); 213 }); 212 214 213 215 // Replacement values. -
branches/1.1dev/lib/TemplateGlue.inc.php
r382 r759 6 6 7 7 /** 8 * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set 8 * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set 9 9 * environment variable. Files must reside within and be relative to env "DOCUMENT_ROOT". 10 10 * … … 21 21 22 22 /** 23 * Prints an image tag for image specified in $src. 23 * Prints an image tag for image specified in $src. 24 24 * 25 25 * @param string $src File name of the image, including dir and file extension. … … 30 30 { 31 31 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 32 32 33 33 if (false === ($gis = @getimagesize($filepath)) || preg_match('/width|height/', $extra)) { 34 34 $image_size = ''; … … 36 36 $image_size = $gis[3]; 37 37 } 38 38 39 39 return sprintf('<img src="%s" %s alt="%s" %s />', 40 40 $src, … … 52 52 * Finds the values of an enumeration or set column of a MySQL database, returning them in an array. 53 53 * Use this to generate a pull-down menu of options or to validate the existance 54 * of options. (Quinn 10 Feb 2001) 54 * of options. (Quinn 10 Feb 2001) 55 55 * 56 56 * @param string $db_table database table to lookup … … 62 62 { 63 63 $qid = dbQuery("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false); 64 64 65 65 $row = mysql_fetch_row($qid); 66 if ( preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) {66 if (isset($row[1]) && preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) { 67 67 natsort($enum[1]); 68 68 return $enum[1]; … … 74 74 /** 75 75 * Prints option fields for a select form. Works only with enum or set 76 * data types in table columns. 76 * data types in table columns. 77 77 * 78 78 * @param string $db_table database table to lookup … … 109 109 /** 110 110 * Prints checkbox fields. Works only with enum or set 111 * data types in table columns. 111 * data types in table columns. 112 112 * 113 113 * @param string $db_table database table to lookup … … 118 118 */ 119 119 function printSetCheckboxes($db_table, $db_col, $preselected, $columns=1, $flag=null) 120 { 120 { 121 121 // Sometimes preselected comes as a comma list. 122 122 if (!is_array($preselected)) { 123 123 $preselected = explode(',', $preselected); 124 124 } 125 125 126 126 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 127 127 // Here we assume in all the values of an array are 'on' that we can find the data … … 131 131 $preselected = array_keys($preselected); 132 132 } 133 134 // Retreive values of a Set or ENUM database column. 133 134 // Retreive values of a Set or ENUM database column. 135 135 $values = getSetEnumFieldValues($db_table, $db_col); 136 136 137 137 if (!empty($values)) { 138 138 ?> … … 160 160 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 161 161 $col_cnt++; 162 162 163 163 // Look for preselected value. 164 164 if (in_array($item, $preselected)) { … … 189 189 /** 190 190 * Prints radio select fields. Works only with enum or set 191 * data types in table columns. 191 * data types in table columns. 192 192 * 193 193 * @param string $db_table database table to lookup … … 198 198 */ 199 199 function printSetRadios($db_table, $db_col, $preselected, $columns=1, $flag=null) 200 { 200 { 201 201 // Sometimes preselected comes as a comma list. 202 202 if (!is_array($preselected)) { 203 203 $preselected = explode(',', $preselected); 204 204 } 205 205 206 206 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 207 207 // Here we assume in all the values of an array are 'on' that we can find the data … … 211 211 $preselected = array_keys($preselected); 212 212 } 213 214 // Retreive values of a Set or ENUM database column. 213 214 // Retreive values of a Set or ENUM database column. 215 215 $values = getSetEnumFieldValues($db_table, $db_col); 216 216 217 217 if (!empty($values)) { 218 218 ?> … … 240 240 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 241 241 $col_cnt++; 242 242 243 243 // Look for preselected value. 244 244 if (in_array($item, $preselected)) { … … 262 262 263 263 /** 264 * Prints a pulldown menu containing the specified values and keys of a table. 264 * Prints a pulldown menu containing the specified values and keys of a table. 265 265 * 266 266 * @param string $db_table database table to lookup … … 284 284 <?php 285 285 } 286 286 287 287 // When the 'blank' value needs a specific key->val pair. 288 288 if (is_array($blank)) { … … 304 304 /** 305 305 * Prints checkbox fields. Works only with enum or set 306 * data types in table columns. 306 * data types in table columns. 307 307 * 308 308 * @param string $db_table database table to lookup … … 321 321 $preselected = explode(',', $preselected); 322 322 } 323 323 324 324 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 325 325 // Here we assume in all the values of an array are 'on' that we can find the data … … 329 329 $preselected = array_keys($preselected); 330 330 } 331 331 332 332 $qid = dbQuery("SELECT $key_column, $val_column FROM $db_table $extra_clause",false); 333 333 while ($row = mysql_fetch_assoc($qid)) { 334 334 $values[] = $row; 335 335 } 336 336 337 337 // Rearrange array so sort is in vertical columns. 338 338 // if ($vert_columns) { … … 360 360 return false; 361 361 } 362 362 363 363 // Initialize the HTML table generation vars. 364 364 $num_cells = sizeof($values) - 1; … … 378 378 $row_cnt++; 379 379 } 380 380 381 381 if ($col_cnt < $cols_lastrow) { 382 382 $lastrow_add = $col_cnt; … … 384 384 $lastrow_add = $cols_lastrow; 385 385 } 386 386 387 387 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 388 388 $col_cnt++; 389 389 390 390 // Look for preselected value. 391 391 if (in_array($box[$val_column], $preselected)) { … … 394 394 $checked = ''; 395 395 } 396 396 397 397 // Print a cell with named checkboxes. 398 398 $checkbox_name = oTxt(sprintf($name, $val_column, $box[$val_column])); … … 400 400 <?php 401 401 } 402 402 403 403 if ($col_cnt < $columns) { 404 404 // This last cell must expand to fill the last blank cells. -
branches/1.1dev/lib/Utilities.inc.php
r756 r759 292 292 * 293 293 * @param string $text A string for which to convert to color. 294 * 295 * @return string A hexadecimal html color.296 */ 297 function getTextColor($text, $method=1 )294 * @param float $n Brightness value between 0-1. 295 * @return string A hexadecimal html color. 296 */ 297 function getTextColor($text, $method=1, $n=0.87) 298 298 { 299 299 $hash = md5($text); … … 310 310 case 1 : 311 311 default : 312 // Reduce all hex values slighly to avoid all white. 313 array_walk($rgb, create_function('&$v', '$v = dechex(round(hexdec($v) * 0.87));')); 312 // Reduce all hex values slightly to avoid all white. 313 array_walk($rgb, function (&$v) use ($n) { 314 $v = dechex(round(hexdec($v) * $n)); 315 }); 314 316 break; 315 317 case 2 :
Note: See TracChangeset
for help on using the changeset viewer.