Some code-cosmetics applied:
authorRoland Häder <roland@mxchange.org>
Tue, 18 May 2010 19:44:22 +0000 (19:44 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 18 May 2010 19:44:22 +0000 (19:44 +0000)
- No longer gettings a $configInstance, lets use
  $templateInstance->getConfigInstance() instead.
- Some other minor costemical changes

14 files changed:
inc/classes/interfaces/template/class_CompileableTemplate.php
inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php
inc/classes/main/discovery/class_
inc/classes/main/parser/xml/class_XmlParser.php
inc/classes/main/registry/class_
inc/classes/main/registry/class_BaseRegistry.php
inc/classes/main/template/class_BaseTemplateEngine.php
inc/classes/main/template/console/class_ConsoleTemplateEngine.php
inc/classes/main/template/image/class_ImageTemplateEngine.php
inc/classes/main/template/mail/class_MailTemplateEngine.php
inc/classes/main/template/menu/class_MenuTemplateEngine.php
inc/classes/main/template/web/class_WebTemplateEngine.php
inc/loader/class_ClassLoader.php
setup-repos.sh

index c6b1a1a..1e7f82f 100644 (file)
@@ -184,10 +184,10 @@ interface CompileableTemplate extends FrameworkInterface {
        /**
         * Removes all comments, tabs and new-line charcters to compact the content
         *
-        * @param       $content        The uncompacted content
-        * @return      $content        The compacted content
+        * @param       $uncompactedContent             The uncompacted content
+        * @return      $compactedContent               The compacted content
         */
-       function compactContent ($content);
+       function compactContent ($uncompactedContent);
 }
 
 // [EOF]
index c849ef1..2cddb8c 100644 (file)
@@ -433,11 +433,15 @@ class XmlRewriterTemplateDecorator extends BaseDecorator implements CompileableT
        /**
         * Removes all comments, tabs and new-line charcters to compact the content
         *
-        * @param       $content        The uncompacted content
-        * @return      $content        The compacted content
+        * @param       $uncompactedContent             The uncompacted content
+        * @return      $compactedContent               The compacted content
         */
-       public function compactContent ($content) {
-               $this->getTemplateInstance()->compactContent($content);
+       public function compactContent ($uncompactedContent) {
+               // Compact it ...
+               $compactedContent = $this->getTemplateInstance()->compactContent($uncompactedContent);
+
+               // ... and return it
+               return $compactedContent;
        }
 }
 
index 4f6d851..61327dd 100644 (file)
@@ -1,8 +1,6 @@
 <?php
 /**
- * A local payment discovery class. This class looks in local database for
- * registered payment types and like all the others it at least returns the
- * money bank transfer type.
+ * A ??? discovery class.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
index 76c3987..63d508a 100644 (file)
@@ -63,7 +63,13 @@ class XmlParser extends BaseParser implements Parseable {
         */
        public function parseXmlContent ($content) {
                // Convert all to UTF8
-               if (function_exists('recode')) {
+               if (empty($content)) {
+                       // No empty content!
+                       $this->debugOuput('Empty content! Backtrace: <pre>');
+                       debug_print_backtrace();
+                       $this->debugOuput('</pre>');
+                       die();
+               } elseif (function_exists('recode')) {
                        // Recode found, so use it
                        $content = recode('html..utf8', $content);
                } else {
index e86c165..c2a1b7c 100644 (file)
@@ -57,4 +57,3 @@ class ???Registry extends BaseRegistry implements Register {
 
 // [EOF]
 ?>
-
index 3311128..ca01a2a 100644 (file)
@@ -32,6 +32,11 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable {
         */
        private $instanceRegistry = array();
 
+       /**
+        * Raw data entries (non-objects)
+        */
+       private $rawEntries = array();
+
        /**
         * Protected constructor
         *
@@ -68,6 +73,70 @@ class BaseRegistry extends BaseFrameworkSystem implements Registerable {
                $this->instanceRegistry[$instanceKey] = $objectInstance;
        }
 
+       /**
+        * Adds a new entry to the given list name. If you want to add objects
+        * please use addInstance() and getInstance() instead.
+        *
+        * @param       $key    The key to identify the whole list
+        * @param       $value  The value to be stored
+        * @return      void
+        */
+       public final function addEntry ($key, $value) {
+               // Simply add it
+               $this->rawEntries[$key][] = $value;
+       }
+
+       /**
+        * Getter for entries or "sub entries"
+        *
+        * @return      $entries        An array with entries from this registry
+        */
+       public final function getEntries ($key = null) {
+               // Default is whole array
+               $entries = $this->rawEntries;
+
+               // Is $key set?
+               if (!is_null($key)) {
+                       // Then use this entry
+                       $entries = $this->rawEntries[$key];
+               } // END - if
+
+               // Return the array
+               return $entries;
+       }
+
+       /**
+        * "Getter" for an array of all entries for given key
+        *
+        * @param       $lookFor        The key to look for
+        * @return      $entry          An array with all keys
+        */
+       public function getArrayFromKey ($lookFor) {
+               // Init array
+               $entry = array();
+
+               // "Walk" over all entries
+               foreach ($this->getEntries('object-name') as $key=>$value) {
+                       // If $value matches the $lookFor, we need to look for more entries for this!
+                       if ($lookFor == $value) {
+                               // Look for more entries
+                               foreach ($this->getEntries() as $key2=>$value2) {
+                                       // Both keys must match!
+                                       if ($key == $key2) {
+                                               // Then add it
+                                               $entry[$key2] = $value2[$key];
+                                       } // END - if
+                               } // END - foreach
+
+                               // Skip further lookups
+                               break;
+                       } // END - if
+               } // END - foreach
+
+               // Return it
+               return $entry;
+       }
+
        /**
         * Gets a registered instance or null if not found
         *
index b64477c..c1aa4f8 100644 (file)
@@ -1496,27 +1496,27 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
        /**
         * Removes all commentd, tabs and new-line characters to compact the content
         *
-        * @param       $content        The uncompacted content
-        * @return      $content        The compacted content
+        * @param       $uncompactedContent             The uncompacted content
+        * @return      $compactedContent               The compacted content
         */
-       public function compactContent ($content) {
+       public function compactContent ($uncompactedContent) {
                // First, remove all tab/new-line/revert characters
-               $content = str_replace("\t", '', str_replace("\n", '', str_replace("\r", '', $content)));
+               $compactedContent = str_replace("\t", '', str_replace("\n", '', str_replace("\r", '', $uncompactedContent)));
 
                // Then regex all comments like <!-- //--> away
-               preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $content, $matches);
+               preg_match_all('/<!--[\w\W]*?(\/\/){0,1}-->/', $compactedContent, $matches);
 
                // Do we have entries?
                if (isset($matches[0][0])) {
                        // Remove all
                        foreach ($matches[0] as $match) {
                                // Remove the match
-                               $content = str_replace($match, '', $content);
+                               $compactedContent = str_replace($match, '', $compactedContent);
                        } // END - foreach
                } // END - if
 
                // Return compacted content
-               return $content;
+               return $compactedContent;
        }
 }
 
index 330545a..83fc014 100644 (file)
@@ -71,9 +71,6 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem
                        throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
-               // Get configuration instance
-               $configInstance = FrameworkConfiguration::getInstance();
-
                // Set the base path
                $templateInstance->setTemplateBasePath($templateBasePath);
 
@@ -82,11 +79,11 @@ class ConsoleTemplateEngine extends BaseTemplateEngine implements CompileableTem
                $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
                return $templateInstance;
index bc0e802..2c6cb37 100644 (file)
@@ -104,9 +104,6 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                        throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
-               // Get configuration instance
-               $configInstance = FrameworkConfiguration::getInstance();
-
                // Set the base path
                $templateInstance->setTemplateBasePath($templateBasePath);
 
@@ -115,11 +112,11 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
                return $templateInstance;
index 9907227..4230ac6 100644 (file)
@@ -98,9 +98,6 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                        throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
-               // Get configuration instance
-               $configInstance = FrameworkConfiguration::getInstance();
-
                // Set the base path
                $templateInstance->setTemplateBasePath($templateBasePath);
 
@@ -109,11 +106,11 @@ class MailTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
                return $templateInstance;
index 59d1eee..af9a375 100644 (file)
@@ -121,9 +121,6 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                        throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
-               // Get configuration instance
-               $configInstance = FrameworkConfiguration::getInstance();
-
                // Set the base path
                $templateInstance->setTemplateBasePath($templateBasePath);
 
@@ -132,11 +129,11 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('menu_template_extension'));
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('menu_template_extension'));
 
                // Absolute output path for compiled templates
-               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Set the menu instance
                $templateInstance->setMenuInstance($menuInstance);
index b2377a9..043277a 100644 (file)
@@ -71,9 +71,6 @@ class WebTemplateEngine extends BaseTemplateEngine implements CompileableTemplat
                        throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
                }
 
-               // Get configuration instance
-               $configInstance = FrameworkConfiguration::getInstance();
-
                // Set the base path
                $templateInstance->setTemplateBasePath($templateBasePath);
 
@@ -82,11 +79,11 @@ class WebTemplateEngine extends BaseTemplateEngine implements CompileableTemplat
                $templateInstance->setFileIoInstance($ioInstance);
 
                // Set template extensions
-               $templateInstance->setRawTemplateExtension($configInstance->getConfigEntry('raw_template_extension'));
-               $templateInstance->setCodeTemplateExtension($configInstance->getConfigEntry('code_template_extension'));
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('code_template_extension'));
 
                // Absolute output path for compiled templates
-               $templateInstance->setCompileOutputPath($configInstance->getConfigEntry('base_path') . $configInstance->getConfigEntry('compile_output_path'));
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
 
                // Return the prepared instance
                return $templateInstance;
index 34fd3c3..79768ff 100644 (file)
@@ -53,12 +53,12 @@ class ClassLoader {
        /**
         * Suffix with extension for all class files
         */
-       private $prefix = "class_";
+       private $prefix = 'class_';
 
        /**
         * Suffix with extension for all class files
         */
-       private $suffix = ".php";
+       private $suffix = '.php';
 
        /**
         * A list for directory names (no leading/trailing slashes!) which not be scanned by the path scanner
@@ -135,8 +135,8 @@ class ClassLoader {
 
                // Construct the FQFN for the cache
                if (!defined('DEVELOPER')) {
-                       $this->listCacheFQFN  = $this->configInstance->getConfigEntry('local_db_path') . "list-" . $this->configInstance->getConfigEntry('app_name') . ".cache";
-                       $this->classCacheFQFN = $this->configInstance->getConfigEntry('local_db_path') . "class-" . $this->configInstance->getConfigEntry('app_name') . ".cache";
+                       $this->listCacheFQFN  = $this->configInstance->getConfigEntry('local_db_path') . 'list-' . $this->configInstance->getConfigEntry('app_name') . '.cache';
+                       $this->classCacheFQFN = $this->configInstance->getConfigEntry('local_db_path') . 'class-' . $this->configInstance->getConfigEntry('app_name') . '.cache';
                } // END - if
 
                // Set suffix and prefix from configuration
@@ -260,7 +260,7 @@ class ClassLoader {
                // If the basePath is false it is invalid
                if ($basePath2 === false) {
                        /* @todo: Do not die here. */
-                       die("Cannot read {$basePath} !");
+                       die('Cannot read ' . $basePath . ' !');
                } else {
                        // Set base path
                        $basePath = $basePath2;
index b3d9164..60d1fb6 100755 (executable)
@@ -42,7 +42,7 @@ install http://www.ship-simu.org/repos/install/trunk/application/install/" . ||
        fi
        cd .. # trunk
 else
-       echo "${0}: --- Not setting admin external source. ---"
+       echo "${0}: --- Not setting admin/install external source. ---"
 fi
 cd .. # root
 echo "${0}: Running commit ..."