* @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 XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable { /** * Some XML nodes must be available for later data extraction */ const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id'; const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status'; const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address'; const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address'; /** * Protected constructor * * @return void */ protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); // Init sub-nodes array $this->setSubNodes(array( // These nodes don't contain any data 'my-data', 'your-data', // Data from *this* node self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS, self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS, self::ANNOUNCEMENT_DATA_NODE_STATUS, self::ANNOUNCEMENT_DATA_SESSION_ID, // Data from other node 'your-external-address', 'your-internal-address', 'your-session-id', // Answer status (generic field) self::ANSWER_STATUS, )); } /** * 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 createXmlAnnouncementAnswerTemplateEngine () { // Get a new instance $templateInstance = new XmlAnnouncementAnswerTemplateEngine(); // Init instance $templateInstance->initXmlTemplateEngine('node', 'announcement_answer'); // 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 /* * Assign the found characters to variable and use the last entry from * stack as the name. */ parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters); } /** * Getter for cache file (FQFN) * * @return $fqfn Full-qualified file name of the menu cache */ public function getAnnouncementAnswerCacheFqfn () { $this->partialStub('Please implement this method.'); } /** * Starts the announcement-answer * * @return void */ protected function startAnnouncementAnswer () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer'); } /** * Starts the my-data * * @return void */ protected function startMyData () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data'); } /** * Starts the my-external-address * * @return void */ protected function startMyExternalAddress () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS); } /** * Starts the my-internal-address * * @return void */ protected function startMyInternalAddress () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS); } /** * Starts the my-session-id * * @return void */ protected function startMySessionId () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID); } /** * Starts the my-status * * @return void */ protected function startMyStatus () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS); } /** * Finishes the my-status * * @return void */ protected function finishMyStatus () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the my-session-id * * @return void */ protected function finishMySessionId () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the my-internal-address * * @return void */ protected function finishMyInternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the my-external-address * * @return void */ protected function finishMyExternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the my-data * * @return void */ protected function finishMyData () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Starts the your-data * * @return void */ protected function startYourData () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data'); } /** * Starts the your-external-address * * @return void */ protected function startYourExternalAddress () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address'); } /** * Starts the your-internal-address * * @return void */ protected function startYourInternalAddress () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address'); } /** * Starts the your-session-id * * @return void */ protected function startYourSessionId () { // Push the node name on the stacker $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id'); } /** * Finishes the your-session-id * * @return void */ protected function finishYourSessionId () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the your-internal-address * * @return void */ protected function finishYourInternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the your-external-address * * @return void */ protected function finishYourExternalAddress () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the your-data * * @return void */ protected function finishYourData () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } /** * Finishes the announcement-answer * * @return void */ protected function finishAnnouncementAnswer () { // Pop the last entry $this->getStackInstance()->popNamed('node_announcement_answer'); } } // [EOF] ?>