mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-24 15:49:06 +01:00
prototype for an admin app using et2 and a navigation tree, need to set index url in database: UPDATE egw_applications SET app_index="admin.admin_ui.index&ajax=true" WHERE app_name="admin" (dont forget to clear cache)
This commit is contained in:
parent
bca1712229
commit
ffceaf445a
@ -31,6 +31,8 @@ class admin_prefs_sidebox_hooks
|
||||
*/
|
||||
static function all_hooks($args)
|
||||
{
|
||||
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
|
||||
|
||||
if (!isset($_GET['menuaction']) && substr($_SERVER['PHP_SELF'],-16) == '/admin/index.php')
|
||||
{
|
||||
admin_statistics::check();
|
||||
@ -38,9 +40,21 @@ class admin_prefs_sidebox_hooks
|
||||
$appname = 'admin';
|
||||
$location = is_array($args) ? $args['location'] : $args;
|
||||
|
||||
if ($location == 'sidebox_menu')
|
||||
{
|
||||
// Destination div for folder tree
|
||||
$file[] = array(
|
||||
'no_lang' => true,
|
||||
'text' => '<span id="admin_tree_target" class="admin_tree" />',
|
||||
'link' => false,
|
||||
'icon' => false
|
||||
);
|
||||
display_sidebox($appname,lang('Admin'),$file);
|
||||
return;
|
||||
}
|
||||
if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'admins')
|
||||
{
|
||||
$file['new admin'] = egw::link('/index.php', array('menuaction' => 'admin.admin_ui.index'));
|
||||
|
||||
if (! $GLOBALS['egw']->acl->check('site_config_access',1,'admin'))
|
||||
{
|
||||
$file['Site Configuration'] = egw::link('/index.php','menuaction=admin.uiconfig.index&appname=admin');
|
||||
@ -136,7 +150,7 @@ $file['new admin'] = egw::link('/index.php', array('menuaction' => 'admin.admin_
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($file as &$url) if (is_array($url)) $url = $url['link'];
|
||||
foreach($file as &$url) if (is_array($url) && $url['link']) $url = $url['link'];
|
||||
display_sidebox($appname,lang('Admin'),$file);
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ class admin_ui
|
||||
*/
|
||||
public function index(array $content=null, $msg='')
|
||||
{
|
||||
$tpl = new etemplate('admin.index');
|
||||
$tpl = new etemplate_new('admin.index');
|
||||
|
||||
$content = array();
|
||||
$content['msg'] = 'Hi Ralf ;-)';
|
||||
//$content['msg'] = 'Hi Ralf ;-)';
|
||||
$sel_options['tree'] = $this->tree_data();
|
||||
$tpl->exec('admin.admin_ui.index', $content, $sel_options);
|
||||
}
|
||||
@ -106,6 +106,7 @@ class admin_ui
|
||||
$data['im0'] = $icon;
|
||||
}
|
||||
}
|
||||
unset($data['icon']);
|
||||
$parent =& $tree['item'];
|
||||
$parts = explode('/', $data['id']);
|
||||
if ($data['id'][0] == '/') array_shift($parts); // remove root
|
||||
@ -128,12 +129,14 @@ class admin_ui
|
||||
'item' => array(),
|
||||
'child' => 1,
|
||||
);
|
||||
if ($path == '/admin') $parent[$path]['open'] = true;
|
||||
}
|
||||
$parent =& $parent[$path]['item'];
|
||||
}
|
||||
$data['text'] = lang($data['text']);
|
||||
if (!empty($data['title'])) $data['title'] = lang($data['title']);
|
||||
$parent[$data['id']] = $data;
|
||||
if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']);
|
||||
|
||||
$parent[$data['id']] = self::fix_userdata($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,6 +156,28 @@ class admin_ui
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix userdata as understood by tree
|
||||
*
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
private static function fix_userdata(array $data)
|
||||
{
|
||||
// store link as userdata, maybe we should store everything not directly understood by tree this way ...
|
||||
foreach(array_diff_key($data, array_flip(array(
|
||||
'id','text','tooltip','im0','im1','im2','item','child','select','open','call',
|
||||
))) as $name => $content)
|
||||
{
|
||||
$data['userdata'][] = array(
|
||||
'name' => $name,
|
||||
'content' => $content,
|
||||
);
|
||||
unset($data[$name]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function strip_item_keys(&$items)
|
||||
{
|
||||
$items = array_values($items);
|
||||
@ -177,7 +202,7 @@ class admin_ui
|
||||
function display_section($appname,$file,$file2=False)
|
||||
{
|
||||
admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file;
|
||||
error_log(__METHOD__."(".array2string(func_get_args()).")");
|
||||
//error_log(__METHOD__."(".array2string(func_get_args()).")");
|
||||
}
|
||||
return array_merge($GLOBALS['egw']->hooks->process('admin', array('admin')), self::$hook_data);
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ class uiconfig
|
||||
$t->set_var('lang_cancel', lang('Cancel'));
|
||||
|
||||
// set currentapp to our calling app, to show the right sidebox-menu
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = $show_app;
|
||||
// $GLOBALS['egw_info']['flags']['currentapp'] = $show_app;
|
||||
|
||||
// render the page
|
||||
$GLOBALS['egw']->framework->render(
|
||||
|
@ -14,6 +14,7 @@ $GLOBALS['egw_info'] = array(
|
||||
'flags' => array(
|
||||
'currentapp' => 'admin',
|
||||
'noheader' => true,
|
||||
'nonavbar' => true,
|
||||
),
|
||||
);
|
||||
include('../header.inc.php');
|
||||
|
88
admin/js/app.js
Normal file
88
admin/js/app.js
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
* EGroupware - Admin - Javascript UI
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @package filemanager
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @copyright (c) 2013 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* UI for Admin
|
||||
*
|
||||
* @augments AppJS
|
||||
*/
|
||||
app.admin = AppJS.extend(
|
||||
{
|
||||
appname: 'admin',
|
||||
/**
|
||||
* et2 widget container
|
||||
*/
|
||||
et2: null,
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @memberOf app.filemanager
|
||||
*/
|
||||
init: function()
|
||||
{
|
||||
// call parent
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
destroy: function()
|
||||
{
|
||||
delete this.et2;
|
||||
// call parent
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* This function is called when the etemplate2 object is loaded
|
||||
* and ready. If you must store a reference to the et2 object,
|
||||
* make sure to clean it up in destroy().
|
||||
*
|
||||
* @param _et2 etemplate2 Newly ready object
|
||||
*/
|
||||
et2_ready: function(_et2)
|
||||
{
|
||||
// call parent
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this.et2 = _et2.widgetContainer;
|
||||
|
||||
var iframe = this.et2.getWidgetById('admin_iframe');
|
||||
if (iframe) iframe.set_src(egw.webserverUrl+'/admin/index.php');
|
||||
},
|
||||
|
||||
/**
|
||||
* Run an admin module / onclick callback for tree
|
||||
*
|
||||
* @param string _id id of clicked node
|
||||
* @param et2_tree _widget reference to tree widget
|
||||
*/
|
||||
run: function(_id, _widget)
|
||||
{
|
||||
var link = _widget.getUserData(_id, 'link');
|
||||
var iframe = this.et2.getWidgetById('admin_iframe');
|
||||
|
||||
if (typeof link == 'undefined')
|
||||
{
|
||||
_widget.openItem(_id, 'toggle');
|
||||
}
|
||||
else if (link[0] == '/' || link.substr(0,4) == 'http')
|
||||
{
|
||||
iframe.set_src(link+'&nonavbar=1');
|
||||
}
|
||||
else if (link.substr(0,11) == 'javascript:')
|
||||
{
|
||||
eval(link.substr(11));
|
||||
}
|
||||
}
|
||||
});
|
21
admin/templates/default/app.css
Normal file
21
admin/templates/default/app.css
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* EGroupware - CSS Styles used by admin app
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
.admin_tree table, .admin_tree tr, .admin_tree td {
|
||||
border: none;
|
||||
}
|
||||
|
||||
div#divAppbox {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background-image: none;
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="admin.index" template="" lang="" group="0" version="1.9.001">
|
||||
<tree autoloading="admin_ui::ajax_tree" id="tree"/><!-- onclick="app.admin.run(widget.event_args[0],widget);" parent_node="tree_target"/ -->
|
||||
<tree autoloading="admin_ui::ajax_tree" id="admin_tree" onclick="app.admin.run(widget.event_args[0],widget);" parent_node="admin_tree_target"/>
|
||||
<html id="msg"/>
|
||||
<!-- iframe frameborder="1" height="auto" id="iframe" scrolling="auto" width="100%"/ -->
|
||||
<iframe frameborder="1" height="500px" id="admin_iframe" scrolling="auto" width="100%"/>
|
||||
</template>
|
||||
</overlay>
|
||||
|
@ -570,6 +570,66 @@ var et2_tree = et2_inputWidget.extend(
|
||||
}
|
||||
//alert(returnValue.join('#,#'));
|
||||
return returnValue;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetch user-data stored in specified node under given name
|
||||
*
|
||||
* User-data need to be stored in json as follows:
|
||||
*
|
||||
* {"id": "node-id", "im0": ..., "userdata": [{"name": "user-name", "content": "user-value"},...]}
|
||||
*
|
||||
* In above example getUserData("node-id", "user-name") will return "user-value"
|
||||
*
|
||||
* @param _nodeId
|
||||
* @param _name
|
||||
* @returns
|
||||
*/
|
||||
getUserData: function(_nodeId, _name)
|
||||
{
|
||||
if(this.input == null) return null;
|
||||
return this.input.getUserData(_nodeId, _name);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stores / updates user-data in specified node and name
|
||||
*
|
||||
* @param _nodeId
|
||||
* @param _name
|
||||
* @param _value
|
||||
* @returns
|
||||
*/
|
||||
setUserData: function(_nodeId, _name, _value)
|
||||
{
|
||||
if(this.input == null) return null;
|
||||
return this.input.setUserData(_nodeId, _name, _value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Query nodes open state and optinal change it
|
||||
*
|
||||
* @param _id node-id
|
||||
* @param _open specify to change true: open, false: close, everything else toggle
|
||||
* @returns true if open, false if closed
|
||||
*/
|
||||
openItem: function(_id, _open)
|
||||
{
|
||||
if (this.input == null) return null;
|
||||
|
||||
var is_open = this.input.getOpenState(_id) == 1;
|
||||
|
||||
if (typeof _open != 'undefined' && is_open !== _open)
|
||||
{
|
||||
if(is_open)
|
||||
{
|
||||
this.input.closeItem(_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.input.openItem(_id);
|
||||
}
|
||||
}
|
||||
return is_open;
|
||||
}
|
||||
});
|
||||
et2_register_widget(et2_tree, ["tree","tree-cat"]);
|
||||
|
@ -127,6 +127,12 @@ class idots_framework extends egw_framework
|
||||
function navbar()
|
||||
{
|
||||
if (self::$navbar_done) return '';
|
||||
|
||||
if (!empty($_GET['nonavbar']) || $GLOBALS['egw_info']['flags']['currentapp'] == 'admin' && empty($_GET['ajax']))
|
||||
{
|
||||
if (!self::$header_done) return $this->header();
|
||||
return '';
|
||||
}
|
||||
self::$navbar_done = true;
|
||||
|
||||
// the navbar
|
||||
@ -722,7 +728,8 @@ egw.set_user('.$GLOBALS['egw']->accounts->json($GLOBALS['egw_info']['user']['acc
|
||||
$this->tpl->set_var($this->_get_footer());
|
||||
$content .= $this->tpl->fp('out','footer');
|
||||
}
|
||||
elseif (!isset($GLOBALS['egw_info']['flags']['noheader']) || !$GLOBALS['egw_info']['flags']['noheader'])
|
||||
elseif (!isset($GLOBALS['egw_info']['flags']['noheader']) || !$GLOBALS['egw_info']['flags']['noheader'] ||
|
||||
!empty($_GET['nonavbar']) || $GLOBALS['egw_info']['flags']['currentapp'] == 'admin' && empty($_GET['ajax']))
|
||||
{
|
||||
$content .= "</body>\n</html>\n"; // close body and html tag, eg. for popups
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user