2001-01-11 10:52:33 +01:00
|
|
|
<?php
|
2001-03-13 14:15:53 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare API - next *
|
|
|
|
* This file written by Joseph Engo <jengo@phpgroupware.org> *
|
|
|
|
* 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$ */
|
2001-09-02 20:37:38 +02:00
|
|
|
|
2001-09-18 21:42:27 +02:00
|
|
|
/*!
|
|
|
|
@class nextmatchs
|
|
|
|
@abstract
|
|
|
|
*/
|
2001-09-28 23:27:40 +02:00
|
|
|
class nextmatchs
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
var $maxmatches;
|
|
|
|
var $action;
|
|
|
|
var $template;
|
|
|
|
|
|
|
|
function nextmatchs()
|
|
|
|
{
|
|
|
|
global $phpgw_info, $menuaction;
|
|
|
|
|
|
|
|
$this->template = createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
|
|
|
|
$this->template->set_file(array(
|
|
|
|
'_nextmatchs' => 'nextmatchs.tpl'
|
|
|
|
));
|
|
|
|
$this->template->set_block('_nextmatchs','nextmatchs');
|
|
|
|
$this->template->set_block('_nextmatchs','filter');
|
|
|
|
$this->template->set_block('_nextmatchs','form');
|
|
|
|
$this->template->set_block('_nextmatchs','icon');
|
|
|
|
$this->template->set_block('_nextmatchs','link');
|
|
|
|
$this->template->set_block('_nextmatchs','search');
|
|
|
|
$this->template->set_block('_nextmatchs','cats');
|
|
|
|
$this->template->set_block('_nextmatchs','search_filter');
|
|
|
|
$this->template->set_block('_nextmatchs','cats_search_filter');
|
|
|
|
|
|
|
|
if(isset($phpgw_info['user']['preferences']['common']['maxmatchs'])
|
|
|
|
&& intval($phpgw_info['user']['preferences']['common']['maxmatchs']) > 0)
|
|
|
|
{
|
|
|
|
$this->maxmatches = intval($phpgw_info['user']['preferences']['common']['maxmatchs']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->maxmatches = 15;
|
|
|
|
}
|
2001-06-29 01:12:12 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if(isset($menuaction))
|
|
|
|
{
|
|
|
|
$this->action = $menuaction;
|
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
2001-08-03 21:14:10 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function set_icon
|
|
|
|
@abstract ?
|
|
|
|
@param $align ?
|
|
|
|
@param $img_src ?
|
|
|
|
@param $label ?
|
|
|
|
*/
|
|
|
|
function set_icon($align,$img,$label)
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw, $phpgw_info;
|
|
|
|
|
|
|
|
switch(strtolower($phpgw_info['user']['account_lid']))
|
|
|
|
{
|
|
|
|
case 'ceb':
|
2001-09-18 21:42:27 +02:00
|
|
|
$border = 2;
|
|
|
|
break;
|
2001-09-28 23:27:40 +02:00
|
|
|
default:
|
2001-09-18 21:42:27 +02:00
|
|
|
$border = 0;
|
|
|
|
break;
|
2001-09-28 23:27:40 +02:00
|
|
|
}
|
2001-08-03 21:14:10 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$var = array(
|
|
|
|
'align' => $align,
|
|
|
|
'img' => $phpgw->common->image('phpgwapi',$img),
|
|
|
|
'label' => lang($label),
|
|
|
|
'border' => $border
|
|
|
|
);
|
|
|
|
$this->template->set_var($var);
|
|
|
|
return $this->template->fp('out','link');
|
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
|
2001-08-04 04:47:19 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function page
|
|
|
|
@abstract ?
|
|
|
|
*/
|
|
|
|
function page($extravars='')
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw;
|
|
|
|
|
|
|
|
if($extravars && is_string($extravars) && substr($extravars,0,1)!='&')
|
2001-09-02 20:37:38 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$extras = '&'.$extravars;
|
2001-08-03 21:14:10 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
elseif($extravars && is_array($extravars))
|
2001-03-13 14:15:53 +01:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
@reset($extravars);
|
|
|
|
while(list($var,$value) = each($extravars))
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$t_extras[] = $var.'='.$value;
|
2001-08-03 21:14:10 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
$extras = implode($t_extras,'&');
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
|
|
|
|
return $phpgw->link('/index.php','menuaction='.$this->action.$extras);
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
2001-08-03 21:14:10 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function set_link
|
|
|
|
@abstract ?
|
|
|
|
@param $img_src ?
|
|
|
|
@param $label ?
|
|
|
|
@param $link ?
|
|
|
|
@param $extravars ?
|
|
|
|
*/
|
|
|
|
function set_link($align,$img,$link,$alt,$extravars)
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw, $phpgw_info;
|
|
|
|
|
|
|
|
$hidden = '';
|
|
|
|
while(list($var,$value) = each($extravars))
|
2001-03-29 19:13:35 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if(((is_int($value) && $value == 0) || $value))
|
2001-08-03 21:14:10 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if(is_int($value))
|
2001-08-03 21:14:10 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$param = intval($value);
|
2001-08-03 21:14:10 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$param = '"'.$value.'"';
|
|
|
|
}
|
|
|
|
$hidden .= ' <input type="hidden" name="'.$var.'" value='.$param.'>'."\n";
|
2001-08-03 21:14:10 +02:00
|
|
|
}
|
2001-03-29 19:13:35 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
$border = 0;
|
|
|
|
$var = Array(
|
|
|
|
'align' => $align,
|
|
|
|
'action' => ($this->action?$this->page():$phpgw->link($link)),
|
|
|
|
'form_name' => $img,
|
|
|
|
'hidden' => substr($hidden,0,strlen($hidden)-1),
|
|
|
|
'img' => $phpgw->common->image('phpgwapi',$img),
|
|
|
|
'label' => $alt,
|
|
|
|
'border' => $border,
|
|
|
|
'start' => $extravars['start']
|
|
|
|
);
|
|
|
|
$this->template->set_var($var);
|
|
|
|
return $this->template->fp('out','form');
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function show_tpl
|
|
|
|
@abstract ?
|
|
|
|
@param $sn ?
|
|
|
|
@param $start ?
|
|
|
|
@param $total ?
|
|
|
|
@param $extra ?
|
|
|
|
@param $twidth ?
|
|
|
|
@param $bgtheme ?
|
|
|
|
@param $search_obj ?
|
|
|
|
@param $filter_obj ?
|
|
|
|
@param $showsearch ?
|
|
|
|
*/
|
|
|
|
function show_tpl($sn,$localstart,$total,$extra, $twidth, $bgtheme,$search_obj=0,$filter_obj=1,$showsearch=1,$yours=0,$cat_id=0,$cat_field='fcat_id')
|
|
|
|
{
|
|
|
|
global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
|
|
|
|
$start = $localstart;
|
|
|
|
|
|
|
|
$cats = CreateObject('phpgwapi.categories');
|
|
|
|
|
|
|
|
$extravars = Array();
|
|
|
|
$extravars = $this->split_extras($extravars,$extra);
|
|
|
|
|
|
|
|
$var = array(
|
|
|
|
'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
|
|
|
|
'lang_category' => lang('Category'),
|
|
|
|
'lang_all' => lang('All'),
|
|
|
|
'lang_select' => lang('Select'),
|
|
|
|
'cat_field' => $cat_field,
|
|
|
|
'categories' => $cats->formated_list('select','all',$cat_id,'True'),
|
|
|
|
'filter_value' => $filter,
|
|
|
|
'qfield' => $qfield,
|
|
|
|
'start_value' => $start,
|
|
|
|
'order_value' => $order,
|
|
|
|
'sort_value' => $sort,
|
|
|
|
'query_value' => urlencode(stripslashes($query)),
|
|
|
|
'table_width' => $twidth,
|
|
|
|
'th_bg' => $phpgw_info['theme']['th_bg'],
|
|
|
|
'left' => $this->left($sn,$start,$total,$extra),
|
|
|
|
'search' => ($showsearch?$this->search($search_obj):''),
|
|
|
|
'filter' => ($filter_obj?$this->filter($filter_obj,$yours):''),
|
|
|
|
'right' => $this->right($sn,$start,$total,$extra)
|
|
|
|
);
|
|
|
|
$this->template->set_var($var);
|
|
|
|
$this->template->parse('cats','cats');
|
|
|
|
$this->template->parse('cats_search_filter_data','cats_search_filter');
|
|
|
|
return $this->template->fp('out','nextmatchs');
|
|
|
|
}
|
|
|
|
|
|
|
|
function split_extras($extravars,$extradata)
|
|
|
|
{
|
|
|
|
if($extradata)
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if(is_string($extradata))
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$extraparams = explode('&',$extradata);
|
|
|
|
$c_extraparams = count($extraparams) + 1;
|
|
|
|
for($i=0;$i<$c_extraparams;$i++)
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if($extraparams[$i])
|
|
|
|
{
|
|
|
|
list($var,$value) = explode('=',$extraparams[$i]);
|
|
|
|
if($var != 'menuaction')
|
|
|
|
{
|
|
|
|
$extravars[$var] = $value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->action = $value;
|
|
|
|
}
|
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
}
|
|
|
|
elseif(is_array($extradata))
|
|
|
|
{
|
|
|
|
while(list($var,$value) = each($extradata))
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if($var != 'menuaction')
|
|
|
|
{
|
|
|
|
$extravars[$var] = $value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->action = $value;
|
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
return $extravars;
|
2001-09-02 20:37:38 +02:00
|
|
|
}
|
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
function extras_to_string($extra)
|
2001-09-02 20:37:38 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if(is_array($extra))
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
@reset($extra);
|
|
|
|
while(list($var,$value) = each($extra))
|
|
|
|
{
|
|
|
|
$t_extras[] = $var . '=' . $value;
|
|
|
|
}
|
|
|
|
$extra_s = '&' . implode('&',$t_extras);
|
2001-08-08 09:44:27 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
return $extra_s;
|
2001-08-03 21:14:10 +02:00
|
|
|
}
|
2001-08-04 14:11:07 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function left
|
|
|
|
@abstract ?
|
|
|
|
@param $scriptname ?
|
|
|
|
@param $start ?
|
|
|
|
@param $total ?
|
|
|
|
@param $extradate ?
|
|
|
|
*/
|
|
|
|
function left($scriptname,$start,$total,$extradata = '')
|
|
|
|
{
|
|
|
|
global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
|
2001-08-03 21:14:10 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$extravars = Array(
|
|
|
|
'order' => $order,
|
|
|
|
'filter' => $filter,
|
|
|
|
'q_field' => $qfield,
|
|
|
|
'sort' => $sort,
|
|
|
|
'query' => urlencode(stripslashes($query))
|
|
|
|
);
|
2001-08-03 21:14:10 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$extravars = $this->split_extras($extravars,$extradata);
|
2001-08-08 09:44:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$ret_str = '';
|
2001-08-04 14:11:07 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (($start != 0)
|
|
|
|
&& ($start > $this->maxmatches))
|
2001-03-13 14:15:53 +01:00
|
|
|
{
|
2001-08-03 21:14:10 +02:00
|
|
|
$extravars['start'] = 0;
|
2001-09-28 23:27:40 +02:00
|
|
|
$ret_str .= $this->set_link('left','first.gif',$scriptname,lang('First page'),$extravars);
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$ret_str .= $this->set_icon('left','first-grey.gif',lang('First page'));
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-08-04 14:11:07 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($start != 0)
|
|
|
|
{
|
|
|
|
// Changing the sorting order screaws up the starting number
|
|
|
|
if (($start - $this->maxmatches) < 0)
|
|
|
|
{
|
|
|
|
$extravars['start'] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$extravars['start'] = ($start - $this->maxmatches);
|
|
|
|
}
|
|
|
|
$ret_str .= $this->set_link('left','left.gif',$scriptname,lang('Previous page'),$extravars);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ret_str .= $this->set_icon('left','left-grey.gif',lang('Previous page'));
|
|
|
|
}
|
|
|
|
return $ret_str;
|
|
|
|
} /* left() */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function right
|
|
|
|
@abstract ?
|
|
|
|
@param $scriptname ?
|
|
|
|
@param $start ?
|
|
|
|
@param $total ?
|
|
|
|
@param $extradate ?
|
2001-09-18 21:42:27 +02:00
|
|
|
*/
|
2001-09-28 23:27:40 +02:00
|
|
|
function right($scriptname,$start,$total,$extradata = '')
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*
|
|
|
|
$extravars = Array();
|
|
|
|
if ((isset($order)) && ($order != ''))
|
|
|
|
{
|
|
|
|
$extravars['order'] = $order;
|
|
|
|
}
|
|
|
|
if ((isset($filter)) && ($filter != ''))
|
|
|
|
{
|
|
|
|
$extravars['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if ((isset($q_field)) && ($q_field != ''))
|
|
|
|
{
|
|
|
|
$extravars['q_field'] = $qfield;
|
|
|
|
}
|
|
|
|
if ((isset($sort)) && ($sort != ''))
|
|
|
|
{
|
|
|
|
$extravars['sort'] = $sort;
|
|
|
|
}
|
|
|
|
if ((isset($query)) && ($query != ''))
|
|
|
|
{
|
|
|
|
$extravars['query'] = urlencode(stripslashes($query));
|
|
|
|
}
|
|
|
|
*/
|
2001-08-04 14:11:07 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$extravars = Array(
|
|
|
|
'order' => $order,
|
|
|
|
'filter' => $filter,
|
|
|
|
'q_field' => $qfield,
|
|
|
|
'sort' => $sort,
|
|
|
|
'query' => urlencode(stripslashes($query))
|
|
|
|
);
|
2001-08-08 09:44:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$extravars = $this->split_extras($extravars,$extradata);
|
2001-08-08 09:44:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$ret_str = '';
|
2001-07-02 00:50:53 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (($total > $this->maxmatches)
|
|
|
|
&& ($total > $start + $this->maxmatches))
|
|
|
|
{
|
|
|
|
$extravars['start'] = ($start + $this->maxmatches);
|
|
|
|
$ret_str .= $this->set_link('right','right.gif',$scriptname,lang('Next page'),$extravars);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ret_str .= $this->set_icon('right','right-grey.gif',lang('Next page'));
|
|
|
|
}
|
2001-07-02 00:50:53 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (($start != $total - $this->maxmatches)
|
|
|
|
&& (($total - $this->maxmatches) > ($start + $this->maxmatches)))
|
|
|
|
{
|
|
|
|
$extravars['start'] = ($total - $this->maxmatches);
|
|
|
|
$ret_str .= $this->set_link('right','last.gif',$scriptname,lang('Last page'),$extravars);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ret_str .= $this->set_icon('right','last-grey.gif',lang('Last page'));
|
|
|
|
}
|
|
|
|
return $ret_str;
|
|
|
|
} /* right() */
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function search_filter
|
|
|
|
@abstract ?
|
|
|
|
@param $search_obj default 0
|
|
|
|
*/
|
|
|
|
function search_filter($search_obj=0,$filter_obj=1,$yours=0,$link='',$extra='')
|
|
|
|
{
|
|
|
|
global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
|
|
|
|
|
|
|
|
$start = $localstart;
|
|
|
|
$var = array(
|
|
|
|
'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
|
|
|
|
'filter_value' => $filter,
|
|
|
|
'qfield' => $qfield,
|
|
|
|
'start_value' => $start,
|
|
|
|
'order_value' => $order,
|
|
|
|
'sort_value' => $sort,
|
|
|
|
'query_value' => urlencode(stripslashes($query)),
|
|
|
|
'th_bg' => $phpgw_info['theme']['th_bg'],
|
|
|
|
'search' => $this->search($search_obj),
|
|
|
|
'filter' => ($filter_obj?$this->filter($filter_obj,$yours):'')
|
|
|
|
);
|
|
|
|
$this->template->set_var($var);
|
|
|
|
return $this->template->fp('out','search_filter');
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function cats_search_filter
|
|
|
|
@abstract ?
|
|
|
|
@param $search_obj default 0
|
|
|
|
*/
|
|
|
|
function cats_search_filter($search_obj=0,$filter_obj=1,$yours=0,$cat_id=0,$cat_field='fcat_id',$link='',$extra='')
|
|
|
|
{
|
|
|
|
global $filter, $qfield, $start, $order, $sort, $query, $phpgw, $phpgw_info;
|
|
|
|
|
|
|
|
$start = $localstart;
|
|
|
|
$cats = CreateObject('phpgwapi.categories');
|
|
|
|
$var = array(
|
|
|
|
'form_action' => ($this->action?$this->page($extra):$phpgw->link($sn, $extra)),
|
|
|
|
'lang_category' => lang('Category'),
|
|
|
|
'lang_all' => lang('All'),
|
|
|
|
'lang_select' => lang('Select'),
|
|
|
|
'cat_field' => $cat_field,
|
|
|
|
'categories' => $cats->formated_list('select','all',$cat_id,'True'),
|
|
|
|
'filter_value' => $filter,
|
|
|
|
'qfield' => $qfield,
|
|
|
|
'start_value' => $start,
|
|
|
|
'order_value' => $order,
|
|
|
|
'sort_value' => $sort,
|
|
|
|
'query_value' => urlencode(stripslashes($query)),
|
|
|
|
'th_bg' => $phpgw_info['theme']['th_bg'],
|
|
|
|
'search' => $this->search($search_obj),
|
|
|
|
'filter' => ($filter_obj?$this->filter($filter_obj,$yours):'')
|
|
|
|
);
|
|
|
|
$this->template->set_var($var);
|
|
|
|
return $this->template->fp('out','cats_search_filter');
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function search
|
|
|
|
@abstract ?
|
|
|
|
@param $search_obj default 0
|
|
|
|
*/
|
|
|
|
function search($search_obj=0)
|
|
|
|
{
|
|
|
|
global $query;
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$_query = stripslashes($query);
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
// If the place a " in there search, it will mess everything up
|
|
|
|
// Our only option is to remove it
|
|
|
|
if (ereg('"',$_query))
|
|
|
|
{
|
|
|
|
$_query = ereg_replace('"','',$_query);
|
|
|
|
}
|
|
|
|
$var = array(
|
|
|
|
'query_value' => stripslashes($_query),
|
|
|
|
'searchby' => $this->searchby($search_obj),
|
|
|
|
'lang_search' => lang('Search')
|
|
|
|
);
|
|
|
|
$this->template->set_var($var);
|
|
|
|
return $this->template->fp('out','search');
|
|
|
|
} /* search() */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function filterobj
|
|
|
|
@abstract ?
|
|
|
|
@param $filtertable
|
|
|
|
@param $indxfieldname ?
|
|
|
|
@param $strfieldname ?
|
|
|
|
*/
|
|
|
|
function filterobj($filtertable, $idxfieldname, $strfieldname)
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw;
|
2001-05-21 11:05:21 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$filter_obj = array(array('none','show all'));
|
|
|
|
$index = 0;
|
2001-03-25 00:19:39 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$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() */
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function searchby
|
|
|
|
@abstract ?
|
|
|
|
@param $search_obj ?
|
|
|
|
*/
|
|
|
|
function searchby($search_obj)
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $qfield, $phpgw, $phpgw_info;
|
|
|
|
|
|
|
|
$str = '';
|
|
|
|
if (is_array($search_obj))
|
2001-03-13 14:15:53 +01:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$indexlimit = count($search_obj);
|
|
|
|
for ($index=0; $index<$indexlimit; $index++)
|
2001-03-13 14:15:53 +01:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($qfield == '')
|
|
|
|
{
|
|
|
|
$qfield = $search_obj[$index][0];
|
|
|
|
}
|
|
|
|
$str .= '<option value="' . $search_obj[$index][0] . '"' . ($qfield == $search_obj[$index][0]?' selected':'') . '>' . lang($search_obj[$index][1]) . '</option>';
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
$str = '<select name="qfield">' . $str . '</select>' . "\n";
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
return $str;
|
|
|
|
} /* searchby() */
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function filter
|
|
|
|
@abstract ?
|
|
|
|
@param $filter_obj
|
|
|
|
*/
|
|
|
|
function filter($filter_obj,$yours=0)
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $filter, $phpgw, $phpgw_info;
|
2001-08-04 14:11:07 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (is_long($filter_obj))
|
|
|
|
{
|
|
|
|
if ($filter_obj == 1)
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
// $user_groups = $phpgw->accounts->membership($phpgw_info['user']['account_id']);
|
|
|
|
$indexlimit = count($user_groups);
|
|
|
|
|
|
|
|
if ($yours)
|
|
|
|
{
|
|
|
|
$filter_obj = array(
|
2001-09-18 21:42:27 +02:00
|
|
|
array('none',lang('Show all')),
|
2001-04-21 01:12:37 +02:00
|
|
|
array('yours',lang('Only yours')),
|
2001-09-18 21:42:27 +02:00
|
|
|
array('private',lang('private'))
|
2001-09-28 23:27:40 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$filter_obj = array(
|
2001-09-18 21:42:27 +02:00
|
|
|
array('none',lang('Show all')),
|
|
|
|
array('private',lang('private'))
|
2001-09-28 23:27:40 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
for ($index=0; $index<$indexlimit; $index++)
|
|
|
|
{
|
|
|
|
$filter_obj[2+$index][0] = $user_groups[$index]['account_id'];
|
|
|
|
$filter_obj[2+$index][1] = 'Group - ' . $user_groups[$index]['account_name'];
|
|
|
|
}
|
2001-08-08 09:44:27 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_array($filter_obj))
|
|
|
|
{
|
|
|
|
$str = '';
|
|
|
|
|
|
|
|
$indexlimit = count($filter_obj);
|
|
|
|
|
2001-08-08 09:44:27 +02:00
|
|
|
for ($index=0; $index<$indexlimit; $index++)
|
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($filter == '')
|
|
|
|
{
|
|
|
|
$filter = $filter_obj[$index][0];
|
|
|
|
}
|
|
|
|
$str .= ' <option value="' . $filter_obj[$index][0] . '"'.($filter == $filter_obj[$index][0]?' selected':'') . '>' . $filter_obj[$index][1] . '</option>'."\n";
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
|
|
|
|
$str = ' <select name="filter" onChange="this.form.submit()">'."\n" . $str . ' </select>';
|
|
|
|
$this->template->set_var('select',$str);
|
|
|
|
$this->template->set_var('lang_filter',lang('Filter'));
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-05-21 11:05:21 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
return $this->template->fp('out','filter');
|
|
|
|
} /* filter() */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function alternate_row_color
|
|
|
|
@abstract alternate row colour
|
|
|
|
@param $currentcolor default ''
|
|
|
|
*/
|
|
|
|
function alternate_row_color($currentcolor = '')
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw_info;
|
2001-05-21 11:05:21 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (! $currentcolor)
|
|
|
|
{
|
|
|
|
global $tr_color;
|
|
|
|
$currentcolor = $tr_color;
|
|
|
|
}
|
2001-03-13 14:15:53 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($currentcolor == $phpgw_info['theme']['row_on'])
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$tr_color = $phpgw_info['theme']['row_off'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$tr_color = $phpgw_info['theme']['row_on'];
|
2001-03-13 14:15:53 +01:00
|
|
|
}
|
2001-05-21 11:05:21 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
return $tr_color;
|
2001-08-08 09:44:27 +02:00
|
|
|
}
|
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
// If you are using the common bgcolor="{tr_color}"
|
|
|
|
// This function is a little cleanier approch
|
|
|
|
/*!
|
|
|
|
@function template_alternate_row_color
|
|
|
|
@abstract ?
|
|
|
|
@param $tpl ?
|
|
|
|
*/
|
|
|
|
function template_alternate_row_color(&$tpl)
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$tpl->set_var('tr_color',$this->alternate_row_color());
|
2001-08-08 09:44:27 +02:00
|
|
|
}
|
2001-01-11 10:52:33 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function show_sort_order
|
|
|
|
@abstract ?
|
|
|
|
@param $sort ?
|
|
|
|
@param $var ?
|
|
|
|
@param $order ?
|
|
|
|
@param $program ?
|
|
|
|
@param $text ?
|
|
|
|
@param $extra default ''
|
|
|
|
*/
|
|
|
|
function show_sort_order($sort,$var,$order,$program,$text,$extra='',$build_a_href=True)
|
2001-08-08 09:44:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw, $filter, $qfield, $start, $query;
|
2001-08-08 09:44:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (($order == $var) && ($sort == 'ASC'))
|
|
|
|
{
|
|
|
|
$sort = 'DESC';
|
|
|
|
}
|
|
|
|
else if (($order == $var) && ($sort == 'DESC'))
|
|
|
|
{
|
|
|
|
$sort = 'ASC';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$sort = 'ASC';
|
|
|
|
}
|
2001-01-20 00:45:37 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (is_array($extra))
|
|
|
|
{
|
|
|
|
$extra = $this->extras_to_string($extra);
|
|
|
|
}
|
2001-08-04 14:11:07 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$extravar = 'order='.$var.'&sort='.$sort.'&filter='.$filter.'&qfield='.$qfield.'&start='.$start.'&query='.urlencode(stripslashes($query)).$extra;
|
2001-09-18 21:42:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$link = ($this->action?$this->page($extravar):$phpgw->link($program,$extravar));
|
2001-09-02 20:37:38 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($build_a_href)
|
|
|
|
{
|
|
|
|
return '<a href="' . $link . '">' . $text . '</a>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $link;
|
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
2001-01-25 07:09:08 +01:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
/*!
|
|
|
|
@function show_sort_order_imap
|
|
|
|
@abstract ?
|
|
|
|
@param $old_sort : the current sort value
|
|
|
|
@param $new_sort : the sort value you want if you click on this
|
|
|
|
@param $default_order : user's preference for ordering list items (force this when a new [different] sorting is requested)
|
|
|
|
@param $order : the current order (will be flipped if old_sort = new_sort)
|
|
|
|
@param $program : script file name
|
|
|
|
@param $text : Text the link will show
|
|
|
|
@param $extra : any extra stuff you want to pass, url style
|
|
|
|
*/
|
|
|
|
function show_sort_order_imap($old_sort,$new_sort,$default_order,$order,$program,$text,$extra='')
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
global $phpgw;
|
2001-09-02 20:37:38 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
if (is_array($extra))
|
2001-09-18 21:42:27 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
$extra = $this->extras_to_string($extra);
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($old_sort == $new_sort)
|
2001-09-02 20:37:38 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
// alternate order, like on outkrook, click on present sorting reverses order
|
|
|
|
if ((int)$order == 1)
|
|
|
|
{
|
|
|
|
$our_order = 0;
|
|
|
|
}
|
|
|
|
elseif ((int)$order == 0)
|
|
|
|
{
|
|
|
|
$our_order = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// we should never get here
|
|
|
|
$our_order = 1;
|
|
|
|
}
|
2001-09-02 20:37:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
//user has selected a new sort scheme, reset the order to user's default
|
|
|
|
$our_order = $default_order;
|
2001-09-02 20:37:38 +02:00
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$extravar = 'order='.$our_order.'&sort='.$new_sort.$extra;
|
2001-08-08 09:44:27 +02:00
|
|
|
|
2001-09-28 23:27:40 +02:00
|
|
|
$link = ($this->action?$this->page($extravar):$phpgw->link($program,$extravar));
|
|
|
|
return '<a href="' .$link .'">' .$text .'</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_hits($total_records='',$start=0)
|
2001-06-28 22:02:56 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($total_records > $this->maxmatches)
|
2001-06-28 22:02:56 +02:00
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
if ($start + $this->maxmatches > $total_records)
|
|
|
|
{
|
|
|
|
$end = $total_records;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$end = $start + $this->maxmatches;
|
|
|
|
}
|
|
|
|
return lang('showing x - x of x',($start + 1),$end,$total_records);
|
2001-06-28 22:02:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-28 23:27:40 +02:00
|
|
|
return lang('showing x',$total_records);
|
2001-06-28 22:02:56 +02:00
|
|
|
}
|
2001-09-18 21:42:27 +02:00
|
|
|
}
|
2001-09-28 23:27:40 +02:00
|
|
|
} // End of nextmatchs class
|
2001-03-26 10:24:35 +02:00
|
|
|
?>
|