From: Roland Häder Date: Tue, 18 May 2010 19:44:22 +0000 (+0000) Subject: Some code-cosmetics applied: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=fffe0ef5a4c39831127b1afed64d8ea0e077b09e;p=core.git Some code-cosmetics applied: - No longer gettings a $configInstance, lets use $templateInstance->getConfigInstance() instead. - Some other minor costemical changes --- diff --git a/inc/classes/interfaces/template/class_CompileableTemplate.php b/inc/classes/interfaces/template/class_CompileableTemplate.php index c6b1a1a8..1e7f82fd 100644 --- a/inc/classes/interfaces/template/class_CompileableTemplate.php +++ b/inc/classes/interfaces/template/class_CompileableTemplate.php @@ -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] diff --git a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php b/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php index c849ef13..2cddb8cf 100644 --- a/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php +++ b/inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php @@ -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; } } diff --git a/inc/classes/main/discovery/class_ b/inc/classes/main/discovery/class_ index 4f6d8512..61327dd3 100644 --- a/inc/classes/main/discovery/class_ +++ b/inc/classes/main/discovery/class_ @@ -1,8 +1,6 @@ * @version 0.0.0 diff --git a/inc/classes/main/parser/xml/class_XmlParser.php b/inc/classes/main/parser/xml/class_XmlParser.php index 76c39879..63d508a5 100644 --- a/inc/classes/main/parser/xml/class_XmlParser.php +++ b/inc/classes/main/parser/xml/class_XmlParser.php @@ -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:
');
+			debug_print_backtrace();
+			$this->debugOuput('
'); + die(); + } elseif (function_exists('recode')) { // Recode found, so use it $content = recode('html..utf8', $content); } else { diff --git a/inc/classes/main/registry/class_ b/inc/classes/main/registry/class_ index e86c1653..c2a1b7cf 100644 --- a/inc/classes/main/registry/class_ +++ b/inc/classes/main/registry/class_ @@ -57,4 +57,3 @@ class ???Registry extends BaseRegistry implements Register { // [EOF] ?> - diff --git a/inc/classes/main/registry/class_BaseRegistry.php b/inc/classes/main/registry/class_BaseRegistry.php index 33111286..ca01a2a2 100644 --- a/inc/classes/main/registry/class_BaseRegistry.php +++ b/inc/classes/main/registry/class_BaseRegistry.php @@ -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 * diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index b64477c4..c1aa4f8f 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -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('//', $content, $matches); + preg_match_all('//', $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; } } diff --git a/inc/classes/main/template/console/class_ConsoleTemplateEngine.php b/inc/classes/main/template/console/class_ConsoleTemplateEngine.php index 330545a2..83fc014a 100644 --- a/inc/classes/main/template/console/class_ConsoleTemplateEngine.php +++ b/inc/classes/main/template/console/class_ConsoleTemplateEngine.php @@ -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; diff --git a/inc/classes/main/template/image/class_ImageTemplateEngine.php b/inc/classes/main/template/image/class_ImageTemplateEngine.php index bc0e8021..2c6cb376 100644 --- a/inc/classes/main/template/image/class_ImageTemplateEngine.php +++ b/inc/classes/main/template/image/class_ImageTemplateEngine.php @@ -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; diff --git a/inc/classes/main/template/mail/class_MailTemplateEngine.php b/inc/classes/main/template/mail/class_MailTemplateEngine.php index 99072276..4230ac6b 100644 --- a/inc/classes/main/template/mail/class_MailTemplateEngine.php +++ b/inc/classes/main/template/mail/class_MailTemplateEngine.php @@ -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; diff --git a/inc/classes/main/template/menu/class_MenuTemplateEngine.php b/inc/classes/main/template/menu/class_MenuTemplateEngine.php index 59d1eeef..af9a3756 100644 --- a/inc/classes/main/template/menu/class_MenuTemplateEngine.php +++ b/inc/classes/main/template/menu/class_MenuTemplateEngine.php @@ -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); diff --git a/inc/classes/main/template/web/class_WebTemplateEngine.php b/inc/classes/main/template/web/class_WebTemplateEngine.php index b2377a99..043277a6 100644 --- a/inc/classes/main/template/web/class_WebTemplateEngine.php +++ b/inc/classes/main/template/web/class_WebTemplateEngine.php @@ -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; diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php index 34fd3c3c..79768fff 100644 --- a/inc/loader/class_ClassLoader.php +++ b/inc/loader/class_ClassLoader.php @@ -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; diff --git a/setup-repos.sh b/setup-repos.sh index b3d91640..60d1fb6b 100755 --- a/setup-repos.sh +++ b/setup-repos.sh @@ -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 ..."