* @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @todo This template engine does not make use of setTemplateType() * * 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 . */ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { // Constants const OBJECT_TYPE_DATA_NAME = 'object-name'; const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation'; const OBJECT_TYPE_DATA_MAX_SPREAD = 'object-max-spread'; const OBJECT_TYPE_DATA_PROTOCOL = 'object-protocol'; const OBJECT_TYPE_DATA_RECIPIENT_TYPE = 'object-recipient-type'; /** * Instance for the object registry */ private $objectRegistryInstance = NULL; /** * Protected constructor * * @return void */ protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); // Init object type registry instance $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance(); // Init sub nodes $this->setSubNodes(array( 'object-list', 'object-list-entry', self::OBJECT_TYPE_DATA_NAME, self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION, self::OBJECT_TYPE_DATA_MAX_SPREAD, self::OBJECT_TYPE_DATA_PROTOCOL, self::OBJECT_TYPE_DATA_RECIPIENT_TYPE )); } /** * Creates an instance of the class TemplateEngine and prepares it for usage * * @return $templateInstance An instance of TemplateEngine * @throws BasePathIsEmptyException If the provided $templateBasePath is empty * @throws InvalidBasePathStringException If $templateBasePath is no string * @throws BasePathIsNoDirectoryException If $templateBasePath is no * directory or not found * @throws BasePathReadProtectedException If $templateBasePath is * read-protected */ public static final function createXmlObjectRegistryTemplateEngine () { // Get a new instance $templateInstance = new XmlObjectRegistryTemplateEngine(); // Init template instance $templateInstance->initXmlTemplateEngine('node', 'object_registry'); // Return the prepared instance return $templateInstance; } /** * Currently not used * * @param $resource XML parser resource (currently ignored) * @param $characters Characters to handle * @return void * @todo Find something useful with this! */ public function characterHandler ($resource, $characters) { // Trim all spaces away $characters = trim($characters); // Is this string empty? if (empty($characters)) { // Then skip it silently return; } // END - if // Get current XML node name as an array index $nodeName = $this->getStackInstance()->getNamed('node_object_registry'); // Is the node name self::OBJECT_TYPE_DATA_NAME? if ($nodeName == self::OBJECT_TYPE_DATA_NAME) { // Output debug message self::createDebugInstance(__CLASS__)->debugOutput('TAGS[' . __METHOD__ . ':' . __LINE__ . ']: Adding object type ' . $characters . ' to registry.'); } // END - if // Add it to the registry $this->objectRegistryInstance->addEntry($nodeName, $characters); } /** * Getter for cache file (FQFN) * * @return $fqfn Full-qualified file name of the menu cache */ public function getObjectRegistryCacheFqfn () { $this->partialStub('Please implement this method.'); } /** * Starts the object-registry * * @return void */ protected function startObjectRegistry () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', 'object-registry'); } /** * Starts the object-list * * @param $objectCount Count of all objects * @return void * @todo Handle $objectCount */ protected function startObjectList ($objectCount) { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', 'object-list'); } /** * Starts the object-list-entry * * @return void */ protected function startObjectListEntry () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', 'object-list-entry'); } /** * Starts the object-name * * @return void */ protected function startObjectName () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_NAME); } /** * Starts the object-recipient-limitation * * @return void */ protected function startObjectRecipientLimitation () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION); } /** * Starts the object-max-spread * * @return void */ protected function startObjectMaxSpread () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_MAX_SPREAD); } /** * Starts the object-protocol * * @return void */ protected function startObjectProtocol () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_PROTOCOL); } /** * Starts the object-recipient-type * * @return void */ protected function startObjectRecipientType () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_TYPE); } /** * Finishes the object-recipient-type * * @return void */ protected function finishObjectRecipientType () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-protocol * * @return void */ protected function finishObjectProtocol () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-max-spread * * @return void */ protected function finishObjectMaxSpread () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-recipient-limitation * * @return void */ protected function finishObjectRecipientLimitation () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-name * * @return void */ protected function finishObjectName () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-list-entry * * @return void */ protected function finishObjectListEntry () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-list * * @return void */ protected function finishObjectList () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } /** * Finishes the object-registry * * @return void */ protected function finishObjectRegistry () { // Pop the last entry $this->getStackInstance()->popNamed('node_object_registry'); } } // [EOF] ?>