phpldapadmin/htdocs/create_form.php

135 lines
4.1 KiB
PHP
Raw Normal View History

2009-06-30 08:09:20 +00:00
<?php
2009-06-30 10:28:51 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/Attic/create_form.php,v 1.31.2.5 2005/12/31 04:21:37 wurley Exp $
2009-06-30 09:22:30 +00:00
2009-06-30 09:29:51 +00:00
/**
2009-06-30 08:05:37 +00:00
* The menu where the user chooses an RDN, Container, and Template for creating a new entry.
* After submitting this form, the user is taken to their chosen Template handler.
*
2009-06-30 09:29:51 +00:00
* Variables that come in via common.php
* - server_id
2009-06-30 08:09:20 +00:00
* Variables that come in as GET vars
2009-06-30 08:05:37 +00:00
* - container (rawurlencoded) (optional)
2009-06-30 09:29:51 +00:00
*
* @package phpLDAPadmin
*/
/**
2009-06-30 08:05:37 +00:00
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
if ($ldapserver->isReadOnly())
pla_error(_('You cannot perform updates while server is in read-only mode'));
if (! $ldapserver->haveAuthInfo())
pla_error(_('Not enough information to login to server. Please check your configuration.'));
2009-06-30 08:05:37 +00:00
2009-06-30 08:07:14 +00:00
$container = $_REQUEST['container'];
2009-06-30 09:29:51 +00:00
$server_menu_html = server_select_list($ldapserver->server_id,true);
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
include './header.php';
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
echo '<body>';
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
printf('<h3 class="title">%s</h3>',_('Create Object'));
printf('<h3 class="subtitle">%s</h3>',_('Choose a template'));
printf('<center><h3>%s</h3></center>',_('Select a template for the creation process'));
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '<form action="template_engine.php" method="post">';
printf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($container));
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
echo '<table class="create">';
printf('<tr><td class="heading">%s:</td><td>%s</td></tr>',_('Server'),$server_menu_html);
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '<tr>';
printf('<td class="heading">%s:</td>',_('Template'));
echo '<td>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '<table class="template_display">';
echo '<tr><td>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '<table class="templates">';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
$i = -1;
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
$template_xml = new Templates($ldapserver->server_id);
$templates = $template_xml->_template;
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
# Remove non-visable templates.
foreach ($templates as $index => $template)
if (isset($template['visible']) && (! $template['visible']))
unset ($templates[$index]);
2009-06-30 09:29:51 +00:00
$templates['custom']['title'] = 'Custom';
$templates['custom']['icon'] = 'images/object.png';
2009-06-30 10:26:08 +00:00
$count = count($templates);
foreach ($templates as $name => $template) {
2009-06-30 09:29:51 +00:00
$i++;
# If the template doesnt have a title, we'll use the desc field.
$template['desc'] = isset($template['title']) ? $template['title'] : $template['desc'];
# Balance the columns properly
2009-06-30 10:26:08 +00:00
if ((count($templates) % 2 == 0 && $i == intval($count / 2)) ||
(count($templates) % 2 == 1 && $i == intval($count / 2) + 1))
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
echo '</table></td><td><table class="templates">';
2009-06-30 09:29:51 +00:00
# Check and see if this template should be shown in the list
$isValid = false;
2009-06-30 10:26:08 +00:00
if (isset($template['regexp'])) {
if (@preg_match('/'.$template['regexp'].'/i',$container))
2009-06-30 09:29:51 +00:00
$isValid = true;
2009-06-30 10:26:08 +00:00
} else
2009-06-30 09:29:51 +00:00
$isValid = true;
if (isset($template['invalid']) && $template['invalid'])
$isValid = false;
2009-06-30 10:26:08 +00:00
echo '<tr>';
if (! $isValid || (isset($template['handler']) && ! file_exists(TMPLDIR.'creation/'.$template['handler'])))
echo '<td class="icon"><img src="images/error.png" /></td>';
else
printf('<td><input type="radio" name="template" value="%s" id="%s" %s /></td>',
htmlspecialchars($name),htmlspecialchars($name),
! $isValid ? 'disabled' : (strcasecmp('Custom',$name) ? '' : 'checked'));
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
printf('<td class="icon"><label for="%s"><img src="%s" /></label></td>',
htmlspecialchars($name),$template['icon']);
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
printf('<td class="name"><label for="%s">',
htmlspecialchars($name));
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
if (strcasecmp('Custom', $template['desc']) == 0)
echo '<b>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
if (! $isValid)
2009-06-30 09:29:51 +00:00
if (isset($template['invalid']) && $template['invalid'])
2009-06-30 10:26:08 +00:00
printf('<span style="color: gray"><acronym title="%s">',
isset($template['invalid_reason']) ? $template['invalid_reason'] :
_('This template has been disabled in the XML file.'));
2009-06-30 09:29:51 +00:00
else
2009-06-30 10:26:08 +00:00
printf('<span style="color: gray"><acronym title="%s">',
_('This template is not allowed in this container.'));
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo htmlspecialchars($template['desc']);
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
if (! $isValid) echo '</acronym></span>';
if (strcasecmp('Custom', $template['desc']) == 0)
echo '</b>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '</label></td></tr>';
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
}
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
echo '</table>';
echo '</td></tr></table>';
echo '</td></tr>';
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
printf('<tr><td colspan="2"><center><input type="submit" name="submit" value="%s" /></center></td></tr>',
htmlspecialchars(_('Proceed >>')));
2009-06-30 08:05:37 +00:00
2009-06-30 10:26:08 +00:00
echo '</table>';
echo '</form></body></html>';
?>