]> git.mxchange.org Git - shipsimu.git/commitdiff
getConfigInstance() is now protected, factories added
authorRoland Häder <roland@mxchange.org>
Wed, 14 May 2008 19:57:42 +0000 (19:57 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 14 May 2008 19:57:42 +0000 (19:57 +0000)
.gitattributes
inc/classes/main/class_BaseFrameworkSystem.php
inc/classes/main/controller/default/class_WebDefaultNewsController.php
inc/classes/main/factories/.htaccess [new file with mode: 0644]
inc/classes/main/factories/class_BaseFactory.php [new file with mode: 0644]
inc/classes/main/factories/web/.htaccess [new file with mode: 0644]
inc/classes/main/factories/web/class_NewsFactory.php [new file with mode: 0644]
inc/classes/main/language/class_LanguageSystem.php
inc/classes/main/template/class_TemplateEngine.php
inc/classes/middleware/compressor/class_CompressorChannel.php
templates/de/code/header.ctp

index 7e557427c101c36b6dd056b55859949f9890fbfa..a5e046ff5cf496882900cd5bfaef7dba402b7d0f 100644 (file)
@@ -274,6 +274,10 @@ inc/classes/main/debug/class_DebugWebOutput.php -text
 inc/classes/main/extended/.htaccess -text
 inc/classes/main/extended/class_ObjectLimits.php -text
 inc/classes/main/extended/class_SerializationContainer.php -text
+inc/classes/main/factories/.htaccess -text
+inc/classes/main/factories/class_BaseFactory.php -text
+inc/classes/main/factories/web/.htaccess -text
+inc/classes/main/factories/web/class_NewsFactory.php -text
 inc/classes/main/io/.htaccess -text
 inc/classes/main/io/class_FileIOStream.php -text
 inc/classes/main/io/class_FrameworkDirectoryPointer.php -text
index 4abdf2995886afc834c0f3ffefa31412df5de770..8dbbdaa9ab71a2827fdaab8433143381fce5cb76 100644 (file)
@@ -304,7 +304,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         *
         * @return      $cfhInstance - Configuration instance
         */
-       public final function getConfigInstance () {
+       protected final function getConfigInstance () {
                return self::$cfgInstance;
        }
 
index b9f1ee8fed25e41989fdc9994151a45d2dbfa925..835f94b88ea3393fd94aafdf5149c8924b9519cc 100644 (file)
@@ -85,7 +85,7 @@ class WebDefaultNewsController extends BaseController implements Controller {
                $commandInstance = $this->resolverInstance->resolvCommandByRequest($requestInstance);
 
                // Load the news here
-               $this->loadNews($requestInstance);
+               $this->loadNewsByRequest($requestInstance);
 
                // Execute the command
                $commandInstance->execute($requestInstance, $responseInstance);
@@ -95,14 +95,14 @@ class WebDefaultNewsController extends BaseController implements Controller {
        }
 
        /**
-        * Loads news from the connected database for later usage
+        * Loads news by a given request
         *
         * @param       $requestInstance        An instance of a request class
         * @return      void
         */
-       private function loadNews (Requestable $requestInstance) {
-               // Get the news page variable from the request instance
-               $newsPage = $requestInstance->getRequestElement("news_page");
+       private function loadNewsByRequest (Requestable $requestInstance) {
+               // Generate a new news object but not carring about which concrete we have
+               $newsInstance = NewsFactory::createFactoryByRequest($requestInstance)->createNewsObject();
        }
 }
 
diff --git a/inc/classes/main/factories/.htaccess b/inc/classes/main/factories/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/factories/class_BaseFactory.php b/inc/classes/main/factories/class_BaseFactory.php
new file mode 100644 (file)
index 0000000..11c8ec9
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * A general (base) factory
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @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 BaseFactory extends BaseFrameworkSystem {
+       /**
+        * Private constructor
+        *
+        * @param       $class  Name of the real class (not BaseFactory)
+        * @return      void
+        */
+       protected function __construct ($class) {
+               // Call parent constructor
+               parent::__construct($class);
+
+               // Clean up a little
+               $this->removeNumberFormaters();
+               $this->removeSystemArray();
+       }
+}
+
+// [EOF]
+?>
diff --git a/inc/classes/main/factories/web/.htaccess b/inc/classes/main/factories/web/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/classes/main/factories/web/class_NewsFactory.php b/inc/classes/main/factories/web/class_NewsFactory.php
new file mode 100644 (file)
index 0000000..d863891
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * A news factory for web pages
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @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 NewsFactory extends BaseFactory {
+       /**
+        * Private constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set part description
+               $this->setObjectDescription("News-Fabrik f&uuml;r Webseiten");
+
+               // Create unique ID number
+               $this->createUniqueID();
+       }
+
+       /**
+        * Singleton getter for a special factory instance depending on the given
+        * request
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @return      $factoryInstance        An instance of a NewsFactory class
+        */
+       public final static function createFactoryByRequest (Requestable $requestInstance) {
+               // Generate the new instance
+               $factoryInstance = new NewsFactory();
+
+               // Get the element name
+               $element = FrameworkConfiguration::getInstance()->readConfig("app_selector_get");
+
+               // Analyze the request, first get the Uni* application name (short one from URL)
+               $appVariable = $requestInstance->getRequestElement($element);
+
+               // Add more code here...
+
+               // Return the prepared factory instance
+               return $factoryInstance;
+       }
+}
+
+// [EOF]
+?>
index 4aa9490c2e434b4ef08e2cd5cf74d897931aa799..35db75c562c4a81abd44dac09078ed656249e1b7 100644 (file)
@@ -101,7 +101,7 @@ class LanguageSystem extends BaseFrameworkSystem implements ManageableLanguage {
                $langInstance->initLanguageStrings();
 
                // Set language code from default config
-               $langInstance->setLanguageCode($langInstance->getConfigInstance()->readConfig("default_lang"));
+               $langInstance->setLanguageCode(FrameworkConfiguration::getInstance()->readConfig("default_lang"));
 
                // Remember this instance
                self::$thisInstance = $langInstance;
index e11b84d553c537104e487e13ade529ef7e0d28e6..4c1500625a55fdf0b5d297927517d569997b9308 100644 (file)
@@ -167,7 +167,7 @@ class TemplateEngine extends BaseFrameworkSystem implements CompileableTemplate
                }
 
                // Get configuration instance
-               $cfgInstance = $tplInstance->getConfigInstance();
+               $cfgInstance = FrameworkConfiguration::getInstance();
 
                // Set the base path
                $tplInstance->setBasePath($basePath);
index b5fa5654abed02b9cf166e1a4d3781ad212f939c..fd04ac118bdc9bde22430a9bd6faf09c4e096a4e 100644 (file)
@@ -55,7 +55,7 @@ class CompressorChannel extends BaseMiddleware {
                        // Read all directories but no sub directories
                        while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess"))) {
                                // Is this a class file?
-                               if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == $cInstance->getConfigInstance()->readConfig("php_extension"))) {
+                               if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig("php_extension"))) {
                                        // Get the compressor's name. That's why you must name
                                        // your files like your classes and also that's why you
                                        // must keep on class in one file.
index 2b2457d15757b54963b5266ae5bcbc9716da03c4..b82ab23a8f5bcb344e5aa304e4c888c86a2959ac 100644 (file)
@@ -1,5 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
        <title>
                $content[title]