18
18
require './common.php';
19
require TMPLDIR.'template_config.php';
21
if( $ldapserver->isReadOnly() )
22
pla_error( $lang['no_updates_in_read_only_mode'] );
23
if( ! $ldapserver->haveAuthInfo())
24
pla_error( $lang['not_enough_login_info'] );
26
$step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : 1; // defaults to 1
20
if ($ldapserver->isReadOnly())
21
pla_error(_('You cannot perform updates while server is in read-only mode'));
22
if (! $ldapserver->haveAuthInfo())
23
pla_error(_('Not enough information to login to server. Please check your configuration.'));
27
25
$container = $_REQUEST['container'];
29
26
$server_menu_html = server_select_list($ldapserver->server_id,true);
31
include './header.php'; ?>
35
<h3 class="title"><?php echo $lang['createf_create_object']?></h3>
36
<h3 class="subtitle"><?php echo $lang['createf_choose_temp']?></h3>
37
<center><h3><?php echo $lang['createf_select_temp']?></h3></center>
39
<form action="creation_template.php" method="post">
40
<input type="hidden" name="container" value="<?php echo htmlspecialchars( $container ); ?>" />
41
<table class="create">
43
<td class="heading"><?php echo $lang['server']; ?>:</td>
44
<td><?php echo $server_menu_html; ?></td>
48
<td class="heading"><?php echo $lang['template']; ?>:</td>
51
<table class="template_display">
54
<table class="templates">
28
include './header.php';
32
printf('<h3 class="title">%s</h3>',_('Create Object'));
33
printf('<h3 class="subtitle">%s</h3>',_('Choose a template'));
34
printf('<center><h3>%s</h3></center>',_('Select a template for the creation process'));
36
echo '<form action="template_engine.php" method="post">';
37
printf('<input type="hidden" name="container" value="%s" />',htmlspecialchars($container));
39
echo '<table class="create">';
40
printf('<tr><td class="heading">%s:</td><td>%s</td></tr>',_('Server'),$server_menu_html);
43
printf('<td class="heading">%s:</td>',_('Template'));
46
echo '<table class="template_display">';
49
echo '<table class="templates">';
59
if ($config->GetValue('template_engine','enable')) {
60
$template_xml = new Templates($ldapserver->server_id);
62
if ($config->GetValue('template_engine','disable_old'))
63
$templates = $template_xml->getTemplates();
66
$templates = array_merge($template_xml->getTemplates(),$templates);
69
# Remove non-visable templates.
70
foreach ($templates as $index => $template)
71
if (isset($template['visible']) && (! $template['visible']))
72
unset ($templates[$index]);
53
$template_xml = new Templates($ldapserver->server_id);
54
$templates = $template_xml->_template;
56
# Remove non-visable templates.
57
foreach ($templates as $index => $template)
58
if (isset($template['visible']) && (! $template['visible']))
59
unset ($templates[$index]);
74
61
$templates['custom']['title'] = 'Custom';
75
62
$templates['custom']['icon'] = 'images/object.png';
77
$count = count( $templates );
78
foreach( $templates as $name => $template ) {
64
$count = count($templates);
65
foreach ($templates as $name => $template) {
81
68
# If the template doesnt have a title, we'll use the desc field.
82
69
$template['desc'] = isset($template['title']) ? $template['title'] : $template['desc'];
84
71
# Balance the columns properly
85
if( ( count( $templates ) % 2 == 0 && $i == intval( $count / 2 ) ) ||
86
( count( $templates ) % 2 == 1 && $i == intval( $count / 2 ) + 1 ) )
72
if ((count($templates) % 2 == 0 && $i == intval($count / 2)) ||
73
(count($templates) % 2 == 1 && $i == intval($count / 2) + 1))
88
echo "</table></td><td><table class=\"templates\">";
75
echo '</table></td><td><table class="templates">';
90
77
# Check and see if this template should be shown in the list
93
if( isset($template['regexp'] ) ) {
94
if( @preg_match( "/".$template['regexp']."/i", $container ) ) {
80
if (isset($template['regexp'])) {
81
if (@preg_match('/'.$template['regexp'].'/i',$container))
101
86
if (isset($template['invalid']) && $template['invalid'])
110
if (isset($template['invalid']) && $template['invalid'] || (isset($template['handler']) && ! file_exists(TMPLDIR.'creation/'.$template['handler']))) {
113
<img src="images/error.png" />
120
<input type="radio" name="template" value="<?php echo htmlspecialchars($name);?>"
121
id="<?php echo htmlspecialchars($name); ?>"
124
if( 0 == strcasecmp( 'Custom', $name ) ) echo ' checked';
125
if( ! $isValid ) echo ' disabled';
134
<label for="<?php echo htmlspecialchars($name);?>">
135
<img src="<?php echo $template['icon']; ?>" />
140
<label for="<?php echo htmlspecialchars($name);?>">
142
<?php if( 0 == strcasecmp( 'Custom', $template['desc'] ) ) echo '<b>';
90
if (! $isValid || (isset($template['handler']) && ! file_exists(TMPLDIR.'creation/'.$template['handler'])))
91
echo '<td class="icon"><img src="images/error.png" /></td>';
93
printf('<td><input type="radio" name="template" value="%s" id="%s" %s /></td>',
94
htmlspecialchars($name),htmlspecialchars($name),
95
! $isValid ? 'disabled' : (strcasecmp('Custom',$name) ? '' : 'checked'));
97
printf('<td class="icon"><label for="%s"><img src="%s" /></label></td>',
98
htmlspecialchars($name),$template['icon']);
100
printf('<td class="name"><label for="%s">',
101
htmlspecialchars($name));
103
if (strcasecmp('Custom', $template['desc']) == 0)
145
107
if (isset($template['invalid']) && $template['invalid'])
146
printf('<span style="color: gray"><acronym title="%s">',$lang['template_invalid']);
108
printf('<span style="color: gray"><acronym title="%s">',
109
isset($template['invalid_reason']) ? $template['invalid_reason'] :
110
_('This template has been disabled in the XML file.'));
148
printf('<span style="color: gray"><acronym title="%s">',$lang['template_restricted']);
150
echo htmlspecialchars( $template['desc'] );
152
if( ! $isValid ) echo "</acronym></span>";
153
if( 0 == strcasecmp( 'Custom', $template['desc'] ) ) echo '</b>'; ?>
159
<?php } // end foreach ?>
169
<td colspan="2"><center><input type="submit" name="submit" value="<?php echo $lang['proceed_gt']?>" /></center></td>
112
printf('<span style="color: gray"><acronym title="%s">',
113
_('This template is not allowed in this container.'));
115
echo htmlspecialchars($template['desc']);
117
if (! $isValid) echo '</acronym></span>';
118
if (strcasecmp('Custom', $template['desc']) == 0)
121
echo '</label></td></tr>';
126
echo '</td></tr></table>';
129
printf('<tr><td colspan="2"><center><input type="submit" name="submit" value="%s" /></center></td></tr>',
130
htmlspecialchars(_('Proceed >>')));
133
echo '</form></body></html>';