phpldapadmin/htdocs/template_engine.php

58 lines
2.1 KiB
PHP
Raw Normal View History

2009-06-30 09:29:51 +00:00
<?php
/**
* Template render engine.
*
2009-06-30 09:29:51 +00:00
* @package phpLDAPadmin
* @subpackage Page
2009-06-30 09:29:51 +00:00
* @author The phpLDAPadmin development team
*/
2009-06-30 09:29:51 +00:00
/**
The template engine has the following responsibilities:
* If we are passed a DN, then we are editing an existing entry
* If we are not passed a DN, then we are passed a container (and creating a new entry in that container)
In both cases, we are optionally passed a template ID.
* If we have a template ID, then we'll render the creation/editing using that template
* If we are not passed a template ID, then we'll either:
* Present a list of available templates,
* Present the default template, because there are non available (due to hidden,regexp or non-existant)
* Present the only template, if there is only one.
Creating and editing entries use two objects:
* A template object which describes how the template should be rendered (and what values should asked for, etc)
* A page object, which is responsible for actually sending out the HTML to the browser.
So:
* we init a new TemplateRender object
* we init a new Template object
* set the DN or container on the template object
* If setting the DN, this in turn should read the "old values" from the LDAP server
* If we are not on the first page (ie: 2nd, 3rd, 4th step, etc), we should accept the post values that we have obtained thus far
* Finally submit the update to "update_confirm", or the create to "create", when complete.
2009-06-30 09:29:51 +00:00
*/
require './common.php';
2009-06-30 10:26:08 +00:00
$request = array();
$request['dn'] = get_request('dn','REQUEST');
$request['page'] = new TemplateRender($app['server']->getIndex(),get_request('template','REQUEST',false,null));
2009-06-30 09:29:51 +00:00
# If we have a DN, then this is to edit the entry.
if ($request['dn']) {
$app['server']->dnExists($request['dn'])
or error(sprintf('%s (%s)',_('No such entry'),pretty_print_dn($request['dn'])),'error','index.php');
2009-06-30 09:29:51 +00:00
$request['page']->setDN($request['dn']);
$request['page']->accept();
2009-06-30 09:29:51 +00:00
2009-06-30 10:46:00 +00:00
} else {
if ($app['server']->isReadOnly())
2009-06-30 11:52:55 +00:00
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
2009-06-30 09:29:51 +00:00
$request['page']->setContainer(get_request('container','REQUEST'));
$request['page']->accept();
2009-06-30 10:26:08 +00:00
}
?>