From 5d4493670cd3f4b8f1cf22f1fe8ba298f5eb692b Mon Sep 17 00:00:00 2001 From: jengo Date: Tue, 13 Mar 2001 13:15:53 +0000 Subject: [PATCH] Converted nextmatchs to work off templates --- phpgwapi/inc/class.nextmatchs.inc.php | 530 +++++++++--------- phpgwapi/templates/default/nextmatchs.tpl | 20 + .../templates/default/nextmatchs_filter.tpl | 1 + .../templates/default/nextmatchs_icon.tpl | 1 + .../templates/default/nextmatchs_link.tpl | 1 + .../templates/default/nextmatchs_search.tpl | 5 + phpgwapi/templates/justweb/nextmatchs.tpl | 20 + .../templates/justweb/nextmatchs_filter.tpl | 1 + .../templates/justweb/nextmatchs_icon.tpl | 1 + .../templates/justweb/nextmatchs_link.tpl | 1 + .../templates/justweb/nextmatchs_search.tpl | 5 + phpgwapi/templates/verdilak/nextmatchs.tpl | 20 + .../templates/verdilak/nextmatchs_filter.tpl | 1 + .../templates/verdilak/nextmatchs_icon.tpl | 1 + .../templates/verdilak/nextmatchs_link.tpl | 1 + .../templates/verdilak/nextmatchs_search.tpl | 5 + 16 files changed, 346 insertions(+), 268 deletions(-) create mode 100644 phpgwapi/templates/default/nextmatchs.tpl create mode 100644 phpgwapi/templates/default/nextmatchs_filter.tpl create mode 100644 phpgwapi/templates/default/nextmatchs_icon.tpl create mode 100644 phpgwapi/templates/default/nextmatchs_link.tpl create mode 100644 phpgwapi/templates/default/nextmatchs_search.tpl create mode 100644 phpgwapi/templates/justweb/nextmatchs.tpl create mode 100644 phpgwapi/templates/justweb/nextmatchs_filter.tpl create mode 100644 phpgwapi/templates/justweb/nextmatchs_icon.tpl create mode 100644 phpgwapi/templates/justweb/nextmatchs_link.tpl create mode 100644 phpgwapi/templates/justweb/nextmatchs_search.tpl create mode 100644 phpgwapi/templates/verdilak/nextmatchs.tpl create mode 100644 phpgwapi/templates/verdilak/nextmatchs_filter.tpl create mode 100644 phpgwapi/templates/verdilak/nextmatchs_icon.tpl create mode 100644 phpgwapi/templates/verdilak/nextmatchs_link.tpl create mode 100644 phpgwapi/templates/verdilak/nextmatchs_search.tpl diff --git a/phpgwapi/inc/class.nextmatchs.inc.php b/phpgwapi/inc/class.nextmatchs.inc.php index b1d9301df4..e0f5d9e5a9 100644 --- a/phpgwapi/inc/class.nextmatchs.inc.php +++ b/phpgwapi/inc/class.nextmatchs.inc.php @@ -1,292 +1,284 @@ * - * Handles limiting number of rows displayed * - * Copyright (C) 2000, 2001 Joseph Engo * - * -------------------------------------------------------------------------* - * This library is part of the phpGroupWare API * - * http://www.phpgroupware.org/api * - * ------------------------------------------------------------------------ * - * This library is free software; you can redistribute it and/or modify it * - * under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 of the License, * - * or any later version. * - * This library is distributed in the hope that it will be useful, but * - * WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License * - * along with this library; if not, write to the Free Software Foundation, * - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - \**************************************************************************/ + /**************************************************************************\ + * phpGroupWare API - next * + * This file written by Joseph Engo * + * Handles limiting number of rows displayed * + * Copyright (C) 2000, 2001 Joseph Engo * + * -------------------------------------------------------------------------* + * This library is part of the phpGroupWare API * + * http://www.phpgroupware.org/api * + * ------------------------------------------------------------------------ * + * This library is free software; you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as published by * + * the Free Software Foundation; either version 2.1 of the License, * + * or any later version. * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License * + * along with this library; if not, write to the Free Software Foundation, * + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + \**************************************************************************/ - /* $Id$ */ -class nextmatchs -{ + /* $Id$ */ - // I split this up so it can be used in differant layouts. - function show($sn,$start,$total,$extra, $twidth, $bgtheme, - $search_obj=0,$filter_obj=1,$showsearch=1) - { - echo $this->tablestart($sn,$twidth, $bgtheme); - echo $this->left($sn,$start,$total,$extra); - if ($showsearch == 1) - { - echo $this->search($search_obj); - } - echo $this->filter($filter_obj); - echo $this->right($sn,$start,$total,$extra); - echo $this->tableend(); - } + class nextmatchs + { - // -------------------------------------------------------------------- - // same as show, only without direct output for use within templates - // *** the show function can be removed as soon as every program using - // nextmatch is converted to use template and show_tpl (loge) - // -------------------------------------------------------------------- - function show_tpl($sn,$start,$total,$extra, $twidth, $bgtheme, - $search_obj=0,$filter_obj=1,$showsearch=1) - { - $var = $this->tablestart($sn,$twidth, $bgtheme); - $var .= $this->left($sn,$start,$total,$extra); - if ($showsearch == 1) - { - $var .= $this->search($search_obj); - } - $var .= $this->filter($filter_obj); - $var .= $this->right($sn,$start,$total,$extra); - $var .= $this->tableend(); - return $var; - } + function set_icon(&$tpl,$align,$img_src,$label) + { + $tpl->set_var('align',$align); + $tpl->set_var('img_src',PHPGW_IMAGES_DIR . $img_src); + $tpl->set_var('label',lang($label)); + $tpl->parse('out','link',True); + } - function tablestart($scriptname, $twidth="75%", $bgtheme="D3DCE3") - { - global $filter, $qfield, $start, $order, $sort, $query, $phpgw; - - $str = "
link($scriptname) . "\"> - - - - - - "; - - $str .= "\n\n"; - return $str; - } + function set_link(&$tpl,$align,$img_src,$label,$link,$extravars) + { + global $phpgw; - function tableend() - { - $str = "\n
\n
"; - $str .= "
"; - return $str; - } - + $tpl->set_var('align',$align); + if ($link) + { + $tpl->set_var('a_open',''); + $tpl->set_var('a_closed',''); + } + $tpl->set_var('img_src',PHPGW_IMAGES_DIR . $img_src); + $tpl->set_var('label',lang($label)); + $tpl->parse('out','link',True); + } + + function show_tpl($sn,$start,$total,$extra, $twidth, $bgtheme,$search_obj=0,$filter_obj=1,$showsearch=1) + { + global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info; + $tpl = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR); + $tpl->set_file(array( + 'nextmatchs' => 'nextmatchs.tpl' + )); + + $tpl->set_var('form_action',$phpgw->link($sn)); + $tpl->set_var('filter_value',$filter); + $tpl->set_var('qfield_value',$qfield); + $tpl->set_var('start_value',$start); + $tpl->set_var('order_value',$order); + $tpl->set_var('sort_value',$sort); + $tpl->set_var('query_value',$query); + $tpl->set_var('table_width',$twidth); + $tpl->set_var('th_bg',$phpgw_info['theme']['th_bg']); + + $tpl->set_var('left',$this->left($sn,$start,$total,$extra)); + + if ($showsearch == 1) + { + $tpl->set_var(search,$this->search($search_obj)); + } + + $tpl->set_var('filter',$this->filter($filter_obj)); + $tpl->set_var('right',$this->right($sn,$start,$total,$extra)); + + return $tpl->fp('out','nextmatchs'); + } - function left($scriptname,$start,$total,$extradata = "") - { - global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw; + function left($scriptname,$start,$total,$extradata = '') + { + global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw; + $tpl = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR); + $tpl->set_file(array( + 'link' => 'nextmatchs_link.tpl' + )); - $str = ""; - $maxmatchs = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]; + $maxmatchs = $phpgw_info['user']['preferences']['common']['maxmatchs']; - if (( $start != 0 ) && ( $start > $maxmatchs )) - $str .= " link($scriptname,"start=0" - . "&order=$order&filter=$filter&qfield=$qfield" - . "&sort=$sort&query=$query".$extradata) - . "\">\""\n"; - else - $str .= "" - . " \""\n"; + if (($start != 0) && ($start > $maxmatchs)) + { + $this->set_link(&$tpl,'left','/first.gif','First page',$scriptname,'start=0&order=' . $order . '&filter=' + . $filter . '&qfield=' . $qfield . '&sort=' . $sort . '&query=' . $query . $extradata); + } + else + { + $this->set_icon(&$tpl,'left','/first-grey.gif','First page'); + } - if ($start != 0) { - // Changing the sorting order screaws up the starting number - if ( ($start - $maxmatchs) < 0) - $t_start = 0; - else - $t_start = ($start - $maxmatchs); + if ($start != 0) + { + // Changing the sorting order screaws up the starting number + if (($start - $maxmatchs) < 0) + { + $t_start = 0; + } + else + { + $t_start = ($start - $maxmatchs); + } - $str .= "link($scriptname,"start=$t_start" - . "&order=$order&filter=$filter&qfield=$qfield" - . "&sort=$sort&query=$query".$extradata) - . "\">\""\n"; - } else - $str .= "" - . "\""\n"; + $this->set_link(&$tpl,'left','/left.gif','Previous page',$scriptname,'start=' . $t_start + . '&order=' . $order . '&filter=' . $filter . '&qfield=' . $qfield . '&sort=' . $sort + . '&query=' . $query . $extradata); + } + else + { + $this->set_icon(&$tpl,'left','/left-grey.gif','Previous page'); + } - return $str; - } /* left() */ + return $tpl->fp('out_','out'); + } /* left() */ - function search($search_obj=0) - { - global $query; + function right($scriptname,$start,$total,$extradata = '') + { + global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw; + $tpl = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR); + $tpl->set_file(array( + 'link' => 'nextmatchs_link.tpl' + )); + $maxmatchs = $phpgw_info['user']['preferences']['common']['maxmatchs']; - $str = "" - . "
" - . " " - . $this->searchby($search_obj) - . "" - . "
" - . ""; + if (($total > $maxmatchs) && ($total > $start + $maxmatchs)) + { + $this->set_link(&$tpl,'right','/right.gif','Next page',$scriptname,'start=' + . ($start+$maxmatchs) . '&order=' . $order . '&filter=' . $filter . '&qfield=' . $qfield + . '&sort=' . $sort . '&query=' . $query . $extradata); + } + else + { + $this->set_icon(&$tpl,'right','/right-grey.gif','Next page'); + } + + if (($start != $total - $maxmatchs) && (($total - $maxmatchs) > ($start + $maxmatchs))) + { + $this->set_link(&$tpl,'right','/last.gif','Last page',$scriptname,'start=' + . ($total-$maxmatchs) . '&order=' . $order . '&filter=' . $filter . '&qfield=' .$qfield + . '&sort=' . $sort . '&query=' . $query . $extradata); + } + else + { + $this->set_icon(&$tpl,'right','/last-grey.gif','Last page'); + } + + return $tpl->fp('out_','out'); + } /* right() */ + + function search($search_obj=0) + { + global $query; + $tpl = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR); + $tpl->set_file(array( + 'search' => 'nextmatchs_search.tpl' + )); + $tpl->set_var('query_value',$query); + $tpl->set_var('searchby',$this->searchby($search_obj)); + $tpl->set_var('lang_search',lang('Search')); - return $str; - } /* search() */ + return $tpl->fp('out','search'); + } /* search() */ - function filterobj($filtertable, $idxfieldname, $strfieldname) - { - global $phpgw; + function filterobj($filtertable, $idxfieldname, $strfieldname) + { + global $phpgw; + + $filter_obj = array(array('none','show all')); + $index = 0; + + $phpgw->db->query("SELECT $idxfieldname, $strfieldname from $filtertable",__LINE__,__FILE__); + while($phpgw->db->next_record()) + { + $index++; + $filter_obj[$index][0] = $phpgw->db->f($idxfieldname); + $filter_obj[$index][1] = $phpgw->db->f($strfieldname); + } - $filter_obj = array(array("none","show all")); - $index = 0; - - $phpgw->db->query("SELECT $idxfieldname, $strfieldname from $filtertable",__LINE__,__FILE__); - while($phpgw->db->next_record()) - { - $index++; - $filter_obj[$index][0] = $phpgw->db->f("$idxfieldname"); - $filter_obj[$index][1] = $phpgw->db->f("$strfieldname"); - } - - return $filter_obj; - } /* filterobj() */ + return $filter_obj; + } /* filterobj() */ - function searchby($search_obj) - { - global $qfield, $phpgw, $phpgw_info; + function searchby($search_obj) + { + global $qfield, $phpgw, $phpgw_info; - $str = ""; - if (is_array($search_obj)) - { - $str .= "'; - $indexlimit = count($search_obj); - for ($index=0; $index<$indexlimit; $index++) - { - if ($qfield == "") - { - $qfield = $search_obj[$index][0]; - } + $indexlimit = count($search_obj); + for ($index=0; $index<$indexlimit; $index++) + { + if ($qfield == '') + { + $qfield = $search_obj[$index][0]; + } - $str .= "