*/
public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
// Add some generic data all messageData arrays provide
- $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]);
+ $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]);
$dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]);
}
}
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_TCP_PORT,
- XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT
+ XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_UDP_PORT,
+ BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
);
// Init message-data->configuration translation array
$this->messageDataElements = array(
XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST,
+ BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
);
// Init message-data->configuration translation array
*/
public function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance) {
// Is it not empty?
- assert(!empty($messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]));
+ assert(!empty($messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]));
// Construct configuration entry for handling class' name
- $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[NetworkPackage::MESSAGE_DATA_ANSWER_STATUS]) . '_handler_class';
+ $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]) . '_handler_class';
// Try to get a class
$handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry);
/**
* Generic answer status field
*/
- const MESSAGE_DATA_ANSWER_STATUS = 'answer_status';
/**
* Tags separator
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
+class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
/**
* Some XML nodes must be available for later data extraction
*/
'your-external-ip',
'your-internal-ip',
'your-session-id',
+ // Answer status (generic field)
+ self::ANSWER_STATUS,
);
}
--- /dev/null
+<?php
+/**
+ * An ??? answer template engine class for XML templates
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 <http://www.gnu.org/licenses/>.
+ */
+class Xml???AnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * 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 createXml???TemplateEngine () {
+ // Get a new instance
+ $templateInstance = new Xml???TemplateEngine();
+
+ // Init template instannce
+ $templateInstance->initXmlTemplateEngine('PREFIX', '!!!');
+
+ // Return the prepared instance
+ return $templateInstance;
+ }
+
+ /**
+ * Currently not used
+ *
+ * @param $resource XML parser resource (currently ignored)
+ * @param $characters Characters to handle
+ * @return void
+ */
+ public function characterHandler ($resource, $characters) {
+ // Trim all spaces away
+ $characters = trim($characters);
+
+ // Is this string empty?
+ if (empty($characters)) {
+ // Then skip it silently
+ return false;
+ } // END - if
+
+ // Assign data with matching variable here
+ parent::assignVariable($this->getStackerInstance()->getNamed('!!!'), $characters);
+ }
+
+ /**
+ * Getter for cache file (FQFN)
+ *
+ * @return $fqfn Full-qualified file name of the menu cache
+ */
+ public function get???CacheFqfn () {
+ $this->partialStub('Please implement this method.');
+ }
+
+ /**
+ * Starts the |||
+ *
+ * @return void
+ */
+ protected function start??? () {
+ // Push the node name on the stacker
+ $this->getStackerInstance()->pushNamed('!!!', '|||');
+ }
+
+ /**
+ * Finishes the |||
+ *
+ * @return void
+ */
+ protected function finish??? () {
+ // Pop the last entry
+ $this->getStackerInstance()->popNamed('!!!');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * An generic answer template engine class for XML templates
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.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 <http://www.gnu.org/licenses/>.
+ */
+class BaseXmlAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
+ /**
+ * Generic 'answer_status' field
+ */
+ const ANSWER_STATUS = 'answer-status';
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Starts the answer-status
+ *
+ * @return void
+ */
+ protected function startAnswerStatus () {
+ // Push the node name on the stacker
+ $this->getStackerInstance()->pushNamed($this->getStackerName(), self::ANSWER_STATUS);
+ }
+
+ /**
+ * Finishes the answer-status
+ *
+ * @return void
+ */
+ protected function finishAnswerStatus () {
+ // Pop the last entry
+ $this->getStackerInstance()->popNamed($this->getStackerName());
+ }
+}
+
+// [EOF]
+?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
+class XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
// Constants for array elements
const REQUEST_DATA_SESSION_ID = 'session-id';
const REQUEST_DATA_NODE_LIST = 'node-list';
$this->subNodes = array(
self::REQUEST_DATA_SESSION_ID,
self::REQUEST_DATA_NODE_LIST,
+ // Answer status (generic field)
+ self::ANSWER_STATUS,
);
}
*/
private $typePrefix = 'xml';
+ /**
+ * Name of stacker
+ */
+ private $stackerName = '';
+
/**
* Content from dependency
*/
// Init a variable stacker
$stackerInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class');
+ // Set name
+ $this->stackerName = $typePrefix . '_' . $xmlTemplateType;
+
// Init stacker
- $stackerInstance->initStacker($typePrefix . '_' . $xmlTemplateType);
+ $stackerInstance->initStacker($this->stackerName);
// Set it
$this->setStackerInstance($stackerInstance);
return $this->mainNodes;
}
+ /**
+ * Getter for stacker name
+ *
+ * @return $stackerName Name of stacker of this class
+ */
+ protected final function getStackerName () {
+ return $this->stackerName;
+ }
+
/**
* Getter for sub node array
*
//-->
<your-session-id>{?your_session_id?}</your-session-id>
</your-data>
+ <!--
+ Status of this answer. This can be something like OKAY if all went fine or
+ any other error code.
+ //-->
+ <answer-status>{?answer_status?}</answer-status>
</announcement-answer>
List of all nodes (will be completed later)
//-->
<node-list />
+ <!--
+ Status of this answer. This can be something like OKAY if all went fine or
+ any other error code.
+ //-->
+ <answer-status>{?answer_status?}</answer-status>
</request-node-list-answer>