2012-07-14 17:38:02 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EGroupware - eTemplate serverside itempicker widget
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2016-03-19 14:06:07 +01:00
|
|
|
* @package api
|
|
|
|
* @subpackage etemplate
|
2012-07-14 17:38:02 +02:00
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
|
|
|
* @author Christian Binder <christian@jaytraxx.de>
|
2016-03-19 14:06:07 +01:00
|
|
|
* @copyright 2002-16 by RalfBecker@outdoor-training.de
|
2012-07-14 17:38:02 +02:00
|
|
|
* @copyright 2012 by Christian Binder <christian@jaytraxx.de>
|
|
|
|
* @version $Id: class.etemplate_widget_itempicker.inc.php 36221 2011-08-20 10:27:38Z jaytraxx $
|
|
|
|
*/
|
|
|
|
|
2016-03-19 14:06:07 +01:00
|
|
|
namespace EGroupware\Api\Etemplate\Widget;
|
|
|
|
|
|
|
|
use EGroupware\Api\Etemplate;
|
|
|
|
use EGroupware\Api;
|
|
|
|
|
2012-07-14 17:38:02 +02:00
|
|
|
/**
|
|
|
|
* eTemplate itempicker widget
|
|
|
|
*/
|
2016-03-19 14:06:07 +01:00
|
|
|
class ItemPicker extends Etemplate\Widget
|
2012-07-14 17:38:02 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param string|XMLReader $xml string with xml or XMLReader positioned on the element to construct
|
|
|
|
* @throws egw_exception_wrong_parameter
|
|
|
|
*/
|
2012-08-02 22:07:58 +02:00
|
|
|
public function __construct($xml = '')
|
2012-07-14 17:38:02 +02:00
|
|
|
{
|
2012-08-02 22:07:58 +02:00
|
|
|
if($xml) {
|
|
|
|
parent::__construct($xml);
|
|
|
|
}
|
2012-07-14 17:38:02 +02:00
|
|
|
}
|
2016-03-19 14:06:07 +01:00
|
|
|
|
2012-07-21 12:50:04 +02:00
|
|
|
/**
|
|
|
|
* Find items that match the given parameters
|
2012-08-02 22:07:58 +02:00
|
|
|
* using the egw_link class
|
2012-07-21 12:50:04 +02:00
|
|
|
*/
|
2016-03-19 14:06:07 +01:00
|
|
|
public static function ajax_item_search($app, $type, $pattern, $options=array())
|
|
|
|
{
|
2012-07-21 12:50:04 +02:00
|
|
|
$options['type'] = $type ? $type : $options['type'];
|
2016-03-19 14:06:07 +01:00
|
|
|
$items = Api\Link::query($app, $pattern, $options);
|
2012-07-21 12:50:04 +02:00
|
|
|
|
2016-03-20 14:02:55 +01:00
|
|
|
$response = Api\Json\Response::get();
|
2012-07-21 12:50:04 +02:00
|
|
|
$response->data($items);
|
|
|
|
}
|
2012-07-14 17:38:02 +02:00
|
|
|
}
|
2016-03-19 14:06:07 +01:00
|
|
|
Etemplate\Widget::registerWidget(__NAMESPACE__.'\\ItemPicker', 'itempicker');
|