WIP EGroupware without phpgwapi&etemplate

This commit is contained in:
Ralf Becker 2016-05-04 19:07:54 +00:00
parent d7eb464605
commit 4af0e7cb1c
20 changed files with 105 additions and 62 deletions

View File

@ -756,8 +756,12 @@ class addressbook_ui extends addressbook_bo
'disableClass' => 'rowNoEdit', 'disableClass' => 'rowNoEdit',
); );
} }
if (isset($actions['export']['children']['csv']) && !importexport_helper_functions::has_definitions('addressbook','export')) unset($actions['export']['children']['csv']); if (isset($actions['export']['children']['csv']) &&
(!isset($GLOBALS['egw_info']['user']['apps']['importexport']) ||
!importexport_helper_functions::has_definitions('addressbook','export')))
{
unset($actions['export']['children']['csv']);
}
// Intercept open action in order to open entry into view mode instead of edit // Intercept open action in order to open entry into view mode instead of edit
if (Api\Header\UserAgent::mobile()) if (Api\Header\UserAgent::mobile())
{ {

View File

@ -284,7 +284,7 @@ etemplate2.prototype.bind_unload = function()
{ {
this.destroy_session = jQuery.proxy(function(ev) this.destroy_session = jQuery.proxy(function(ev)
{ {
var request = egw.json(this.app+".etemplate_new.ajax_destroy_session.etemplate", var request = egw.json("EGroupware\\Api\\Etemplate::ajax_destroy_session",
[this.etemplate_exec_id], null, null, false); [this.etemplate_exec_id], null, null, false);
request.sendRequest(); request.sendRequest();
}, this); }, this);

View File

@ -415,7 +415,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
{ {
this.serializedTabState = serialized; this.serializedTabState = serialized;
egw.jsonq("api.jdots_framework.ajax_tab_changed_state", [data]); egw.jsonq("api.jdots_framework.ajax_tab_changed_state.template", [data]);
} }
}, },
@ -998,7 +998,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
var app = framework.activeApp; var app = framework.activeApp;
framework.activeApp = ''; framework.activeApp = '';
framework.setActiveApp(app); framework.setActiveApp(app);
egw.loading_prompt(app.appName,true,egw.lang('please wait...'),app.browser.baseDiv, egwIsMobile()?'horizental':'spinner'); egw.loading_prompt(app.appName,true,egw.lang('please wait...'),app.browser.baseDiv, egwIsMobile()?'horizental':'spinner');
// Give framework a chance to deal, then reset the etemplates // Give framework a chance to deal, then reset the etemplates

View File

@ -302,7 +302,7 @@
} }
//Send the sort order to the server via ajax //Send the sort order to the server via ajax
var req = egw.jsonq('api.jdots_framework.ajax_appsort', [name_array]); var req = egw.jsonq('api.jdots_framework.ajax_appsort.template', [name_array]);
}, },
/** /**

View File

@ -289,7 +289,7 @@
window.setTimeout(resize_popup, 50); window.setTimeout(resize_popup, 50);
}); });
} }
var et2 = new etemplate2(node, currentapp+".etemplate_new.ajax_process_content.etemplate"); var et2 = new etemplate2(node, "EGroupware\\Api\\Etemplate::ajax_process_content");
et2.load(data.name,data.url,data.data); et2.load(data.name,data.url,data.data);
if (typeof data.response != 'undefined') if (typeof data.response != 'undefined')
{ {

View File

@ -283,7 +283,7 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd)
/** /**
* The dataFetch function provides an abstraction layer for the * The dataFetch function provides an abstraction layer for the
* corresponding "etemplate_widget_nextmatch::ajax_get_rows" function. * corresponding "EGroupware\Api\Etemplate\Widget\Nextmatch::ajax_get_rows" function.
* The server returns the following structure: * The server returns the following structure:
* { * {
* order: [uid, ...], * order: [uid, ...],
@ -429,7 +429,7 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd)
// independent of changes happening while waiting for the response // independent of changes happening while waiting for the response
_context.filters = jQuery.extend({}, _filters); _context.filters = jQuery.extend({}, _filters);
var request = egw.json( var request = egw.json(
_app+".etemplate_widget_nextmatch.ajax_get_rows.etemplate", "EGroupware\\Api\\Etemplate\\Widget\\Nextmatch::ajax_get_rows",
[ [
_execId, _execId,
_queriedRange, _queriedRange,
@ -836,7 +836,7 @@ egw.extend("data_storage", egw.MODULE_GLOBAL, function (_app, _wnd) {
if(typeof registeredCallbacks[_uid] !== "undefined" && registeredCallbacks[_uid].length > 0) if(typeof registeredCallbacks[_uid] !== "undefined" && registeredCallbacks[_uid].length > 0)
{ {
var _execId = registeredCallbacks[_uid][0].execId; var _execId = registeredCallbacks[_uid][0].execId;
// This widget ID MUST be a nextmatch, because the data call is to etemplate_widget_nexmatch // This widget ID MUST be a nextmatch, because the data call is to Etemplate\Widget\Nexmatch
var nextmatchId = registeredCallbacks[_uid][0].widgetId; var nextmatchId = registeredCallbacks[_uid][0].widgetId;
var uid = _uid.split("::"); var uid = _uid.split("::");
var context = { var context = {

View File

@ -398,7 +398,7 @@ egw.extend('links', egw.MODULE_GLOBAL, function()
// if there's no active jsonq request, start a new one // if there's no active jsonq request, start a new one
if (title_uid == null) if (title_uid == null)
{ {
title_uid = this.jsonq(_app+'.etemplate_widget_link.ajax_link_titles.etemplate',[{}], this.link_title_callback, this, this.link_title_before_send); title_uid = this.jsonq('EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_titles',[{}], this.link_title_callback, this, this.link_title_before_send);
} }
}, },

View File

@ -0,0 +1,50 @@
<?php
/**
* EGroupware API: HTTP_REFERER header handling
*
* @link http://www.egroupware.org
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright 2001-2016 by RalfBecker@outdoor-training.de
* @package api
* @subpackage header
* @version $Id$
*/
namespace EGroupware\Api\Header;
/**
* Handling of HTTP_REFERER header
*/
class Referer
{
/**
* gets an eGW conformant referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function
*
* @param string $default ='' default to use if referer is not set by webserver or not determinable
* @param string $referer ='' referer string to use, default ('') use $_SERVER['HTTP_REFERER']
* @return string
* @todo get "real" referer for jDots template
*/
static function get($default='',$referer='')
{
// HTTP_REFERER seems NOT to get urldecoded
if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']);
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path
{
$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part
}
if (strlen($webserver_url) > 1)
{
list(,$referer) = explode($webserver_url,$referer,2);
}
$ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer);
if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default;
return $ret;
}
}
UserAgent::_init_static();

