sort- and filter-headers for the nextmatch widget

This commit is contained in:
Ralf Becker 2003-12-09 00:03:41 +00:00
parent 232e7bacff
commit 2b7b9e388f
7 changed files with 146 additions and 35 deletions

View File

@ -551,12 +551,13 @@
@param $name form-name of this widget/field (used as a unique index into extension_data)
@param &$value value of the extensions content(-array)
@abstract executes the post_process-function of the extension $cell[type]
@returns True if a value should be returned (default for no postprocess fkt.), else False
@author ralfbecker
*/
{
if (!$this->haveExtension($type,'post_process'))
{
return False;
return True;
}
return $GLOBALS['phpgw_info']['etemplate']['extension'][$type]->post_process($name,$value,
$GLOBALS['phpgw_info']['etemplate']['extension_data'][$name],
@ -644,10 +645,6 @@
$pos = &$arr;
foreach($idxs as $idx)
{
if (!is_array($pos))
{
return $pos = '';
}
$pos = &$pos[$idx];
}
return $pos;

View File

@ -1,7 +1,7 @@
<?php
/**************************************************************************\
* phpGroupWare - eTemplate Extension - Nextmatch Widget *
* http://www.phpgroupware.org *
* eGroupWare - eTemplate Extension - Nextmatch Widget *
* http://www.eGroupWare.org *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
@ -25,19 +25,72 @@
'pre_process' => True,
'post_process' => True
);
var $human_name = 'Nextmatch'; // this is the name for the editor
var $human_name = array(
'nextmatch' => 'Nextmatch',
'nextmatch-sortheader' => 'Nextmatch Sortheader',
'nextmatch-filterheader' => 'Nextmatch Filterheader'
);
function nextmatch_widget($ui)
{
}
function last_part($name)
{
$parts = explode('[',str_replace(']','',$name));
return $parts[count($parts)-1];
}
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
//echo "<p>nextmatch_widget.pre_process: value = "; _debug_array($value);
$nm_global = &$GLOBALS['phpgw_info']['etemplate']['nextmatch'];
//echo "<p>nextmatch_widget.pre_process(name='$name'): value = "; _debug_array($value);
echo "<p>nextmatch_widget.pre_process(name='$name'): nm_global = "; _debug_array($nm_global);
$extension_data = array(
'type' => $cell['type']
);
switch ($cell['type'])
{
case 'nextmatch-sortheader':
$cell['type'] = 'button';
$cell['onchange'] = True;
if (!$cell['help'])
{
$cell['help'] = 'click to order after that criteria';
}
if ($this->last_part($name) == $nm_global['order']) // we're the active column
{
$cell[1] = $cell;
$cell[1]['span'] = ',activ_sortcolumn';
$cell[2] = $tmpl->empty_cell('image',$nm_global['sort']!='DESC'?'down':'up');
$cell['type'] = 'hbox';
$cell['size'] = '2,0,0';
$cell['name'] = $cell['label'] = '';
}
else
{
$cell['span'] = ',inactiv_sortcolumn';
}
return True;
case 'nextmatch-filterheader':
$cell['type'] = 'select';
if (!$cell['size'])
{
$cell['size'] = 'All';
}
if (!$cell['help'])
{
$cell['help'] = 'select which values to show';
}
$cell['onchange'] = True;
$extension_data['old_value'] = $value = $nm_global['col_filter'][$this->last_part($name)];
return True;
}
list($app,$class,$method) = explode('.',$value['get_rows']);
$obj = CreateObject($app.'.'.$class);
if (!is_object($obj))
if (!is_object($obj) || !method_exists($obj,$method))
{
echo "<p>nextmatch_widget::pre_process($name): '$value[get_rows]' is no valid method !!!</p>\n";
//return;
@ -116,16 +169,38 @@
$cell['label'] = $cell['help'] = '';
// save values in persistent extension_data to be able use it in post_process
$extension_data = $value;
$extension_data += $value;
foreach(array('sort','order','col_filter') as $n) // save them for the sortheader
{
$nm_global[$n] = $value[$n];
}
$value['bottom'] = $value; // copy the values for the bottom-bar
return False; // NO extra Label
}
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl)
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
{
//echo "<p>nextmatch_widget.post_process: value = "; _debug_array($value);
$nm_global = &$GLOBALS['phpgw_info']['etemplate']['nextmatch'];
//echo "<p>nextmatch_widget.post_process(name='$name',value_in='$value_in',order='$nm_global[order]'): value = "; _debug_array($value);
switch($extension_data['type'])
{
case 'nextmatch-sortheader':
if ($value_in)
{
$nm_global['order'] = $this->last_part($name);
}
return False; // dont report value back, as it's in the wrong location (rows)
case 'nextmatch-filterheader':
if ($value_in != $extension_data['old_value'])
{
$nm_global['filter'][$this->last_part($name)] = $value_in;
}
return False; // dont report value back, as it's in the wrong location (rows)
}
$old_value = $extension_data;
$max = $GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
@ -183,6 +258,18 @@
$value['start'] = (int) (($old_value['total']-2) / $max) * $max;
$loop = True;
}
elseif ($nm_global['order'])
{
$value['order'] = $nm_global['order'];
$value['sort'] = $old_value['order'] == $nm_global['order'] && $old_value['sort']!='DESC'?'DESC':'ASC';
$loop = True;
}
elseif ($nm_global['filter'])
{
if (!is_array($value['col_filter'])) $value['col_filter'] = array();
$value['col_filter'] += $nm_global['filter'];
$loop = True;
}
return True;
}
}

View File

@ -151,13 +151,7 @@
$hooked = $hooked['body_data'];
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('java_script' => $GLOBALS['phpgw_info']['flags']['java_script'].$this->include_java_script(2)));
}
/* is in show now for every template
list($width,$height,,,,,$overflow) = explode(',',$this->size);
if ($overflow)
{
$html = $this->html->div($html,'STYLE="'.($width?"width: $width; ":'').($height?"height: $height; ":'')."overflow: $overflow;\"");
}
*/
$id = $this->save_appsession($this->as_array(1) + array(
'readonlys' => $readonlys,
'content' => $content,
@ -378,7 +372,7 @@
{
$cell = &$cols[$c_key];
list($col_width,$col_disabled) = explode(',',$opts[$col]);
if (!$cell['height']) // if not set, cell-height = height of row
{
$cell['height'] = $height;
@ -405,7 +399,8 @@
continue; // col is disabled
}
$row_data[$col] = $this->show_cell($cell,$content,$sel_options,$readonlys,$cname,
$c,$r,$span);
$c,$r,$span,$cl);
if ($row_data[$col] == '' && $this->rows == 1)
{
unset($row_data[$col]); // omit empty/disabled cells if only one row
@ -439,7 +434,6 @@
}
}
$row_data[".$col"] .= $this->html->formatOptions($cell['align'],'ALIGN');
list(,$cl) = explode(',',$cell['span']);
$cl = $this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
$c,$r,$show_c,$show_row,$content);
$row_data[".$col"] .= $this->html->formatOptions($cl,'CLASS');
@ -469,7 +463,7 @@
@param for rest see show
@result the generated HTML
*/
function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span)
function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span,&$class)
{
if (is_int($this->debug) && $this->debug >= 3 || $this->debug == $cell['type'])
{
@ -515,9 +509,11 @@
$ext_type = $type;
$extra_label = $this->extensionPreProcess($ext_type,$form_name,$value,$cell,$readonlys[$name]);
$readonly = $readonly || $cell['readonly']; // might be set be extension
$readonly = $readonly || $cell['readonly']; // might be set by extension
$this->set_array($content,$name,$value);
}
list(,$class) = explode(',',$cell['span']); // might be set by extension
$cell_options = $cell['size'];
if ($cell_options[0] == '@')
{
@ -807,7 +803,7 @@
case 'image':
$image = $value != '' ? $value : $name;
$image = $this->html->image(substr($this->name,0,strpos($this->name,'.')),
$image,strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label,'BORDER="0"');
$image,strlen($label) > 1 && !$cell['no_lang'] ? lang($label) : $label,'border="0"');
$html .= $image;
$extra_link = $cell_options;
$extra_label = False;
@ -827,7 +823,7 @@
$box_anz = 0;
for ($n = 1; $n <= $cell_options; ++$n)
{
$h = $this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul);
$h = $this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul,$cl);
if ($h != '' && $h != '&nbsp;')
{
if ($cell['type'] == 'vbox')
@ -844,7 +840,6 @@
{
$rows[$box_row]['.'.$box_col] = $this->html->formatOptions($cell[$n]['align'],'ALIGN');
}
list(,$cl) = explode(',',$cell[$n]['span']);
$cl = $this->expand_name(isset($this->class_conf[$cl]) ? $this->class_conf[$cl] : $cl,
$show_c,$show_row,$content['.c'],$content['.row'],$content);
$rows[$box_row]['.'.$box_col] .= $this->html->formatOptions($cl,'CLASS');
@ -874,7 +869,7 @@
}
for ($n = 1; $n <= $cell_options; ++$n)
{
$h = $this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul);
$h = $this->show_cell($cell[$n],$content,$sel_options,$readonlys,$cname,$show_c,$show_row,$nul,$nul);
$vis = !empty($value) && $value == $cell_options[$n]['name'] || $n == 1 && $first ? 'visible' : 'hidden';
list (,$cl) = explode(',',$cell[$n]['span']);
$html .= $this->html->div($h,$this->html->formatOptions(array(
@ -976,8 +971,8 @@
}
$content_in = $cname ? array($cname => $content) : $content;
$content = array();
reset($to_process);
while (list($form_name,$type) = each($to_process))
foreach($to_process as $form_name => $type)
{
if (is_array($type))
{
@ -994,12 +989,15 @@
{
$value = ''; // blur-values is equal to emtpy
}
//echo "<p>process_show($this->name) $type: $form_name = '$value'</p>\n";
// echo "<p>process_show($this->name) $type: $form_name = '$value'</p>\n";
list($type,$sub) = explode('-',$type);
switch ($type)
{
case 'ext':
$this->extensionPostProcess($sub,$form_name,$this->get_array($content,$form_name),$value);
if (!$this->extensionPostProcess($sub,$form_name,$this->get_array($content,$form_name),$value))
{
$this->unset_array($content,$form_name);
}
break;
case 'text':
case 'textarea':

View File

@ -25,3 +25,19 @@
);
}
display_sidebox($appname,$menu_title,$file);
$menu_title = lang('Documentation');
$docs = $GLOBALS['phpgw_info']['server']['webserver_url'].'/etemplate/doc/';
$file = Array(
array(
'text' => 'eTemplate Tutorial',
'link' => $docs.'etemplate.html',
'target' => 'docs'
),
array(
'text' => 'eTemplate Referenz',
'link' => $docs.'referenz.html',
'target' => 'docs'
),
);
display_sidebox($appname,$menu_title,$file);

View File

@ -1,5 +1,5 @@
<?php
// eTemplates for Application 'etemplate', generated by etemplate.dump() 2003-10-26 18:35
// eTemplates for Application 'etemplate', generated by etemplate.dump() 2003-12-09 10:45
/* $Id$ */
@ -147,3 +147,6 @@ $templ_data[] = array('name' => 'etemplate.db-tools.edit','template' => '','lang
$templ_data[] = array('name' => 'etemplate.db-tools.indices','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:4:{i:0;a:3:{s:2:\"c1\";s:2:\"th\";s:2:\"c2\";s:2:\"th\";s:2:\"c3\";s:3:\"row\";}i:1;a:8:{s:1:\"A\";a:3:{s:4:\"type\";s:5:\"label\";s:4:\"span\";s:3:\"all\";s:5:\"label\";s:19:\"Multicolumn Indices\";}s:1:\"B\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"C\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"D\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"E\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"F\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"G\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"H\";a:1:{s:4:\"type\";s:5:\"label\";}}i:2;a:8:{s:1:\"A\";a:4:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:1:\"#\";s:7:\"no_lang\";s:1:\"1\";s:5:\"align\";s:6:\"center\";}s:1:\"B\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:10:\"ColumnName\";}s:1:\"C\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:10:\"ColumnName\";}s:1:\"D\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:10:\"ColumnName\";}s:1:\"E\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:10:\"ColumnName\";}s:1:\"F\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:10:\"ColumnName\";}s:1:\"G\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:6:\"Unique\";}s:1:\"H\";a:5:{s:4:\"type\";s:6:\"button\";s:5:\"label\";s:9:\"Add Index\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:9:\"add_index\";s:4:\"help\";s:28:\"Add a new multi-column index\";}}i:3;a:8:{s:1:\"A\";a:4:{s:4:\"type\";s:5:\"label\";s:7:\"no_lang\";s:1:\"1\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:14:\"Index[$row][n]\";}s:1:\"B\";a:5:{s:4:\"type\";s:6:\"select\";s:4:\"size\";s:4:\"none\";s:7:\"no_lang\";s:1:\"1\";s:4:\"name\";s:14:\"Index[$row][0]\";s:4:\"help\";s:49:\"Select the indexed columns in their desired order\";}s:1:\"C\";a:6:{s:4:\"type\";s:6:\"select\";s:4:\"size\";s:4:\"none\";s:7:\"no_lang\";s:1:\"1\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:14:\"Index[$row][1]\";s:4:\"help\";s:49:\"Select the indexed columns in their desired order\";}s:1:\"D\";a:5:{s:4:\"type\";s:6:\"select\";s:4:\"size\";s:4:\"none\";s:7:\"no_lang\";s:1:\"1\";s:4:\"name\";s:14:\"Index[$row][2]\";s:4:\"help\";s:49:\"Select the indexed columns in their desired order\";}s:1:\"E\";a:6:{s:4:\"type\";s:6:\"select\";s:4:\"size\";s:4:\"none\";s:7:\"no_lang\";s:1:\"1\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:14:\"Index[$row][3]\";s:4:\"help\";s:49:\"Select the indexed columns in their desired order\";}s:1:\"F\";a:5:{s:4:\"type\";s:6:\"select\";s:4:\"size\";s:4:\"none\";s:7:\"no_lang\";s:1:\"1\";s:4:\"name\";s:14:\"Index[$row][4]\";s:4:\"help\";s:49:\"Select the indexed columns in their desired order\";}s:1:\"G\";a:4:{s:4:\"type\";s:8:\"checkbox\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:19:\"Index[$row][unique]\";s:4:\"help\";s:59:\"DB ensures that every row has a unique value in that column\";}s:1:\"H\";a:5:{s:4:\"type\";s:6:\"button\";s:5:\"label\";s:12:\"Delete Index\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:18:\"delete_index[$row]\";s:4:\"help\";s:18:\"Deletes this index\";}}}','size' => '','style' => '','modified' => '1067173445',);
$templ_data[] = array('name' => 'etemplate.nextmatch_widget','template' => '','lang' => '','group' => '0','version' => '0.9.15.008','data' => 'a:5:{i:0;a:3:{s:1:\"A\";s:3:\"40%\";s:1:\"C\";s:3:\"40%\";s:2:\"h4\";s:13:\",!@bottom_too\";}i:1;a:3:{s:1:\"A\";a:2:{s:4:\"type\";s:8:\"template\";s:4:\"name\";s:12:\"@header_left\";}s:1:\"B\";a:5:{s:4:\"type\";s:4:\"hbox\";s:4:\"size\";s:1:\"2\";s:5:\"align\";s:6:\"center\";i:1;a:4:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:7:\"showing\";s:7:\"no_lang\";s:1:\"1\";s:4:\"name\";s:5:\"range\";}i:2;a:4:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:2:\"of\";s:7:\"no_lang\";s:1:\"1\";s:4:\"name\";s:5:\"total\";}}s:1:\"C\";a:3:{s:4:\"type\";s:8:\"template\";s:5:\"align\";s:5:\"right\";s:4:\"name\";s:13:\"@header_right\";}}i:2;a:3:{s:1:\"A\";a:4:{s:4:\"type\";s:8:\"template\";s:4:\"span\";s:3:\"all\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:33:\"etemplate.nextmatch_widget.nm_row\";}s:1:\"B\";a:2:{s:4:\"type\";s:5:\"label\";s:8:\"onchange\";s:1:\"1\";}s:1:\"C\";a:1:{s:4:\"type\";s:5:\"label\";}}i:3;a:3:{s:1:\"A\";a:5:{s:4:\"type\";s:8:\"template\";s:4:\"size\";s:4:\"rows\";s:4:\"span\";s:3:\"all\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:9:\"@template\";}s:1:\"B\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"C\";a:1:{s:4:\"type\";s:5:\"label\";}}i:4;a:3:{s:1:\"A\";a:5:{s:4:\"type\";s:8:\"template\";s:4:\"size\";s:6:\"bottom\";s:4:\"span\";s:3:\"all\";s:5:\"align\";s:6:\"center\";s:4:\"name\";s:33:\"etemplate.nextmatch_widget.nm_row\";}s:1:\"B\";a:1:{s:4:\"type\";s:5:\"label\";}s:1:\"C\";a:1:{s:4:\"type\";s:5:\"label\";}}}','size' => '100%','style' => '.activ_sortcolumn { color: red; font-weight: bold; }
.inactiv_sortcolumn { color: green; font-weight: normal; }','modified' => '1070783966',);

View File

@ -43,6 +43,7 @@ click here to attach the file etemplate de hier clicken um die Datei anzuh
click here to create the link etemplate de hier clicken um die Verknüpfung anzulegen
click here to start the search etemplate de hier clicken um die Suche zu starten
click here to upload the file etemplate de hier clicken um die Datei hochzuladen
click to order after that criteria etemplate de anclicken um nach diesem Kriterium zu sortieren
columnname etemplate de Spaltenname
comment etemplate de Kommentar
create a new table for the application etemplate de Neue Tabelle für die Anwendung anlegen
@ -73,6 +74,7 @@ discard changes etemplate de verwirft
displayed in front of input or input is inserted for a '%s' in the label (label of the submitbutton or image-filename) etemplate de wird vor dem Eingabefeld angezeigt oder das Feld wird für ein '%s' eingefügt (Beschriftung einer Schaltfläche oder Dateiname eine Grafik)
displayed in statusline of browser if input-field gets focus etemplate de wird in der Statuszeile des Browsers angezeit, wenn das Eingabefeld angesprochen wird
do you want to save the changes you made in table %s? etemplate de Wollen Sie die Änderungen in der Tabelle '%s' speichern?
documentation etemplate de Dokumentation
drop a table - this can not be undone etemplate de Tabelle löschen (drop) - NICHT rückgänig zu machen
drop table etemplate de Tabelle löschen
dump4setup etemplate de Dump4Setup
@ -100,6 +102,8 @@ etemplate common de eTemplate
etemplate '%1' imported, use save to put it in the database etemplate de eTemplate '%1' importiert, benutze Speichern um es in der Datenbank abzulegen
etemplate '%1' written to '%2' etemplate de eTemplate '%1' wurde nach '%2' geschrieben
etemplate editor etemplate de eTemplate Editor
etemplate referenz etemplate de eTemplate Handbuch
etemplate tutorial etemplate de eTemplate Einführung
exchange this row with the one above etemplate de diese Zeile mit der darüber austauschen
exchange this two columns etemplate de diese beiden Spalten austauschen
export the loaded etemplate into a xml-file etemplate de das geladene eTemplate als XML Datei (.xet) exportieren
@ -221,6 +225,7 @@ select priority etemplate de Priorit
select state etemplate de US-State auswählen
select the indexed columns in their desired order etemplate de Zu indizierende Spalten in der gewünchten Reihenfolge auswählen
select this etemplate to delete it etemplate de dieses eTemplate zum Löschen auswählen
select which values to show etemplate de auswählen welche Werte angezeigt werden
select year etemplate de Jahr auswählen
selectbox etemplate de Auswahlbox
sets today as date etemplate de setzt heutiges Datum

View File

@ -43,6 +43,7 @@ click here to attach the file etemplate en click here to attach the file
click here to create the link etemplate en click here to create the Link
click here to start the search etemplate en Click here to start the search
click here to upload the file etemplate en Click here to upload the file
click to order after that criteria etemplate en click to order after that criteria
columnname etemplate en ColumnName
comment etemplate en Comment
create a new table for the application etemplate en Create a new table for the application
@ -73,6 +74,7 @@ discard changes etemplate en discard changes
displayed in front of input or input is inserted for a '%s' in the label (label of the submitbutton or image-filename) etemplate en displayed in front of input or input is inserted for a '%s' in the label (label of the Submitbutton or Image-filename)
displayed in statusline of browser if input-field gets focus etemplate en displayed in statusline of browser if input-field gets focus
do you want to save the changes you made in table %s? etemplate en Do you want to save the changes you made in table %s?
documentation etemplate en Documentation
drop a table - this can not be undone etemplate en Drop a table - this can NOT be undone
drop table etemplate en Drop Table
dump4setup etemplate en Dump4Setup
@ -100,6 +102,8 @@ etemplate common en eTemplate
etemplate '%1' imported, use save to put it in the database etemplate en eTemplate '%1' imported, use Save to put it in the database
etemplate '%1' written to '%2' etemplate en eTemplate '%1' written to '%2'
etemplate editor etemplate en eTemplate Editor
etemplate referenz etemplate en eTemplate Referenz
etemplate tutorial etemplate en eTemplate Tutorial
exchange this row with the one above etemplate en exchange this row with the one above
exchange this two columns etemplate en exchange this two columns
export the loaded etemplate into a xml-file etemplate en export the loaded eTemplate into a xml-file
@ -221,6 +225,7 @@ select priority etemplate en Select Priority
select state etemplate en Select State
select the indexed columns in their desired order etemplate en Select the indexed columns in their desired order
select this etemplate to delete it etemplate en select this eTemplate to delete it
select which values to show etemplate en select which values to show
select year etemplate en Select Year
selectbox etemplate en Selectbox
sets today as date etemplate en sets today as date