forked from extern/egroupware
use new api in home and portlets
This commit is contained in:
parent
2821c9bf43
commit
38412a1149
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware - Addressbook - A portlet for displaying a list of entries
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package addressbook
|
||||
@ -10,6 +9,11 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Acl;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* The addressbook_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
@ -24,7 +28,7 @@ class addressbook_favorite_portlet extends home_favorite_portlet
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$context['appname'] = 'addressbook';
|
||||
|
||||
|
||||
// Let parent handle the basic stuff
|
||||
parent::__construct($context,$need_reload);
|
||||
|
||||
@ -45,11 +49,11 @@ class addressbook_favorite_portlet extends home_favorite_portlet
|
||||
);
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
$ui = new addressbook_ui();
|
||||
$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(EGW_ACL_READ,lang('All'));
|
||||
$this->context['sel_options']['filter2'] = $ui->get_lists(EGW_ACL_READ,array('' => lang('none')));
|
||||
$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All'));
|
||||
$this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ,array('' => lang('none')));
|
||||
$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
|
||||
|
||||
parent::exec($id, $etemplate);
|
||||
@ -76,7 +80,7 @@ class addressbook_favorite_portlet extends home_favorite_portlet
|
||||
* output is handled by parent.
|
||||
*
|
||||
* @param type $id
|
||||
* @param etemplate_new $etemplate
|
||||
* @param Etemplate $etemplate
|
||||
*/
|
||||
public static function process($values = array())
|
||||
{
|
||||
@ -86,34 +90,33 @@ class addressbook_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
if (!count($values['nm']['selected']) && !$values['nm']['select_all'])
|
||||
{
|
||||
egw_framework::message(lang('You need to select some entries first'));
|
||||
Framework::message(lang('You need to select some entries first'));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Some processing to add values in for links and cats
|
||||
$multi_action = $values['nm']['action'];
|
||||
$success = $failed = $action_msg = null;
|
||||
$success = $failed = $action_msg = $msg = null;
|
||||
if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
|
||||
$success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes']))
|
||||
{
|
||||
$msg .= lang('%1 contact(s) %2',$success,$action_msg);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'success'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
|
||||
foreach($values['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'addressbook::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get addressbook tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
}
|
||||
elseif(is_null($msg))
|
||||
{
|
||||
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
elseif($msg)
|
||||
{
|
||||
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
unset($values['nm']['action']);
|
||||
unset($values['nm']['select_all']);
|
||||
|
@ -1,15 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Egroupware - Addressbook - A portlet for displaying a list of entries
|
||||
/**
|
||||
* Egroupware - Calendar - A portlet for displaying a list of entries
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package addressbook
|
||||
* @package calendar
|
||||
* @subpackage home
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* The addressbook_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
@ -32,7 +36,6 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
|
||||
if($this->favorite['state']['view'] == 'listview')
|
||||
{
|
||||
$ui = new calendar_uilist();
|
||||
$this->context['template'] = 'calendar.list.rows';
|
||||
$this->context['sel_options'] = array();
|
||||
$this->nm_settings += array(
|
||||
@ -55,16 +58,16 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
$need_reload = $reload && $need_reload;
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
|
||||
// Always load app's javascript, so most actions have a chance of working
|
||||
egw_framework::validate_file('.','app',$this->context['appname']);
|
||||
Framework::includeJS('.','app',$this->context['appname']);
|
||||
|
||||
// Always load app's css
|
||||
egw_framework::includeCSS('calendar', 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
|
||||
egw_framework::includeCSS('calendar','app');
|
||||
|
||||
Framework::includeCSS('calendar', 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
|
||||
Framework::includeCSS('calendar','app');
|
||||
|
||||
if($this->favorite['state']['view'] == 'listview' || is_array($this->favorite) && !$this->favorite['state']['view'])
|
||||
{
|
||||
$ui = new calendar_uilist();
|
||||
@ -98,12 +101,9 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
case 'listview':
|
||||
$this->context['sel_options']['filter'] = &$ui->date_filters;
|
||||
$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
|
||||
|
||||
// Early exit
|
||||
return parent::exec($id, $etemplate);
|
||||
|
||||
break;
|
||||
|
||||
case 'planner_user':
|
||||
case 'planner_cat':
|
||||
case 'planner':
|
||||
@ -121,7 +121,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
$etemplate->read('calendar.view');
|
||||
$etemplate->set_dom_id($id);
|
||||
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
|
||||
|
||||
|
||||
$ui->month($this->favorite['state']['view'] == 'month' ?
|
||||
0 :
|
||||
(int)$ui->cal_prefs['multiple_weeks'],
|
||||
@ -150,7 +150,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
|
||||
unset($GLOBALS['egw_info']['flags']['app_header']);
|
||||
// Force loading of CSS
|
||||
egw_framework::include_css_js_response();
|
||||
Framework::include_css_js_response();
|
||||
|
||||
// Set this to calendar so app.js gets initialized
|
||||
$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
@ -184,8 +184,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
* Here we need to handle any incoming data. Setup is done in the constructor,
|
||||
* output is handled by parent.
|
||||
*
|
||||
* @param type $id
|
||||
* @param etemplate_new $etemplate
|
||||
* @param $values =array()
|
||||
*/
|
||||
public static function process($values = array())
|
||||
{
|
||||
@ -195,39 +194,39 @@ class calendar_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
if (!count($values['nm']['selected']) && !$values['nm']['select_all'])
|
||||
{
|
||||
egw_framework::message(lang('You need to select some entries first'));
|
||||
Framework::message(lang('You need to select some entries first'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = $failed = $action_msg = null;
|
||||
$success = $failed = $action_msg = $msg = null;
|
||||
if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
|
||||
$success,$failed,$action_msg,'calendar_list',$msg, $values['nm']['checkboxes']['no_notifications']))
|
||||
{
|
||||
$msg .= lang('%1 event(s) %2',$success,$action_msg);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'success'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
|
||||
foreach($values['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'calendar::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get addressbook tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
}
|
||||
elseif(is_null($msg))
|
||||
{
|
||||
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
elseif($msg)
|
||||
{
|
||||
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
unset($values['nm']['action']);
|
||||
unset($values['nm']['select_all']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* No filters default favorite causes problems with calendar's special state handling,
|
||||
* so just remove it.
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware - Filemanager - A portlet for displaying a list of entries
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package filemanager
|
||||
@ -10,13 +9,16 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Vfs;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* The filemanager_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
*/
|
||||
class filemanager_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct the portlet
|
||||
*
|
||||
@ -24,12 +26,10 @@ class filemanager_favorite_portlet extends home_favorite_portlet
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$context['appname'] = 'filemanager';
|
||||
|
||||
|
||||
// Let parent handle the basic stuff
|
||||
parent::__construct($context,$need_reload);
|
||||
|
||||
$ui = new filemanager_ui();
|
||||
|
||||
$this->nm_settings += array(
|
||||
'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows',
|
||||
'csv_export' => true,
|
||||
@ -45,12 +45,12 @@ class filemanager_favorite_portlet extends home_favorite_portlet
|
||||
'row_modified' => 'mtime',
|
||||
'parent_id' => 'dir',
|
||||
'is_parent' => 'mime',
|
||||
'is_parent_value'=> egw_vfs::DIR_MIME_TYPE,
|
||||
'is_parent_value'=> Vfs::DIR_MIME_TYPE,
|
||||
'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
|
||||
);
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
|
||||
$this->context['sel_options']['filter'] = array(
|
||||
@ -93,7 +93,7 @@ class filemanager_favorite_portlet extends home_favorite_portlet
|
||||
* output is handled by parent.
|
||||
*
|
||||
* @param type $id
|
||||
* @param etemplate_new $etemplate
|
||||
* @param Etemplate $etemplate
|
||||
*/
|
||||
public static function process($content = array())
|
||||
{
|
||||
@ -104,13 +104,13 @@ class filemanager_favorite_portlet extends home_favorite_portlet
|
||||
if ($content['nm']['action'])
|
||||
{
|
||||
$msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
|
||||
if($msg) egw_json_response::get()->apply('egw.message',array($msg));
|
||||
if($msg) Api\Json\Response::get()->apply('egw.message',array($msg));
|
||||
foreach($content['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'filemanager::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get filemanager tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
|
||||
Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package home
|
||||
@ -10,13 +9,16 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* Show birthdays
|
||||
*
|
||||
*/
|
||||
class home_birthday_portlet extends home_portlet {
|
||||
/**
|
||||
class home_birthday_portlet extends home_portlet
|
||||
{
|
||||
/**
|
||||
* Constructor sets up the portlet according to the user's saved property values
|
||||
* for this particular portlet. It is possible to have multiple instances of the
|
||||
* same portlet with different properties.
|
||||
@ -29,6 +31,9 @@
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
unset($need_reload); // not used, but required by function signature
|
||||
if (false) parent::__construct();
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
@ -57,15 +62,15 @@
|
||||
*
|
||||
* @param id String unique ID, provided to the portlet so it can make sure content is
|
||||
* unique, if needed.
|
||||
* @param etemplate etemplate_new Etemplate to generate content
|
||||
* @param etemplate Etemplate Etemplate to generate content
|
||||
*/
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
$content = array();
|
||||
|
||||
$etemplate->read('home.birthdays');
|
||||
|
||||
if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') // calendar config
|
||||
|
||||
if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') // calendar Api\Config
|
||||
{
|
||||
$content = $this->get_birthdays();
|
||||
}
|
||||
@ -79,7 +84,7 @@
|
||||
*/
|
||||
protected function get_birthdays()
|
||||
{
|
||||
$contacts = new addressbook_bo();
|
||||
$contacts = new Api\Contacts();
|
||||
$month_start = date('-m-',$contacts->now_su);
|
||||
$days = $this->context['days'];
|
||||
$birthdays = array();
|
||||
@ -110,6 +115,7 @@
|
||||
unset($month_start); unset($month_end);
|
||||
if ($bdays)
|
||||
{
|
||||
$ab_lang_loaded = 0;
|
||||
for($n = 0; $n <= $days; ++$n)
|
||||
{
|
||||
$day = date('-m-d',$contacts->now_su+$n*24*3600);
|
||||
@ -117,7 +123,7 @@
|
||||
{
|
||||
if(substr($contact['bday'],-6) == $day)
|
||||
{
|
||||
if (!$ab_lang_loaded++) $GLOBALS['egw']->translation->add_app('addressbook');
|
||||
if (!$ab_lang_loaded++) Api\Translation::add_app('addressbook');
|
||||
switch($n)
|
||||
{
|
||||
case 0:
|
||||
@ -130,7 +136,7 @@
|
||||
list($y,$m,$d) = explode('-',$contact['bday']);
|
||||
if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = '';
|
||||
$text = lang("In %1 days (%2) is %3's birthday.",$n,
|
||||
$GLOBALS['egw']->common->dateformatorder($y,$m,$d,true),
|
||||
common::dateformatorder($y,$m,$d,true),
|
||||
$contact['n_given'].' '.$contact['n_family']);
|
||||
break;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
/***
|
||||
* EGroupware - Home - A simple portlet for displaying a list of entries
|
||||
*
|
||||
* @link www.egroupware.org
|
||||
@ -11,6 +11,10 @@
|
||||
* @version $Id: class.home_list_portlet.inc.php 49321 2014-11-06 21:40:03Z nathangray $
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
|
||||
/**
|
||||
* The home_favorite_portlet uses a nextmatch to display the entries for a particular
|
||||
@ -26,10 +30,10 @@ class home_favorite_portlet extends home_portlet
|
||||
'appname' => '',
|
||||
'favorite' => 'blank'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Nextmatch settings
|
||||
* @see etemplate_widget_nextmatch
|
||||
* @see Etemplate\Widget\Nextmatch
|
||||
* @var array
|
||||
*/
|
||||
protected $nm_settings = array(
|
||||
@ -55,6 +59,8 @@ class home_favorite_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// Process dropped data (Should be [appname => <appname>, id => <favorite ID>]) into something useable
|
||||
if($context['dropped_data'])
|
||||
{
|
||||
@ -67,7 +73,7 @@ class home_favorite_portlet extends home_portlet
|
||||
}
|
||||
|
||||
unset($context['dropped_data']);
|
||||
|
||||
|
||||
$need_reload = true;
|
||||
}
|
||||
// Favorite not set for new widgets created via context menu
|
||||
@ -76,14 +82,14 @@ class home_favorite_portlet extends home_portlet
|
||||
// Set initial size to 6x3, default is way too small
|
||||
$context['width'] = max($context['width'], 6);
|
||||
$context['height'] = max($context['height'], 3);
|
||||
|
||||
|
||||
$need_reload = true;
|
||||
}
|
||||
|
||||
// Load and copy favorite
|
||||
if($context['favorite'] && !is_array($context['favorite']))
|
||||
{
|
||||
$favorites = egw_favorites::get_favorites($context['appname']);
|
||||
$favorites = Framework\Favorites::get_favorites($context['appname']);
|
||||
$context['favorite'] = $favorites[$context['favorite']];
|
||||
$need_reload = true;
|
||||
}
|
||||
@ -101,13 +107,14 @@ class home_favorite_portlet extends home_portlet
|
||||
}
|
||||
$this->nm_settings['columnselection_pref'] = "nextmatch-home.{$this->context['id']}";
|
||||
|
||||
translation::add_app($context['appname']);
|
||||
Api\Translation::add_app($context['appname']);
|
||||
}
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
if($etemplate == null)
|
||||
{
|
||||
$etemplate = new etemplate_new();
|
||||
$etemplate = new Etemplate();
|
||||
}
|
||||
$etemplate->read('home.favorite');
|
||||
|
||||
@ -121,11 +128,11 @@ class home_favorite_portlet extends home_portlet
|
||||
|
||||
|
||||
// Always load app's css
|
||||
egw_framework::includeCSS($this->context['appname'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
|
||||
egw_framework::includeCSS($this->context['appname'],'app');
|
||||
Framework::includeCSS($this->context['appname'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
|
||||
Framework::includeCSS($this->context['appname'],'app');
|
||||
|
||||
// Always load app's javascript, so most actions have a chance of working
|
||||
egw_framework::validate_file('.','app',$this->context['appname']);
|
||||
Framework::includeJS('.','app',$this->context['appname']);
|
||||
|
||||
// Set this so app's JS gets initialized
|
||||
$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
@ -138,19 +145,21 @@ class home_favorite_portlet extends home_portlet
|
||||
|
||||
public static function process($content = array())
|
||||
{
|
||||
unset($content); // not used, but required by function signature
|
||||
|
||||
// We need to keep the template going, thanks.
|
||||
etemplate_widget::setElementAttribute('','','');
|
||||
Etemplate\Widget::setElementAttribute('','','');
|
||||
}
|
||||
|
||||
public function get_actions(){
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Some descriptive information about the portlet, so that users can decide if
|
||||
* they want it or not, and for inclusion in lists, hover text, etc.
|
||||
*
|
||||
* These should be already translated, no further translation will be done.
|
||||
* These should be already translated, no further Api\Translation will be done.
|
||||
*
|
||||
* @return Array with keys
|
||||
* - displayName: Used in lists
|
||||
@ -171,7 +180,7 @@ class home_favorite_portlet extends home_portlet
|
||||
* Settings should be in the same style as for preferences. It is OK to return an empty array
|
||||
* for no customizable settings.
|
||||
*
|
||||
* These should be already translated, no further translation will be done.
|
||||
* These should be already translated, no further Api\Translation will be done.
|
||||
*
|
||||
* @see preferences/inc/class.preferences_settings.inc.php
|
||||
* @return Array of settings. Each setting should have the following keys:
|
||||
@ -184,7 +193,7 @@ class home_favorite_portlet extends home_portlet
|
||||
public function get_properties()
|
||||
{
|
||||
$properties = parent::get_properties();
|
||||
$favorites = egw_favorites::get_favorites($this->context['appname']);
|
||||
$favorites = Framework\Favorites::get_favorites($this->context['appname']);
|
||||
$favorite_list = array();
|
||||
foreach($favorites as $id => $favorite)
|
||||
{
|
||||
|
@ -11,6 +11,9 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
class home_legacy_portlet extends home_portlet
|
||||
{
|
||||
|
||||
@ -18,33 +21,36 @@ class home_legacy_portlet extends home_portlet
|
||||
* Context for this portlet
|
||||
*/
|
||||
protected $context = array();
|
||||
|
||||
|
||||
/**
|
||||
* Custom title from hook
|
||||
*/
|
||||
protected $title = 'Legacy';
|
||||
|
||||
|
||||
/**
|
||||
* @var String Content generated by hook
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
|
||||
public function __construct(array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
unset($need_reload); // not used, but required by function signature
|
||||
if (false) parent::__construct();
|
||||
|
||||
$this->context = $context;
|
||||
|
||||
|
||||
// Try to load content here, so all needed info is available
|
||||
$appname = $this->context['app'];
|
||||
if(!$appname || !$GLOBALS['egw']->hooks->hook_exists('home', $appname))
|
||||
if(!$appname || !Api\Hooks::exists('home', $appname))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Set a fallback title for if we can't extract it
|
||||
$this->title = lang($this->context['app']);
|
||||
|
||||
|
||||
// Execute hook to get content
|
||||
ob_start();
|
||||
$_content = $GLOBALS['egw']->hooks->single('home',$appname);
|
||||
$_content = Api\Hooks::single('home',$appname);
|
||||
if (!$_content || $_content == 1) // content has been echoed and not returned
|
||||
{
|
||||
$_content = ob_get_contents();
|
||||
@ -57,24 +63,23 @@ class home_legacy_portlet extends home_portlet
|
||||
libxml_use_internal_errors(true);
|
||||
$dom->loadHTML($_content,LIBXML_NOWARNING + LIBXML_NOERROR);
|
||||
$finder = new DOMXPath($dom);
|
||||
|
||||
|
||||
// Find header for title
|
||||
$title = $finder->query("//div[contains(@class,'divSideboxHeader')]/descendant::strong");
|
||||
if($title->length)
|
||||
{
|
||||
$this->title = $title->item(0)->textContent;
|
||||
}
|
||||
|
||||
|
||||
// Remove header
|
||||
$content = $finder->query("//div[contains(@class,'divSideboxHeader')]/descendant::strong/ancestor::tr");
|
||||
for($i = 0; $i < $content->length; $i++)
|
||||
{
|
||||
$content->item($i)->parentNode->removeChild($content->item($i));
|
||||
}
|
||||
|
||||
|
||||
// Content remains
|
||||
$content = $dom->saveHTML();
|
||||
$this->content = $content;
|
||||
$this->content = $dom->saveHTML();
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +95,7 @@ class home_legacy_portlet extends home_portlet
|
||||
* unique, if needed.
|
||||
* @return string HTML fragment for display
|
||||
*/
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
$etemplate->read('home.legacy');
|
||||
|
||||
@ -119,4 +124,3 @@ class home_legacy_portlet extends home_portlet
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -11,6 +11,11 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api\Link;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Vfs;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* A single entry is displayed with its application icon and title
|
||||
*/
|
||||
@ -46,6 +51,8 @@ class home_link_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// Process dropped data into something useable
|
||||
if($context['dropped_data'])
|
||||
{
|
||||
@ -53,9 +60,9 @@ class home_link_portlet extends home_portlet
|
||||
unset($context['dropped_data']);
|
||||
$need_reload = true;
|
||||
}
|
||||
if($context['entry'] && is_array($context['entry']));
|
||||
if($context['entry'] && is_array($context['entry']))
|
||||
{
|
||||
$this->title = $context['entry']['title'] = egw_link::title($context['entry']['app'], $context['entry']['id']);
|
||||
$this->title = $context['entry']['title'] = Link::title($context['entry']['app'], $context['entry']['id']);
|
||||
|
||||
// Reload to get the latest title
|
||||
// TODO: This is a performance hit, it would be good to do this less
|
||||
@ -90,7 +97,7 @@ class home_link_portlet extends home_portlet
|
||||
* @param id String unique ID, provided to the portlet so it can make sure content is
|
||||
* unique, if needed.
|
||||
*/
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
// Check for custom template for app
|
||||
$custom_template = false;
|
||||
@ -107,7 +114,7 @@ class home_link_portlet extends home_portlet
|
||||
|
||||
|
||||
$etemplate->set_dom_id($id);
|
||||
|
||||
|
||||
$content = array(
|
||||
'image' => $this->image
|
||||
);
|
||||
@ -117,9 +124,9 @@ class home_link_portlet extends home_portlet
|
||||
{
|
||||
|
||||
// Always load app's css
|
||||
egw_framework::includeCSS($this->context['entry']['app'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
|
||||
egw_framework::includeCSS($this->context['entry']['app'],'app');
|
||||
|
||||
Framework::includeCSS($this->context['entry']['app'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
|
||||
Framework::includeCSS($this->context['entry']['app'],'app');
|
||||
|
||||
try
|
||||
{
|
||||
$classname = $this->context['entry']['app'] . '_egw_record';
|
||||
@ -153,7 +160,7 @@ class home_link_portlet extends home_portlet
|
||||
error_log("Problem loading record " . array2string($this->context['entry']));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
// Set a fallback image
|
||||
if($content['image'] == false)
|
||||
{
|
||||
@ -173,8 +180,8 @@ class home_link_portlet extends home_portlet
|
||||
{
|
||||
$this->context['entry']['app'] = 'file';
|
||||
$this->context['entry']['path'] = $this->context['entry']['title'] = $this->context['entry']['id'];
|
||||
$this->context['entry']['type'] = egw_vfs::mime_content_type($this->context['entry']['id']);
|
||||
$content['image'] = egw_framework::link('/api/thumbnail.php',array('path' => $this->context['entry']['id']));
|
||||
$this->context['entry']['type'] = Vfs::mime_content_type($this->context['entry']['id']);
|
||||
$content['image'] = Framework::link('/api/thumbnail.php',array('path' => $this->context['entry']['id']));
|
||||
}
|
||||
|
||||
$content += $this->context;
|
||||
@ -193,7 +200,7 @@ class home_link_portlet extends home_portlet
|
||||
* Settings should be in the same style as for preferences. It is OK to return an empty array
|
||||
* for no customizable settings.
|
||||
*
|
||||
* These should be already translated, no further translation will be done.
|
||||
* These should be already translated, no further Api\Translation will be done.
|
||||
*
|
||||
* @see preferences/inc/class.preferences_settings.inc.php
|
||||
* @return Array of settings. Each setting should have the following keys:
|
||||
|
@ -11,6 +11,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api\Vfs;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* The home_list_portlet uses the link system and its associated link-list widget
|
||||
@ -38,6 +40,8 @@ class home_list_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
if(!is_array($context['list'])) $context['list'] = array();
|
||||
|
||||
// Process dropped data (Should be GUIDs) into something useable
|
||||
@ -65,7 +69,7 @@ class home_list_portlet extends home_portlet
|
||||
if($item['app'] == 'filemanager' || $item['app'] == 'file')
|
||||
{
|
||||
$item['app'] = 'file';
|
||||
$item['type'] = egw_vfs::mime_content_type($item['id']);
|
||||
$item['type'] = Vfs::mime_content_type($item['id']);
|
||||
|
||||
// Always reload...
|
||||
$need_reload = true;
|
||||
@ -78,7 +82,7 @@ class home_list_portlet extends home_portlet
|
||||
* Some descriptive information about the portlet, so that users can decide if
|
||||
* they want it or not, and for inclusion in lists, hover text, etc.
|
||||
*
|
||||
* These should be already translated, no further translation will be done.
|
||||
* These should be already translated, no further Api\Translation will be done.
|
||||
*
|
||||
* @return Array with keys
|
||||
* - displayName: Used in lists
|
||||
@ -101,7 +105,7 @@ class home_list_portlet extends home_portlet
|
||||
* unique, if needed.
|
||||
* @return string HTML fragment for display
|
||||
*/
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
$etemplate->read('home.list');
|
||||
|
||||
@ -119,7 +123,7 @@ class home_list_portlet extends home_portlet
|
||||
{
|
||||
$list['app'] = 'file';
|
||||
$list['path'] = $list['title'] = $list['icon'] = $list['id'];
|
||||
$list['type'] = egw_vfs::mime_content_type($list['id']);
|
||||
$list['type'] = Vfs::mime_content_type($list['id']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +136,7 @@ class home_list_portlet extends home_portlet
|
||||
* Settings should be in the same style as for preferences. It is OK to return an empty array
|
||||
* for no customizable settings.
|
||||
*
|
||||
* These should be already translated, no further translation will be done.
|
||||
* These should be already translated, no further Api\Translation will be done.
|
||||
*
|
||||
* @see preferences/inc/class.preferences_settings.inc.php
|
||||
* @return Array of settings. Each setting should have the following keys:
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package home
|
||||
@ -10,6 +9,9 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* A simple HTML note-to-self
|
||||
*
|
||||
@ -24,12 +26,14 @@ class home_note_portlet extends home_portlet
|
||||
public $public_functions = array(
|
||||
'edit' => true
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Context for this portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// Title not set for new widgets created via context menu
|
||||
if(!$context['title'])
|
||||
{
|
||||
@ -39,7 +43,7 @@ class home_note_portlet extends home_portlet
|
||||
|
||||
$need_reload = true;
|
||||
}
|
||||
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
@ -54,34 +58,31 @@ class home_note_portlet extends home_portlet
|
||||
|
||||
if($content['group'] && $GLOBALS['egw_info']['apps']['admin'])
|
||||
{
|
||||
$prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
|
||||
$prefs = new Api\Preferences(is_numeric($content['group']) ? $content['group'] : $GLOBALS['egw_info']['user']['account_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$prefs = $GLOBALS['egw']->preferences;
|
||||
}
|
||||
$type = is_numeric($group) ? "user" : $group;
|
||||
$portlets = $prefs->read_repository();
|
||||
$portlets = $portlets['home'];
|
||||
$type = is_numeric($content['group']) ? "user" : $content['group'];
|
||||
$arr = $prefs->read_repository();
|
||||
$portlets = $arr['home'];
|
||||
if($content['button'])
|
||||
{
|
||||
// Save updated preferences
|
||||
// Save updated Api\Preferences
|
||||
$portlets[$id]['note'] = $content['note'];
|
||||
$prefs->add('home', $id, $portlets[$id],$type);
|
||||
$prefs->save_repository(True,$type);
|
||||
// Yay for AJAX submit
|
||||
egw_json_response::get()->apply('window.opener.app.home.refresh',array($id));
|
||||
|
||||
Api\Json\Response::get()->apply('window.opener.app.home.refresh',array($id));
|
||||
|
||||
if(key($content['button'])=='save')
|
||||
{
|
||||
egw_json_response::get()->apply('window.close',array());
|
||||
Api\Json\Response::get()->apply('window.close',array());
|
||||
}
|
||||
}
|
||||
$etemplate = new etemplate_new('home.note');
|
||||
$etemplate = new Etemplate('home.note');
|
||||
|
||||
$content = array(
|
||||
'note' => $portlets[$id]['note']
|
||||
);
|
||||
$etemplate->setElementAttribute('note', 'width', '99%');
|
||||
$etemplate->setElementAttribute('note', 'height', $height);
|
||||
$preserve = array(
|
||||
@ -89,10 +90,12 @@ class home_note_portlet extends home_portlet
|
||||
'height' => $height,
|
||||
'group' => $portlets[$id]['group']
|
||||
);
|
||||
$etemplate->exec('home.home_note_portlet.edit',$content, array(),array('note'=>false,'save'=>false), $preserve);
|
||||
$etemplate->exec('home.home_note_portlet.edit',array(
|
||||
'note' => $portlets[$id]['note']
|
||||
), array(),array('note'=>false,'save'=>false), $preserve);
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
// Allow to submit directly back here
|
||||
if(is_array($id) && $id['id'])
|
||||
@ -107,7 +110,7 @@ class home_note_portlet extends home_portlet
|
||||
if(!$content['note'])
|
||||
{
|
||||
$content['note'] = '';
|
||||
egw_json_response::get()->apply('app.home.note_edit',array($id));
|
||||
Api\Json\Response::get()->apply('app.home.note_edit',array($id));
|
||||
}
|
||||
|
||||
$etemplate->exec('home.home_note_portlet.exec',$content,array(),array('__ALL__'=>true),array('id' =>$id));
|
||||
|
@ -11,6 +11,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
abstract class home_portlet
|
||||
{
|
||||
/**
|
||||
@ -33,7 +35,7 @@ abstract class home_portlet
|
||||
* @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
|
||||
*/
|
||||
public abstract function __construct(Array &$context = array(), &$need_reload = false);
|
||||
|
||||
|
||||
/**
|
||||
* Some descriptive information about the portlet, so that users can decide if
|
||||
* they want it or not, and for inclusion in lists, hover text, etc.
|
||||
@ -52,9 +54,9 @@ abstract class home_portlet
|
||||
*
|
||||
* @param id String unique ID, provided to the portlet so it can make sure content is
|
||||
* unique, if needed.
|
||||
* @param etemplate etemplate_new Etemplate to generate content
|
||||
* @param Etemplate $etemplate eTemplate to generate content
|
||||
*/
|
||||
public abstract function exec($id = null, etemplate_new &$etemplate = null);
|
||||
public abstract function exec($id = null, Etemplate &$etemplate = null);
|
||||
|
||||
/**
|
||||
* Return a list of settings to customize the portlet.
|
||||
@ -96,7 +98,7 @@ abstract class home_portlet
|
||||
* same id / key to override the default action.
|
||||
*/
|
||||
public abstract function get_actions();
|
||||
|
||||
|
||||
/**
|
||||
* If this portlet can accept, display, or otherwise handle multiple
|
||||
* EgroupWare entries. Used for drag and drop processing. How the entries
|
||||
|
@ -10,6 +10,10 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
class home_tutorial_ui
|
||||
{
|
||||
/**
|
||||
@ -32,15 +36,13 @@ class home_tutorial_ui
|
||||
if (!EGroupware\Api\Hooks::exists('sidebox_all', 'home') ||
|
||||
EGroupware\Api\Hooks::exists('sidebox_all', 'home', true) != 'home_tutorial_ui::tutorial_menu')
|
||||
{
|
||||
$setup_info = array();
|
||||
include(EGW_SERVER_ROOT.'/home/setup/setup.inc.php');
|
||||
$GLOBALS['egw']->hooks->register_hooks('home', $setup_info['home']['hooks']);
|
||||
Api\Hooks::read(true);
|
||||
}
|
||||
|
||||
//Allow youtube frame to pass the CSP check
|
||||
egw_framework::csp_frame_src_attrs(array('https://www.youtube.com'));
|
||||
Api\Header\ContentSecurityPolicy::add('frame-src', array('https://www.youtube.com'));
|
||||
|
||||
$tmpl = new etemplate_new('home.tutorial');
|
||||
$tmpl = new Etemplate('home.tutorial');
|
||||
if (!is_array($content))
|
||||
{
|
||||
// Get tutorial object id
|
||||
@ -92,7 +94,7 @@ class home_tutorial_ui
|
||||
else
|
||||
{
|
||||
$content = array();
|
||||
egw_framework::message(lang('You do not have permission to see this tutorial!'));
|
||||
Framework::message(lang('You do not have permission to see this tutorial!'));
|
||||
}
|
||||
|
||||
$tmpl->exec('home.home_tutorial_ui.popup', $content, $sel_options, array(), array(), 2);
|
||||
@ -103,7 +105,7 @@ class home_tutorial_ui
|
||||
*/
|
||||
function ajax_data()
|
||||
{
|
||||
$response = egw_json_response::get();
|
||||
$response = Api\Json\Response::get();
|
||||
$response->data(json_decode(self::getJsonData()));
|
||||
}
|
||||
|
||||
@ -114,13 +116,13 @@ class home_tutorial_ui
|
||||
*/
|
||||
static function getJsonData()
|
||||
{
|
||||
if (!($json = egw_cache::getCache(egw_cache::TREE, 'home', 'egw_tutorial_json')))
|
||||
if (!($json = Api\Cache::getCache(Api\Cache::TREE, 'home', 'egw_tutorial_json')))
|
||||
{
|
||||
$json = file_get_contents('http://www.egroupware.de/videos/tutorials.json');
|
||||
// Fallback tutorials.json
|
||||
if (!$json) $json = file_get_contents('home/setup/tutorials.json');
|
||||
// Cache the json object for two hours
|
||||
egw_cache::setCache(egw_cache::TREE, 'home', 'egw_tutorial_json', $json, 7200);
|
||||
Api\Cache::setCache(Api\Cache::TREE, 'home', 'egw_tutorial_json', $json, 7200);
|
||||
}
|
||||
|
||||
return $json;
|
||||
@ -132,7 +134,7 @@ class home_tutorial_ui
|
||||
*/
|
||||
public static function tutorial_menu()
|
||||
{
|
||||
if (html::$ua_mobile) return;
|
||||
if (Api\Header\UserAgent::mobile()) return;
|
||||
$tutorials = json_decode(self::getJsonData(),true);
|
||||
$appname = $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
if (!is_array($tutorials[$appname])) return false;
|
||||
|
@ -10,6 +10,10 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* General user interface object of the Home app
|
||||
*
|
||||
@ -37,9 +41,9 @@ class home_ui
|
||||
self::setup_default_home();
|
||||
|
||||
// CSS for Gridster grid layout
|
||||
egw_framework::includeCSS('/api/js/jquery/gridster/jquery.gridster.css');
|
||||
Framework::includeCSS('/api/js/jquery/gridster/jquery.gridster.css');
|
||||
|
||||
$template = new etemplate_new('home.index');
|
||||
$template = new Etemplate('home.index');
|
||||
|
||||
// Get a list of portlets
|
||||
$content = array(
|
||||
@ -51,13 +55,13 @@ class home_ui
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = 'home';
|
||||
|
||||
// Main screen message
|
||||
translation::add_app('mainscreen');
|
||||
$greeting = translation::translate('mainscreen_message',false,'');
|
||||
Api\Translation::add_app('mainscreen');
|
||||
$greeting = Api\Translation::translate('mainscreen_message',false,'');
|
||||
|
||||
if($greeting == 'mainscreen_message'|| empty($greeting))
|
||||
{
|
||||
translation::add_app('mainscreen','en'); // trying the en one
|
||||
$greeting = translation::translate('mainscreen_message',false,'');
|
||||
Api\Translation::add_app('mainscreen','en'); // trying the en one
|
||||
$greeting = Api\Translation::translate('mainscreen_message',false,'');
|
||||
}
|
||||
if(!($greeting == 'mainscreen_message'|| empty($greeting)))
|
||||
{
|
||||
@ -67,6 +71,7 @@ class home_ui
|
||||
$template->exec('home.home_ui.index', $content);
|
||||
|
||||
// Now run the portlets themselves
|
||||
$attrs = array();
|
||||
foreach($content['portlets'] as $portlet => $p_data)
|
||||
{
|
||||
$id = $p_data['id'];
|
||||
@ -152,7 +157,7 @@ class home_ui
|
||||
* Actual portlet content is provided by each portlet.
|
||||
* @param template etemplate so attributes can be set
|
||||
*/
|
||||
protected function get_user_portlets(etemplate_new &$template)
|
||||
protected function get_user_portlets(Etemplate &$template)
|
||||
{
|
||||
$portlets = array();
|
||||
|
||||
@ -228,9 +233,9 @@ class home_ui
|
||||
|
||||
// This should be set already, but just in case the execution path
|
||||
// is different from normal...
|
||||
if(egw_json_response::isJSONResponse())
|
||||
if(Api\Json\Response::isJSONResponse())
|
||||
{
|
||||
$GLOBALS['egw']->framework->response = egw_json_response::get();
|
||||
$GLOBALS['egw']->framework->response = Api\Json\Response::get();
|
||||
}
|
||||
|
||||
$classname = $context['class'];
|
||||
@ -239,7 +244,7 @@ class home_ui
|
||||
$desc = $portlet->get_description();
|
||||
|
||||
// Pre-set up etemplate so it only needs done once
|
||||
$etemplate = new etemplate_new();
|
||||
$etemplate = new Etemplate();
|
||||
|
||||
// Exclude common attributes changed through UI and settings lacking a type
|
||||
$settings = $portlet->get_properties();
|
||||
@ -285,7 +290,7 @@ class home_ui
|
||||
$appname = $app;
|
||||
}
|
||||
}
|
||||
egw_framework::validate_file('', $classname, $appname ? $appname : 'home');
|
||||
Framework::includeJS('', $classname, $appname ? $appname : 'home');
|
||||
|
||||
if($full_exec)
|
||||
{
|
||||
@ -320,7 +325,7 @@ class home_ui
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($no_pref || !$GLOBALS['egw']->hooks->hook_exists('home', $appname))
|
||||
if($no_pref || !Api\Hooks::exists('home', $appname))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -344,7 +349,7 @@ class home_ui
|
||||
*/
|
||||
protected function get_portlet_list()
|
||||
{
|
||||
$list = egw_cache::getTree('home', 'portlet_classes', function() {
|
||||
$list = Api\Cache::getTree('home', 'portlet_classes', function() {
|
||||
$list = array();
|
||||
$classes = array();
|
||||
|
||||
@ -411,7 +416,7 @@ class home_ui
|
||||
}, array(), 60);
|
||||
|
||||
// Filter list by current user's permissions
|
||||
foreach($list as $appname => $children)
|
||||
foreach(array_keys($list) as $appname)
|
||||
{
|
||||
if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
|
||||
if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
|
||||
@ -457,11 +462,11 @@ class home_ui
|
||||
// If it's a group, we'd like to know which
|
||||
if($location == 'group')
|
||||
{
|
||||
$options = array('account_type' => $type);
|
||||
$groups = accounts::link_query('',$options);
|
||||
foreach($groups as $gid => $name)
|
||||
$options = array('account_type' => 'groups');
|
||||
$groups = Api\Accounts::link_query('',$options);
|
||||
foreach(array_keys($groups) as $gid)
|
||||
{
|
||||
$prefs = new preferences($gid);
|
||||
$prefs = new Api\Preferences($gid);
|
||||
$prefs->read_repository();
|
||||
if (isset($prefs->user['home'][$portlet_id]))
|
||||
{
|
||||
@ -472,7 +477,7 @@ class home_ui
|
||||
}
|
||||
$actions['remove_default_'.$location] = array(
|
||||
'type' => 'popup',
|
||||
'caption' => lang('Remove as default for %1',is_numeric($location) ? accounts::id2name($location,'account_fullname') : $location),
|
||||
'caption' => lang('Remove as default for %1',is_numeric($location) ? Api\Accounts::id2name($location,'account_fullname') : $location),
|
||||
'onExecute' => 'javaScript:app.home.set_default',
|
||||
'group' => 'Admins',
|
||||
'portlet_group' => $location
|
||||
@ -526,7 +531,7 @@ class home_ui
|
||||
}
|
||||
if($group && $GLOBALS['egw_info']['user']['apps']['admin'])
|
||||
{
|
||||
$prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
|
||||
$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -536,7 +541,7 @@ class home_ui
|
||||
|
||||
$prefs->read_repository();
|
||||
|
||||
$response = egw_json_response::get();
|
||||
$response = Api\Json\Response::get();
|
||||
|
||||
if($values =='~reload~')
|
||||
{
|
||||
@ -588,6 +593,7 @@ class home_ui
|
||||
$add = true;
|
||||
$classname = substr($classname, 4);
|
||||
}
|
||||
$content = null;
|
||||
$portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec);
|
||||
|
||||
$context['class'] = get_class($portlet);
|
||||
@ -637,7 +643,7 @@ class home_ui
|
||||
// Load the appropriate group
|
||||
if($group)
|
||||
{
|
||||
$prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
|
||||
$prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -651,7 +657,7 @@ class home_ui
|
||||
{
|
||||
foreach($portlet_ids as $id)
|
||||
{
|
||||
egw_json_response::get()->call('egw.message', lang("Set default"));
|
||||
Api\Json\Response::get()->call('egw.message', lang("Set default"));
|
||||
// Current user is setting the default, copy their settings
|
||||
$settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id];
|
||||
$settings['group'] = $group;
|
||||
@ -666,16 +672,16 @@ class home_ui
|
||||
{
|
||||
foreach($portlet_ids as $id)
|
||||
{
|
||||
egw_json_response::get()->call('egw.message', lang("Removed default"));
|
||||
Api\Json\Response::get()->call('egw.message', lang("Removed default"));
|
||||
$prefs->delete('home',$id, $type);
|
||||
}
|
||||
}
|
||||
$prefs->save_repository(false,$type);
|
||||
|
||||
// Update preferences client side for consistency
|
||||
// Update Api\Preferences client side for consistency
|
||||
$prefs = $GLOBALS['egw']->preferences;
|
||||
$pref = $prefs->read_repository();
|
||||
egw_json_response::get()->call('egw.set_preferences', (array)$pref['home'], 'home');
|
||||
Api\Json\Response::get()->call('egw.set_preferences', (array)$pref['home'], 'home');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -697,12 +703,12 @@ class home_ui
|
||||
$lang = $preferences->default['common']['lang'];
|
||||
if (empty($lang)) $lang = 'en';
|
||||
|
||||
translation::add_app('calendar', $lang);
|
||||
Api\Translation::add_app('calendar', $lang);
|
||||
$weekview = lang('Weekview');
|
||||
|
||||
if ($GLOBALS['egw_info']['apps']['news_admin'])
|
||||
{
|
||||
$cats = new categories('', 'news_admin');
|
||||
$cats = new Api\Categories('', 'news_admin');
|
||||
$cat_id_egw_org_news = $cats->name2id('egroupware.org');
|
||||
}
|
||||
|
||||
@ -776,12 +782,12 @@ class home_ui
|
||||
{
|
||||
foreach($prefs as $name => $value)
|
||||
{
|
||||
preferences::delete_preference($app, $name, 'default');
|
||||
Api\Preferences::delete_preference($app, $name, 'default');
|
||||
$preferences->add($app, $name, $value, 'default');
|
||||
}
|
||||
}
|
||||
// remove tutorial from home, as it is now in sidebox
|
||||
preferences::delete_preference('home', 'portlet_setup142t', 'default');
|
||||
Api\Preferences::delete_preference('home', 'portlet_setup142t', 'default');
|
||||
$preferences->delete('home', 'portlet_setup142t', 'default');
|
||||
|
||||
// assigning saved preferences to egw_info, which is used for this request
|
||||
@ -802,7 +808,7 @@ class home_ui
|
||||
|
||||
default:
|
||||
call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION)));
|
||||
config::save_value(self::HOME_VERSION, self::CURRENT_HOME_VERSION, 'phpgwapi');
|
||||
Api\Config::save_value(self::HOME_VERSION, self::CURRENT_HOME_VERSION, 'phpgwapi');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware Weather widget
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package home
|
||||
@ -10,6 +9,10 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* Widget displaying the weather
|
||||
*
|
||||
@ -33,6 +36,8 @@ class home_weather_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// City not set for new widgets created via context menu
|
||||
if(!$context['city'] || $context['height'] < 2)
|
||||
{
|
||||
@ -42,11 +47,11 @@ class home_weather_portlet extends home_portlet
|
||||
}
|
||||
|
||||
$need_reload = true;
|
||||
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
// Allow to submit directly back here
|
||||
if(is_array($id) && $id['id'])
|
||||
@ -82,11 +87,11 @@ class home_weather_portlet extends home_portlet
|
||||
// Caching is best done by city ID, so store that
|
||||
if($content['city_id'] && (!$this->context['city_id'] || $content['city_id'] != $this->context['city_id']))
|
||||
{
|
||||
|
||||
$portlets = $GLOBALS['egw']->preferences->read_repository();
|
||||
$portlets = $portlets['home'];
|
||||
|
||||
// Save updated preferences
|
||||
$arr = $GLOBALS['egw']->preferences->read_repository();
|
||||
$portlets = $arr['home'];
|
||||
|
||||
// Save updated Api\Preferences
|
||||
$portlets[$id]['city_id'] = $content['city_id'];
|
||||
$this->context['city'] = $portlets[$id]['city'] = $content['settings']['city'] =
|
||||
$content['settings']['title'] = $content['city'] = is_array($content['city']) ? $content['city']['name'] : $content['city'];
|
||||
@ -111,11 +116,11 @@ class home_weather_portlet extends home_portlet
|
||||
{
|
||||
$content['current']['no_current_temp'] = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Direct to full forecast page
|
||||
$content['attribution'] ='http://openweathermap.org/city/'.$content['city_id'];
|
||||
|
||||
|
||||
$etemplate->exec('home.home_weather_portlet.exec',$content,array(),array('__ALL__'=>true),array('id' =>$id));
|
||||
}
|
||||
|
||||
@ -136,7 +141,8 @@ class home_weather_portlet extends home_portlet
|
||||
{
|
||||
$query['APPID'] = self::API_KEY;
|
||||
}
|
||||
$data = egw_cache::getTree('home', json_encode($query), function($query) use(&$clear_cache) {
|
||||
$data = Api\Cache::getTree('home', json_encode($query), function($query)
|
||||
{
|
||||
$debug = false;
|
||||
if($debug) error_log('Fetching fresh data from ' . static::API_URL);
|
||||
|
||||
@ -158,7 +164,7 @@ class home_weather_portlet extends home_portlet
|
||||
if($debug)
|
||||
{
|
||||
error_log(__METHOD__ .' weather info:');
|
||||
foreach($data as $key => $val)
|
||||
foreach(array_keys($data) as $key)
|
||||
{
|
||||
error_log($key . ': ' .array2string($data[$key]));
|
||||
}
|
||||
@ -166,7 +172,7 @@ class home_weather_portlet extends home_portlet
|
||||
if(is_string($data['message']))
|
||||
{
|
||||
$desc = $this->get_description();
|
||||
egw_framework::message($desc['displayName'] . ': ' . $desc['title'] . "\n".$data['message'], 'warning');
|
||||
Framework::message($desc['displayName'] . ': ' . $desc['title'] . "\n".$data['message'], 'warning');
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -181,11 +187,11 @@ class home_weather_portlet extends home_portlet
|
||||
if($data['list'])
|
||||
{
|
||||
$massage =& $data['list'];
|
||||
|
||||
|
||||
for($i = 0; $i < min(count($massage), $this->context['width']); $i++)
|
||||
{
|
||||
$forecast =& $massage[$i];
|
||||
$forecast['day'] = egw_time::to($forecast['dt'],'l');
|
||||
$forecast['day'] = Api\DateTime::to($forecast['dt'],'l');
|
||||
self::format_forecast($forecast);
|
||||
}
|
||||
// Chop data to fit into portlet
|
||||
|
@ -21,9 +21,6 @@ $GLOBALS['egw_info'] = array(
|
||||
include('../header.inc.php');
|
||||
$GLOBALS['egw_info']['flags']['nonavbar']=false;
|
||||
|
||||
// check and if neccessary force user to chane password
|
||||
auth::check_password_age('home','index');
|
||||
|
||||
// Home is treated specially, so a redirect won't work.
|
||||
$home = new home_ui();
|
||||
echo $home->index();
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware - Infolog - A portlet for displaying a list of portlet entries
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package infolog
|
||||
@ -10,6 +9,10 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* The infolog_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
@ -27,7 +30,7 @@ class infolog_favorite_portlet extends home_favorite_portlet
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$context['appname'] = 'infolog';
|
||||
|
||||
|
||||
// Let parent handle the basic stuff
|
||||
parent::__construct($context,$need_reload);
|
||||
|
||||
@ -66,7 +69,7 @@ class infolog_favorite_portlet extends home_favorite_portlet
|
||||
// Make sure we pass the type check
|
||||
if ($query['col_filter']['info_type'])
|
||||
{
|
||||
$tpl = new etemplate_new;
|
||||
$tpl = new Etemplate;
|
||||
if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type']))
|
||||
{
|
||||
$query['template'] = $tpl->name;
|
||||
@ -80,13 +83,12 @@ class infolog_favorite_portlet extends home_favorite_portlet
|
||||
unset($GLOBALS['egw_info']['flags']['app_header']);
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Here we need to handle any incoming data. Setup is done in the constructor,
|
||||
* output is handled by parent.
|
||||
*
|
||||
* @param type $id
|
||||
* @param etemplate_new $etemplate
|
||||
* @param $values =array()
|
||||
*/
|
||||
public static function process($values = array())
|
||||
{
|
||||
@ -96,7 +98,7 @@ class infolog_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
if (!count($values['nm']['selected']) && !$values['nm']['select_all'])
|
||||
{
|
||||
egw_framework::message(lang('You need to select some entries first'));
|
||||
Framework::message(lang('You need to select some entries first'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,28 +129,28 @@ class infolog_favorite_portlet extends home_favorite_portlet
|
||||
unset($values[$multi_action.'_popup']);
|
||||
unset($values[$multi_action]);
|
||||
}
|
||||
$success = $failed = $action_msg = null;
|
||||
$success = $failed = $action_msg = $msg = null;
|
||||
if ($ui->action($values['nm']['multi_action'], $values['nm']['selected'], $values['nm']['select_all'],
|
||||
$success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications']))
|
||||
{
|
||||
$msg .= lang('%1 entries %2',$success,$action_msg);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'success'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
|
||||
foreach($values['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'infolog::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get infolog tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
|
||||
}
|
||||
elseif(is_null($msg))
|
||||
{
|
||||
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
elseif($msg)
|
||||
{
|
||||
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
unset($values['nm']['multi_action']);
|
||||
unset($values['nm']['select_all']);
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
/**
|
||||
* Egroupware - Resources - A portlet for displaying a list of entries
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package resources
|
||||
@ -10,13 +9,16 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Acl;
|
||||
use EGroupware\Api\Etemplate;
|
||||
|
||||
/**
|
||||
* The resources_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
*/
|
||||
class resources_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct the portlet
|
||||
*
|
||||
@ -24,12 +26,10 @@ class resources_favorite_portlet extends home_favorite_portlet
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$context['appname'] = 'resources';
|
||||
|
||||
|
||||
// Let parent handle the basic stuff
|
||||
parent::__construct($context,$need_reload);
|
||||
|
||||
$ui = new resources_ui();
|
||||
|
||||
$this->context['template'] = 'resources.show.rows';
|
||||
$this->nm_settings += array(
|
||||
'get_rows' => 'resources.resources_bo.get_rows',
|
||||
@ -48,11 +48,11 @@ class resources_favorite_portlet extends home_favorite_portlet
|
||||
);
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
public function exec($id = null, Etemplate &$etemplate = null)
|
||||
{
|
||||
$ui = new resources_ui();
|
||||
|
||||
$this->context['sel_options']['filter']= array(''=>lang('all categories'))+(array)$ui->bo->acl->get_cats(EGW_ACL_READ);
|
||||
$this->context['sel_options']['filter']= array(''=>lang('all categories'))+(array)$ui->bo->acl->get_cats(Acl::READ);
|
||||
$this->context['sel_options']['filter2'] = resources_bo::$filter_options;
|
||||
if(!$content['nm']['filter2'])
|
||||
{
|
||||
@ -67,8 +67,7 @@ class resources_favorite_portlet extends home_favorite_portlet
|
||||
* Here we need to handle any incoming data. Setup is done in the constructor,
|
||||
* output is handled by parent.
|
||||
*
|
||||
* @param type $id
|
||||
* @param etemplate_new $etemplate
|
||||
* @param $content =array()
|
||||
*/
|
||||
public static function process($content = array())
|
||||
{
|
||||
@ -93,7 +92,7 @@ class resources_favorite_portlet extends home_favorite_portlet
|
||||
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
|
||||
{
|
||||
$msg = lang('You need to select some entries first!');
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -103,21 +102,20 @@ class resources_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
$msg .= lang('%1 resource(s) %2',$success,$action_msg);
|
||||
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'success'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
|
||||
foreach($content['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'resources::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get resources tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
|
||||
Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
|
||||
}
|
||||
elseif(empty($msg))
|
||||
{
|
||||
$msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user