use new api in home and portlets

This commit is contained in:
Ralf Becker 2016-04-28 18:06:46 +00:00
parent 2821c9bf43
commit 38412a1149
16 changed files with 266 additions and 218 deletions

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware - Addressbook - A portlet for displaying a list of entries * Egroupware - Addressbook - A portlet for displaying a list of entries
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package addressbook * @package addressbook
@ -10,6 +9,11 @@
* @version $Id$ * @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 * The addressbook_list_portlet uses a nextmatch / favorite
* to display a list of entries. * to display a list of entries.
@ -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(); $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']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All'));
$this->context['sel_options']['filter2'] = $ui->get_lists(EGW_ACL_READ,array('' => lang('none'))); $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']); $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
parent::exec($id, $etemplate); parent::exec($id, $etemplate);
@ -76,7 +80,7 @@ class addressbook_favorite_portlet extends home_favorite_portlet
* output is handled by parent. * output is handled by parent.
* *
* @param type $id * @param type $id
* @param etemplate_new $etemplate * @param Etemplate $etemplate
*/ */
public static function process($values = array()) 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']) 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 else
{ {
// Some processing to add values in for links and cats // Some processing to add values in for links and cats
$multi_action = $values['nm']['action']; $success = $failed = $action_msg = $msg = null;
$success = $failed = $action_msg = null;
if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'], 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'])) $success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes']))
{ {
$msg .= lang('%1 contact(s) %2',$success,$action_msg); $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) foreach($values['nm']['selected'] as &$id)
{ {
$id = 'addressbook::'.$id; $id = 'addressbook::'.$id;
} }
// Directly request an update - this will get addressbook tab too // 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)) elseif(is_null($msg))
{ {
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); $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) elseif($msg)
{ {
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); $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']['action']);
unset($values['nm']['select_all']); unset($values['nm']['select_all']);

View File

@ -1,15 +1,19 @@
<?php <?php
/**
/* * Egroupware - Calendar - A portlet for displaying a list of entries
* Egroupware - Addressbook - A portlet for displaying a list of entries *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package addressbook * @package calendar
* @subpackage home * @subpackage home
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Nathan Gray * @author Nathan Gray
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/** /**
* The addressbook_list_portlet uses a nextmatch / favorite * The addressbook_list_portlet uses a nextmatch / favorite
* to display a list of entries. * to display a list of entries.
@ -32,7 +36,6 @@ class calendar_favorite_portlet extends home_favorite_portlet
if($this->favorite['state']['view'] == 'listview') if($this->favorite['state']['view'] == 'listview')
{ {
$ui = new calendar_uilist();
$this->context['template'] = 'calendar.list.rows'; $this->context['template'] = 'calendar.list.rows';
$this->context['sel_options'] = array(); $this->context['sel_options'] = array();
$this->nm_settings += array( $this->nm_settings += array(
@ -55,15 +58,15 @@ class calendar_favorite_portlet extends home_favorite_portlet
$need_reload = $reload && $need_reload; $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 // 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 // Always load app's css
egw_framework::includeCSS('calendar', 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) || Framework::includeCSS('calendar', 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
egw_framework::includeCSS('calendar','app'); Framework::includeCSS('calendar','app');
if($this->favorite['state']['view'] == 'listview' || is_array($this->favorite) && !$this->favorite['state']['view']) if($this->favorite['state']['view'] == 'listview' || is_array($this->favorite) && !$this->favorite['state']['view'])
{ {
@ -98,12 +101,9 @@ class calendar_favorite_portlet extends home_favorite_portlet
case 'listview': case 'listview':
$this->context['sel_options']['filter'] = &$ui->date_filters; $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']); $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
// Early exit // Early exit
return parent::exec($id, $etemplate); return parent::exec($id, $etemplate);
break;
case 'planner_user': case 'planner_user':
case 'planner_cat': case 'planner_cat':
case 'planner': case 'planner':
@ -150,7 +150,7 @@ class calendar_favorite_portlet extends home_favorite_portlet
unset($GLOBALS['egw_info']['flags']['app_header']); unset($GLOBALS['egw_info']['flags']['app_header']);
// Force loading of CSS // Force loading of CSS
egw_framework::include_css_js_response(); Framework::include_css_js_response();
// Set this to calendar so app.js gets initialized // Set this to calendar so app.js gets initialized
$old_app = $GLOBALS['egw_info']['flags']['currentapp']; $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, * Here we need to handle any incoming data. Setup is done in the constructor,
* output is handled by parent. * output is handled by parent.
* *
* @param type $id * @param $values =array()
* @param etemplate_new $etemplate
*/ */
public static function process($values = array()) public static function process($values = array())
{ {
@ -195,32 +194,32 @@ class calendar_favorite_portlet extends home_favorite_portlet
{ {
if (!count($values['nm']['selected']) && !$values['nm']['select_all']) 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 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'], 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'])) $success,$failed,$action_msg,'calendar_list',$msg, $values['nm']['checkboxes']['no_notifications']))
{ {
$msg .= lang('%1 event(s) %2',$success,$action_msg); $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) foreach($values['nm']['selected'] as &$id)
{ {
$id = 'calendar::'.$id; $id = 'calendar::'.$id;
} }
// Directly request an update - this will get addressbook tab too // 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)) elseif(is_null($msg))
{ {
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); $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) elseif($msg)
{ {
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); $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']['action']);
unset($values['nm']['select_all']); unset($values['nm']['select_all']);

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware - Filemanager - A portlet for displaying a list of entries * Egroupware - Filemanager - A portlet for displaying a list of entries
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package filemanager * @package filemanager
@ -10,13 +9,16 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Vfs;
use EGroupware\Api\Etemplate;
/** /**
* The filemanager_list_portlet uses a nextmatch / favorite * The filemanager_list_portlet uses a nextmatch / favorite
* to display a list of entries. * to display a list of entries.
*/ */
class filemanager_favorite_portlet extends home_favorite_portlet class filemanager_favorite_portlet extends home_favorite_portlet
{ {
/** /**
* Construct the portlet * Construct the portlet
* *
@ -28,8 +30,6 @@ class filemanager_favorite_portlet extends home_favorite_portlet
// Let parent handle the basic stuff // Let parent handle the basic stuff
parent::__construct($context,$need_reload); parent::__construct($context,$need_reload);
$ui = new filemanager_ui();
$this->nm_settings += array( $this->nm_settings += array(
'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows', 'get_rows' => 'filemanager.filemanager_favorite_portlet.get_rows',
'csv_export' => true, 'csv_export' => true,
@ -45,12 +45,12 @@ class filemanager_favorite_portlet extends home_favorite_portlet
'row_modified' => 'mtime', 'row_modified' => 'mtime',
'parent_id' => 'dir', 'parent_id' => 'dir',
'is_parent' => 'mime', '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') '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( $this->context['sel_options']['filter'] = array(
@ -93,7 +93,7 @@ class filemanager_favorite_portlet extends home_favorite_portlet
* output is handled by parent. * output is handled by parent.
* *
* @param type $id * @param type $id
* @param etemplate_new $etemplate * @param Etemplate $etemplate
*/ */
public static function process($content = array()) public static function process($content = array())
{ {
@ -104,13 +104,13 @@ class filemanager_favorite_portlet extends home_favorite_portlet
if ($content['nm']['action']) if ($content['nm']['action'])
{ {
$msg = filemanager_ui::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); $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) foreach($content['nm']['selected'] as &$id)
{ {
$id = 'filemanager::'.$id; $id = 'filemanager::'.$id;
} }
// Directly request an update - this will get filemanager tab too // 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']));
} }
} }
} }

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package home * @package home
@ -10,12 +9,15 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Etemplate;
/** /**
* Show birthdays * 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 * 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 * for this particular portlet. It is possible to have multiple instances of the
@ -29,6 +31,9 @@
*/ */
public function __construct(Array &$context = array(), &$need_reload = false) 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; $this->context = $context;
} }
@ -57,15 +62,15 @@
* *
* @param id String unique ID, provided to the portlet so it can make sure content is * @param id String unique ID, provided to the portlet so it can make sure content is
* unique, if needed. * 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(); $content = array();
$etemplate->read('home.birthdays'); $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(); $content = $this->get_birthdays();
} }
@ -79,7 +84,7 @@
*/ */
protected function get_birthdays() protected function get_birthdays()
{ {
$contacts = new addressbook_bo(); $contacts = new Api\Contacts();
$month_start = date('-m-',$contacts->now_su); $month_start = date('-m-',$contacts->now_su);
$days = $this->context['days']; $days = $this->context['days'];
$birthdays = array(); $birthdays = array();
@ -110,6 +115,7 @@
unset($month_start); unset($month_end); unset($month_start); unset($month_end);
if ($bdays) if ($bdays)
{ {
$ab_lang_loaded = 0;
for($n = 0; $n <= $days; ++$n) for($n = 0; $n <= $days; ++$n)
{ {
$day = date('-m-d',$contacts->now_su+$n*24*3600); $day = date('-m-d',$contacts->now_su+$n*24*3600);
@ -117,7 +123,7 @@
{ {
if(substr($contact['bday'],-6) == $day) 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) switch($n)
{ {
case 0: case 0:
@ -130,7 +136,7 @@
list($y,$m,$d) = explode('-',$contact['bday']); list($y,$m,$d) = explode('-',$contact['bday']);
if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = ''; if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = '';
$text = lang("In %1 days (%2) is %3's birthday.",$n, $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']); $contact['n_given'].' '.$contact['n_family']);
break; break;
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/** /***
* EGroupware - Home - A simple portlet for displaying a list of entries * EGroupware - Home - A simple portlet for displaying a list of entries
* *
* @link www.egroupware.org * @link www.egroupware.org
@ -11,6 +11,10 @@
* @version $Id: class.home_list_portlet.inc.php 49321 2014-11-06 21:40:03Z nathangray $ * @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 * The home_favorite_portlet uses a nextmatch to display the entries for a particular
@ -29,7 +33,7 @@ class home_favorite_portlet extends home_portlet
/** /**
* Nextmatch settings * Nextmatch settings
* @see etemplate_widget_nextmatch * @see Etemplate\Widget\Nextmatch
* @var array * @var array
*/ */
protected $nm_settings = 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) 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 // Process dropped data (Should be [appname => <appname>, id => <favorite ID>]) into something useable
if($context['dropped_data']) if($context['dropped_data'])
{ {
@ -83,7 +89,7 @@ class home_favorite_portlet extends home_portlet
// Load and copy favorite // Load and copy favorite
if($context['favorite'] && !is_array($context['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']]; $context['favorite'] = $favorites[$context['favorite']];
$need_reload = true; $need_reload = true;
} }
@ -101,13 +107,14 @@ class home_favorite_portlet extends home_portlet
} }
$this->nm_settings['columnselection_pref'] = "nextmatch-home.{$this->context['id']}"; $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) if($etemplate == null)
{ {
$etemplate = new etemplate_new(); $etemplate = new Etemplate();
} }
$etemplate->read('home.favorite'); $etemplate->read('home.favorite');
@ -121,11 +128,11 @@ class home_favorite_portlet extends home_portlet
// Always load app's css // Always load app's css
egw_framework::includeCSS($this->context['appname'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) || 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');
// Always load app's javascript, so most actions have a chance of working // 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 // Set this so app's JS gets initialized
$old_app = $GLOBALS['egw_info']['flags']['currentapp']; $old_app = $GLOBALS['egw_info']['flags']['currentapp'];
@ -138,8 +145,10 @@ class home_favorite_portlet extends home_portlet
public static function process($content = array()) public static function process($content = array())
{ {
unset($content); // not used, but required by function signature
// We need to keep the template going, thanks. // We need to keep the template going, thanks.
etemplate_widget::setElementAttribute('','',''); Etemplate\Widget::setElementAttribute('','','');
} }
public function get_actions(){ public function get_actions(){
@ -150,7 +159,7 @@ class home_favorite_portlet extends home_portlet
* Some descriptive information about the portlet, so that users can decide if * 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. * 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 * @return Array with keys
* - displayName: Used in lists * - 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 * Settings should be in the same style as for preferences. It is OK to return an empty array
* for no customizable settings. * 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 * @see preferences/inc/class.preferences_settings.inc.php
* @return Array of settings. Each setting should have the following keys: * @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() public function get_properties()
{ {
$properties = parent::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(); $favorite_list = array();
foreach($favorites as $id => $favorite) foreach($favorites as $id => $favorite)
{ {

View File

@ -11,6 +11,9 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Etemplate;
class home_legacy_portlet extends home_portlet class home_legacy_portlet extends home_portlet
{ {
@ -31,11 +34,14 @@ class home_legacy_portlet extends home_portlet
public function __construct(array &$context = array(), &$need_reload = false) 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; $this->context = $context;
// Try to load content here, so all needed info is available // Try to load content here, so all needed info is available
$appname = $this->context['app']; $appname = $this->context['app'];
if(!$appname || !$GLOBALS['egw']->hooks->hook_exists('home', $appname)) if(!$appname || !Api\Hooks::exists('home', $appname))
{ {
return; return;
} }
@ -44,7 +50,7 @@ class home_legacy_portlet extends home_portlet
// Execute hook to get content // Execute hook to get content
ob_start(); 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 if (!$_content || $_content == 1) // content has been echoed and not returned
{ {
$_content = ob_get_contents(); $_content = ob_get_contents();
@ -73,8 +79,7 @@ class home_legacy_portlet extends home_portlet
} }
// Content remains // Content remains
$content = $dom->saveHTML(); $this->content = $dom->saveHTML();
$this->content = $content;
} }
} }
@ -90,7 +95,7 @@ class home_legacy_portlet extends home_portlet
* unique, if needed. * unique, if needed.
* @return string HTML fragment for display * @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'); $etemplate->read('home.legacy');
@ -119,4 +124,3 @@ class home_legacy_portlet extends home_portlet
); );
} }
} }
?>

View File

@ -11,6 +11,11 @@
* @version $Id$ * @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 * 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) public function __construct(Array &$context = array(), &$need_reload = false)
{ {
if (false) parent::__construct();
// Process dropped data into something useable // Process dropped data into something useable
if($context['dropped_data']) if($context['dropped_data'])
{ {
@ -53,9 +60,9 @@ class home_link_portlet extends home_portlet
unset($context['dropped_data']); unset($context['dropped_data']);
$need_reload = true; $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 // Reload to get the latest title
// TODO: This is a performance hit, it would be good to do this less // 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 * @param id String unique ID, provided to the portlet so it can make sure content is
* unique, if needed. * 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 // Check for custom template for app
$custom_template = false; $custom_template = false;
@ -117,8 +124,8 @@ class home_link_portlet extends home_portlet
{ {
// Always load app's css // Always load app's css
egw_framework::includeCSS($this->context['entry']['app'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) || 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');
try try
{ {
@ -173,8 +180,8 @@ class home_link_portlet extends home_portlet
{ {
$this->context['entry']['app'] = 'file'; $this->context['entry']['app'] = 'file';
$this->context['entry']['path'] = $this->context['entry']['title'] = $this->context['entry']['id']; $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']); $this->context['entry']['type'] = Vfs::mime_content_type($this->context['entry']['id']);
$content['image'] = egw_framework::link('/api/thumbnail.php',array('path' => $this->context['entry']['id'])); $content['image'] = Framework::link('/api/thumbnail.php',array('path' => $this->context['entry']['id']));
} }
$content += $this->context; $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 * Settings should be in the same style as for preferences. It is OK to return an empty array
* for no customizable settings. * 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 * @see preferences/inc/class.preferences_settings.inc.php
* @return Array of settings. Each setting should have the following keys: * @return Array of settings. Each setting should have the following keys:

View File

@ -11,6 +11,8 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api\Vfs;
use EGroupware\Api\Etemplate;
/** /**
* The home_list_portlet uses the link system and its associated link-list widget * 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) public function __construct(Array &$context = array(), &$need_reload = false)
{ {
if (false) parent::__construct();
if(!is_array($context['list'])) $context['list'] = array(); if(!is_array($context['list'])) $context['list'] = array();
// Process dropped data (Should be GUIDs) into something useable // 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') if($item['app'] == 'filemanager' || $item['app'] == 'file')
{ {
$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... // Always reload...
$need_reload = true; $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 * 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. * 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 * @return Array with keys
* - displayName: Used in lists * - displayName: Used in lists
@ -101,7 +105,7 @@ class home_list_portlet extends home_portlet
* unique, if needed. * unique, if needed.
* @return string HTML fragment for display * @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'); $etemplate->read('home.list');
@ -119,7 +123,7 @@ class home_list_portlet extends home_portlet
{ {
$list['app'] = 'file'; $list['app'] = 'file';
$list['path'] = $list['title'] = $list['icon'] = $list['id']; $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 * Settings should be in the same style as for preferences. It is OK to return an empty array
* for no customizable settings. * 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 * @see preferences/inc/class.preferences_settings.inc.php
* @return Array of settings. Each setting should have the following keys: * @return Array of settings. Each setting should have the following keys:

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware * Egroupware
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package home * @package home
@ -10,6 +9,9 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Etemplate;
/** /**
* A simple HTML note-to-self * A simple HTML note-to-self
* *
@ -30,6 +32,8 @@ class home_note_portlet extends home_portlet
*/ */
public function __construct(Array &$context = array(), &$need_reload = false) public function __construct(Array &$context = array(), &$need_reload = false)
{ {
if (false) parent::__construct();
// Title not set for new widgets created via context menu // Title not set for new widgets created via context menu
if(!$context['title']) if(!$context['title'])
{ {
@ -54,34 +58,31 @@ class home_note_portlet extends home_portlet
if($content['group'] && $GLOBALS['egw_info']['apps']['admin']) 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 else
{ {
$prefs = $GLOBALS['egw']->preferences; $prefs = $GLOBALS['egw']->preferences;
} }
$type = is_numeric($group) ? "user" : $group; $type = is_numeric($content['group']) ? "user" : $content['group'];
$portlets = $prefs->read_repository(); $arr = $prefs->read_repository();
$portlets = $portlets['home']; $portlets = $arr['home'];
if($content['button']) if($content['button'])
{ {
// Save updated preferences // Save updated Api\Preferences
$portlets[$id]['note'] = $content['note']; $portlets[$id]['note'] = $content['note'];
$prefs->add('home', $id, $portlets[$id],$type); $prefs->add('home', $id, $portlets[$id],$type);
$prefs->save_repository(True,$type); $prefs->save_repository(True,$type);
// Yay for AJAX submit // 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') 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', 'width', '99%');
$etemplate->setElementAttribute('note', 'height', $height); $etemplate->setElementAttribute('note', 'height', $height);
$preserve = array( $preserve = array(
@ -89,10 +90,12 @@ class home_note_portlet extends home_portlet
'height' => $height, 'height' => $height,
'group' => $portlets[$id]['group'] '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 // Allow to submit directly back here
if(is_array($id) && $id['id']) if(is_array($id) && $id['id'])
@ -107,7 +110,7 @@ class home_note_portlet extends home_portlet
if(!$content['note']) if(!$content['note'])
{ {
$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)); $etemplate->exec('home.home_note_portlet.exec',$content,array(),array('__ALL__'=>true),array('id' =>$id));

View File

@ -11,6 +11,8 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api\Etemplate;
abstract class home_portlet abstract class home_portlet
{ {
/** /**
@ -52,9 +54,9 @@ abstract class home_portlet
* *
* @param id String unique ID, provided to the portlet so it can make sure content is * @param id String unique ID, provided to the portlet so it can make sure content is
* unique, if needed. * 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. * Return a list of settings to customize the portlet.

View File

@ -10,6 +10,10 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
class home_tutorial_ui class home_tutorial_ui
{ {
/** /**
@ -32,15 +36,13 @@ class home_tutorial_ui
if (!EGroupware\Api\Hooks::exists('sidebox_all', 'home') || if (!EGroupware\Api\Hooks::exists('sidebox_all', 'home') ||
EGroupware\Api\Hooks::exists('sidebox_all', 'home', true) != 'home_tutorial_ui::tutorial_menu') EGroupware\Api\Hooks::exists('sidebox_all', 'home', true) != 'home_tutorial_ui::tutorial_menu')
{ {
$setup_info = array(); Api\Hooks::read(true);
include(EGW_SERVER_ROOT.'/home/setup/setup.inc.php');
$GLOBALS['egw']->hooks->register_hooks('home', $setup_info['home']['hooks']);
} }
//Allow youtube frame to pass the CSP check //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)) if (!is_array($content))
{ {
// Get tutorial object id // Get tutorial object id
@ -92,7 +94,7 @@ class home_tutorial_ui
else else
{ {
$content = array(); $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); $tmpl->exec('home.home_tutorial_ui.popup', $content, $sel_options, array(), array(), 2);
@ -103,7 +105,7 @@ class home_tutorial_ui
*/ */
function ajax_data() function ajax_data()
{ {
$response = egw_json_response::get(); $response = Api\Json\Response::get();
$response->data(json_decode(self::getJsonData())); $response->data(json_decode(self::getJsonData()));
} }
@ -114,13 +116,13 @@ class home_tutorial_ui
*/ */
static function getJsonData() 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'); $json = file_get_contents('http://www.egroupware.de/videos/tutorials.json');
// Fallback tutorials.json // Fallback tutorials.json
if (!$json) $json = file_get_contents('home/setup/tutorials.json'); if (!$json) $json = file_get_contents('home/setup/tutorials.json');
// Cache the json object for two hours // 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; return $json;
@ -132,7 +134,7 @@ class home_tutorial_ui
*/ */
public static function tutorial_menu() public static function tutorial_menu()
{ {
if (html::$ua_mobile) return; if (Api\Header\UserAgent::mobile()) return;
$tutorials = json_decode(self::getJsonData(),true); $tutorials = json_decode(self::getJsonData(),true);
$appname = $GLOBALS['egw_info']['flags']['currentapp']; $appname = $GLOBALS['egw_info']['flags']['currentapp'];
if (!is_array($tutorials[$appname])) return false; if (!is_array($tutorials[$appname])) return false;

View File

@ -10,6 +10,10 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/** /**
* General user interface object of the Home app * General user interface object of the Home app
* *
@ -37,9 +41,9 @@ class home_ui
self::setup_default_home(); self::setup_default_home();
// CSS for Gridster grid layout // 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 // Get a list of portlets
$content = array( $content = array(
@ -51,13 +55,13 @@ class home_ui
$GLOBALS['egw_info']['flags']['currentapp'] = 'home'; $GLOBALS['egw_info']['flags']['currentapp'] = 'home';
// Main screen message // Main screen message
translation::add_app('mainscreen'); Api\Translation::add_app('mainscreen');
$greeting = translation::translate('mainscreen_message',false,''); $greeting = Api\Translation::translate('mainscreen_message',false,'');
if($greeting == 'mainscreen_message'|| empty($greeting)) if($greeting == 'mainscreen_message'|| empty($greeting))
{ {
translation::add_app('mainscreen','en'); // trying the en one Api\Translation::add_app('mainscreen','en'); // trying the en one
$greeting = translation::translate('mainscreen_message',false,''); $greeting = Api\Translation::translate('mainscreen_message',false,'');
} }
if(!($greeting == 'mainscreen_message'|| empty($greeting))) if(!($greeting == 'mainscreen_message'|| empty($greeting)))
{ {
@ -67,6 +71,7 @@ class home_ui
$template->exec('home.home_ui.index', $content); $template->exec('home.home_ui.index', $content);
// Now run the portlets themselves // Now run the portlets themselves
$attrs = array();
foreach($content['portlets'] as $portlet => $p_data) foreach($content['portlets'] as $portlet => $p_data)
{ {
$id = $p_data['id']; $id = $p_data['id'];
@ -152,7 +157,7 @@ class home_ui
* Actual portlet content is provided by each portlet. * Actual portlet content is provided by each portlet.
* @param template etemplate so attributes can be set * @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(); $portlets = array();
@ -228,9 +233,9 @@ class home_ui
// This should be set already, but just in case the execution path // This should be set already, but just in case the execution path
// is different from normal... // 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']; $classname = $context['class'];
@ -239,7 +244,7 @@ class home_ui
$desc = $portlet->get_description(); $desc = $portlet->get_description();
// Pre-set up etemplate so it only needs done once // 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 // Exclude common attributes changed through UI and settings lacking a type
$settings = $portlet->get_properties(); $settings = $portlet->get_properties();
@ -285,7 +290,7 @@ class home_ui
$appname = $app; $appname = $app;
} }
} }
egw_framework::validate_file('', $classname, $appname ? $appname : 'home'); Framework::includeJS('', $classname, $appname ? $appname : 'home');
if($full_exec) if($full_exec)
{ {
@ -320,7 +325,7 @@ class home_ui
break; break;
} }
} }
if($no_pref || !$GLOBALS['egw']->hooks->hook_exists('home', $appname)) if($no_pref || !Api\Hooks::exists('home', $appname))
{ {
continue; continue;
} }
@ -344,7 +349,7 @@ class home_ui
*/ */
protected function get_portlet_list() protected function get_portlet_list()
{ {
$list = egw_cache::getTree('home', 'portlet_classes', function() { $list = Api\Cache::getTree('home', 'portlet_classes', function() {
$list = array(); $list = array();
$classes = array(); $classes = array();
@ -411,7 +416,7 @@ class home_ui
}, array(), 60); }, array(), 60);
// Filter list by current user's permissions // 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']['apps']))) {
if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['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 it's a group, we'd like to know which
if($location == 'group') if($location == 'group')
{ {
$options = array('account_type' => $type); $options = array('account_type' => 'groups');
$groups = accounts::link_query('',$options); $groups = Api\Accounts::link_query('',$options);
foreach($groups as $gid => $name) foreach(array_keys($groups) as $gid)
{ {
$prefs = new preferences($gid); $prefs = new Api\Preferences($gid);
$prefs->read_repository(); $prefs->read_repository();
if (isset($prefs->user['home'][$portlet_id])) if (isset($prefs->user['home'][$portlet_id]))
{ {
@ -472,7 +477,7 @@ class home_ui
} }
$actions['remove_default_'.$location] = array( $actions['remove_default_'.$location] = array(
'type' => 'popup', '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', 'onExecute' => 'javaScript:app.home.set_default',
'group' => 'Admins', 'group' => 'Admins',
'portlet_group' => $location 'portlet_group' => $location
@ -526,7 +531,7 @@ class home_ui
} }
if($group && $GLOBALS['egw_info']['user']['apps']['admin']) 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 else
{ {
@ -536,7 +541,7 @@ class home_ui
$prefs->read_repository(); $prefs->read_repository();
$response = egw_json_response::get(); $response = Api\Json\Response::get();
if($values =='~reload~') if($values =='~reload~')
{ {
@ -588,6 +593,7 @@ class home_ui
$add = true; $add = true;
$classname = substr($classname, 4); $classname = substr($classname, 4);
} }
$content = null;
$portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec); $portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec);
$context['class'] = get_class($portlet); $context['class'] = get_class($portlet);
@ -637,7 +643,7 @@ class home_ui
// Load the appropriate group // Load the appropriate group
if($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 else
{ {
@ -651,7 +657,7 @@ class home_ui
{ {
foreach($portlet_ids as $id) 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 // Current user is setting the default, copy their settings
$settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id]; $settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id];
$settings['group'] = $group; $settings['group'] = $group;
@ -666,16 +672,16 @@ class home_ui
{ {
foreach($portlet_ids as $id) 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->delete('home',$id, $type);
} }
} }
$prefs->save_repository(false,$type); $prefs->save_repository(false,$type);
// Update preferences client side for consistency // Update Api\Preferences client side for consistency
$prefs = $GLOBALS['egw']->preferences; $prefs = $GLOBALS['egw']->preferences;
$pref = $prefs->read_repository(); $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']; $lang = $preferences->default['common']['lang'];
if (empty($lang)) $lang = 'en'; if (empty($lang)) $lang = 'en';
translation::add_app('calendar', $lang); Api\Translation::add_app('calendar', $lang);
$weekview = lang('Weekview'); $weekview = lang('Weekview');
if ($GLOBALS['egw_info']['apps']['news_admin']) 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'); $cat_id_egw_org_news = $cats->name2id('egroupware.org');
} }
@ -776,12 +782,12 @@ class home_ui
{ {
foreach($prefs as $name => $value) foreach($prefs as $name => $value)
{ {
preferences::delete_preference($app, $name, 'default'); Api\Preferences::delete_preference($app, $name, 'default');
$preferences->add($app, $name, $value, 'default'); $preferences->add($app, $name, $value, 'default');
} }
} }
// remove tutorial from home, as it is now in sidebox // 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'); $preferences->delete('home', 'portlet_setup142t', 'default');
// assigning saved preferences to egw_info, which is used for this request // assigning saved preferences to egw_info, which is used for this request
@ -802,7 +808,7 @@ class home_ui
default: default:
call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION))); 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; break;
} }
} }

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware Weather widget * Egroupware Weather widget
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package home * @package home
@ -10,6 +9,10 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/** /**
* Widget displaying the weather * Widget displaying the weather
* *
@ -33,6 +36,8 @@ class home_weather_portlet extends home_portlet
*/ */
public function __construct(Array &$context = array(), &$need_reload = false) public function __construct(Array &$context = array(), &$need_reload = false)
{ {
if (false) parent::__construct();
// City not set for new widgets created via context menu // City not set for new widgets created via context menu
if(!$context['city'] || $context['height'] < 2) if(!$context['city'] || $context['height'] < 2)
{ {
@ -46,7 +51,7 @@ class home_weather_portlet extends home_portlet
$this->context = $context; $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 // Allow to submit directly back here
if(is_array($id) && $id['id']) if(is_array($id) && $id['id'])
@ -83,10 +88,10 @@ class home_weather_portlet extends home_portlet
if($content['city_id'] && (!$this->context['city_id'] || $content['city_id'] != $this->context['city_id'])) if($content['city_id'] && (!$this->context['city_id'] || $content['city_id'] != $this->context['city_id']))
{ {
$portlets = $GLOBALS['egw']->preferences->read_repository(); $arr = $GLOBALS['egw']->preferences->read_repository();
$portlets = $portlets['home']; $portlets = $arr['home'];
// Save updated preferences // Save updated Api\Preferences
$portlets[$id]['city_id'] = $content['city_id']; $portlets[$id]['city_id'] = $content['city_id'];
$this->context['city'] = $portlets[$id]['city'] = $content['settings']['city'] = $this->context['city'] = $portlets[$id]['city'] = $content['settings']['city'] =
$content['settings']['title'] = $content['city'] = is_array($content['city']) ? $content['city']['name'] : $content['city']; $content['settings']['title'] = $content['city'] = is_array($content['city']) ? $content['city']['name'] : $content['city'];
@ -136,7 +141,8 @@ class home_weather_portlet extends home_portlet
{ {
$query['APPID'] = self::API_KEY; $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; $debug = false;
if($debug) error_log('Fetching fresh data from ' . static::API_URL); if($debug) error_log('Fetching fresh data from ' . static::API_URL);
@ -158,7 +164,7 @@ class home_weather_portlet extends home_portlet
if($debug) if($debug)
{ {
error_log(__METHOD__ .' weather info:'); error_log(__METHOD__ .' weather info:');
foreach($data as $key => $val) foreach(array_keys($data) as $key)
{ {
error_log($key . ': ' .array2string($data[$key])); error_log($key . ': ' .array2string($data[$key]));
} }
@ -166,7 +172,7 @@ class home_weather_portlet extends home_portlet
if(is_string($data['message'])) if(is_string($data['message']))
{ {
$desc = $this->get_description(); $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(); return array();
} }
@ -185,7 +191,7 @@ class home_weather_portlet extends home_portlet
for($i = 0; $i < min(count($massage), $this->context['width']); $i++) for($i = 0; $i < min(count($massage), $this->context['width']); $i++)
{ {
$forecast =& $massage[$i]; $forecast =& $massage[$i];
$forecast['day'] = egw_time::to($forecast['dt'],'l'); $forecast['day'] = Api\DateTime::to($forecast['dt'],'l');
self::format_forecast($forecast); self::format_forecast($forecast);
} }
// Chop data to fit into portlet // Chop data to fit into portlet

View File

@ -21,9 +21,6 @@ $GLOBALS['egw_info'] = array(
include('../header.inc.php'); include('../header.inc.php');
$GLOBALS['egw_info']['flags']['nonavbar']=false; $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 is treated specially, so a redirect won't work.
$home = new home_ui(); $home = new home_ui();
echo $home->index(); echo $home->index();

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware - Infolog - A portlet for displaying a list of portlet entries * Egroupware - Infolog - A portlet for displaying a list of portlet entries
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog * @package infolog
@ -10,6 +9,10 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/** /**
* The infolog_list_portlet uses a nextmatch / favorite * The infolog_list_portlet uses a nextmatch / favorite
* to display a list of entries. * to display a list of entries.
@ -66,7 +69,7 @@ class infolog_favorite_portlet extends home_favorite_portlet
// Make sure we pass the type check // Make sure we pass the type check
if ($query['col_filter']['info_type']) if ($query['col_filter']['info_type'])
{ {
$tpl = new etemplate_new; $tpl = new Etemplate;
if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type'])) if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type']))
{ {
$query['template'] = $tpl->name; $query['template'] = $tpl->name;
@ -85,8 +88,7 @@ class infolog_favorite_portlet extends home_favorite_portlet
* Here we need to handle any incoming data. Setup is done in the constructor, * Here we need to handle any incoming data. Setup is done in the constructor,
* output is handled by parent. * output is handled by parent.
* *
* @param type $id * @param $values =array()
* @param etemplate_new $etemplate
*/ */
public static function process($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']) 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 else
{ {
@ -127,28 +129,28 @@ class infolog_favorite_portlet extends home_favorite_portlet
unset($values[$multi_action.'_popup']); unset($values[$multi_action.'_popup']);
unset($values[$multi_action]); 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'], 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'])) $success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications']))
{ {
$msg .= lang('%1 entries %2',$success,$action_msg); $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) foreach($values['nm']['selected'] as &$id)
{ {
$id = 'infolog::'.$id; $id = 'infolog::'.$id;
} }
// Directly request an update - this will get infolog tab too // 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)) elseif(is_null($msg))
{ {
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); $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) elseif($msg)
{ {
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); $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']['multi_action']);
unset($values['nm']['select_all']); unset($values['nm']['select_all']);

View File

@ -1,6 +1,5 @@
<?php <?php
/**
/*
* Egroupware - Resources - A portlet for displaying a list of entries * Egroupware - Resources - A portlet for displaying a list of entries
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package resources * @package resources
@ -10,13 +9,16 @@
* @version $Id$ * @version $Id$
*/ */
use EGroupware\Api;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/** /**
* The resources_list_portlet uses a nextmatch / favorite * The resources_list_portlet uses a nextmatch / favorite
* to display a list of entries. * to display a list of entries.
*/ */
class resources_favorite_portlet extends home_favorite_portlet class resources_favorite_portlet extends home_favorite_portlet
{ {
/** /**
* Construct the portlet * Construct the portlet
* *
@ -28,8 +30,6 @@ class resources_favorite_portlet extends home_favorite_portlet
// Let parent handle the basic stuff // Let parent handle the basic stuff
parent::__construct($context,$need_reload); parent::__construct($context,$need_reload);
$ui = new resources_ui();
$this->context['template'] = 'resources.show.rows'; $this->context['template'] = 'resources.show.rows';
$this->nm_settings += array( $this->nm_settings += array(
'get_rows' => 'resources.resources_bo.get_rows', '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(); $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; $this->context['sel_options']['filter2'] = resources_bo::$filter_options;
if(!$content['nm']['filter2']) 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, * Here we need to handle any incoming data. Setup is done in the constructor,
* output is handled by parent. * output is handled by parent.
* *
* @param type $id * @param $content =array()
* @param etemplate_new $etemplate
*/ */
public static function process($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']) if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
{ {
$msg = lang('You need to select some entries first!'); $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 else
{ {
@ -103,21 +102,20 @@ class resources_favorite_portlet extends home_favorite_portlet
{ {
$msg .= lang('%1 resource(s) %2',$success,$action_msg); $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) foreach($content['nm']['selected'] as &$id)
{ {
$id = 'resources::'.$id; $id = 'resources::'.$id;
} }
// Directly request an update - this will get resources tab too // 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)) elseif(empty($msg))
{ {
$msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); $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'));
} }
} }
} }
} }
} }