changed interface for extensions to:

pre_process(&$cell,&$value,&$extension_data,&$readonlys)
post_process(&$cell,&$value,&$extension_data,&$loop)
This commit is contained in:
Ralf Becker 2002-09-24 22:02:20 +00:00
parent 7bd87b1180
commit 4f491de35d
2 changed files with 79 additions and 6 deletions

View File

@ -0,0 +1,73 @@
<?php
/**************************************************************************\
* phpGroupWare - eTemplate Extension - InfoLog LinkList Widget *
* http://www.phpgroupware.org *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/*!
@class linklist_widget
@author ralfbecker
@abstract widget that shows the links to an entry and a Unlink Button for each entry
@discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
*/
class linklist_widget
{
var $public_functions = array(
'pre_process' => True,
'post_process' => True
);
var $human_name = 'LinkList'; // this is the name for the editor
function linklist_widget($ui)
{
$this->link = CreateObject('infolog.bolink');
}
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
{
$app = $value['app'] = 'addressbook';
$id = $value['id'] = 921;
//echo "<p>linklist_widget.preprocess: app='$app', id='$id', value="; _debug_array($value);
if (!$value['title'])
{
$value['title'] = $this->link->title($app,$id);
}
$extension_data = $value;
$links = $this->link->get_links($app,$id);
for($row=1; list(,$link) = each($links); ++$row)
{
$value[$row] = $link;
$value[$row]['title'] = $this->link->title($link['app'],$link['id']);
}
$cell['size'] = $cell['name'];
$cell['type'] = 'template';
$cell['name'] = 'infolog.linklist_widget';
return True; // extra Label is ok
}
function post_process(&$cell,&$value,&$extension_data,&$loop)
{
list($unlink) = @each($value['unlink']);
$pre_value = $extension_data;
//echo "<p>linklist_widget.postprocess: app='$pre_value[app]', id='$pre_value[id]', unlink='$unlink', value="; _debug_array($value);
if ($unlink)
{
$this->link->unlink($unlink,$pre_value['app'],$pre_value['id']);
$loop = True;
$value = $pre_value;
}
}
}

View File

@ -31,7 +31,7 @@
$this->link = CreateObject('infolog.bolink');
}
function pre_process(&$cell,&$value,&$templ)
function pre_process(&$cell,&$value,&$extension_data,&$readonlys)
{
$search = $value['search'] ? 1 : 0;
$create = $value['create'] ? 1 : 0;
@ -39,7 +39,7 @@
if ($search && count($ids = $this->link->query($value['app'],$value['query'])))
{
$GLOBALS['phpgw_info']['etemplate']['extension_data']['linkto_widget'][$cell['name']]['app'] = $value['app'];
$extension_data['app'] = $value['app'];
$value = array(
'app' => $value['app'],
@ -52,7 +52,7 @@
{
if (!$create)
{
$GLOBALS['phpgw_info']['etemplate']['extension_data']['linkto_widget'][$cell['name']] = $value;
$extension_data = $value;
}
$value = array(
'app' => $value['app'],
@ -69,7 +69,7 @@
return True; // extra Label is ok
}
function post_process(&$cell,&$value,&$templ)
function post_process(&$cell,&$value,&$extension_data,&$loop)
{
$search = $value['search'] ? 1 : 0;
$create = $value['create'] ? 1 : 0;
@ -79,13 +79,13 @@
if ($create)
{
$value = array_merge($value,$GLOBALS['phpgw_info']['etemplate']['extension_data']['linkto_widget'][$cell['name']]);
$value = array_merge($value,$extension_data);
if ($value['to_app']) // make the link
{
$this->link->link($value['to_app'],$value['to_id'],$value['app'],$value['id'],$value['remark']);
echo "<p>linkto($value[app],$value[id],'$value[remark]')</p>\n";
}
}
$templ->loop = $search || $create;
$loop = $search || $create;
}
}