Converted admin hooks over to templates

This commit is contained in:
jengo 2001-05-16 05:12:20 +00:00
parent 7c2172852a
commit e4de7df1b1
4 changed files with 107 additions and 124 deletions

View File

@ -1,68 +1,27 @@
<?php
/**************************************************************************\
* phpGroupWare - administration *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
{
/*
// This block of code is included by the main Administration page
// it points to the user, application and other global config
// pages.
// $appname is defined in the included file, (=="admin" for this file)
// $phpgw and $phpgwinfo are also in scope
// Find the icon to display
echo "<p>\n";
$imgfile = $phpgw->common->get_image_dir("admin")."/" . $appname .".gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("admin")."/" . $appname .".gif";
} else {
$imgfile = $phpgw->common->get_image_dir("admin")."/navbar.gif";
if (file_exists($imgfile)) {
$imgpath = $phpgw->common->get_image_path("admin")."/navbar.gif";
} else {
$imgpath = "";
}
}
// Show the header for the section
section_start("Administration",$imgpath);
*/
echo "<p>\n";
$imgfile = $phpgw->common->get_image_dir($appname) . '/' . $appname . '.gif';
if (file_exists($imgfile))
{
$imgpath = $phpgw->common->get_image_path($appname) . '/' . $appname . '.gif';
}
else
{
$imgfile = $phpgw->common->get_image_dir($appname) . '/navbar.gif';
if (file_exists($imgfile))
{
$imgpath = $phpgw->common->get_image_path($appname) . '/navbar.gif';
}
else
{
$imgpath = '';
}
}
$imgpath = $phpgw->common->image($appname,'navbar.gif');
section_start(ucfirst($appname),$imgpath);
// actual items in this section
echo '<a href="' . $phpgw->link('/admin/accounts.php') . '">' . lang('User accounts')."</a><br>\n";
echo '<a href="' . $phpgw->link('/admin/groups.php') . '">' . lang('User groups')."</a><br>\n";
echo "<p>\n";
echo '<a href="' . $phpgw->link('/admin/applications.php') . '">' . lang('Applications')."</a><br>\n";
echo "<p>\n";
echo '<a href="' . $phpgw->link('/admin/categories.php') . '">' . lang('Global Categories')."</a><br>\n";
echo "<p>\n";
echo '<a href="' . $phpgw->link('/admin/mainscreen_message.php') . '">' . lang('Change main screen message') . "</a><br>\n";
echo "<p>\n";
echo '<a href="' . $phpgw->link('/admin/currentusers.php') . '">' . lang('View sessions') . "</a><br>\n";
echo '<a href="' . $phpgw->link('/admin/accesslog.php') . '">' . lang('View Access Log') . "</a><br>\n";
section_item($phpgw->link('/admin/accounts.php'),lang('User accounts'));
section_item($phpgw->link('/admin/groups.php'),lang('User groups'));
section_item($phpgw->link('/admin/applications.php'),lang('Applications'));
section_item($phpgw->link('/admin/categories.php'),lang('Global Categories'));
section_item($phpgw->link('/admin/mainscreen_message.php'),lang('Change main screen message'));
section_item($phpgw->link('/admin/currentusers.php'),lang('View sessions'));
section_item($phpgw->link('/admin/accesslog.php'),lang('View Access Log'));
section_end();
}

View File

