aliroEditor.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*******************************************************************************
00004  * Aliro - the modern, accessible content management system
00005  *
00006  * Aliro is open source software, free to use, and licensed under GPL.
00007  * You can find the full licence at http://www.gnu.org/copyleft/gpl.html GNU/GPL
00008  *
00009  * The author freely draws attention to the fact that Aliro derives from Mambo,
00010  * software that is controlled by the Mambo Foundation.  However, this section
00011  * of code is totally new.  If it should contain any fragments that are similar
00012  * to Mambo, please bear in mind (1) there are only so many ways to do things
00013  * and (2) the author of Aliro is also the author and copyright owner for large
00014  * parts of Mambo 4.6.
00015  *
00016  * Tribute should be paid to all the developers who took Mambo to the stage
00017  * it had reached at the time Aliro was created.  It is a feature rich system
00018  * that contains a good deal of innovation.
00019  *
00020  * Your attention is also drawn to the fact that Aliro relies on other items of
00021  * open source software, which is very much in the spirit of open source.  Aliro
00022  * wishes to give credit to those items of code.  Please refer to
00023  * http://aliro.org/credits for details.  The credits are not included within
00024  * the Aliro package simply to avoid providing a marker that allows hackers to
00025  * identify the system.
00026  *
00027  * Copyright in this code is strictly reserved by its author, Martin Brampton.
00028  * If it seems appropriate, the copyright will be vested in the Aliro Organisation
00029  * at a suitable time.
00030  *
00031  * Copyright (c) 2007 Martin Brampton
00032  *
00033  * http://aliro.org
00034  *
00035  * counterpoint@aliro.org
00036  *
00037  * aliroEditor is the basic framework for editors.  The actual editors are mambots
00038  * and the methods provided here trigger the active editor mambot(s).  The class is
00039  * a singleton but does not have any data suitable to be cached.
00040  *
00041  */
00042 
00043 class aliroEditor {
00044 
00045     private static $instance = __CLASS__;
00046     private $mambothandler = '';
00047     private $initiated = false;
00048 
00049     private function __construct () {
00050         $this->mambothandler = aliroMambotHandler::getInstance();
00051     }
00052 
00053     private function __clone () {
00054         // Just here to enforce singleton
00055     }
00056 
00057     public static function getInstance () {
00058         return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
00059     }
00060 
00061     public function initEditor() {
00062         $this->initiated = true;
00063         return $this->triggerEditor ('onIniEditor');
00064     }
00065 
00066     public function getEditorContents( $editorArea, $hiddenField ) {
00067         echo $this->getEditorContentsText($editorArea, $hiddenField);
00068     }
00069 
00070     public function getEditorContentsText ( $editorArea, $hiddenField ) {
00071         if (!$this->initiated) $this->initEditor();
00072         return $this->triggerEditor ('onGetEditorContents', array($editorArea, $hiddenField));
00073     }
00074 
00075     public function editorAreaText ($name, $content, $hiddenField, $width, $height, $col, $row) {
00076         if (!$this->initiated) $this->initEditor();
00077         return $this->triggerEditor ('onEditorArea', array($name, $content, $hiddenField, $width, $height, $col, $row));
00078     }
00079     // just present a textarea
00080     public function editorArea( $name, $content, $hiddenField, $width, $height, $col, $row ) {
00081         echo $this->editorAreaText ($name, $content, $hiddenField, $width, $height, $col, $row);
00082     }
00083 
00084     private function triggerEditor ($trigger, $arguments=null) {
00085         $html = '';
00086         if ($arguments) $results = call_user_func(array($this->mambothandler, 'triggerOnce'), $trigger, $arguments);
00087         else $results = call_user_func(array($this->mambothandler, 'triggerOnce'), $trigger);
00088         foreach ($results as $result) $html .= trim($result);
00089         return $html;
00090     }
00091 
00092 }

Generated on Thu Apr 17 13:03:26 2008 for ALIRO by  doxygen 1.5.5