moved to etemplate.link_widget (with sub-widgets)

This commit is contained in:
Ralf Becker 2002-10-09 00:40:01 +00:00
parent 4870c4a3d7
commit bafaceec62
3 changed files with 6 additions and 190 deletions

View File

@ -1,83 +0,0 @@
<?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($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
if (!is_array($value))
{
$value = array('to_id' => $value,'to_app' => $GLOBALS['phpgw_info']['flags']['currentapp']);
}
$app = $value['to_app'];
$id = $value['to_id'];
//echo "<p>linklist_widget.preprocess: app='$app', id='$id', value="; _debug_array($value);
if (!$value['title'])
{
$value['title'] = $this->link->title($to_app,$to_id);
}
$extension_data = $value;
$links = $this->link->get_links($app,$id);
if (!count($links))
{
$cell = $tmpl->empty_cell();
return False;
}
$tpl = new etemplate('infolog.linklist_widget');
for($row=$tpl->rows-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';
$cell['obj'] = &$tpl;
return True; // extra Label is ok
}
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
{
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

@ -1,103 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare - eTemplate Extension - InfoLog LinkTo 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 linkto_widget
@author ralfbecker
@abstract widget that enable you to make a link to an other entry of a link-aware app
@discussion This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function
*/
class linkto_widget
{
var $public_functions = array(
'pre_process' => True,
'post_process' => True
);
var $human_name = 'LinkTo'; // this is the name for the editor
function linkto_widget($ui)
{
$this->link = CreateObject('infolog.bolink');
}
function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
{
if (!is_array($value))
{
$value = array('to_id' => $value,'to_app' => $GLOBALS['phpgw_info']['flags']['currentapp']);
}
//echo "<p>linkto_widget.preprocess: name='$name', query='$value[query]',app='$value[app]',button=$value[button]</p>\n";
if ($value['button'] == 'search' && count($ids = $this->link->query($value['app'],$value['query'])))
{
$extension_data['app'] = $value['app'];
$value = array(
'app' => $value['app'],
'options-id' => $ids,
'remark' => ''
);
$next = 'create';
}
else
{
if (!$value['button'])
{
$extension_data = $value;
}
$value = array(
'app' => $value['app'],
'options-app' => $this->link->app_list(),
'query' => $value['query'],
'msg' => $value['button'] == 'search' ? 'Nothing found - try again !!!' : ''
);
$next = 'search';
}
$cell['size'] = $cell['name'];
$cell['type'] = 'template';
$cell['name'] = "infolog.linkto_widget.$next";
return True; // extra Label is ok
}
function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
{
if ($value['search'])
{
$button = 'search';
}
elseif ($value['create'])
{
$button = 'create';
}
elseif ($value['new'])
{
$button = 'new';
}
unset($value[$button]);
//echo "<p>linkto_widget.postprocess: query='$value[query]',app='$value[app]',id='$value[id]', button='$button'</p>\n";
if ($button == 'create')
{
$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";
}
}
$value['button'] = $button;
$loop = $button != '';
}
}

File diff suppressed because one or more lines are too long