Location: PHPKode > projects > Mocovie web framework > webs/common/controls/shoutbox.php
<?php
/**
 *  Copyright (C) 2011  Kai Dorschner
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Kai Dorschner <the-hide@address.com>
 * @copyright Copyright 2011, Kai Dorschner
 * @license http://www.gnu.org/licenses/gpl.html GPLv3
 * @package mocovi
 * @subpackage controls
 */

ControlFactory::load('formreceiver');
ControlFactory::load('dataprocessor');

class shoutbox_control extends dataprocessor_control /*implements FormreceiverDelegate*/
{
	protected $form = 
		'<?xml version="1.0" encoding="utf-8"?>
		<element
			xmlns:xml="http://www.w3.org/XML/1998/namespace"
			xmlns:xref="x-schema:refSchema.xml"
			xmlns:xi="http://www.w3.org/2001/XInclude"
			xmlns="http://mocovi.de/schema/xmlfs1.0"
			>
			<form xml:id="abc1">
				<input preset="email"/>
				<input pattern="/[a-zA-Z _.-]+/" name="comment"/>
			</form>
			<formreceiver reference="abc1"/>
		</element>
		';

	protected function _beforeLoad(DomNode $parent)
	{
		$dom = new DomDocument();
		$dom->loadXML($this->form);
		$this->sourceNode->appendChild($formNode = $GLOBALS['filesystem']->getDOM()->importNode($dom->documentElement, true));
		return true;
	}


	/**
	 * @override
	 */
	protected function program()
	{
		if($email = $this->dataProvider()->get('email'))
		{
			ControlFactory::createVirtual
				( 'gravatar'
				, array('email' => $email)
				)
				->load($this->node)
				->run();
		}
		if($comment = $this->dataProvider()->get('comment'))
		{
			ControlFactory::create($this->dom->createTextNode($comment))
				->load
					(
						ControlFactory::createVirtual('paragraph')
							->load($this->node)
							->run()
					)
				->run()
			;
			
		}
	}
}
Return current item: Mocovie web framework