Location: PHPKode > projects > OpenNitro > trunk/Nitro/Modules/HTML.inc.php
<?php
//
// +---------------------------------------------------------------------------+
// | Nitro :: Module :: HTML                                                   |
// +---------------------------------------------------------------------------+
// | Copyright (c) 2006 June Systems BV                                        |
// +---------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or modify it   |
// | under the terms of the GNU Lesser General Public License as published by  |
// | the Free Software Foundation; either version 2.1 of the License, or (at   |
// | your option) any later version.                                           |
// |                                                                           |
// | This library is distributed in the hope that it will be useful, but       |
// | WITHOUT ANY WARRANTY; without even the implied warranty of                |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser   |
// | General Public License for more details.                                  |
// |                                                                           |
// | You should have received a copy of the GNU Lesser General Public License  |
// | along with this library; if not, write to the Free Software Foundation,   |
// | Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA            |
// +---------------------------------------------------------------------------+
// | Authors: Siggi Oskarsson <hide@address.com>                          |
// |          Jesper Avot <hide@address.com                              |
// +---------------------------------------------------------------------------+
//
// $Id: HTML.inc.php 229 2008-04-17 09:20:31Z oli $
//
// Nitro's default HTML Module class.
//

/**
 * This file contains the Nitro HTML Module
 *
 * @author			Siggi Oskarsson
 * @copyright		June Systems BV, 2006
 * @version			$Revision: 1.4 $
 * @package			Modules
 */

/**
 * Include prototype module class
 */
require_once "Nitro/Module.inc.php";

/**
 * HTML module class
 *
 * This module contains the Nitro HTML class. This is used to display
 * plain html text on a template and can only be used in conjunction 
 * with a medium that supports html marked up text.
 *
 * @package	Modules
 * @author	Siggi Oskarsson <hide@address.com>
 * @author  Jesper Avot <hide@address.com>
 * @copyright	June Systems BV, 2006
 * @access public
 */
class NitroModuleHTML extends NitroModule {
	/**
	 * @var	string Module ID string
	 */
	var $IDString = "NitroModuleHTML";
	
	/**
	 * HTML module constructor function
	 *
	 * @param string $ObjectID String with the current ObjectID
	 * @param mixed $Settings Array with the Module Settings, default is FALSE
	 * @access	public
	 */
	function NitroModuleHTML($ObjectID, $Settings = FALSE)
	{
		/**
		 * Call the parent constructor
		 */
		parent::NitroModule();

		/**
		 * Set ObjectID and ModuleSettings
		 */
		$this->ObjectID = $ObjectID;
		$this->SetModuleSettings($Settings);
	}
	
	/**
	 * GetModuleDataConfiguration function
	 *
	 * @return array Array for the form libraries.
	 */
	function GetModuleDataConfiguration()
	{
		return Array("HTML" => "TEXTHTML/STYLE=width: 600px; height: 300px;/LABLE=" . Language('HTML Input'));
	}

	/**
	 * Draw function
	 *
	 * @param mixed $RunTimeSettings RunTimeSettings for the Object, default is FALSE
	 * @return mixed The drawn HTML Object or FALSE if failed.
	 */
	function Draw($RunTimeSettings = FALSE)
	{
		if ($Divs = $this->DrawSections($RunTimeSettings)) {
			return $Divs["HTML"];
		} else {
			return FALSE;
		}
	}

	/**
	 * DrawSections function
	 *
	 * @param mixed $RunTimeSettings RunTimeSettings for the object, default is FALSE
	 * @return mixed Array with the drawn Object, or in case of failure FALSE.
	 */
	function DrawSections($RunTimeSettings = FALSE)
	{
		if ($this->Settings["HTML"]) {
			$HTML = $this->Settings["HTML"];
			
			if (array_key_exists('Replace', $RunTimeSettings) && is_array($RunTimeSettings["Replace"]) && count($RunTimeSettings["Replace"])) {
				/**
				 * Replace item(s) found. Replace it with the right value.
				 */
				foreach ($RunTimeSettings["Replace"] AS $ID => $ParameterValue) {
					$HTML = preg_replace("/{%" . $ID . "%}/i", $ParameterValue, $HTML);
				}
				
				/**
				 * After the Replace, clean up the output.
				 */
				$HTML = preg_replace("/{%[^}]%} ?/", "", $HTML);
			}
			
			return Array("HTML" => $HTML);
		} else {
			Error("HTML section of module " . __CLASS__ . " missing", __FILE__, __LINE__, NitroErrorERROR);
			
			return FALSE;
		}
	}

	/**
	 * isCacheable function
	 *
	 * Check if this Module is cacheable or not.
	 *
	 * @return mixed Is the Module allowed to be cached or not.
	 */
	function isCacheable()
	{
		return $this->cacheID();
	}
}
?>
Return current item: OpenNitro