| version 1.32, 2002/11/24 17:01:11 |
version 1.33, 2002/12/02 23:13:31 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.31 2002/11/22 12:48:46 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.32 2002/11/24 17:01:11 nepto Exp $ */ |
| |
|
| /* phpMyEdit intro {{{ */ |
/* phpMyEdit intro {{{ */ |
| /* |
/* |
|
|
| */ |
*/ |
| function fqn($field, $use_qfx = false, $dont_desc = false, $dont_cols = false) /* {{{ */ |
function fqn($field, $use_qfx = false, $dont_desc = false, $dont_cols = false) /* {{{ */ |
| { |
{ |
| if (is_string($field)) { |
preg_match('/^\d*$/', $field) || $field = array_search($field, $this->fds); |
| $field = array_search($field, $this->fds); |
|
| } |
|
| |
|
| // on copy/change always use simple key retrieving |
// on copy/change always use simple key retrieving |
| if ($this->add_operation() |
if ($this->add_operation() |
| || $this->copy_operation() |
|| $this->copy_operation() |
| Line 1653 function form_control(theForm) |
|
| Line 1650 function form_control(theForm) |
|
| $desc = false; |
$desc = false; |
| } |
} |
| //$raw_sort_field = 'qf'.$field; |
//$raw_sort_field = 'qf'.$field; |
| $sort_field = 'qf'.$field; |
$sort_field = $this->fqn($field); |
| $sort_field_w = $this->fdd[$field]['name']; |
$sort_field_w = $this->fdd[$field]['name']; |
| $this->fdd[$field]['expression'] && $sort_field_w .= ' (expression)'; |
$this->fdd[$field]['expression'] && $sort_field_w .= ' (expression)'; |
| if ($desc) { |
if ($desc) { |
| $sort_field .= ' DESC'; |
$sort_field .= ' DESC'; |
| Line 1691 function form_control(theForm) |
|
| Line 1688 function form_control(theForm) |
|
| } |
} |
| |
|
| /* |
/* |
| |
* Main list_table() query |
| |
* |
| |
* Each row of the HTML table is one record from the SQL query. We must |
| |
* perform this query before filter printing, because we want to use |
| |
* mysql_field_len() function. We will also fetch the first row to get |
| |
* the field names. |
| |
*/ |
| |
$res = $this->myquery($this->query_make($qparts), __LINE__); |
| |
$row = @mysql_fetch_array($res, MYSQL_ASSOC); |
| |
|
| |
/* |
| * FILTER |
* FILTER |
| * |
* |
| * Draw the filter and fill it with any data typed in last pass and stored |
* Draw the filter and fill it with any data typed in last pass and stored |
| * in the array parameter keyword 'filter'. Prepare the SQL WHERE clause. |
* in the array parameter keyword 'filter'. Prepare the SQL WHERE clause. |
| */ |
*/ |
| |
|
| if ($this->fl) { |
if ($row !== false && $this->fl) { |
| echo '<tr>'; |
echo '<tr>'; |
| echo '<td colspan='.$sys_cols.' align="center">'; |
echo '<td colspan='.$sys_cols.' align="center">'; |
| echo '<input type="submit" name="filter" value="' |
echo '<input type="submit" name="filter" value="' |
| .$this->labels['Query'].'" /></td>'."\n"; |
.$this->labels['Query'].'" /></td>'."\n"; |
| for ($kk = $k = 0; $k < $this->num_fds; $k++) { |
|
| |
/* Variable $fields is used to get index of particular field in |
| |
result. That index can be passed in example to mysql_field_len() |
| |
function. Use field names as indexes to $fields array. */ |
| |
$fields = array_flip(array_keys($row)); |
| |
for ($k = 0; $k < $this->num_fds; $k++) { |
| $this->field_name = $this->fds[$k]; |
$this->field_name = $this->fds[$k]; |
| $fd = $this->field_name; |
$fd = $this->field_name; |
| $this->field = $this->fdd[$fd]; |
$this->field = $this->fdd[$fd]; |
| Line 1717 function form_control(theForm) |
|
| Line 1730 function form_control(theForm) |
|
| if (isset($this->fdd[$fd]['width'])) { |
if (isset($this->fdd[$fd]['width'])) { |
| $widthStyle = ' STYLE=\'width: "'.(6*$this->fdd[$fd]['width']).'px"\''; |
$widthStyle = ' STYLE=\'width: "'.(6*$this->fdd[$fd]['width']).'px"\''; |
| } |
} |
| |
|
| $opened = false; |
$opened = false; |
| if ($this->displayed[$k]) { |
if ($this->displayed[$k]) { |
| echo '<td '.$widthStyle.'>'; |
echo '<td'.$widthStyle.'>'; |
| $opened = true; |
$opened = true; |
| } |
} |
| |
|
| |
|
| $type = $this->fdd[$fd]['type']; |
$type = $this->fdd[$fd]['type']; |
| if ($this->col_has_values($k)) { |
if ($this->col_has_values($k)) { |
| $type = 'string'; |
$type = 'string'; |
| } |
} |
| |
/* if ( stristr($this->fdd[$fd]['options'],'L') or |
| /* |
!isset ($this->fdd[$fd]['options'])) */ |
| if ( |
|
| stristr($this->fdd[$fd]['options'],'L') or |
|
| !isset ($this->fdd[$fd]['options']) |
|
| ) |
|
| */ |
|
| if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
| continue; |
continue; |
| } |
} |
| $kk++; // $kk counts only displayed fields |
|
| |
|
| if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') { |
if ($this->fdd[$fd]['select'] == 'D' or $this->fdd[$fd]['select'] == 'M') { |
| /* |
/* |
| * Multiple fields processing - default size is 2 and array required for values |
* Multiple fields processing - default size is 2 and array required for values |
| Line 1757 function form_control(theForm) |
|
| Line 1760 function form_control(theForm) |
|
| $size_ml_props = ''; |
$size_ml_props = ''; |
| if ($type != 'blob') { |
if ($type != 'blob') { |
| $maxlen = intval($this->fdd[$k]['maxlen']); |
$maxlen = intval($this->fdd[$k]['maxlen']); |
| $maxlen > 0 || $maxlen = intval(@mysql_field_len($res, $kk)); |
$maxlen > 0 || $maxlen = intval(@mysql_field_len($res, $fields["qf$k"])); |
| $size = $maxlen < 30 ? min($maxlen, 8) : 12; |
$size = $maxlen < 30 ? min($maxlen, 8) : 12; |
| $size && $size_ml_props .= ' size="'.$size.'"'; |
$size && $size_ml_props .= ' size="'.$size.'"'; |
| $maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"'; |
| |
if (0) { |
| |
echo $this->fdd[$fd]['name'],'|qf',$k,'|'; |
| |
echo mysql_field_len($res, $fields["qf$k"]); |
| |
echo "|size=$size|maxlen=$maxlen<br>\n"; |
| |
} |
| } |
} |
| if ($this->col_is_string($k)) { |
if ($this->col_is_string($k)) { |
| // it's treated as a string |
// it's treated as a string |
| Line 1830 function form_control(theForm) |
|
| Line 1838 function form_control(theForm) |
|
| } // if elseif else |
} // if elseif else |
| } // for |
} // for |
| echo '</tr>'."\n"; |
echo '</tr>'."\n"; |
| } // if first and fl |
} |
| |
|
| /* |
/* |
| * Display the current query |
* Display the current query |
| Line 1846 function form_control(theForm) |
|
| Line 1854 function form_control(theForm) |
|
| .'</td></tr>'."\n"; |
.'</td></tr>'."\n"; |
| } |
} |
| |
|
| /* |
|
| * Each row of the HTML table is one record from the SQL Query |
|
| * Main list_table() query |
|
| */ |
|
| $res = $this->myquery($this->query_make($qparts), __LINE__); |
|
| $first = true; |
|
| $rowCount = 0; |
|
| |
|
| if ($this->nav_text_links() || $this->nav_graphic_links()) { |
if ($this->nav_text_links() || $this->nav_graphic_links()) { |
| // gather query & GET options to preserve for Update/Delete links |
// gather query & GET options to preserve for Update/Delete links |
| $qstrparts = array(); |
$qstrparts = array(); |
| Line 1893 function form_control(theForm) |
|
| Line 1893 function form_control(theForm) |
|
| $qpdelete[] = 'operation='.$this->labels['Delete']; |
$qpdelete[] = 'operation='.$this->labels['Delete']; |
| $qpdeleteStr = '?'.join('&',$qpdelete).$this->qfn; |
$qpdeleteStr = '?'.join('&',$qpdelete).$this->qfn; |
| } |
} |
| |
|
| |
$fetched = true; |
| |
$first = true; |
| |
$rowCount = 0; |
| |
|
| while ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) { |
while ((!$fetched && ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) !== false) |
| |
|| ($fetched && $row !== false)) { |
| |
$fetched = false; |
| |
|
| echo '<tr class="'.(($rowCount++%2)?'pme_tr_o':'pme_tr_e')."\">\n"; |
echo '<tr class="'.(($rowCount++%2)?'pme_tr_o':'pme_tr_e')."\">\n"; |
| if ($sys_cols) { |
if ($sys_cols) { |