inc/classes/interfaces/mailer/class_DeliverableMail.php -text
inc/classes/interfaces/menu/.htaccess -text
inc/classes/interfaces/menu/class_RenderableMenu.php -text
+inc/classes/interfaces/parser/.htaccess -text
+inc/classes/interfaces/parser/class_Parseable.php -text
inc/classes/interfaces/points/.htaccess -text
inc/classes/interfaces/points/class_BookablePoints.php -text
inc/classes/interfaces/reader/.htaccess -text
inc/classes/main/output/.htaccess -text
inc/classes/main/output/class_ConsoleOutput.php -text
inc/classes/main/output/class_WebOutput.php -text
+inc/classes/main/parser/.htaccess -text
+inc/classes/main/parser/class_ -text
+inc/classes/main/parser/class_BaseParser.php -text
+inc/classes/main/parser/xml/.htaccess -text
+inc/classes/main/parser/xml/class_XmlParser.php -text
inc/classes/main/points/.htaccess -text
inc/classes/main/points/class_UserPoints.php -text
inc/classes/main/reader/.htaccess -text
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Parseable interface
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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/>.
+ */
+interface Parseable extends FrameworkInterface {
+ /**
+ * Parses the given XML content
+ *
+ * @param $content Valid XML content
+ * @return void
+ * @throws XmlParserException If an XML error was found
+ */
+ function parseXmlContent ($content);
+}
+
+//
+?>
<?php
/**
- *
+ * A ??? !!! class
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* 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 extends BaseFrameworkSystem {
+class ???!!! extends Base!!! implements CompileableTemplate {
/**
* Protected constructor
*
// Call parent constructor
parent::__construct(__CLASS__);
}
+
+ /**
+ * Creates an instance of the class !!! and prepares it for usage
+ *
+ * @param $appInstance A manageable application
+ * @return $///Instance An instance of !!!
+ public final static function create???!!! (ManageableApplication $appInstance) {
+ // Get a new instance
+ $///Instance = new ???!!!();
+
+ // Return the prepared instance
+ return $///Instance;
+ }
}
// [EOF]
<?php
/**
- * A general
+ * A general ???
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
private $totalCounter = 0;
// Exception constants
- const EXCEPTION_XML_PARSER_ERROR = 0x1e0;
- const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1;
- const EXCEPTION_XML_NODE_MISMATCH = 0x1e2;
const EXCEPTION_GROUP_NOT_OPENED = 0x1e3;
const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4;
const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5;
/**
* Groupable image strings?
*/
- private $groupable = "single";
+ private $groupable = 'single';
/**
* Protected constructor
* @return void
*/
public function initBackgroundColor () {
- $this->colorMode = "backgroundColor";
+ $this->colorMode = 'backgroundColor';
}
/**
* @return void
*/
public function initForegroundColor () {
- $this->colorMode = "foregroundColor";
+ $this->colorMode = 'foregroundColor';
}
/**
* @return void
* @todo Find something usefull for this method.
*/
- public function initImageString ($groupable = "single") {
+ public function initImageString ($groupable = 'single') {
$this->groupable = $groupable;
}
$foreColor = imagecolorallocate($this->getImageResource(), $red, $green, $blue);
switch ($this->groupable) {
- case "single": // Single image string
+ case 'single': // Single image string
// Compile image string
$imageString = $templateInstance->compileRawCode($this->getString());
imagestring($this->getImageResource(), $size, $x, $y, $imageString, $foreColor);
break;
- case "groupable": // More than one string allowed
+ case 'groupable': // More than one string allowed
// Walk through all groups
foreach ($templateInstance->getVariableGroups() as $group => $set) {
// Set the group
// Set it for later use
$this->setTemplateInstance($templateInstance);
- // Something is not yet ready
- $this->partialStub('Please implement this method.');
+ // Load the base (XML) template for generating menus
+ $this->getTemplateInstance()->loadMenuTemplate('base_menu');
+
+ // Get the prepared content
+ $menuContent = $this->getTemplateInstance()->getRawTemplateData();
+
+ // Render it here
+ $this->getTemplateInstance()->renderXmlContent($menuContent);
+ die('!OK');
}
/**
* Transfers the rendered menu to a given templatex engine by assigning
* the rendered content with a template variable.
*
- * @2param $templateInstance An instance of a CompileableTemplate class
+ * @param $templateInstance An instance of a CompileableTemplate class
* @return void
*/
public function transferContentToTemplateEngine (CompileableTemplate $templateInstance) {
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? Parser class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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 ???Parser extends BaseParser implements Parseable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of the class Parser and prepares it for usage
+ *
+ * @param $templateInstance A CompileableTemplate instance
+ * @return $parserInstance An instance of this parser
+ public final static function create???Parser (CompileableTemplate $templateInstance) {
+ // Get a new instance
+ $parserInstance = new ???Parser();
+
+ // Set the template instance
+ $parserInstance->setTemplateInstance($templateInstance);
+
+ // Return the prepared instance
+ return $parserInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A general Parser
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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 BaseParser extends BaseFrameworkSystem {
+ /**
+ * Protected constructor
+ *
+ * @param $className Name of the class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Xml Parser class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * 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 XmlParser extends BaseParser implements Parseable {
+ // Exception constants
+ const EXCEPTION_XML_PARSER_ERROR = 0x1e0;
+ const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1;
+ const EXCEPTION_XML_NODE_MISMATCH = 0x1e2;
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of the class Parser and prepares it for usage
+ *
+ * @param $templateInstance A CompileableTemplate instance
+ * @return $parserInstance An instance of this parser
+ */
+ public final static function createXmlParser (CompileableTemplate $templateInstance) {
+ // Get a new instance
+ $parserInstance = new XmlParser();
+
+ // Set the template instance
+ $parserInstance->setTemplateInstance($templateInstance);
+
+ // Return the prepared instance
+ return $parserInstance;
+ }
+
+ /**
+ * Parses the given XML content
+ *
+ * @param $content Valid XML content
+ * @return void
+ * @throws XmlParserException If an XML error was found
+ */
+ public function parseXmlContent ($content) {
+ // Convert all to UTF8
+ if (function_exists('recode')) {
+ $content = recode("html..utf8", $content);
+ } else {
+ // @TODO We need to find a fallback solution here
+ $this->partialStub('Cannot find recode extension!');
+ } // END - if
+
+ // Get an XML parser
+ $xmlParser = xml_parser_create();
+
+ // Force case-folding to on
+ xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true);
+
+ // Get template instance
+ $templateInstance = $this->getTemplateInstance();
+
+ // Set object
+ xml_set_object($xmlParser, $templateInstance);
+
+ // Set handler call-backs
+ xml_set_element_handler($xmlParser, 'startElement', 'endElement');
+ xml_set_character_data_handler($xmlParser, 'characterHandler');
+
+ // Now parse the XML tree
+ if (!xml_parse($xmlParser, $content)) {
+ // Error found in XML!
+ //* DEBUG: */ die('<pre>'.htmlentities($content).'</pre>');
+ throw new XmlParserException(array($this, $xmlParser), self::EXCEPTION_XML_PARSER_ERROR);
+ } // END - if
+
+ // Free the parser
+ xml_parser_free($xmlParser);
+ }
+}
+
+// [EOF]
+?>
* @param $template The email template we shall load which is located in
* 'emails' by default
* @return void
+ * @deprecated
+ * @see See loadCodeTemplate()
*/
public function loadEmailTemplate ($template) {
// Set template type
* @return void
* @throws XmlParserException If an XML error was found
*/
- public final function renderXmlContent ($content = null) {
+ public function renderXmlContent ($content = null) {
// Is the content set?
if (is_null($content)) {
// Get current content
$content = $this->getRawTemplateData();
} // END - if
- // Convert all to UTF8
- if (function_exists('recode')) {
- $content = recode("html..utf8", $content);
- } else {
- // @TODO We need to find a fallback solution here
- $this->partialStub('Cannot find recode extension!');
- } // END - if
-
- // Get an XML parser
- $xmlParser = xml_parser_create();
-
- // Force case-folding to on
- xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true);
-
- // Set object
- xml_set_object($xmlParser, $this);
-
- // Set handler call-backs
- xml_set_element_handler($xmlParser, 'startElement', 'endElement');
- xml_set_character_data_handler($xmlParser, 'characterHandler');
-
- // Now parse the XML tree
- if (!xml_parse($xmlParser, $content)) {
- // Error found in XML!
- //* DEBUG: */ die('<pre>'.htmlentities($content).'</pre>');
- throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR);
- } // END - if
+ // Get a XmlParser instance
+ $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this));
- // Free the parser
- xml_parser_free($xmlParser);
+ // Parse the XML document
+ $parserInstance->parseXmlContent($content);
}
}
*/
public final static function createImageTemplateEngine (ManageableApplication $appInstance) {
// Get a new instance
- $tplInstance = new ImageTemplateEngine();
+ $templateInstance = new ImageTemplateEngine();
// Get language and file I/O instances from application
$langInstance = $appInstance->getLanguageInstance();
$ioInstance = $appInstance->getFileIoInstance();
// Determine base path
- $templateBasePath = $tplInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
+ $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $appInstance->getRequestInstance()->getRequestElement('app') . '/';
// Is the base path valid?
if (empty($templateBasePath)) {
// Base path is empty
- throw new BasePathIsEmptyException($tplInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} elseif (!is_string($templateBasePath)) {
// Is not a string
- throw new InvalidBasePathStringException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+ throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
} elseif (!is_dir($templateBasePath)) {
// Is not a path
- throw new BasePathIsNoDirectoryException(array($tplInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+ throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
} elseif (!is_readable($templateBasePath)) {
// Is not readable
- throw new BasePathReadProtectedException(array($tplInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+ throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
}
// Get configuration instance
$configInstance = FrameworkConfiguration::getInstance();
// Set the base path
- $tplInstance->setTemplateBasePath($templateBasePath);
+ $templateInstance->setTemplateBasePath($templateBasePath);
// Set the language and IO instances
- $tplInstance->setLanguageInstance($langInstance);
- $tplInstance->setFileIoInstance($ioInstance);
+ $templateInstance->setLanguageInstance($langInstance);
+ $templateInstance->setFileIoInstance($ioInstance);
// Set template extensions
- $tplInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
- $tplInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+ $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
+ $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
// Absolute output path for compiled templates
- $tplInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+ $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
// Return the prepared instance
- return $tplInstance;
+ return $templateInstance;
}
/**
$methodName = 'setImageProperty' . $this->convertToClassName($element);
} elseif ($element != 'image') {
// Invalid node name found
- throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN);
+ throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
}
// Call method
//* DEBUG: */ echo "END: >".$nodeName."<<br />\n";
if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
// Did not match!
- throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH);
+ throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
} elseif (in_array($nodeName, $this->getSubNodes())) {
// Silently ignore sub nodes
return;
$methodName = 'setEmailProperty' . $this->convertToClassName($element);
} elseif ($element != 'text-mail') {
// Invalid node name found
- throw new InvalidXmlNodeException(array($this, $element, $attributes), BaseHelper::EXCEPTION_XML_NODE_UNKNOWN);
+ throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
}
// Call method
//* DEBUG: */ echo "END: >".$nodeName."<<br />\n";
if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
// Did not match!
- throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), BaseHelper::EXCEPTION_XML_NODE_MISMATCH);
+ throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
} elseif (in_array($nodeName, $this->getSubNodes())) {
// Silently ignore sub nodes
return;
// Return the prepared instance
return $tplInstance;
}
+
+ /**
+ * Load a specified menu template into the engine
+ *
+ * @param $template The menu template we shall load which is
+ * located in 'menu' by default
+ * @return void
+ */
+ public function loadMenuTemplate ($template) {
+ // Set template type
+ $this->setTemplateType($this->getConfigInstance()->getConfigEntry('menu_template_type'));
+
+ // Load the special template
+ $this->loadTemplate($template);
+ }
}
// [EOF]
// CFG: IMAGE-TEMPLATE-TYPE
$cfg->setConfigEntry('image_template_type', 'image');
+// CFG: MENU-TEMPLATE-TYPE
+$cfg->setConfigEntry('menu_template_type', 'menu');
+
// CFG: OUTPUT-CLASS
$cfg->setConfigEntry('output_class', 'WebOutput');
// CFG: MAILER-CLASS
$cfg->setConfigEntry('mailer_class', 'DebugMailer');
+// CFG: XML-PARSER-CLASS
+$cfg->setConfigEntry('xml_parser_class', 'XmlParser');
+
// CFG: MATH-PRIME
$cfg->setConfigEntry('math_prime', 591623);