2011-08-30 22:56:01 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EGroupware - eTemplate serverside image 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
|
2011-08-30 22:56:01 +02:00
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @copyright 2011 Nathan Gray
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2016-03-19 14:06:07 +01:00
|
|
|
namespace EGroupware\Api\Etemplate\Widget;
|
|
|
|
|
|
|
|
use EGroupware\Api\Etemplate;
|
|
|
|
use EGroupware\Api;
|
|
|
|
|
2011-08-30 22:56:01 +02:00
|
|
|
/**
|
|
|
|
* eTemplate image widget
|
2016-03-19 14:06:07 +01:00
|
|
|
*
|
2011-08-30 22:56:01 +02:00
|
|
|
* Displays image from URL, vfs, or finds by name
|
|
|
|
*/
|
2016-03-19 14:06:07 +01:00
|
|
|
class Image extends Etemplate\Widget
|
2011-08-30 22:56:01 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Fill type options in self::$request->sel_options to be used on the client
|
|
|
|
*
|
|
|
|
* @param string $cname
|
2014-10-01 21:10:59 +02:00
|
|
|
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
2011-08-30 22:56:01 +02:00
|
|
|
*/
|
2014-10-01 21:10:59 +02:00
|
|
|
public function beforeSendToClient($cname, array $expand=null)
|
2011-08-30 22:56:01 +02:00
|
|
|
{
|
2014-10-01 21:10:59 +02:00
|
|
|
$form_name = self::form_name($cname, $this->id, $expand);
|
2011-08-30 22:56:01 +02:00
|
|
|
$value =& self::get_array(self::$request->content, $form_name);
|
|
|
|
|
|
|
|
$image = $value != '' ? $value : $this->attrs['src'];
|
|
|
|
|
|
|
|
if (is_string($image)) list($app,$img) = explode('/',$image,2);
|
|
|
|
if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false)
|
|
|
|
{
|
|
|
|
$img = $image;
|
|
|
|
list($app) = explode('.',$form_name);
|
|
|
|
}
|
2016-03-19 14:06:07 +01:00
|
|
|
$src = Api\Image::find($app, $img);
|
2011-08-30 22:56:01 +02:00
|
|
|
if(!$this->id)
|
|
|
|
{
|
|
|
|
// self::setElementAttribute($this->attrs['src'], 'id', $this->attrs['src']);
|
|
|
|
}
|
|
|
|
self::setElementAttribute($this->attrs['src'], 'src', $src);
|
|
|
|
}
|
|
|
|
}
|