mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 08:39:07 +01:00
added linkto_widget extenstion for eTemplates: select on side of a Link
This commit is contained in:
parent
911987d967
commit
e5f2cb6e77
90
infolog/inc/class.linkto_widget.inc.php
Normal file
90
infolog/inc/class.linkto_widget.inc.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?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
|
||||
@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(&$cell,&$value,&$templ)
|
||||
{
|
||||
$search = $value['search'] ? 1 : 0;
|
||||
$create = $value['create'] ? 1 : 0;
|
||||
echo "<p>linkto_widget.preprocess: query='$value[query]',app='$value[app]',search=$search,create=$create</p>\n";
|
||||
|
||||
if ($search && count($ids = $this->link->query($value['app'],$value['query'])))
|
||||
{
|
||||
$GLOBALS['phpgw_info']['etemplate']['extension_data']['linkto_widget'][$cell['name']]['app'] = $value['app'];
|
||||
|
||||
$value = array(
|
||||
'app' => $value['app'],
|
||||
'options-id' => $ids,
|
||||
'remark' => ''
|
||||
);
|
||||
$next = 'create';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$create)
|
||||
{
|
||||
$GLOBALS['phpgw_info']['etemplate']['extension_data']['linkto_widget'][$cell['name']] = $value;
|
||||
}
|
||||
$value = array(
|
||||
'app' => $value['app'],
|
||||
'options-app' => $this->link->app_list(),
|
||||
'query' => $value['query'],
|
||||
'msg' => $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(&$cell,&$value,&$templ)
|
||||
{
|
||||
$search = $value['search'] ? 1 : 0;
|
||||
$create = $value['create'] ? 1 : 0;
|
||||
list($value['app']) = @$value['app']; // no multiselection
|
||||
list($value['id']) = @$value['id'];
|
||||
echo "<p>linkto_widget.postprocess: query='$value[query]',app='$value[app]',id='$value[id]', search=$search,create=$create</p>\n";
|
||||
|
||||
$templ->loop = $search;
|
||||
|
||||
if ($create)
|
||||
{
|
||||
$value = array_merge($value,$GLOBALS['phpgw_info']['etemplate']['extension_data']['linkto_widget'][$cell['name']]);
|
||||
// make the link
|
||||
echo "<p>linkto($value[app],$value[id],'$value[remark]')</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
9
infolog/setup/etemplates.inc.php
Normal file
9
infolog/setup/etemplates.inc.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
// eTemplates for Application 'infolog', generated by etemplate.dump() 2002-09-02 23:51
|
||||
|
||||
$templ_data[] = array('name' => 'infolog.linkto_widget.create','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:3:{i:0;a:0:{}i:1;a:3:{s:1:\"A\";a:2:{s:4:\"type\";s:5:\"label\";s:4:\"name\";s:3:\"app\";}s:1:\"B\";a:3:{s:4:\"type\";s:6:\"select\";s:4:\"name\";s:2:\"id\";s:4:\"help\";s:28:\"Select an entry to link with\";}s:1:\"C\";a:4:{s:4:\"type\";s:6:\"button\";s:5:\"label\";s:4:\"Link\";s:4:\"name\";s:6:\"create\";s:4:\"help\";s:29:\"click here to create the Link\";}}i:2;a:3:{s:1:\"A\";a:2:{s:4:\"type\";s:5:\"label\";s:5:\"label\";s:6:\"Remark\";}s:1:\"B\";a:5:{s:4:\"type\";s:4:\"text\";s:4:\"size\";s:5:\"50,50\";s:4:\"span\";s:3:\"all\";s:4:\"name\";s:6:\"remark\";s:4:\"help\";s:25:\"optional note to the Link\";}s:1:\"C\";a:1:{s:4:\"type\";s:5:\"label\";}}}','size' => '','style' => '',);
|
||||
|
||||
$templ_data[] = array('name' => 'infolog.linkto_widget.search','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:2:{i:0;a:0:{}i:1;a:4:{s:1:\"A\";a:4:{s:4:\"type\";s:6:\"select\";s:5:\"label\";s:6:\"Search\";s:4:\"name\";s:3:\"app\";s:4:\"help\";s:26:\"Select an App to search in\";}s:1:\"B\";a:3:{s:4:\"type\";s:4:\"text\";s:4:\"name\";s:5:\"query\";s:4:\"help\";s:23:\"Enter the query pattern\";}s:1:\"C\";a:4:{s:4:\"type\";s:6:\"button\";s:5:\"label\";s:6:\"Search\";s:4:\"name\";s:6:\"search\";s:4:\"help\";s:30:\"click here to start the search\";}s:1:\"D\";a:3:{s:4:\"type\";s:5:\"label\";s:4:\"size\";s:1:\"i\";s:4:\"name\";s:3:\"msg\";}}}','size' => '','style' => '',);
|
||||
|
||||
$templ_data[] = array('name' => 'infolog.linkto_widget.test','template' => '','lang' => '','group' => '0','version' => '','data' => 'a:2:{i:0;a:0:{}i:1;a:1:{s:1:\"A\";a:2:{s:4:\"type\";s:6:\"linkto\";s:4:\"name\";s:9:\"test_link\";}}}','size' => '','style' => '',);
|
||||
|
Loading…
Reference in New Issue
Block a user