Quantcast
Channel: Marty Thornley » php
Viewing all articles
Browse latest Browse all 9

Adding TinyMCE text editor to Project Pier

0
0

I have recently started using the open source project management app called Project Pier to organize and coordinate my website projects. It is similar to some of the popular hosted services like Basecamp, No Kahuna, or GoPlan with a couple major exceptions – it is FREE and you install and run it on your own server. I will be adding an entire page to the site soon to show how I use Project Pier to upload and share files, send and receive messages and create task lists which can be shared and assigned to anyone working on a project. I might even create a demo project for anyone interested in seeing it in action.

One of the things it was lacking was the ability to add links and other html to the messages. It used a simple text area and did not allow any formatting at all. In the past I had used TinyMCE WYSIWYG editor which can turn any text area into a full-fledged WYSIWYG text editor.

I wasn’t looking forward to digging through an entire application to figure out how to add TinyMCE but I found a post by Matt Gibson which detailed exactly which files needed to be edited. He does a great job of walking you through the initial addition of the TinyMCE files so I won’t repeat it here.

Following his steps adds the WYSIWYG editor, but ProjectPier uses something called textile markup to allow some formatting and the information TinyMCE was passing into the application was getting mixed up. In the comments to that post someone suggested a quick fix to allow the html added by TinyMCE to be passed into the app and be recognized in the messages. If you follow those, you will see that the htnl is now recognized.

Now we have links and lists and all of the formatting shows up on the message pages but when I went back to the overview page, the display was broken again. I realized that one of the functions which I had commented out was working working great for one area of the site, but not for another. So I had to dig a little and tweak a few more files.

I tested it and it seemed fixed by adding back in the commented function. But in case that function should be avoided somewhere else, I created a second function and altered it a little.

In the main folder of your Project Pier installation go to:

/environment/functions/general.php

And replace the newly commented ‘clean’ function at line 72:

[sourcecode lang="php"]
function clean($str) {
//$str = preg_replace(‘/&(?!#[0-9]+;)/s’, ‘&’, $str);
//$str = str_replace(array(”, ‘”‘), array(”, ‘”‘), $str);
return $str;
} // clean
[/sourcecode]

with this:

[sourcecode lang="php"]
function clean($str) {
//$str = preg_replace(‘/&(?!#[0-9]+;)/s’, ‘&’, $str);
//$str = str_replace(array(”, ‘”‘), array(”, ‘”‘), $str);
return $str;
} // clean

// Added this extra function to return the ability to clean strings when needed.
// Listing the comments on the front page needs this in place.

function clean2($str) {
strip_tags($str);
$str = preg_replace(‘/&(?!#[0-9]+;)/s’, ‘&’, $str);
$str = strip_tags($str);
return $str;
} // clean2
[/sourcecode]

I then had to change the call to the ‘clean’ function on line 27 in
application/views/application/render_application_logs.php
And simply replace the word ‘clean’ with ‘clean2′.


Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images