Changeset 42 for trunk/lib/TemplateGlue.inc.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/TemplateGlue.inc.php
r41 r42 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 * … … 19 19 20 20 /** 21 * Returns an image tag for image specified in $src. 21 * Returns an image tag for image specified in $src. 22 22 * 23 23 * @param string $src File name of the image, including path and file extension. … … 28 28 { 29 29 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 30 30 31 31 if (true === ($gis = @getimagesize($filepath)) && !preg_match('/width|height/', $extra)) { 32 32 $image_size = $gis[3]; … … 34 34 $image_size = ''; 35 35 } 36 36 37 37 return sprintf('<img src="%s" %s alt="%s" %s />', 38 38 $src, … … 44 44 45 45 /** 46 * Prints an image tag for image specified in $src. 46 * Prints an image tag for image specified in $src. 47 47 * 48 48 * @param string $src File name of the image, including path and file extension. … … 58 58 * Finds the values of an enumeration or set column of a MySQL database, returning them in an array. 59 59 * Use this to generate a pull-down menu of options or to validate the existance 60 * of options. (Quinn 10 Feb 2001) 60 * of options. (Quinn 10 Feb 2001) 61 61 * 62 62 * @param string $db_table database table to lookup … … 67 67 { 68 68 $qid = DB::query("SHOW COLUMNS FROM " . addslashes($db_table) . " LIKE '" . addslashes($db_col) . "'",false); 69 69 70 70 $row = mysql_fetch_row($qid); 71 71 if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) { … … 79 79 /** 80 80 * Prints option fields for a select form. Works only with enum or set 81 * data types in table columns. 81 * data types in table columns. 82 82 * 83 83 * @param string $db_table database table to lookup … … 134 134 /** 135 135 * Prints checkbox fields. Works only with enum or set 136 * data types in table columns. 136 * data types in table columns. 137 137 * 138 138 * @param string $db_table database table to lookup … … 143 143 */ 144 144 function printSetCheckboxes($db_table, $db_col, $preselected, $columns=1, $flag=null) 145 { 145 { 146 146 ?> 147 147 <table> … … 152 152 $preselected = explode(',', $preselected); 153 153 } 154 154 155 155 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 156 156 // Here we assume in all the values of an array are 'on' that we can find the data … … 160 160 $preselected = array_keys($preselected); 161 161 } 162 163 // Retreive values of a Set or ENUM database column. 162 163 // Retreive values of a Set or ENUM database column. 164 164 $values = getSetEnumFieldValues($db_table, $db_col); 165 165 166 166 // Initialize the HTML table generation vars. 167 167 $num_cells = sizeof($values) - 1; … … 184 184 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 185 185 $col_cnt++; 186 186 187 187 // Look for preselected value. 188 188 if (in_array($v, $preselected)) { … … 212 212 /** 213 213 * Prints radio select fields. Works only with enum or set 214 * data types in table columns. 214 * data types in table columns. 215 215 * 216 216 * @param string $db_table database table to lookup … … 221 221 */ 222 222 function printSetRadios($db_table, $db_col, $preselected, $columns=1, $flag=null) 223 { 223 { 224 224 ?> 225 225 <table> … … 230 230 $preselected = explode(',', $preselected); 231 231 } 232 232 233 233 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 234 234 // Here we assume in all the values of an array are 'on' that we can find the data … … 238 238 $preselected = array_keys($preselected); 239 239 } 240 241 // Retreive values of a Set or ENUM database column. 240 241 // Retreive values of a Set or ENUM database column. 242 242 $values = getSetEnumFieldValues($db_table, $db_col); 243 243 244 244 // Initialize the HTML table generation vars. 245 245 $num_cells = sizeof($values) - 1; … … 262 262 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 263 263 $col_cnt++; 264 264 265 265 // Look for preselected value. 266 266 if (in_array($v, $preselected)) { … … 283 283 284 284 /** 285 * Prints a pulldown menu containing the specified values and keys of a table. 285 * Prints a pulldown menu containing the specified values and keys of a table. 286 286 * 287 287 * @param string $db_table database table to lookup … … 305 305 <?php 306 306 } 307 307 308 308 // When the 'blank' value needs a specific key->val pair. 309 309 if (is_array($blank)) { … … 323 323 /** 324 324 * Prints checkbox fields. Works only with enum or set 325 * data types in table columns. 325 * data types in table columns. 326 326 * 327 327 * @param string $db_table database table to lookup … … 339 339 $preselected = explode(',', $preselected); 340 340 } 341 341 342 342 // Checkbox POST data has the primary data in the keys, and 'on' as the values. 343 343 // Here we assume in all the values of an array are 'on' that we can find the data … … 347 347 $preselected = array_keys($preselected); 348 348 } 349 349 350 350 $qid = DB::query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false); 351 351 while ($row = mysql_fetch_assoc($qid)) { 352 352 $values[] = $row; 353 353 } 354 354 355 355 // Rearrange array so sort is in vertical columns. FIXME: doesn't work. 356 356 // if ($vert_columns) { … … 378 378 return false; 379 379 } 380 380 381 381 // Initialize the HTML table generation vars. 382 382 $num_cells = sizeof($values) - 1; … … 396 396 $row_cnt++; 397 397 } 398 398 399 399 if ($col_cnt < $cols_lastrow) { 400 400 $lastrow_add = $col_cnt; … … 402 402 $lastrow_add = $cols_lastrow; 403 403 } 404 404 405 405 $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt; 406 406 $col_cnt++; 407 407 408 408 // Look for preselected value. 409 409 if (in_array($box[$val_column], $preselected)) { … … 412 412 $checked = ''; 413 413 } 414 414 415 415 // Print a cell with basic named checkboxes. 416 416 $html_name = $val_column . '[' . $box[$val_column] . ']'; … … 420 420 <?php /// FIXME: class=normal? 421 421 } 422 422 423 423 if ($col_cnt < $columns) { 424 424 // This last cell must expand to fill the last blank cells.
Note: See TracChangeset
for help on using the changeset viewer.