[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.Template.inc.php,1.31,1.32 cl
From: |
Bettina Gille <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.Template.inc.php,1.31,1.32 class.nextmatchs.inc.php,1.56,1.57 |
Date: |
Fri, 25 Apr 2003 21:19:47 -0400 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv26769/inc
Modified Files:
class.Template.inc.php class.nextmatchs.inc.php
Log Message:
added extra function for filter plus update tpl class to version .16
Index: class.Template.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.Template.inc.php,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** class.Template.inc.php 31 Mar 2003 17:34:38 -0000 1.31
--- class.Template.inc.php 26 Apr 2003 01:19:45 -0000 1.32
***************
*** 1,17 ****
<?php
! /**************************************************************************\
! * phpGroupWare API - Template class *
! * (C) Copyright 1999-2000 NetUSE GmbH Kristian Koehntopp *
! * ------------------------------------------------------------------------ *
! * This is not part of phpGroupWare, but is used by phpGroupWare.
*
! * http://www.phpgroupware.org/
*
! * ------------------------------------------------------------------------ *
! * This program 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. *
! \**************************************************************************/
!
! /* $Id$ */
class Template
--- 1,16 ----
<?php
!
/**************************************************************************\
! * phpGroupWare API - Template class
*
! * (C) Copyright 1999-2000 NetUSE GmbH Kristian Koehntopp
*
! *
------------------------------------------------------------------------ *
! * This is not part of phpGroupWare, but is used by phpGroupWare.
*
! * http://www.phpgroupware.org/
*
! *
------------------------------------------------------------------------ *
! * This program 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.
*
!
\**************************************************************************/
! /* $Id$ */
class Template
***************
*** 27,31 ****
/* relative filenames are relative to this pathname */
var $root = '';
- var $oldroot = '';
/* $varkeys[key] = 'key'; $varvals[key] = 'value'; */
--- 26,29 ----
***************
*** 44,49 ****
/* last error message is retained here */
var $last_error = '';
! var $print = False;
!
/***************************************************************************/
/* public: Constructor.
--- 42,46 ----
/* last error message is retained here */
var $last_error = '';
!
/***************************************************************************/
/* public: Constructor.
***************
*** 53,60 ****
function Template($root = '.', $unknowns = 'remove')
{
- if(@isset($GLOBALS['phpgw_info']['flags']['printview'])
&& $GLOBALS['phpgw_info']['flags']['printview'] == True)
- {
- $this->print = True;
- }
$this->set_root($root);
$this->set_unknowns($unknowns);
--- 50,53 ----
***************
*** 69,82 ****
{
$this->halt("set_root: $root is not a
directory.");
! return False;
}
- $this->oldroot = $this->root;
$this->root = $root;
! return True;
! }
!
! function reset_root()
! {
! $this->root = $this->oldroot;
}
--- 62,69 ----
{
$this->halt("set_root: $root is not a
directory.");
! return false;
}
$this->root = $root;
! return true;
}
***************
*** 104,108 ****
{
$this->halt("set_file: For handle
$handle filename is empty.");
! return False;
}
$this->file[$handle] =
$this->filename($filename);
--- 91,95 ----
{
$this->halt("set_file: For handle
$handle filename is empty.");
! return false;
}
$this->file[$handle] =
$this->filename($filename);
***************
*** 127,133 ****
{
$this->halt("subst: unable to load $parent.");
! return False;
}
-
if ($name == '')
{
--- 114,119 ----
{
$this->halt("subst: unable to load $parent.");
! return false;
}
if ($name == '')
{
***************
*** 137,147 ****
$reg = "/<!--\s+BEGIN $handle\s+-->(.*)\n\s*<!--\s+END
$handle\s+-->/sm";
preg_match_all($reg, $str, $m);
! $this->set_var($name, $m[1][0]);
! // ralfbecker: readded for compatibility with old way
to set blocks
!
$this->set_var($parent,preg_replace($reg,'{'.$name.'}',$str));
! if ($name != $handle)
! {
! $this->set_var($handle, $m[1][0]);
! }
}
--- 123,129 ----
$reg = "/<!--\s+BEGIN $handle\s+-->(.*)\n\s*<!--\s+END
$handle\s+-->/sm";
preg_match_all($reg, $str, $m);
! $str = preg_replace($reg, '{' . "$name}", $str);
! $this->set_var($handle, $m[1][0]);
! $this->set_var($parent, $str);
}
***************
*** 153,157 ****
* value: value of that variable
*/
! function set_var($varname, $value = '', $append=False)
{
if ($varname == 'phpgw_body' &&
is_object($GLOBALS['phpgw']->xslttpl))
--- 135,139 ----
* value: value of that variable
*/
! function set_var($varname, $value = '')
{
if ($varname == 'phpgw_body' &&
is_object($GLOBALS['phpgw']->xslttpl))
***************
*** 170,182 ****
}
$this->varkeys[$varname] =
$this->varname($varname);
!
! if ($append)
! {
! $this->varvals[$varname] =
$this->get_var($varname).$value;
! }
! else
! {
! $this->varvals[$varname] =
$value;
! }
}
}
--- 152,156 ----
}
$this->varkeys[$varname] =
$this->varname($varname);
! $this->varvals[$varname] = $value;
}
}
***************
*** 193,206 ****
}
$this->varkeys[$k] =
$this->varname($k);
!
! if ($append)
! {
! $this->varvals[$k] =
$this->get_var($k).$v;
! }
! else
! {
! $this->varvals[$k] = $v;
! }
!
}
}
--- 167,171 ----
}
$this->varkeys[$k] =
$this->varname($k);
! $this->varvals[$k] = $v;
}
}
***************
*** 216,220 ****
{
$this->halt("subst: unable to load $handle.");
! return False;
}
--- 181,185 ----
{
$this->halt("subst: unable to load $handle.");
! return false;
}
***************
*** 234,238 ****
{
print $this->subst($handle);
! return False;
}
--- 199,203 ----
{
print $this->subst($handle);
! return false;
}
***************
*** 243,252 ****
* append: append to target handle
*/
! function parse($target, $handle, $append = False)
{
if (!is_array($handle))
{
$str = $this->subst($handle);
! $this->set_var($target, $str, $append);
}
else
--- 208,224 ----
* append: append to target handle
*/
! function parse($target, $handle, $append = false)
{
if (!is_array($handle))
{
$str = $this->subst($handle);
! if ($append)
! {
! $this->set_var($target,
$this->get_var($target) . $str);
! }
! else
! {
! $this->set_var($target, $str);
! }
}
else
***************
*** 262,269 ****
}
! function pparse($target, $handle, $append = False)
{
print $this->parse($target, $handle, $append);
! return False;
}
--- 234,241 ----
}
! function pparse($target, $handle, $append = false)
{
print $this->parse($target, $handle, $append);
! return false;
}
***************
*** 323,327 ****
{
$this->halt("get_undefined: unable to load
$handle.");
! return False;
}
--- 295,299 ----
{
$this->halt("get_undefined: unable to load
$handle.");
! return false;
}
***************
*** 330,334 ****
if (!is_array($m))
{
! return False;
}
reset($m);
--- 302,306 ----
if (!is_array($m))
{
! return false;
}
reset($m);
***************
*** 347,351 ****
else
{
! return False;
}
}
--- 319,323 ----
else
{
! return false;
}
}
***************
*** 367,375 ****
break;
}
! /* If they want NOGIF policy, then I do a global
replace */
! if (@$GLOBALS['phpgw_info']['server']['image_type'] ==
2)
! {
! $str = str_replace ('.gif','.png',$str);
! }
return $str;
}
--- 339,343 ----
break;
}
!
return $str;
}
***************
*** 407,439 ****
}
- if ($this->print && $time!=2 && $time!=4)
- {
- $new_filename = $new_filename.'_print';
- }
-
if (!file_exists($new_filename))
{
! switch($time)
{
! case 2:
! $new_root =
str_replace($GLOBALS['phpgw_info']['server']['template_set'],'default',$root);
! $new_filename =
$this->filename($filename,$new_root,3);
! break;
! case 3:
! $new_filename =
$this->filename($filename,$root,4);
! break;
! case 4:
! $this->halt("filename: file
$new_filename does not exist.");
! break;
! default:
! if (!$this->print)
! {
! $new_root =
str_replace($GLOBALS['phpgw_info']['server']['template_set'],'default',$root);
! $new_filename =
$this->filename(str_replace($root.'/','',$new_filename),$new_root,4);
! }
! else
! {
! $new_filename =
$this->filename($filename,$root,2);
! }
}
}
--- 375,388 ----
}
if (!file_exists($new_filename))
{
! if($time==2)
{
! $this->halt("filename: file
$new_filename does not exist.");
! }
! else
! {
! $new_root =
str_replace($GLOBALS['phpgw_info']['server']['template_set'],'default',$root);
! $new_filename =
$this->filename(str_replace($root.'/','',$new_filename),$new_root,2);
}
}
***************
*** 456,465 ****
if (isset($this->varkeys[$handle]) and
!empty($this->varvals[$handle]))
{
! return True;
}
if (!isset($this->file[$handle]))
{
$this->halt("loadfile: $handle is not a valid
handle.");
! return False;
}
$filename = $this->file[$handle];
--- 405,414 ----
if (isset($this->varkeys[$handle]) and
!empty($this->varvals[$handle]))
{
! return true;
}
if (!isset($this->file[$handle]))
{
$this->halt("loadfile: $handle is not a valid
handle.");
! return false;
}
$filename = $this->file[$handle];
***************
*** 469,473 ****
{
$this->halt("loadfile: While loading $handle,
$filename does not exist or is empty.");
! return False;
}
--- 418,422 ----
{
$this->halt("loadfile: While loading $handle,
$filename does not exist or is empty.");
! return false;
}
***************
*** 493,498 ****
echo('<b>Halted.</b>');
}
-
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
exit;
}
--- 442,445 ----
Index: class.nextmatchs.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.nextmatchs.inc.php,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -r1.56 -r1.57
*** class.nextmatchs.inc.php 22 Apr 2003 22:30:38 -0000 1.56
--- class.nextmatchs.inc.php 26 Apr 2003 01:19:45 -0000 1.57
***************
*** 464,468 ****
}
! // If the place a in there search, it will mess
everything up
// Our only option is to remove it
if(ereg('"',$_query))
--- 464,468 ----
}
! // If the place a '"' in there search, it will mess
everything up
// Our only option is to remove it
if(ereg('"',$_query))
***************
*** 470,478 ****
$_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');
--- 470,484 ----
$_query = ereg_replace('"','',$_query);
}
! $var = array
! (
'query_value' => stripslashes($_query),
'lang_search' => lang('Search')
);
+
+ if (is_array($search_obj))
+ {
+ $var['searchby'] = $this->searchby($search_obj);
+ }
+
$this->template->set_var($var);
return $this->template->fp('out','search');
***************
*** 598,601 ****
--- 604,665 ----
} /* filter() */
+ /* replacement for function filter */
+ function new_filter($data=0)
+ {
+ if(is_array($data))
+ {
+ $filter =
(isset($data['filter'])?$data['filter']:'');
+ $format =
(isset($data['format'])?$data['format']:'all');
+ }
+ else
+ {
+ //$filter =
get_var('filter',Array('GET','POST'));
+ $filter = $data;
+ $format = 'all';
+ }
+
+ switch($format)
+ {
+ case 'yours':
+ $filter_obj = array
+ (
+ array('none',lang('show all')),
+ array('yours',lang('only
yours'))
+ );
+ break;
+ case 'private':
+ $filter_obj = array
+ (
+ array('none',lang('show all')),
+ array('private',lang('only
private'))
+ );
+ break;
+ default:
+ $filter_obj = array
+ (
+ array('none',lang('show all')),
+ array('yours',lang('only
yours')),
+ array('private',lang('only
private'))
+ );
+ }
+
+ $str = '';
+ $indexlimit = count($filter_obj);
+
+ for($index=0; $index<$indexlimit; $index++)
+ {
+ 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";
+ }
+
+ $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'));
+
+ return $this->template->fp('out','filter');
+ } /* filter() */
function xslt_filter($data=0)
***************
*** 603,645 ****
if(is_array($data))
{
! $filter =
(isset($data['filter'])?$data['filter']:'');
! $yours =
(isset($data['yours'])?$data['yours']:'');
}
else
{
! $filter = get_var('filter',Array('GET','POST'));
}
! $filter_obj = array
! (
! array
! (
! 'key' => 'none',
! 'lang' => lang('show all')
! ),
! array
! (
! 'key' => 'yours',
! 'lang' => lang('only yours')
! ),
! array
! (
! 'key' => 'private',
! 'lang' => lang('only private')
! )
! );
!
! if(is_array($filter_obj))
{
! for($i=0;$i<count($filter_obj);$i++)
{
! if($filter_obj[$i]['key'] == $filter)
! {
! $filter_obj[$i]['selected'] =
'yes';
! }
! if (!$yours && $filter_obj[$i]['key']
== 'yours')
! {
! unset($filter_obj[$i]);
! }
}
}
--- 667,710 ----
if(is_array($data))
{
! $filter =
(isset($data['filter'])?$data['filter']:'');
! $format =
(isset($data['format'])?$data['format']:'all');
}
else
{
! //$filter =
get_var('filter',Array('GET','POST'));
! $filter = $data;
! $format = 'all';
! }
!
! switch($format)
! {
! case 'yours':
! $filter_obj = array
! (
! array('key' => 'none','lang' =>
lang('show all')),
! array('key' => 'yours','lang'
=> lang('only yours'))
! );
! break;
! case 'private':
! $filter_obj = array
! (
! array('key' => 'none','lang' =>
lang('show all')),
! array('key' => 'private','lang'
=> lang('only private'))
! );
! break;
! default:
! $filter_obj = array
! (
! array('key' => 'none','lang' =>
lang('show all')),
! array('key' => 'yours','lang'
=> lang('only yours')),
! array('key' => 'private','lang'
=> lang('only private'))
! );
}
! for($i=0;$i<count($filter_obj);$i++)
{
! if($filter_obj[$i]['key'] == $filter)
{
! $filter_obj[$i]['selected'] = 'yes';
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.Template.inc.php,1.31,1.32 class.nextmatchs.inc.php,1.56,1.57,
Bettina Gille <address@hidden> <=