Differences

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

Link to this comparison view

en:entwickler:javascript-editor_integrieren [2015/11/04 21:38]
thomas-rcv created
en:entwickler:javascript-editor_integrieren [2016/12/03 15:09] (current)
ximex codestyle and typos
Line 1: Line 1:
-====== Integrate ​Javascript-Editor ======+====== 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. With Admidio 2.3 the CKEditor is included as the standard. This can now be installed with simple methods in a script.
Line 5: Line 5:
 ===== Install editor in a form ===== ===== Install editor in a form =====
 The installation into a form has become very easy since version 3.0.  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]].+Normally it should have been created with a form of class [[https://​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>​ <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.+Now you can at call the method ​at the appropriate place just with[[https://​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>​ <code php>​$form->​addEditor('​ann_description',​ $gL10n->​get('​SYS_TEXT'​),​ $announcement->​getValue('​ann_description'​),​ array('​property'​ => FIELD_REQUIRED));</​code>​
  
 ===== Storing the contents ===== ===== 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 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'​)+        if ($fieldName === '​ann_description'​)
         {         {
             $value = $this->​dbColumns['​ann_description'​];​             $value = $this->​dbColumns['​ann_description'​];​
Line 19: Line 19:
         else         else
         {         {
-            $value = parent::​getValue($field_name, $format);+            $value = parent::​getValue($fieldName, $format);
         }         }
  
Line 25: Line 25:
     }     }
     ​     ​
-    public function setValue($field_name, $field_value, $check_value ​= true)+    public function setValue($fieldName, $fieldValue, $checkValue ​= true)
     {     {
-        if($field_name ​== '​ann_description'​)+        if ($fieldName === '​ann_description'​)
         {         {
-            return parent::​setValue($field_name, $field_value, false);+            return parent::​setValue($fieldName, $fieldValue, false);
         }         }
-        return parent::​setValue($field_name, $field_value);+        return parent::​setValue($fieldName, $fieldValue);
     }</​code>​     }</​code>​
     ​     ​
 ===== Validation of the HTML content ===== ===== 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>​+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 ===== ===== 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 ')+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';​     $folderName = '​ANNOUNCEMENTS';​
Line 44: Line 44:
  
 ===== Skip the HTML code-Check ===== ===== 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+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);​     $srcArray[$key] = strStripTags($value);​
  • en/entwickler/javascript-editor_integrieren.txt
  • Last modified: 2016/12/03 15:09
  • by ximex