Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:entwickler:javascript-editor_integrieren [2015/11/04 21:38] – created thomas-rcven:entwickler:javascript-editor_integrieren [2025/03/09 11:20] (current) – removed fasse
Line 1: Line 1:
-====== Integrate Javascript-Editor ====== 
  
-With Admidio 2.3 the CKEditor is included as the standard. This can now be installed with simple methods in a script. 
- 
-===== Install editor in a form ===== 
-The installation into a form has become very easy since version 3.0.  
-Normally it should have been created with a form of class [[http://www.admidio.org/dokusource/class_html_form.html|HtmlForm]]. 
-<code php>$form = new HtmlForm('edit_form', $g_root_path.'/adm_program/modules/announcements/announcements_function.php?ann_id='.$getAnnId, $page);</code> 
-Now you can at call the matheod at the appropriate place just with[[http://www.admidio.org/dokusource/class_html_form.html#a8078919d1f9d0fd7966e1a5bfa635f25|addEditor]] and the CKEditor is already contained in your form. 
-<code php>$form->addEditor('ann_description', $gL10n->get('SYS_TEXT'), $announcement->getValue('ann_description'), array('property' => FIELD_REQUIRED));</code> 
- 
-===== Storing the contents ===== 
-If the contents of the editor shall be saved about an object or derived object of **Table Access** - class, it must be deposited an exception in the methods **getValue** and **setValue** for the editor field. This prevents the HTML content is removed from the editor again. <code php> public function getValue($field_name, $$format = '') 
-    { 
-        if($field_name == 'ann_description') 
-        { 
-            $value = $this->dbColumns['ann_description']; 
-        } 
-        else 
-        { 
-            $value = parent::getValue($field_name, $format); 
-        } 
- 
-        return $value; 
-    } 
-     
-    public function setValue($field_name, $field_value, $check_value = true) 
-    { 
-        if($field_name == 'ann_description') 
-        { 
-            return parent::setValue($field_name, $field_value, false); 
-        } 
-        return parent::setValue($field_name, $field_value); 
-    }</code> 
-     
-===== Validation of the HTML content ===== 
-Because only HTML code is passed using the editor, this has yet to be validated before being stored in the database. For this purpose Admidio uses the script htmLawed. This must be integrated into the script that processes the inputs of the editor: <code php> require_once ('../../libs/htmlawed/htmlawed.php'); </code> In the next step  the contents of the field is to be tested by the script: <code php> $_POST['ann_description'] = htmLawed(stripslashes($_POST['ann_description'])); </code> 
- 
-===== Enable image upload ===== 
-If the editor instance shall allow the upload of images, so it must be specified in the upload script  a folder name for a folder within **adm_my_files**. Proceed this by calling the script **adm_program/system/ckeditor_upload_handler.php** and supplement there the IF structure approximately 30 line with the new editor-ID <code php> if($_GET['CKEditor'] == 'ann_description ') 
-{ 
-    $folderName = 'ANNOUNCEMENTS'; 
-}</code> 
- 
-===== Skip the HTML code-Check ===== 
-The final step in the integration of the editor, the system-wide check of all passed variables for Html code must be deactivated for the id of the editor-field. For this purpose, the function **admStrStripTagsSpecial** must be supplemented. <code php> if($key != 'ann_description') // ckeditor-variable 
-{ 
-    $srcArray[$key] = strStripTags($value); 
-}</code> 
-Each new ID will be supplemented with **&& $key != 'editor_id_name'**.\\ \\   
-The integration of the CKEditor for another form is finished! 
  • en/entwickler/javascript-editor_integrieren.1446669514.txt.gz
  • Last modified: 2015/11/04 21:38
  • by thomas-rcv