[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.nextmatchs.inc.php
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.nextmatchs.inc.php |
Date: |
Fri, 01 Sep 2006 14:39:44 +0000 |
CVSROOT: /cvsroot/phpgwapi
Module name: phpgwapi
Changes by: Dave Hall <skwashd> 06/09/01 14:39:44
Modified files:
inc : class.nextmatchs.inc.php
Log message:
clean up the code and make it work with E_ALL and css
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.nextmatchs.inc.php?cvsroot=phpgwapi&r1=1.74&r2=1.75
Patches:
Index: class.nextmatchs.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.nextmatchs.inc.php,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- class.nextmatchs.inc.php 29 Aug 2006 12:42:37 -0000 1.74
+++ class.nextmatchs.inc.php 1 Sep 2006 14:39:44 -0000 1.75
@@ -7,16 +7,14 @@
* @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General
Public License
* @package phpgwapi
* @subpackage gui
- * @version $Id: class.nextmatchs.inc.php,v 1.74 2006/08/29 12:42:37
skwashd Exp $
+ * @version $Id: class.nextmatchs.inc.php,v 1.75 2006/09/01 14:39:44
skwashd Exp $
*/
-
/**
* Include nextmatchs XSLT
*/
include_once(PHPGW_API_INC . '/class.nextmatchs_xslt.inc.php');
-
/**
* Handles limiting number of rows displayed
*
@@ -30,11 +28,14 @@
var $template;
var $extra_filters = array();
+ /**
+ * @constructor
+ */
function nextmatchs($website=False)
{
if(!$website)
{
- $this->template =
createobject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
+ $this->template =
createObject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
$this->template->set_file(array(
'_nextmatchs' => 'nextmatchs.tpl'
));
@@ -65,14 +66,15 @@
}
}
- /*!
- @function get_var
- @abstract Fetch commonly-used GP(C) vars
- @discussion This calls get_var() from functions.inc.php
+ /**
+ * Fetch commonly-used REQUEST vars
+ *
+ * This calls get_var() from functions.inc.php
*/
function get_var()
{
- return array(
+ return array
+ (
get_var('filter',array('GLOBAL','POST','GET')),
get_var('qfield',array('GLOBAL','POST','GET')),
get_var('start',array('GLOBAL','POST','GET')),
@@ -81,118 +83,93 @@
);
}
- /*!
- @function set_icon
- @abstract ?
- @param $align ?
- @param $img_src ?
- @param $label ?
+ /**
+ * Create a button icon
+ *
+ * @deprecated
+ * @internal use CSS instead
+ *
+ * @param string $align the alignment of the icon
+ * @param string $img_src the url to the image
+ * @param string $label the alt text for the image
*/
- function set_icon($align,$img,$label)
+ function set_icon($align, $img, $label)
{
-
switch(strtolower($GLOBALS['phpgw_info']['user']['account_lid']))
- {
- case 'ceb':
- $border = 2;
- break;
- default:
- $border = 0;
- break;
- }
-
- $var = array(
+ $var = array
+ (
'align' => $align,
'img' =>
$GLOBALS['phpgw']->common->image('phpgwapi',$img),
'label' => lang($label),
- 'border' => $border
+ 'border' => 0
);
$this->template->set_var($var);
return $this->template->fp('out','link');
}
- /*!
- @function page
- @abstract ?
+ /**
+ * Wrapper for phpgw::link() which sets the menuaction to the
current menuaction
+ *
+ * @see phpgw::link
+ * @param array $extravars the GET vars to be append to the end
of the url
+ * @return thre link url
*/
- function page($extravars='')
- {
- if($extravars && is_string($extravars) &&
substr($extravars,0,1)!='&')
+ function page($extravars = array())
{
- $extras = '&'.$extravars;
- }
- elseif($extravars && is_array($extravars))
+ if ( $extravars && is_string($extravars) )
{
- @reset($extravars);
- while(list($var,$value) = each($extravars))
+ $extras = explode('&', $extravars);
+ foreach ( $extras as $extra )
{
- if($var != 'menuaction')
+ $tmp = explode('=', $extra);
+ if ( count($tmp) == 2 )
{
- $t_extras[] = $var.'='.$value;
+ $extravars[$tmp[0]] = $tmp[1];
}
}
- //jarg-SOG s
- $extras = '&'.implode($t_extras,'&');
- //jarg-SOG e
}
-
- return
$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->action.$extras);
+ $extravars['menuaction'] = $this->action;
+ return $GLOBALS['phpgw']->link('/index.php',
$extravars);
}
- /*!
- @function set_link
- @abstract ?
- @param $img_src ?
- @param $label ?
- @param $link ?
- @param $extravars ?
+ /**
+ * Create a single image button form
+ *
+ * @param string $img_src the url of the image
+ * @param string $label the alt text for the image
+ * @param string $link the url for the link
+ * @param array $extravars the extra args for the url
*/
function set_link($align,$img,$link,$alt,$extravars)
{
$hidden = '';
- while(list($var,$value) = each($extravars))
- {
- if((is_int($value) && $value == 0) || $value)
- {
-// if(is_int($value))
-// {
-// $param = intval($value);
-// }
-// else
-// {
- $param = '"'.$value.'"';
-// }
- $hidden .= ' <input type="hidden"
name="'.$var.'" value='.$param.'>'."\n";
- }
- }
- $border = 0;
- $var = Array(
+
+ $var = array
+ (
'align' => $align,
- //jarg-SOG s
- 'action' =>
($this->action?$this->page($extravars):$GLOBALS['phpgw']->link($link)),
- //jarg-SOG e
+ 'action' => strlen($this->action) ?
$this->page($extravars) : $GLOBALS['phpgw']->link($link, $extravars),
'form_name' => $img,
- 'hidden' =>
substr($hidden,0,strlen($hidden)-1),
+ 'hidden' => $hidden,
'img' =>
$GLOBALS['phpgw']->common->image('phpgwapi',$img),
'label' => $alt,
- 'border' => $border,
+ 'border' => 0,
'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 ?
+ /**
+ * ?
+ *
+ * @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')
{
@@ -200,7 +177,7 @@
$start = $localstart;
- $cats = CreateObject('phpgwapi.categories');
+ $cats = createObject('phpgwapi.categories');
$extravars = Array();
$extravars = $this->split_extras($extravars,$extra);
@@ -230,38 +207,68 @@
return $this->template->fp('out','nextmatchs');
}
- function split_extras($extravars, $extradata)
- {
- if($extradata)
+ /**
+ * Split url string values into arrays
+ *
+ * @param string $extravars the string to split
+ * @param string $extradata another string?
+ * @return an associative array of URL argument pairs
+ */
+ function split_extras($extravars, $extradata = '')
{
- if(is_string($extradata))
+ if ( is_string($extravars) && strlen($extravars) )
{
- $extraparams = explode('&',$extradata);
- foreach ( $extraparams as $extraparam )
+ $extras = array();
+ $extravars = explode('&', $extravars);
+ foreach ( $extravars as $extravar )
{
- if ( $extraparam )
+ $tmp = explode('=', $extravar); //0 ==
key, 1 == val
+ if ( is_array($tmp) && count($tmp) == 2
) //2 == key/val pair
{
- list($var, $value) =
explode('=', $extraparam);
- if($var != 'menuaction')
+ if ( $tmp[0] == 'menuaction')
{
-
$extravars[$var] = $value;
+ $this->action = $tmp[1];
+ continue;
+ }
+ $extras[$tmp[0]] = $tmp[1];
+ }
+ }
+ $extravars = $extras;
+ unset($extras);
}
else
{
- $this->action =
$value;
+ $extravars = array();
+ }
+
+ if ( is_string($extradata) && strlen($extradata) )
+ {
+ if ( !is_array($extravars) )
+ {
+ $extravars = array();
+ }
+
+ $extraparams = explode('&', $extradata);
+ foreach ( $extraparams as $extraparam )
+ {
+ $tmp = explode('=', $extraparam); //0
== key, 1 == val
+ if ( is_array($tmp) && count($tmp) == 2
) //2 == key/val pair
+ {
+ if ( $tmp[0] == 'menuaction')
+ {
+ $this->action = $tmp[1];
+ continue;
}
+ $extravars[$tmp[0]] = $tmp[1];
}
}
}
- elseif(is_array($extradata))
- {
- if ( isset($extravars['menuaction']) )
+
+ if ( is_array($extravars) &&
isset($extravars['menuaction']) )
{
$this->action =
$extravars['menuaction'];
unset($extravars['menuaction']);
}
- }
- }
return $extravars;
}
@@ -269,7 +276,6 @@
{
if(is_array($extra))
{
- @reset($extra);
while(list($var,$value) = each($extra))
{
$t_extras[] = $var . '=' . $value;
@@ -279,13 +285,13 @@
return $extra_s;
}
- /*!
- @function left
- @abstract ?
- @param $scriptname ?
- @param $start ?
- @param $total ?
- @param $extradate ?
+ /**
+ * ?
+ *
+ * @param $scriptname ?
+ * @param $start ?
+ * @param $total ?
+ * @param $extradate ?
*/
function left($scriptname,$start,$total,$extradata = '')
{
@@ -333,13 +339,13 @@
return $ret_str;
} /* left() */
- /*!
- @function right
- @abstract ?
- @param $scriptname ?
- @param $start ?
- @param $total ?
- @param $extradate ?
+ /**
+ * ?
+ *
+ * @param $scriptname ?
+ * @param $start ?
+ * @param $total ?
+ * @param $extradate ?
*/
function right($scriptname,$start,$total,$extradata = '')
{
@@ -381,10 +387,10 @@
return $ret_str;
} /* right() */
- /*!
- @function search_filter
- @abstract ?
- @param $search_obj default 0
+ /**
+ * ?
+ *
+ * @param $search_obj default 0
*/
function
search_filter($search_obj=0,$filter_obj=1,$yours=0,$link='',$extra='')
{
@@ -407,17 +413,17 @@
return $this->template->fp('out','search_filter');
}
- /*!
- @function cats_search_filter
- @abstract ?
- @param $search_obj default 0
+ /**
+ * ?
+ *
+ * @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='')
{
list($filter,$qfield,$start,$order,$sort) =
$this->get_var();
$start = $localstart;
- $cats = CreateObject('phpgwapi.categories');
+ $cats = createObject('phpgwapi.categories');
$var = array(
'form_action' =>
($this->action?$this->page($extra):$GLOBALS['phpgw']->link($sn, $extra)),
'lang_category' => lang('Category'),
@@ -439,10 +445,10 @@
return $this->template->fp('out','cats_search_filter');
}
- /*!
- @function search
- @abstract ?
- @param $search_obj default 0
+ /**
+ * ?
+ *
+ * @param $search_obj default 0
*/
function search($search_obj=0)
{
@@ -478,12 +484,12 @@
return $this->template->fp('out','search');
} /* search() */
- /*!
- @function filterobj
- @abstract ?
- @param $filtertable
- @param $indxfieldname ?
- @param $strfieldname ?
+ /**
+ * ?
+ *
+ * @param $filtertable
+ * @param $indxfieldname ?
+ * @param $strfieldname ?
*/
function filterobj($filtertable, $idxfieldname, $strfieldname)
{
@@ -501,10 +507,10 @@
return $filter_obj;
} /* filterobj() */
- /*!
- @function searchby
- @abstract ?
- @param $search_obj ?
+ /**
+ * ?
+ *
+ * @param $search_obj ?
*/
function searchby($search_obj)
{
@@ -527,10 +533,10 @@
return $str;
} /* searchby() */
- /*!
- @function filter
- @abstract ?
- @param $filter_obj
+ /**
+ * ?
+ *
+ * @param $filter_obj
*/
function filter($filter_obj,$yours=0)
{
@@ -665,13 +671,30 @@
return $this->template->fp('out','filter');
} /* filter() */
- /*!
- @function alternate_row_color
- @abstract alternate row colour
- @param $currentcolor default ''
+ /**
+ * CSS based alternate row colour
+ *
+ * @param string $currentcolor the current row class
+ * @return string the new row class
+ */
+ function alternate_row_class($classname = '')
+ {
+ if ( ! $classname || $classname == 'row_on')
+ {
+ return 'row_off';
+ }
+ return 'row_on';
+ }
+
+ /**
+ * alternate row colour
+ *
+ * @deprecated
+ * @param $currentcolor default ''
*/
function alternate_row_color($currentcolor = '')
{
+ echo "call to deprecate method
nextmatchs::alternate_row_color() use nextmatchs::alternate_row_class()
instead<br>\n";
if (! $currentcolor)
{
$currentcolor = $GLOBALS['tr_color'];
@@ -690,26 +713,26 @@
// If you are using the common bgcolor="{tr_color}"
// This function is a little cleanier approch
- /*!
- @function template_alternate_row_color
- @abstract ?
- @param $tpl ?
+ /**
+ * ?
+ *
+ * @param $tpl ?
*/
function template_alternate_row_color(&$tpl)
{
$tpl->set_var('tr_color',$this->alternate_row_color());
}
- /*!
- @function show_sort_order
- @abstract ?
- @param $sort ?
- @param $var ?
- @param $order ?
- @param $program ?
- @param $text ?
- @param $extra default ''
- @param $build_an_href default True
+ /**
+ * ?
+ *
+ * @param $sort ?
+ * @param $var ?
+ * @param $order ?
+ * @param $program ?
+ * @param $text ?
+ * @param $extra default ''
+ * @param $build_an_href default True
*/
function show_sort_order($sort, $var = '', $order = '',
$program = '', $text = '', $extra='', $build_an_href = True)
{
@@ -744,20 +767,21 @@
$sort = 'ASC';
}
- if(is_array($extra))
+ if(!is_array($extra))
{
- $extra = $this->extras_to_string($extra);
+ $extra = $this->split_extras($extra);
}
- $extravar =
'order='.$var.'&sort='.$sort.'&filter='.$filter.'&qfield='.$qfield.'&start='.$start.'&query='.$query.$extra;
+ $extra['order'] = $var;
+ $extra['sort'] = $sort;
+ $extra['filter'] = $filter;
+ $extra['qfield'] = $qfield;
+ $extra['start'] = $start;
+ $extra['query'] = $query;
- $link =
($this->action?$this->page($extravar):$GLOBALS['phpgw']->link($program,$extravar));
+ $link = strlen($this->action) ? $this->page($extra) :
$GLOBALS['phpgw']->link($program, $extra);
- if ($text == 'xslt')
- {
- return $link;
- }
- elseif($build_an_href)
+ if($build_an_href)
{
return '<a href="' . $link . '">' . $text .
'</a>';
}
@@ -787,22 +811,22 @@
}
}
- /*!
- @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 : users 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
+ /**
+ * Create a sortable link
+ *
+ * @param int $old_sort the current sort value
+ * @param int $new_sort the sort value you want if you click on
this
+ * @param int $default_order users preference for ordering list
items (force this when a new [different] sorting is requested)
+ * @param string $order the current order (will be flipped if
old_sort = new_sort)
+ * @param string $program the name of the script to call
+ * @param string $text the text label for the link
+ * @param array $extra: any extra values to be append to the
URL get args
*/
- function
show_sort_order_imap($old_sort,$new_sort,$default_order,$order,$program,$text,$extra='')
+ function show_sort_order_imap($old_sort, $new_sort,
$default_order, $order, $program, $text, $extra = array() )
{
- if(is_array($extra))
+ if ( !is_array($extra) )
{
- $extra = $this->extras_to_string($extra);
+ $extra = $this->split_extras($extra);
}
if($old_sort == $new_sort)
{
@@ -827,35 +851,38 @@
$our_order = $default_order;
}
- $extravar =
'order='.$our_order.'&sort='.$new_sort.$extra;
+ $extravar['order'] = $our_order;
+ $extravar['sort'] = $new_sort;
- $link =
($this->action?$this->page($extravar):$GLOBALS['phpgw']->link($program,$extravar));
+ $link = strlen($this->action) ? $this->page($extravar)
: $GLOBALS['phpgw']->link($program,$extravar);
return '<a href="' .$link .'">' .$text .'</a>';
}
- /*!
- @function nav_left_right_imap
- @abstract same code as left and right (as of Dec 07, 2001)
except all combined into one function
- @param feed_vars : array with these elements: <br>
- start
- total
- cmd_prefix
- cmd_suffix
- @return array, combination of functions left and right above,
with these elements:
- first_page
- prev_page
- next_page
- last_page
- @author: jengo, some changes by Angles
+ /**
+ * same code as left and right (as of Dec 07, 2001) except all
combined into one function
+ *
+ * @param feed_vars : array with these elements: <br>
+ * start
+ * total
+ * cmd_prefix
+ * cmd_suffix
+ * @return array, combination of functions left and right
above, with these elements:
+ * first_page
+ * prev_page
+ * next_page
+ * last_page
+ * @author: jengo, some changes by Angles
*/
function nav_left_right_imap($feed_vars)
{
- $return_array = Array(
+ $return_array = Array
+ (
'first_page' => '',
'prev_page' => '',
'next_page' => '',
'last_page' => ''
);
+
$out_vars = array();
// things that might change
$out_vars['start'] = $feed_vars['start'];
@@ -921,13 +948,13 @@
return $return_array;
}
- /*!
- @function set_link_imap
- @abstract ?
- @param $img_src ?
- @param $label ?
- @param $link ?
- @param $extravars ?
+ /**
+ * ?
+ *
+ * @param $img_src ?
+ * @param $label ?
+ * @param $link ?
+ * @param $extravars ?
*/
function set_link_imap($align,$img,$alt_text,$out_vars)
{
- [Phpgroupware-cvs] phpgwapi/inc class.nextmatchs.inc.php,
Dave Hall <=