From: hickert Date: Mon, 4 Oct 2010 06:45:30 +0000 (+0000) Subject: Added textEditor widget X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5cb407458a539f4cb120d1269973080cc4694873;p=gosa.git Added textEditor widget git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19893 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/admin/systems/goto/Config/TemplateWidget_textEditor.tpl b/gosa-plugins/goto/admin/systems/goto/Config/TemplateWidget_textEditor.tpl new file mode 100644 index 000000000..4f2ae450e --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/TemplateWidget_textEditor.tpl @@ -0,0 +1,12 @@ +{if $write_protect} + {t}The text is write protected, due to its encoding. Editing may break it!{/t} +
+ +{/if} + +
+   + +
diff --git a/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_textEditor.inc b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_textEditor.inc new file mode 100644 index 000000000..93b7951c1 --- /dev/null +++ b/gosa-plugins/goto/admin/systems/goto/Config/class_TemplateWidget_textEditor.inc @@ -0,0 +1,75 @@ +mb_extension = function_exists("mb_detect_encoding"); + if($this->mb_extension){ + $this->enc_before_edit = mb_detect_encoding($this->value); + if($this->enc_before_edit != "ASCII"){ + $this->write_protect = TRUE; + } + } + } + + + function render() + { + $smarty = get_smarty(); + $smarty->assign("postName", set_post($this->postName)); + $smarty->assign("write_protect", set_post($this->write_protect)); + $smarty->assign("value", set_post($this->value)); + return($smarty->fetch(get_template_path("TemplateWidget_textEditor.tpl", TRUE, dirname(__FILE__)))); + } + + + function save_object() + { + TemplateWidget::save_object(); + if(isset($_POST['editAnyway'])) $this->write_protect = FALSE; + + if(isset($_POST['ImportUpload'])){ + if(($_FILES['ImportFile']['error']!=0)){ + msg_dialog::display(_("Error"), msgPool::incorrectUpload(), ERROR_DIALOG); + }elseif(($_FILES['ImportFile']['size']==0)){ + msg_dialog::display(_("Error"), msgPool::incorrectUpload(_("file is empty")), ERROR_DIALOG); + }else{ + $str = file_get_contents($_FILES['ImportFile']['tmp_name']); + $this->value = $str; + + // Check encoding again + if($this->mb_extension){ + $this->enc_before_edit = mb_detect_encoding($this->value); + if($this->enc_before_edit != "ASCII"){ + $this->write_protect = TRUE; + } + } + } + } + $this->enc_after_edit = mb_detect_encoding($this->value); + } + + + /*! \brief Check the value entry using the provieded syntax. + * @return Array Returns a list of errors + */ + function check() + { + $msgs = TemplateWidget::check(); + if($this->mb_extension && !$this->write_protect && $this->enc_after_edit !== $this->enc_before_edit ){ + $msg = sprintf(_("The text encodig has changed from '%s' to '%s'. Do you really want to save?"), + "".$this->enc_before_edit."","".$this->enc_after_edit.""); + $msgs[] = $msg; + $this->enc_before_edit = $this->enc_after_edit; + } + return($msgs); + } +} +?> diff --git a/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl b/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl index 799343e28..aceefdb0c 100644 --- a/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl +++ b/gosa-plugins/goto/admin/systems/goto/Config/puppet.tpl @@ -23,9 +23,11 @@ + {$textEditorName} + {$textEditor} - {$fixedList} {$fixedListName} + {$fixedList} {/if} {if $type == 'PuppetTemplate'}