Page Administering Trinity
What we did before with the news will work well with the dynamic page stuff.Editing goes a little bit trickier, especially because we want to use a full blown WYSIWYG editor. We will not dive deeply into the page list as it is almost exactly what we had in the news listing module:
... wait a moment...
There is something here, though that we must explain. Due to the history of the DataBrowser class the callbacks are a bit tricky to do if they need more than one value. Originally a callback only got one value from one single field. When creating a link to the page editor we need two parameters: the id of the page and the page title. The original callback paradigm could not handle this. Well, what does a hacker do? He creates a workaround that combines two field values to one in the SQL query "CONCAT(title,'|',id)" and lets the callback function separate them. "explode("|",$value);". While there is nothing wrong with this approach a cleaner solution should and will be built to the DataBrowser class.
TODO: update the above with the new code solution
Creating the Page Editor
For the time being the editor of choice is called CKEditor. Download the lates stable version and unzip/untar it to your admin/js directory. To be able to administer images you need a CKEditor plugin of some sort. There is a freeware one available called KCFinder. Download it and unpack it in the admin/js directory as well. Finally you should have the directory structure you see below:
The PHP5 version of CKEditor initialization will not work in our environment and we have a patched version below. The main difference the the constructor funtion (public function editor(..)) and the public function replace(...) where we have made changes to the PHP created JavaScript code. So if you are updating to a more recent version of CKEditor please patch the above functions in it or replace it with the function below. The code is very long and it is supplied by the CKEditor team, not us. We have only patched it.
... wait a moment...
Now that we have the JavaScript libraries in place we can write the page editing module. Funny enough the toolbar declarations are taking a good deal of the code. Once again we have a modified version of the original approach. This is because in its default setup CKEditor will break the pages and the page editor badly if we use character "<" inside a page. The small changes we have done will prevent this.
... wait a moment...