TinyMCE in “Add FAQ” for normal users in phpMyFAQ

I am searching for a better knowledge management tool for my team.

Found phpMyFAQ is a good choice.

 

It has many features like

 

  • Various supported database systems
  • Content Management System
  • User and group based permissions
  • LDAP and HTTP authentication
  • Revision system
  • Community modules
  • FAQ statistics
  • Backup and Restore
  • Templating system
  • Powerful search
  • OpenSearch and Microsummaries support
  • User comments
  • Smart answering
  • Easy to use HTML editor
  • Multilanguage support
  • Most popular FAQs, latest FAQs, and sticky FAQs
  • Browse by Category or Tags
  • Search engine optimization
  • Extended sitemap support
  • Simple installation and configuration
  • Exports your FAQ to PDF, XHTML
  • Advanced spam protection

 

 

check http://www.phpmyfaq.de/features.php for details.

 

 

I installed it and explored the features.

Installation is as simple as any other web application.

Untar in document root, create database and db user, access via browser, fill the details. Thats all.

 

The user interface is simple, clean.

I like the AJAX powered instant search.

 

The only issue I found in phpMyFAQ is “the simple textbox for submitting FAQ

 

Any normal logged in user or anonymous user can submit FAQ.

But the form is in plain text area.

 

Only “admin” user can approve the FAQs and publish.

But, for the admin user there is a WYSIWYG editor (TinyMCE) available for formatting the content.

 

 

 

 

 

It is not a good process for the admin user to sit and formatting the content.

He should read, edit and approve the contents.

 

As the phpMyFAQ is open source and it is in PHP, I explored the code and the forums.

Forums gave some ideas and it took some hours to modify the code to enable the TinyMCE for all users.

 

Here is the procedures.

  1. File : save.php

Change the Line No 42:

Original:

$content = PMF_Filter::filterInput(INPUT_POST, ‘content’, FILTER_SANITIZE_STRIPPED);

Modified:

$content = PMF_Filter::filterInput(INPUT_POST, ‘faqcontent’,FILTER_UNSAFE_RAW);

 

Here, I renamed the textarea name from “content” to “faqcontent” to enable TinyMCE only for that textarea and made the content text filter as “ FILTER_UNSAFE_RAW” to enable the text typed in TinyMCE editor to keep the same formatting in the database.

If we use other filters, the formatting is lost before storing in db.

 

  1. File : template/default/add.tpl

     

Change in Line No: 23

Original:

<textarea class=”inputarea” cols=”37″ rows=”10″ name=”content” id=”content”></textarea><br />

Modified:

<textarea class=”inputarea” cols=”37″ rows=”10″ name=”faqcontent” id=”faqcontent”></textarea><br />

Here is the change in the textarea name and id to enable the TinyMCE.

 

  1. File template/default/add.tpl

Same file as we modified before.

Add the following content In the end of the file.


<!-- tinyMCE -->

<script type="text/javascript" src="admin/editor/tiny_mce.js"></script>

<script type="text/javascript">

/*<![CDATA[*/ //<!--

tinyMCE.init({

// General options

mode : "exact",

elements : "faqcontent",

width : "400",

height : "480",

theme : "advanced",

plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,syntaxhl,phpmyfaq",

theme_advanced_blockformats : "p,div,h1,h2,h3,h4,h5,h6,blockquote,dt,dd,code,samp",

// Theme options

theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|styleselect,formatselect,fontselect,fontsizeselect",

theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,syntaxhl,|,forecolor,backcolor",

theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|fullscreen,help",

theme_advanced_toolbar_location : "top",

theme_advanced_toolbar_align : "left",

theme_advanced_statusbar_location : "bottom",

relative_urls : false,

convert_urls : false,

remove_linebreaks : false,

use_native_selects : true,

extended_valid_elements : "code",

// Ajax-based file manager

file_browser_callback : "ajaxfilemanager",

// Drop lists for link/image/media/template dialogs

template_external_list_url : "js/template_list.js"

});

function ajaxfilemanager(field_name, url, type, win)

{

var ajaxfilemanagerurl = "admin/editor/plugins/ajaxfilemanager/ajaxfilemanager.php";

switch (type) {

case "image":

case "media":

case "flash":

case "file":

break;

default:

return false;

}

tinyMCE.activeEditor.windowManager.open({

url : "admin/editor/plugins/ajaxfilemanager/ajaxfilemanager.php",

width : 782,

height : 440,

inline : "yes",

close_previous : "no"

},{

window : win,

input : field_name

});

}

// --> /*]]>*/

</script>

<!-- /tinyMCE -->

Thats all.

Now the TinyMCE editor is enable for all the users.

Security Note:

Enabling TinyMCE for all users may create XSS attacks in public sites.Dont enable this if you use phpMyFAQ for any public sites.I used this as I host in my intranet site.

 

 

8 thoughts on “TinyMCE in “Add FAQ” for normal users in phpMyFAQ

  1. Howdy just wanted to give you a quick heads up. The text in your content seem to be
    running off the screen in Opera. I’m not sure if this is a format issue or something to
    do with internet browser compatibility but I thought I’d post to let you know.
    The design look great though! Hope you get the issue solved soon.
    Kudos

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s