+ protected final function getLanguageInstance () {
+ return self::$langInstance;
+ }
+
+ /**
+ * Setter for language instance
+ *
+ * @param $langInstance An instance to the language sub-system
+ * @return void
+ * @see LanguageSystem
+ */
+ public final function setLanguageInstance (ManageableLanguage $langInstance) {
+ self::$langInstance = $langInstance;
+ }
+
+ /**
+ * Remove the $systemClasses array from memory
+ *
+ * @return void
+ */
+ public final function removeSystemArray () {
+ unset($this->systemClasses);
+ }
+
+ /**
+ * Appends a trailing slash to a string
+ *
+ * @param $str A string (maybe) without trailing slash
+ * @return $str A string with an auto-appended trailing slash
+ */
+ public final function addMissingTrailingSlash ($str) {
+ // Is there a trailing slash?
+ if (substr($str, -1, 1) != "/") $str .= "/";
+ return $str;
+ }
+
+ /**
+ * Private getter for file IO instance
+ *
+ * @return $fileIoInstance An instance to the file I/O sub-system
+ */
+ protected final function getFileIoInstance () {
+ return $this->fileIoInstance;
+ }
+
+ /**
+ * Setter for file I/O instance
+ *
+ * @param $fileIoInstance An instance to the file I/O sub-system
+ * @return void
+ */
+ public final function setFileIoInstance (FileIoHandler $fileIoInstance) {
+ $this->fileIoInstance = $fileIoInstance;
+ }
+
+ /**
+ * Prepare the template engine (WebTemplateEngine by default) for a given
+ * application helper instance (ApplicationHelper by default).
+ *
+ * @param $appInstance An application helper instance or
+ * null if we shall use the default
+ * @return $templateInstance The template engine instance
+ * @throws NullPointerException If the template engine could not
+ * be initialized
+ * @throws UnsupportedTemplateEngineException If $templateInstance is an
+ * unsupported template engine
+ * @throws MissingLanguageHandlerException If the language sub-system
+ * is not yet initialized
+ * @throws NullPointerException If the discovered application
+ * instance is still null
+ */
+ protected function prepareTemplateInstance (BaseFrameworkSystem $appInstance=null) {
+ // Is the application instance set?
+ if (is_null($appInstance)) {
+ // Get the current instance
+ $appInstance = $this->getApplicationInstance();
+
+ // Still null?
+ if (is_null($appInstance)) {
+ // Thrown an exception
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
+ } // END - if
+
+ // Generate FQFN for all application templates
+ $fqfn = sprintf("%s%s/%s",
+ $this->getConfigInstance()->readConfig('application_path'),
+ strtolower($appInstance->getAppShortName()),
+ $this->getConfigInstance()->readConfig('tpl_base_path')
+ );
+
+ // Are both instances set?
+ if ($appInstance->getLanguageInstance() === null) {
+ // Invalid language instance
+ throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER);
+ } elseif ($appInstance->getFileIoInstance() === null) {
+ // Invalid language instance
+ throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER);
+ }
+
+ // Initialize the template engine
+ $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance()));
+
+ // Return the prepared instance
+ return $templateInstance;
+ }
+
+ /**
+ * Debugs this instance by putting out it's full content
+ *
+ * @return void
+ */
+ public final function debugInstance () {
+ // Restore the error handler to avoid trouble with missing array elements or undeclared variables
+ restore_error_handler();
+
+ // Generate the output
+ $content = sprintf("<pre>%s</pre>",
+ trim(
+ htmlentities(
+ print_r($this, true)
+ )
+ )
+ );
+
+ // Output it
+ ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong><div id=\"debug_content\">%s</div>\nLoaded includes: <div id=\"debug_include_list\">%s</div>",