? buttons-nepto.diff
? comprehensive/comprehensive2.php
Index: phpMyEdit.class.php
===================================================================
RCS file: /home/cvs/phpMyEdit/phpMyEdit.class.php,v
retrieving revision 1.143
diff -u -r1.143 phpMyEdit.class.php
--- a/phpMyEdit.class.php 22 Apr 2004 16:15:14 -0000 1.143
+++ b/phpMyEdit.class.php 24 Apr 2004 11:03:56 -0000
@@ -162,6 +162,15 @@
'P' => 'copy',
'D' => 'delete'
);
+ var $default_buttons = array(
+ 'L' => array('<<','<','add','view','change','copy','delete','>','>>','goto','goto_combo'),
+ 'F' => array('<<','<','add','view','change','copy','delete','>','>>','goto','goto_combo'),
+ 'A' => array('save','more','cancel'),
+ 'C' => array('save','more','cancel'),
+ 'P' => array('save', 'cancel'),
+ 'D' => array('save','cancel'),
+ 'V' => array('change','cancel')
+ );
// }}}
/*
@@ -214,10 +223,10 @@
function list_operation() { /* covers also filtering page */ return ! $this->change_operation()
&& ! $this->add_operation() && ! $this->copy_operation()
&& ! $this->delete_operation() && ! $this->view_operation(); }
- function next_operation() { return $this->navop == $this->labels['Next']; }
- function prev_operation() { return $this->navop == $this->labels['Prev']; }
- function first_operation() { return $this->navop == $this->labels['First']; }
- function last_operation() { return $this->navop == $this->labels['Last']; }
+ function next_operation() { return ($this->navop == $this->labels['Next']) || ($this->navop == '>'); }
+ function prev_operation() { return ($this->navop == $this->labels['Prev']) || ($this->navop == '<'); }
+ function first_operation() { return ($this->navop == $this->labels['First']) || ($this->navop == '<<'); }
+ function last_operation() { return ($this->navop == $this->labels['Last']) || ($this->navop == '>>'); }
function goto_operation() { return $this->navop == $this->labels['Go to']; }
function clear_operation() { return $this->sw == $this->labels['Clear']; }
@@ -1293,11 +1302,14 @@
* @param css_class_name CSS class name
* @param js_validation if add JavaScript validation subroutine to button
* @param disabled if mark the button as disabled
+ * (-1 means do not display at all)
*/
- function htmlSubmit($name, $label, $css_class_name, $js_validation = true, $disabled = false) /* {{{ */
+ function htmlSubmit($name, $label, $css_class_name, $js_validation = true, $disabled = 0) /* {{{ */
{
+ if ($disabled < 0)
+ return '';
// Note that isn't valid HTML, but most browsers support it
- $markdisabled = $disabled ? ' disabled' : '';
+ $markdisabled = $disabled > 0 ? ' disabled' : '';
$ret = 'getCSSclass('hr', 'down').'">'."\n");
echo '
',"\n";
echo '',"\n";
echo '| ',"\n";
- $listall = $this->inc <= 0; // Are we doing a listall?
- $disabledprev = !($this->fm > 0 && !$listall);
- $disablednext = !($this->fm + $this->inc < $total_recs && ! $listall);
- $disabledgoto = !($listall || ($disablednext && $disabledprev)) ? '' : ' disabled';
- if (!$listall) {
- $current_page = intval($this->fm / $this->inc) + 1;
- $total_pages = max(1, ceil($total_recs / abs($this->inc)));
- }
- if (!$listall) {
- echo $this->htmlSubmit('navop', 'First', $this->getCSSclass('first', $position), false, $disabledprev), ' ';
- echo $this->htmlSubmit('navop', 'Prev', $this->getCSSclass('prev', $position), false, $disabledprev), ' ';
- }
- if ($this->add_enabled()) {
- echo $this->htmlSubmit('operation', 'Add', $this->getCSSclass('add', $position), false, false), ' ';
- }
- if ($this->nav_buttons()) {
- if ($this->view_enabled()) {
- echo $this->htmlSubmit('operation', 'View', $this->getCSSclass('view', $position), false, !$total_recs), ' ';
- }
- if ($this->change_enabled()) {
- echo $this->htmlSubmit('operation', 'Change', $this->getCSSclass('change', $position), false, !$total_recs), ' ';
- }
- if ($this->copy_enabled()) {
- echo $this->htmlSubmit('operation', 'Copy', $this->getCSSclass('copy', $position), false, !$total_recs), ' ';
- }
- if ($this->delete_enabled()) {
- echo $this->htmlSubmit('operation', 'Delete', $this->getCSSclass('delete', $position), false, !$total_recs), ' ';
- }
- }
- if (!$listall) { //nav buttons are not displayed if explicit listall
- echo $this->htmlSubmit('navop', 'Next', $this->getCSSclass('next', $position), false, $disablednext), ' ';
- echo $this->htmlSubmit('navop', 'Last', $this->getCSSclass('last', $position), false, $disablednext), ' ';
- echo $this->htmlSubmit('navop', 'Go to', $this->getCSSclass('goto', $position), false,
- ($listall || ($disablednext && $disabledprev)));
- echo '';
- }
- echo ' | ',"\n";
+ echo $but_str,'',"\n";
// Message is now written here
if (strlen(@$this->message) > 0) {
echo '',$this->message,' | ',"\n";
@@ -1650,47 +1624,137 @@
if ($listall) {
echo $this->labels['Page'],': 1 ',$this->labels['of'],' 1';
} else {
+ $current_page = intval($this->fm / $this->inc) + 1;
+ $total_pages = max(1, ceil($total_recs / abs($this->inc)));
echo $this->labels['Page'],': ',$current_page;
echo ' ',$this->labels['of'],' ',$total_pages;
}
- echo ' ',$this->labels['Records'],': ',$total_recs;
+ echo ' ',$this->labels['Records'],': ',$this->total_recs;
echo '
',"\n";
+ $position == 'up' && print('',"\n";
echo '',"\n";
echo '| ',"\n";
- if ($this->change_operation()) {
- echo $this->htmlSubmit('savechange', 'Save', $this->getCSSclass('save', $position), true), ' ';
- echo $this->htmlSubmit('morechange', 'Apply', $this->getCSSclass('more', $position), true), ' ';
- echo $this->htmlSubmit('cancelchange', 'Cancel', $this->getCSSclass('cancel', $position), false);
- } elseif ($this->add_operation()) {
- echo $this->htmlSubmit('saveadd', 'Save', $this->getCSSclass('save', $position), true), ' ';
- echo $this->htmlSubmit('moreadd', 'More', $this->getCSSclass('more', $position), true), ' ';
- echo $this->htmlSubmit('canceladd', 'Cancel', $this->getCSSclass('cancel', $position), false);
- } elseif ($this->copy_operation()) {
- echo $this->htmlSubmit('savecopy', 'Save', $this->getCSSclass('save', $position), true), ' ';
- echo $this->htmlSubmit('cancelcopy', 'Cancel', $this->getCSSclass('cancel', $position), false);
- } elseif ($this->delete_operation()) {
- echo $this->htmlSubmit('savedelete', 'Delete', $this->getCSSclass('save', $position), false), ' ';
- echo $this->htmlSubmit('canceldelete', 'Cancel', $this->getCSSclass('cancel', $position), false);
- } elseif ($this->view_operation()) {
- if ($this->change_enabled()) {
- echo $this->htmlSubmit('operation', 'Change', $this->getCSSclass('save', $position), false), ' ';
- }
- echo $this->htmlSubmit('cancelview', 'Cancel', $this->getCSSclass('cancel', $position), false);
- }
- // Message is now written here
- echo ' | ',"\n";
+ echo $but_str,'',"\n";
if (strlen(@$this->message) > 0) {
echo '',$this->message,' | ',"\n";
}
echo '
',"\n";
+ if ($position == 'up') {
+ if ($this->tabs_enabled()) $this->display_tab_labels('up');
+ echo '',"\n";
+ }
+ } /* }}} */
+
+ function display_buttons($position) /* {{{ */
+ {
+ $nav_fnc = 'nav_'.$position;
+ if(! $this->$nav_fnc())
+ return;
+
+ $ret = '';
+ $buttons = $this->default_buttons[$this->page_type];
+ if (is_array($this->buttons)) {
+ foreach (array_keys($this->buttons) as $key) {
+ if (stristr($key, $this->page_type)) {
+ $buttons = $this->buttons[$key][$position];
+ is_array($buttons) || $buttons = array($buttons);
+ break;
+ }
+ }
+ }
+ foreach ($buttons as $name) {
+ $ret .= $this->display_button($name, $position);
+ $ret .= "\n";
+ }
+ return $ret;
+ } /* }}} */
+
+ function display_button($name, $position = 'up') /* {{{ */
+ {
+ if (is_array($name)) {
+ if (isset($name['code'])) return $name['code'];
+ return htmlSubmit($name['name'], $name['value'], $name['css'], $name['disabled']);
+ }
+ $disabled = 1; // show disabled by default
+ if ($name[0] == '+') { $name = substr($name, 1); $disabled = 0; } // always show disabled
+ if ($name[0] == '-') { $name = substr($name, 1); $disabled = -1; } // don't show disabled
+ if ($name == 'cancel') {
+ return $this->htmlSubmit('cancel'.$this->page_types[$this->page_type], 'Cancel',
+ $this->getCSSclass('cancel', $position), false);
+ }
+ if (in_array($name, array('add','view','change','copy','delete'))) {
+ $enabled_fnc = $name.'_enabled';
+ $enabled = $this->$enabled_fnc();
+ if ($name != 'add' && ! $this->total_recs && strstr('LF', $this->page_type))
+ $enabled = false;
+ return $this->htmlSubmit('operation', ucfirst($name),
+ $this->getCSSclass($name, $position), false, $enabled ? 0 : $disabled);
+ }
+ if (in_array($name, array('save','more'))) {
+ $validation = true; // if js validation
+ if ($this->page_type == 'D' && $name == 'save' ) { $value = 'Delete'; $validation = false; }
+ elseif ($this->page_type == 'C' && $name == 'more' ) { $value = 'Apply'; }
+ else $value = ucfirst($name);
+ return $this->htmlSubmit($name.$this->page_types[$this->page_type], $value,
+ $this->getCSSclass($name, $position), $validation);
+ }
+ $listall = $this->inc <= 0; // Are we doing a listall?
+ $disabledprev = !($this->fm > 0 && !$listall);
+ $disabledfirst = $disabledprev;
+ $disablednext = !($this->fm + $this->inc < $this->total_recs && ! $listall);
+ $disabledlast = $disablednext;
+ $total_pages = max(1, ceil($this->total_recs / abs($this->inc)));
+ if (in_array($name, array('first','prev','next','last','<<','<','>','>>'))) {
+ $disabled_var = 'disabled'.$name;
+ if (strlen($name) <= 2) {
+ $nav_values = array('<<' => 'first', '<' => 'prev', '>' => 'next', '>>' => 'last');
+ $disabled_var = 'disabled'.$nav_values[$name];
+ }
+ return $this->htmlSubmit('navop', ucfirst($name),
+ $this->getCSSclass($name, $position), false, $$disabled_var ? $disabled : 0);
+ }
+ if ($name == 'goto_combo') {
+ $disabledgoto = !($listall || ($disablednext && $disabledprev)) ? '' : ' disabled';
+ if ($disablegoto != '' && $disabled < 0) return;
+ $ret = '
';
+ return $ret;
+ }
+ if ($name == 'goto') {
+ return $this->htmlSubmit('navop', 'Go to', $this->getCSSclass('goto', $position),
+ false, ($listall || ($disablednext && $disabledprev)) ? $disabled : 0);
+ }
+ return $name;
+ } /* }}} */
+
+ function number_of_recs() /* {{{ */
+ {
+ $count_parts = array(
+ 'type' => 'select',
+ 'select' => 'count(*)',
+ 'from' => $this->create_join_clause(),
+ 'where' => $this->make_where_from_query_opts());
+ $res = $this->myquery($this->query_make($count_parts), __LINE__);
+ $row = @mysql_fetch_array($res, MYSQL_NUM);
+ $this->total_recs = $row[0];
} /* }}} */
/*
@@ -1741,22 +1805,12 @@
echo '
',"\n";
// Display buttons at top and/or bottom of page.
// Setup query to get num_rows. (sparky)
- $total_recs = 0;
- $count_parts = array(
- 'type' => 'select',
- 'select' => 'count(*)',
- 'from' => $this->create_join_clause(),
- 'where' => $this->make_where_from_query_opts());
- $res = $this->myquery($this->query_make($count_parts), __LINE__);
- $row = @mysql_fetch_array($res, MYSQL_NUM);
- $total_recs = $row[0];
+ $this->number_of_recs();
if ($this->last_operation()) {
- $this->fm = (int)(($total_recs-1)/$this->inc)*$this->inc;
- }
- if ($this->nav_up()) {
- $this->display_list_table_buttons($total_recs, 'up');
- echo '
',"\n";
+ $this->fm = (int)(($this->total_recs - 1)/$this->inc)*$this->inc;
}
+ $this->display_list_table_buttons('up');
+
if ($this->cgi['persist'] != '') {
echo $this->get_origvars_html($this->cgi['persist']);
}
@@ -2186,10 +2240,7 @@
echo '',"\n";
}
echo '',"\n"; // end of table rows listing
- if ($this->nav_down()) {
- echo '
',"\n";
- $this->display_list_table_buttons($total_recs, 'down');
- }
+ $this->display_list_table_buttons('down');
$this->form_end();
} /* }}} */
@@ -2231,13 +2282,8 @@
echo '
',"\n";
echo '
',"\n";
echo '
',"\n";
- if ($this->nav_up()) {
- $this->display_record_buttons('up');
- echo '
',"\n";
- if ($this->tabs_enabled()) {
- $this->display_tab_labels('up');
- }
- }
+ $this->display_record_buttons('up');
+
if ($this->tabs_enabled()) {
echo '
',"\n";
}
@@ -2249,13 +2295,9 @@
}
echo '',"\n";
echo '
',"\n";
- if ($this->nav_down()) {
- if ($this->tabs_enabled()) {
- $this->display_tab_labels('down');
- }
- echo '
',"\n";
- $this->display_record_buttons('down');
- }
+
+ $this->display_record_buttons('down');
+
$this->form_end();
} /* }}} */
@@ -2932,6 +2974,7 @@
if (! $this->nav_up() && ! $this->nav_down()) {
$this->navigation .= 'D'; // down position is default
}
+ $this->buttons = $opts['buttons'];
// Language labels (must go after navigation)
$this->labels = $this->make_language_labels(isset($opts['language'])
? $opts['language'] : $this->get_server_var('HTTP_ACCEPT_LANGUAGE'));