PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/accounts/ldapadmin/templates/template_header.php

https://github.com/azeckoski/az-php-sandbox
PHP | 175 lines | 127 code | 42 blank | 6 comment | 22 complexity | 58b065e793ca6c96c603c752f41fd1c5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. // $Header: /cvsroot/phpldapadmin/phpldapadmin/templates/template_header.php,v 1.6.4.5 2005/12/09 14:32:37 wurley Exp $
  3. /**
  4. * Header page for engine.
  5. * @package phpLDAPadmin
  6. * @author The phpLDAPadmin development team
  7. */
  8. include './header.php';
  9. $time = gettimeofday();
  10. $random_junk = md5(strtotime('now').$time['usec']);
  11. $url_base = sprintf('server_id=%s&amp;dn=%s',$ldapserver->server_id,$encoded_dn);
  12. $export_href_base = sprintf('export_form.php?%s&amp;scope=%s',$url_base,'base');
  13. $export_href_sub = sprintf('export_form.php?%s&amp;scope=%s',$url_base,'sub');
  14. $refresh_href = sprintf('template_engine.php?%s&amp;random=%s',$url_base,$random_junk);
  15. $copy_href = sprintf('copy_form.php?%s',$url_base);
  16. $intattr_href = sprintf('template_engine.php?%s&amp;show_internal_attrs=true',$url_base);
  17. $delete_href = sprintf('delete_form.php?%s',$url_base);
  18. $rename_href = sprintf('rename_form.php?%s',$url_base);
  19. $compare_href = sprintf('compare_form.php?%s',$url_base);
  20. $create_href = sprintf('create_form.php?server_id=%s&amp;container=%s',$ldapserver->server_id,$encoded_dn);
  21. $addattr_href = sprintf('add_attr_form.php?%s',$url_base);
  22. echo '<body>';
  23. if ($dn) {
  24. $actionlayout = '<td class="icon"><img src="images/%s" /></td><td><a href="%s" title="%s">%s</a></td>';
  25. $hintlayout = '<td class="icon"><img src="images/light.png" /></td><td colspan="3"><span class="hint">%s</span></td>';
  26. printf('<h3 class="title">%s</h3>',htmlspecialchars($rdn));
  27. printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
  28. _('Server'),$ldapserver->name,_('Distinguished Name'),htmlspecialchars($dn));
  29. echo "\n";
  30. echo '<table class="edit_dn_menu"><tr>';
  31. printf($actionlayout,'refresh.png',$refresh_href,_('Refresh this entry'),_('Refresh'));
  32. printf($actionlayout,'save.png',$export_href_base,_('Save a dump of this object'),_('Export'));
  33. echo '</tr><tr>';
  34. printf($actionlayout,'cut.png',$copy_href,_('Copy this object to another location, a new DN, or another server'),_('Copy or move this entry'));
  35. if ($show_internal_attrs)
  36. printf($actionlayout,'tools-no.png',$refresh_href,'',_('Hide internal attributes'));
  37. else
  38. printf($actionlayout,'tools.png',$intattr_href,'',_('Show internal attributes'));
  39. echo '</tr>';
  40. if (! $ldapserver->isReadOnly()) {
  41. echo '<tr>';
  42. printf($actionlayout,'trash.png',$delete_href,_('You will be prompted to confirm this decision'),_('Delete this entry'));
  43. printf($actionlayout,'rename.png',$rename_href,'',_('Rename'));
  44. echo '</tr>';
  45. if ($config->GetValue('appearance','show_hints')) {
  46. echo '<tr>';
  47. printf($hintlayout,_('Hint: To delete an attribute, empty the text field and click save.'));
  48. echo '</tr>';
  49. }
  50. echo '<tr>';
  51. printf($actionlayout,'compare.png',$compare_href,'',_('Compare with another entry'));
  52. echo '</tr>';
  53. echo '<tr>';
  54. printf($actionlayout,'star.png',$create_href,'',_('Create a child entry'));
  55. printf($actionlayout,'add.png',$addattr_href,'',_('Add new attribute'));
  56. echo '</tr>';
  57. }
  58. flush();
  59. $children = $ldapserver->getContainerContents($dn,$max_children,'(objectClass=*)',$config->GetValue('deref','view'));
  60. if (($children_count = count($children)) > 0) {
  61. if ($children_count == $max_children)
  62. $children_count = $children_count.'+';
  63. $child_href = sprintf('search.php?server_id=%s&amp;search=true&amp;filter=%s&amp;base_dn=%s&amp;form=advanced&amp;scope=one',
  64. $ldapserver->server_id,rawurlencode('objectClass=*'),$encoded_dn);
  65. echo '<tr>';
  66. printf($actionlayout,'children.png',$child_href,'',($children_count == 1) ? _('View 1 child') : sprintf(_('View %s children'),$children_count));
  67. printf($actionlayout,'save.png',$export_href_sub,_('Save a dump of this object and all of its children'),_('Export subtree'));
  68. echo '</tr>';
  69. }
  70. if ($config->GetValue('appearance','show_hints')) {
  71. echo '<tr>';
  72. printf($hintlayout,_('Hint: To view the schema for an attribute, click the attribute name.'));
  73. echo '</tr>';
  74. }
  75. if ($ldapserver->isReadOnly()) {
  76. echo '<tr>';
  77. printf($hintlayout,_('Viewing entry in read-only mode.'));
  78. echo '</tr>';
  79. }
  80. if ($modified_attrs) {
  81. echo '<tr>';
  82. printf($hintlayout,
  83. ($children_count == 1) ? sprintf(_('An attribute (%s) was modified and is highlighted below.'),implode('',$modified_attrs)) :
  84. sprintf(_('Some attributes (%s) were modified and are highlighted below.'),implode(', ',$modified_attrs)));
  85. echo '</tr>';
  86. }
  87. echo '</table>';
  88. flush();
  89. if (! $ldapserver->isReadOnly()) {
  90. echo '<form action="update_confirm.php" method="post" name="edit_form">';
  91. printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
  92. printf('<input type="hidden" name="dn" value="%s" />',$dn);
  93. }
  94. echo '<br />'."\n\n";
  95. echo '<table class="edit_dn">';
  96. if ($show_internal_attrs) {
  97. $counter = 0;
  98. foreach ($ldapserver->getDNSysAttrs($dn) as $attr => $vals) {
  99. $counter++;
  100. $schema_href = sprintf('schema.php?server_id=%s&amp;view=attributes&amp;viewvalue=%s',
  101. $ldapserver->server_id,real_attr_name($attr));
  102. printf('<tr><td colspan="2" class="attr"><b><a title="'._('Click to view the schema defintion for attribute type \'%s\'').'" href="%s" />%s</b></td></tr>',
  103. $attr,$schema_href,htmlspecialchars($attr));
  104. echo '<tr><td class="val"><small>';
  105. if ($ldapserver->isAttrBinary($attr)) {
  106. $href = sprintf('download_binary_attr.php?server_id=%s&amp;dn=%s&amp;attr=%s',$server_id,$encoded_dn,$attr);
  107. echo _('Binary value');
  108. echo '<br />';
  109. if (count($vals) > 1) {
  110. for ($i=1;$i<=count($vals);$i++)
  111. printf('<a href="%s&amp;value_num=%s"><img src="images/save.png" /> %s(%s)</a><br />',
  112. $href,$i,_('download value'),$i);
  113. } else {
  114. printf('<a href="%s"><img src="images/save.png" /> %s</a><br />',
  115. $href,_('download value'));
  116. }
  117. } else {
  118. foreach ($vals as $v)
  119. printf('%s<br />',htmlspecialchars($v));
  120. }
  121. echo '</small></td></tr>';
  122. }
  123. if ($counter == 0)
  124. printf('<tr><td colspan="2">(%s)</td></tr>',_('No internal attributes'));
  125. echo "\n\n";
  126. }
  127. flush();
  128. } else {
  129. printf('<h3 class="title">%s</h3>',_('Create Object'));
  130. printf('<h3 class="subtitle">%s: <b>%s</b> &nbsp;&nbsp;&nbsp; %s: <b>%s</b></h3>',
  131. _('Server'),$ldapserver->name,_('using template'),htmlspecialchars($_REQUEST['template']));
  132. }
  133. ?>