From c1d88e5878553a4d812569c22f0b46ef28674e2f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 14 Mar 2009 01:50:36 +0000 Subject: [PATCH] Fix in CryptoHelper class, templates are now loaded from application (templates in core are deprecated) --- .../main/class_BaseFrameworkSystem.php | 24 ++++++++++ .../web/class_WebLoginController.php | 2 +- .../main/crypto/class_CryptoHelper.php | 2 +- .../helper/web/links/class_WebLinkHelper.php | 48 ++++++++++++++++++- .../template/class_BaseTemplateEngine.php | 6 ++- 5 files changed, 76 insertions(+), 6 deletions(-) diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index fafe6b03..ade1a136 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -1119,6 +1119,30 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $wrapperInstance->doUpdateByResult($this->getResultInstance()); } // END - if } + + /** + * Outputs a deprecation warning to the developer. + * + * @param $message The message we shall output to the developer + * @return void + * @todo Write a logging mechanism for productive mode + */ + public function deprecationWarning ($message) { + // Is developer mode active? + if (defined('DEVELOPER')) { + // Debug instance is there? + if (!is_null($this->getDebugInstance())) { + // Output stub message + $this->debugOutput($message); + } else { + // Trigger an error + trigger_error($message."
\n"); + } + } else { + // @TODO Finish this part! + $this->partialStub('Developer mode inactive. Message:' . $message); + } + } } // [EOF] diff --git a/inc/classes/main/controller/web/class_WebLoginController.php b/inc/classes/main/controller/web/class_WebLoginController.php index f6be6d61..82582c61 100644 --- a/inc/classes/main/controller/web/class_WebLoginController.php +++ b/inc/classes/main/controller/web/class_WebLoginController.php @@ -61,7 +61,7 @@ class WebLoginController extends BaseController implements Controller { public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { // Get the command instance from the resolver by sending a request instance to the resolver $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance); - + // Add more filters by the command $commandInstance->addExtraFilters($this, $requestInstance); diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index 004ea24f..ace05602 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -44,7 +44,7 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { /** * Seperator on many places */ - private $seperator '|'; + private $seperator = '|'; /** * Protected constructor diff --git a/inc/classes/main/helper/web/links/class_WebLinkHelper.php b/inc/classes/main/helper/web/links/class_WebLinkHelper.php index 5dd2ef7e..7b270687 100644 --- a/inc/classes/main/helper/web/links/class_WebLinkHelper.php +++ b/inc/classes/main/helper/web/links/class_WebLinkHelper.php @@ -57,10 +57,12 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { * * @param $templateInstance An instance of a template engine * @param $linkName Name of the link we shall generate - * @param $linkBase Link base for all generated links + * @param $linkBase Link base for the link. This parameter is deprecated. * @return $helperInstance A prepared instance of this helper + * @throws NullPointerException Thrown if an instance is null + * @throws ConfigEntryNotFoundException A deprecated exception at this point */ - public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase) { + public final static function createWebLinkHelper (CompileableTemplate $templateInstance, $linkName, $linkBase = null) { // Get new instance $helperInstance = new WebLinkHelper(); @@ -70,6 +72,48 @@ class WebLinkHelper extends BaseWebHelper implements HelpableTemplate { // Set link name $helperInstance->setLinkName($linkName); + // Get the application instance + $applicationInstance = Registry::getRegistry()->getInstance('application'); + + // Sanity-check on it + if (is_null($applicationInstance)) { + // Throw an exception here + throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get the request instance + $requestInstance = $applicationInstance->getRequestInstance(); + + // Sanity-check on it + if (is_null($requestInstance)) { + // Throw an exception here + throw new NullPointerException($helperInstance, self::EXCEPTION_IS_NULL_POINTER); + } // END - if + + // Get page (this will throw an exception if not set) + $page = $helperInstance->convertDashesToUnderscores($requestInstance->getRequestElement('page')); + + // Construct config entry + $configEntry = $page . '_' . $linkName; + + // Is the deprecated parameter set? + if (!is_null($linkBase)) { + // Then output a deprecation message + $helperInstance->deprecationWarning(__METHOD__ . ': linkBase is deprecated. Please remove it from your templates and add a config entry ' . $configEntry . ' in your config.php file.'); + } // END - if + + // Determine link base from config now and 'page' request + try { + $newLinkBase = $helperInstance->getConfigInstance()->readConfig($configEntry); + $linkBase = $newLinkBase; + } catch (ConfigEntryNotFoundException $e) { + // Is the deprecated linkBase not set? + if (is_null($linkBase)) { + // Then throw again the exception + throw new ConfigEntryNotFoundException(array(__CLASS__, ($configEntry)), self::EXCEPTION_CONFIG_ENTRY_WAS_NOT_FOUND); + } // END - if + } + // Set link base $helperInstance->setLinkBase($linkBase); diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index c40b183c..21234b81 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -523,7 +523,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem { } // END - if // Construct the FQFN for the template by honoring the current language - $fqfn = sprintf("%s%s/%s/%s%s", + $fqfn = sprintf("%s%s/%s%s/%s/%s%s", + $this->getConfigInstance()->readConfig('application_path'), + Registry::getRegistry()->getInstance('application')->getAppShortName(), $this->getBasePath(), $this->getLanguageInstance()->getLanguageCode(), $this->getTemplateType(), @@ -1018,7 +1020,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { @eval($eval); // Goes something wrong? - if (!isset($result)) { + if ((!isset($result)) || (empty($result))) { // Output eval command $this->debugOutput(sprintf("Failed eval() code:
%s
", $this->markupCode($eval, true)), true); -- 2.39.2