View File

@ -195,7 +195,7 @@ class Translation
} }
$apps = array('common'); $apps = array('common');
// for eTemplate apps, load etemplate before app itself (allowing app to overwrite etemplate translations) // for eTemplate apps, load etemplate before app itself (allowing app to overwrite etemplate translations)
if (class_exists('etemplate_new', false) || class_exists('etemplate', false)) $apps[] = 'etemplate'; if (class_exists('EGroupware\\Api\\Etemplate', false) || class_exists('etemplate', false)) $apps[] = 'etemplate';
if ($GLOBALS['egw_info']['flags']['currentapp']) $apps[] = $GLOBALS['egw_info']['flags']['currentapp']; if ($GLOBALS['egw_info']['flags']['currentapp']) $apps[] = $GLOBALS['egw_info']['flags']['currentapp'];
// load instance specific translations last, so they can overwrite everything // load instance specific translations last, so they can overwrite everything
$apps[] = 'custom'; $apps[] = 'custom';

View File

@ -56,15 +56,16 @@ class boholiday
function boholiday() function boholiday()
{ {
$this->so =& CreateObject('calendar.soholiday'); require_once(__DIR__.'/class.soholiday.inc.php');
$this->so = new soholiday();
$this->start = (int)get_var('start',array('POST','GET')); $this->start = (int)$_REQUEST['start'];
$this->query = get_var('query',array('POST','GET')); $this->query = $_REQUEST['query'];
$this->sort = get_var('sort',array('POST','GET')); $this->sort = $_REQUEST['sort'];
$this->order = get_var('order',array('POST','GET')); $this->order = $_REQUEST['order'];
$this->id = get_var('id',array('POST','GET')); $this->id = $_REQUEST['id'];
$this->year = get_var('year',array('POST','GET'),date('Y')); $this->year = (int)(!empty($_REQUEST['year']) ? $_REQUEST['year'] : date('Y'));
$this->locale = get_var('locale',array('POST','GET')); $this->locale = $_REQUEST['locale'];
if ($this->locale) if ($this->locale)
{ {
$this->locales[] = $this->locale; $this->locales[] = $this->locale;

View File

@ -1474,11 +1474,11 @@ class calendar_bo
if ($end_m == 24*60-1) ++$duration; if ($end_m == 24*60-1) ++$duration;
$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
$timespan = $t = common::formattime(sprintf('%02d',$start_m/60),sprintf('%02d',$start_m%60)); $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
if ($both) // end-time too if ($both) // end-time too
{ {
$timespan .= ' - '.common::formattime(sprintf('%02d',$end_m/60),sprintf('%02d',$end_m%60)); $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
// dont double am/pm if they are the same in both times // dont double am/pm if they are the same in both times
if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
{ {

View File

@ -2031,7 +2031,7 @@ class calendar_uiforms extends calendar_ui
*/ */
function conflicts($event,$conflicts,$preserv) function conflicts($event,$conflicts,$preserv)
{ {
$etpl = CreateObject('etemplate.etemplate_new','calendar.conflicts'); $etpl = new Etemplate('calendar.conflicts');
$allConflicts = array(); $allConflicts = array();
foreach($conflicts as $k => $conflict) foreach($conflicts as $k => $conflict)

View File

@ -412,7 +412,7 @@ class calendar_uiviews extends calendar_ui
/** /**
* Displays the planner view * Displays the planner view
* *
* @param boolean|etemplate_new $home = false if etemplate return content suitable for home-page * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page
*/ */
function &planner($content = array(), $home=false) function &planner($content = array(), $home=false)
{ {

View File

@ -85,6 +85,7 @@ foreach(array(
'common::egw_footer' => "\$GLOBALS['egw']->framework->footer", 'common::egw_footer' => "\$GLOBALS['egw']->framework->footer",
'common::show_date' => 'Api\\DateTime::server2user', 'common::show_date' => 'Api\\DateTime::server2user',
'common::get_tpl_dir' => 'Api\\Framework\\Template::get_dir', 'common::get_tpl_dir' => 'Api\\Framework\\Template::get_dir',
'common::get_referer' => 'Api\\Header\\Referer::get',
'country' => 'Api\\Country', 'country' => 'Api\\Country',
'egw' => 'Api\\Egw', 'egw' => 'Api\\Egw',
'egw_minimal' => 'Api\\Egw\\Base', 'egw_minimal' => 'Api\\Egw\\Base',
@ -158,6 +159,7 @@ foreach(array(
'etemplate_request' => 'Api\\Etemplate\\Request', 'etemplate_request' => 'Api\\Etemplate\\Request',
'nextmatch_widget::category_action' => 'Api\\Etemplate\\Widget\\Nextmatch::category_action', 'nextmatch_widget::category_action' => 'Api\\Etemplate\\Widget\\Nextmatch::category_action',
'nextmatch_widget::DEFAULT_MAX_MENU_LENGTH' => 'Api\\Etemplate\\Widget\\Nextmatch::DEFAULT_MAX_MENU_LENGTH', 'nextmatch_widget::DEFAULT_MAX_MENU_LENGTH' => 'Api\\Etemplate\\Widget\\Nextmatch::DEFAULT_MAX_MENU_LENGTH',
'customfields_widget::update_customfield_links' => 'Api\Storage\Customfields::update_links',
'egw_keymanager' => 'Api\\Etemplate\\KeyManager', 'egw_keymanager' => 'Api\\Etemplate\\KeyManager',
// so_sql and friends // so_sql and friends
'so_sql' => 'Api\\Storage\\Base', 'so_sql' => 'Api\\Storage\\Base',

View File

@ -133,10 +133,12 @@ use EGroupware\Api\Etemplate;
$text = lang("Tomorrow is %1's birthday.", $contact['n_given'].' '.$contact['n_family']); $text = lang("Tomorrow is %1's birthday.", $contact['n_given'].' '.$contact['n_family']);
break; break;
default: default:
list($y,$m,$d) = explode('-',$contact['bday']); $date = Api\DateTime::to($contact['bday'], true);
if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = ''; if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly')
$text = lang("In %1 days (%2) is %3's birthday.",$n, {
common::dateformatorder($y,$m,$d,true), $date = preg_replace('/\d{4}/', '', $date);
}
$text = lang("In %1 days (%2) is %3's birthday.", $n, $date,
$contact['n_given'].' '.$contact['n_family']); $contact['n_given'].' '.$contact['n_family']);
break; break;
} }

View File

@ -86,7 +86,7 @@ if (isset($_GET['tz']))
$GLOBALS['egw']->preferences->add('common','tz',$_GET['tz']); $GLOBALS['egw']->preferences->add('common','tz',$_GET['tz']);
$GLOBALS['egw']->preferences->save_repository(); $GLOBALS['egw']->preferences->save_repository();
if (($referer = common::get_referer())) if (($referer = Api\Header\Referer::get()))
{ {
Egw::redirect_link($referer); Egw::redirect_link($referer);
} }

View File

@ -596,7 +596,7 @@ class infolog_bo
} }
} }
if (($data = $this->so->read($info_id)) === False) if (!$info_id || ($data = $this->so->read($info_id)) === False)
{ {
return null; return null;
} }
@ -948,7 +948,7 @@ class infolog_bo
$to_write['info_responsible'] = $values['info_responsible']; $to_write['info_responsible'] = $values['info_responsible'];
} }
// create (and remove) links in custom fields // create (and remove) links in custom fields
customfields_widget::update_customfield_links('infolog',$values,$old,'info_id'); Api\Storage\Customfields::update_links('infolog',$values,$old,'info_id');
// Check for restore of deleted entry, restore held links // Check for restore of deleted entry, restore held links
if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted')
@ -1361,7 +1361,7 @@ class infolog_bo
foreach ($infos as $info) foreach ($infos as $info)
{ {
$start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone); $start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone);
$title = ($do_events?common::formattime($start->format('H'),$start->format('i')).' ':''). $title = ($do_events ? $start->format(false).' ' : '').
$info['info_subject']; $info['info_subject'];
$view = Link::view('infolog',$info['info_id']); $view = Link::view('infolog',$info['info_id']);
$size = null; $size = null;

View File

@ -704,7 +704,7 @@ class infolog_ui
} }
elseif ($own_referer === '') elseif ($own_referer === '')
{ {
$own_referer = common::get_referer(); $own_referer = Api\Header\Referer::get();
if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false) if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false)
{ {
$own_referer = Api\Cache::getSession('infolog', 'own_session'); $own_referer = Api\Cache::getSession('infolog', 'own_session');
@ -787,9 +787,9 @@ class infolog_ui
} }
if (!$action) if (!$action)
{ {
$action = is_array($values) && $values['action'] ? $values['action'] : get_var('action',array('POST','GET')); $action = is_array($values) && $values['action'] ? $values['action'] : $_REQUEST['action'];
$action_id = is_array($values) && $values['action_id'] ? $values['action_id'] : get_var('action_id',array('POST','GET')); $action_id = is_array($values) && $values['action_id'] ? $values['action_id'] : $_REQUEST['action_id'];
$action_title = is_array($values) && $values['action_title'] ? $values['action_title'] : get_var('action_title',array('POST','GET')); $action_title = is_array($values) && $values['action_title'] ? $values['action_title'] : $_REQUEST['action_title'];
} }
//echo "<p>".__METHOD__."(action='$action/$action_id',called_as='$called_as/$values[referer]',own_referer='$own_referer') values=\n"; _debug_array($values); //echo "<p>".__METHOD__."(action='$action/$action_id',called_as='$called_as/$values[referer]',own_referer='$own_referer') values=\n"; _debug_array($values);
if (!is_array($values)) if (!is_array($values))
@ -1881,12 +1881,12 @@ class infolog_ui
else // new call via GET else // new call via GET
{ {
//echo "<p>infolog_ui::edit: info_id=$info_id, action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n"; //echo "<p>infolog_ui::edit: info_id=$info_id, action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
$action = $action ? $action : get_var('action', array('POST','GET')); $action = $action ? $action : $_REQUEST['action'];
$action_id = $action_id ? $action_id : get_var('action_id',array('POST','GET')); $action_id = $action_id ? $action_id : $_REQUEST['action_id'];
$info_id = $content ? $content : get_var('info_id', array('POST','GET')); $info_id = $content ? $content : $_REQUEST['info_id'];
$type = $type ? $type : get_var('type', array('POST','GET')); $type = $type ? $type : $_REQUEST['type'];
$referer = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] : $referer = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] :
common::get_referer('/index.php?menuaction=infolog.infolog_ui.index')); Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer); // remove previou/old msg from referer if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer); // remove previou/old msg from referer
$no_popup = $_GET['no_popup']; $no_popup = $_GET['no_popup'];
$print = (int) $_REQUEST['print']; $print = (int) $_REQUEST['print'];
@ -2360,7 +2360,7 @@ class infolog_ui
{ {
$icon = $this->icons[$cat][$id]; $icon = $this->icons[$cat][$id];
} }
if ($icon && !is_readable(common::get_image_dir() . '/' . $icon)) if ($icon && !Api\Image::find('infolog', $icon))
{ {
$icon = False; $icon = False;
} }

View File

@ -101,7 +101,7 @@ if (isset($_GET['menuaction']))
'no_exception_handler' => true, // we already installed our own 'no_exception_handler' => true, // we already installed our own
// only log ajax requests which represent former GET requests or submits // only log ajax requests which represent former GET requests or submits
// cuts down updates to egw_access_log table // cuts down updates to egw_access_log table
'no_dla_update' => !preg_match('/(\.etemplate_new\.ajax_process_content\.etemplate|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']), 'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']),
) )
); );
include_once('./header.inc.php'); include_once('./header.inc.php');

View File

@ -1213,32 +1213,16 @@ class common
} }
/** /**
* gets an eGW conformat referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function * gets an eGW conformant referer from $_SERVER['HTTP_REFERER'], suitable for direct use in the link function
* *
* @param string $default ='' default to use if referer is not set by webserver or not determinable * @param string $default ='' default to use if referer is not set by webserver or not determinable
* @param string $referer ='' referer string to use, default ('') use $_SERVER['HTTP_REFERER'] * @param string $referer ='' referer string to use, default ('') use $_SERVER['HTTP_REFERER']
* @return string * @return string
* @todo get "real" referer for jDots template * @deprecated use Api\Header\Referer::get
*/ */
static function get_referer($default='',$referer='') static function get_referer($default='',$referer='')
{ {
// HTTP_REFERER seems NOT to get urldecoded return Api\Header\Referer::get($default, $referer);
if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']);
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
if (empty($webserver_url) || $webserver_url{0} == '/') // url is just a path
{
$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer); // removing the domain part
}
if (strlen($webserver_url) > 1)
{
list(,$referer) = explode($webserver_url,$referer,2);
}
$ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer);
if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default;
return $ret;
} }
// some depricated functions for the migration // some depricated functions for the migration