@ -17,64 +17,56 @@
$phpgw_info['flags']['currentapp'] = 'admin';
include('../header.inc.php');
check_code($cd);
$admin_tpl = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$admin_tpl->set_file(array(
'admin' => 'index.tpl',
));
$admin_tpl->set_block('admin','list');
$admin_tpl->set_block('admin','app_row');
$admin_tpl->set_block('admin','app_row_noicon');
$admin_tpl->set_block('admin','link_row');
$admin_tpl->set_block('admin','spacer_row');
$admin_tpl->set_var('title',lang('Administration'));
// This func called by the includes to dump a row header
function section_start($name='',$icon='')
{
global $phpgw,$phpgw_info;
echo '<table width="75%" border="0" cellspacing="0" cellpadding="0"><tr>';
global $phpgw, $phpgw_info, $admin_tpl;
$admin_tpl->set_var('icon_backcolor',$phpgw_info['theme']['row_off']);
$admin_tpl->set_var('link_backcolor',$phpgw_info['theme']['row_off']);
$admin_tpl->set_var('app_name',lang($name));
$admin_tpl->set_var('app_icon',$icon);
if ($icon)
{
echo '<td width="5%"><img src="' . $icon . '" alt="[Icon]" align="middle"></td>';
echo '<td><fontsize="+2">' . lang($name) . '</font></td>';
$admin_tpl->parse('rows','app_row',True);
}
else
{
echo '<td colspan="2"><font size="+2">' . $name . '</font></td>';
}
echo '</tr>';
echo '<tr><td colspan="2">';
$admin_tpl->parse('rows','app_row_noicon',True);
}
}
function section_item($pref_link='',$pref_text='')
{
global $phpgw, $phpgw_info, $admin_tpl;
$admin_tpl->set_var('pref_link',$pref_link);
$admin_tpl->set_var('pref_text',$pref_text);
$admin_tpl->parse('rows','link_row',True);
}
function section_end()
{
echo '</td></tr></table>';
global $phpgw, $phpgw_info, $admin_tpl;
$admin_tpl->parse('rows','spacer_row',True);
}
// We only want to list applications that are enabled, even if hidden from navbar, plus the common stuff
// (if they can get to the admin page, the admin app is enabled, hence it is shown)
$phpgw->common->hook();
$admin_tpl->pparse('out','list');
$phpgw->db->query("SELECT app_name FROM phpgw_applications WHERE app_enabled=1 OR app_enabled=2 ORDER BY app_title",__LINE__,__FILE__);
// Stuff it in an array in the off chance the admin includes need the db
while ($phpgw->db->next_record())
{
$apps[] = $phpgw->db->f('app_name');
}
for ($i =0; $i < sizeof($apps); $i++)
{
$appname = $apps[$i];
$f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_admin.inc.php';
if (file_exists($f))
{
include($f);
echo "<p>\n";
}
}
if ($SHOW_INFO > 0)
{
echo '<p><a href="' . $phpgw->link('/admin/index.php', 'SHOW_INFO=0'). '">' . lang('Hide PHP Information') . '</a>';
echo "<hr>\n";
phpinfo();
echo "<hr>\n";
}
else
{
echo '<p><a href="' . $phpgw->link('/admin/index.php', 'SHOW_INFO=1'). '">' . lang('PHP Information') . '</a>';
}
$phpgw->common->phpgw_footer();
?>
?>

View File

@ -0,0 +1,33 @@
<!-- BEGIN list -->
<b>{title}</b>
<hr><p>
<table width="75%" border="0" cellspacing="0" cellpadding="0">
{rows}
</table>
<!-- END list -->
<!-- BEGIN app_row -->
<tr bgcolor="{icon_backcolor}">
<td width="5%" valign="middle"><img src="{app_icon}" alt="[ {app_name} ]"></td>
<td width="95%" valign="middle"><strong>&nbsp;&nbsp;{app_name}</strong></td>
</tr>
<!-- END app_row -->
<!-- BEGIN app_row_noicon -->
<tr bgcolor="{icon_backcolor}">
<td colspan="2" width="95%" valign="middle"><strong>&nbsp;&nbsp;{app_name}</strong></td>
</tr>
<!-- END app_row_noicon -->
<!-- BEGIN link_row -->
<tr>
<td colspan="2">&nbsp;&#8226;&nbsp;<a href="{pref_link}">{pref_text}</a></td>
</tr>
<!-- END link_row -->
<!-- BEGIN spacer_row -->
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<!-- END spacer_row -->

View File

@ -1,22 +1,21 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
{
echo "<p>";
$imgpath = $phpgw->common->image($appname,'navbar.gif');
section_start(ucfirst($appname),$imgpath);
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
echo '<a href="' . $phpgw->link('/calendar/holiday_admin.php') . '">' . lang('Calendar Holiday Management') . '</a>';
/* $Id$ */
section_end();
}
?>
$imgpath = $phpgw->common->image($appname,'navbar.gif');
section_start(ucfirst($appname),$imgpath);
section_item($phpgw->link('/calendar/holiday_admin.php'),lang('Calendar Holiday Management'));
section_end();
?>