summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd95070)
raw | patch | inline | side by side (parent: bd95070)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 23 Jun 2009 08:09:38 +0000 (08:09 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 23 Jun 2009 08:09:38 +0000 (08:09 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13765 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/fai/admin/fai/class_faiTemplateEdit.inc | [new file with mode: 0644] | patch | blob |
gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc | patch | blob | history | |
gosa-plugins/fai/admin/fai/faiTemplateEdit.tpl | [new file with mode: 0644] | patch | blob |
gosa-plugins/fai/admin/fai/faiTemplateEntry.tpl | patch | blob | history |
diff --git a/gosa-plugins/fai/admin/fai/class_faiTemplateEdit.inc b/gosa-plugins/fai/admin/fai/class_faiTemplateEdit.inc
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+
+class faiTemplateEdit extends plugin
+{
+ /* attribute list for save action */
+ var $config = "";
+ var $dn = "";
+ var $value = "";
+
+ // Encoding identification. Allows to warn the user.
+ var $enc_before_edit = "";
+ var $enc_after_edit = "";
+ var $write_protect = false;
+
+ function faiTemplateEdit (&$config, $dn, $value)
+ {
+ plugin::plugin ($config, $dn);
+ $this->value = $value;
+ $this->enc_before_edit = mb_detect_encoding($value);
+ if($this->enc_before_edit != "ASCII"){
+ $this->write_protect = TRUE;
+ }
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* We now split cn/FAItemplatePath to make things more clear... */
+ $smarty = get_smarty();
+ $smarty->assign("templateValue",htmlspecialchars(($this->value)));
+ $smarty->assign("write_protect",$this->write_protect);
+ return($smarty->fetch(get_template_path('faiTemplateEdit.tpl', TRUE)));
+ }
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['templateValue']) && !$this->write_protect){
+ $this->value = get_post('templateValue');
+ $this->enc_after_edit = mb_detect_encoding($this->value);
+ }
+ if(isset($_POST['editAnyway'])) $this->write_protect = FALSE;
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ $message = array();
+ if(!$this->write_protect && $this->enc_after_edit !== $this->enc_before_edit ){
+ $msg = sprintf(_("The file encodig has changed from '%s' to '%s', do you really want to save?"),
+ "<i>".$this->enc_before_edit."</i>","<i>".$this->enc_after_edit."</i>");
+ $message[] = $msg;
+ $this->enc_before_edit = $this->enc_after_edit;
+ }
+ return($message);
+ }
+
+ function save()
+ {
+ return($this->value);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc b/gosa-plugins/fai/admin/fai/class_faiTemplateEntry.inc
index ad1451a3695dcd6e7f34e4008cefe5d4e7a8ac91..2902562ee9d7d4ebf4bb35ba39d0c5c1b0657efe 100644 (file)
if(isset($_GET['getFAItemplate'])){
send_binary_content($this->FAItemplateFile,$this->cn.".FAItemplate");
}
-
- $status= _("no file uploaded yet");
+ /* File edit requested */
+ if(isset($_GET['editFAItemplate'])){
+ $this->dialog = new faiTemplateEdit($this->config,$this->dn,$this->FAItemplateFile);
+ }
+
+ /* File edit requested, was canceled */
+ if(isset($_POST['templateEditCancel'])){
+ $this->dialog = null;
+ }
+
+ /* File edit requested, was canceled */
+ if($this->dialog instanceOf faiTemplateEdit && isset($_POST['templateEditSave'])){
+ $this->dialog->save_object();
+ $msgs = $this->dialog->check();
+ if(count($msgs)){
+ msg_dialog::displayChecks($msgs);
+ }else{
+ $this->FAItemplateFile = $this->dialog->save();
+ $this->dialog = null;
+ }
+ }
+
+ /* Display opened dialog */
+ if($this->dialog){
+ $this->dialog->save_object();
+ return($this->dialog->execute());
+ }
+
+ $status= _("no file uploaded yet");
$bStatus = false; // Hide download icon on default
-
if(strlen($this->FAItemplateFile)){
-
$status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile));
$bStatus = true; // Display download icon
}
+
$smarty->assign("status",$status);
$smarty->assign("bStatus",$bStatus);
diff --git a/gosa-plugins/fai/admin/fai/faiTemplateEdit.tpl b/gosa-plugins/fai/admin/fai/faiTemplateEdit.tpl
--- /dev/null
@@ -0,0 +1,19 @@
+<h2>Template entry</h2>
+
+{if $write_protect}
+{t}This FAI template is write protected due to its character encoding, editing may brake this file!{/t}
+<br><input type='submit' value='{t}Edit anyway{/t}' name='editAnyway'>
+{/if}
+
+<textarea {if $write_protect} disabled {/if}
+ style='width:100%; height: 350px;'
+ {if !$write_protect}name="templateValue"{/if}
+>{$templateValue}</textarea>
+
+<p class='seperator'>
+ <div style='text-align:right;'>
+ <input type='submit' name='templateEditSave' value='{msgPool type=okButton}'>
+
+ <input type='submit' name='templateEditCancel' value='{msgPool type=cancelButton'}'>
+ </div>
+</p>
diff --git a/gosa-plugins/fai/admin/fai/faiTemplateEntry.tpl b/gosa-plugins/fai/admin/fai/faiTemplateEntry.tpl
index 789dac439c54939cdc64178f6630d9c684d496fe..f2a7cbf6631b544120103c0bf1764e4644ab87e3 100644 (file)
<table width="100%" summary="">
<tr>
- <td colspan=2><h2><img class="middle" alt="" src="plugins/fai/images/fai_template.png" title="{t}Template attributes{/t}"> {t}Template attributes{/t}</h2></td>
+ <td colspan=2>
+ <h2>
+ <img class="center" alt=""
+ src="plugins/fai/images/fai_template.png"
+ title="{t}Template attributes{/t}"> {t}Template attributes{/t}
+ </h2>
+ </td>
</tr>
<tr>
<td style="vertical-align:top;width:50%;border-right:1px solid #B0B0B0">
- <table summary="">
+ <table summary="">
<tr>
- <td style="vertical-align:top">
- <LABEL for="FAItemplateFile">
- {t}File{/t}{$must}
- </LABEL>
- </td>
- <td style="vertical-align:top" class="center">
- {$status}
- {if $bStatus}
- <a href="{$plug}&getFAItemplate">
- <img class="center" alt="{t}Save template{/t}..." title="{t}Save template{/t}..." src="images/save.png" border="0" />
- </a>
- {/if}
- <br>
- <br>
+ <td>
+ {t}File{/t}{$must}: {$status}
+ {if $bStatus}
+ <a href="{$plug}&getFAItemplate">
+ <img class="center" alt="{t}Save template{/t}..."
+ title="{t}Save template{/t}..." src="images/save.png" border="0" />
+ </a>
+ <a href="{$plug}&editFAItemplate">
+ <img class="center" alt="{t}Edit template{/t}..."
+ title="{t}Edit template{/t}..." src="images/lists/edit.png" border="0" />
+ </a>
+ {/if}
+ </td>
+ </tr>
+ {if $bStatus}
+ <tr>
+ <td>
+ {t}Full path{/t}: <i>{$FAItemplatePath}</i>
+ </td>
+ </tr>
+ {/if}
+ <tr>
+ <td style="vertical-align:top" class="center">
{render acl=$FAItemplateFileACL}
- <input type="file" name="FAItemplateFile" value="" id="FAItemplateFile">
+ <input type="file" name="FAItemplateFile" value="" id="FAItemplateFile">
{/render}
{render acl=$FAItemplateFileACL}
- <input type="submit" value="{t}Upload{/t}" name="TmpFileUpload">
-{/render}
- <br>
- <br>
- </td>
- </tr><tr>
- <td>
- {t}Full path{/t}
- </td>
- <td>
-{render acl=$FAItemplatePathACL}
- <i>{$FAItemplatePath}</i>
+ <input type="submit" value="{t}Upload{/t}" name="TmpFileUpload">
{/render}
- </td>
- </tr>
- </table>
+ </td>
+ </tr>
+ </table>
</td>
<td>
<table summary="">