X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fhelper%2Fclass_BaseHelper.php;h=da4f6b12b3f0fffe558ac1d0ab99c5c4539b341b;hp=6c7c82d5c1ec2973112e8b5641f051a1aba89bee;hb=eb7f95605a457b70446885631e03db5d5778b80c;hpb=361e6320e50a8bb1a3ccb675388b8042361669ae diff --git a/inc/classes/main/helper/class_BaseHelper.php b/inc/classes/main/helper/class_BaseHelper.php index 6c7c82d5..da4f6b12 100644 --- a/inc/classes/main/helper/class_BaseHelper.php +++ b/inc/classes/main/helper/class_BaseHelper.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007 - 2009 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -30,7 +30,7 @@ class BaseHelper extends BaseFrameworkSystem { /** * Rendered content created by the helper class */ - private $content = ""; + private $content = ''; /** * Array with groups @@ -45,12 +45,12 @@ class BaseHelper extends BaseFrameworkSystem { /** * Previously opened group */ - private $previousGroupId = ""; + private $previousGroupId = ''; /** * Previously opened sub group */ - private $previousSubGroupId = ""; + private $previousSubGroupId = ''; /** * Total counter for groups and sub groups @@ -76,10 +76,6 @@ class BaseHelper extends BaseFrameworkSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -89,7 +85,7 @@ class BaseHelper extends BaseFrameworkSystem { * @return void */ protected final function addContent ($newContent) { - $this->content .= (string) trim($newContent)."\n"; + $this->content .= (string) trim($newContent) . "\n"; } /** @@ -194,8 +190,13 @@ class BaseHelper extends BaseFrameworkSystem { * @throws NullPointerException If recovery of requested value instance failed */ public function prefetchValueInstance ($registryKey, $extraKey = null) { - // Get the required instance - $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); + try { + // Get the required instance + $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); + } catch (NullPointerException $e) { + // Not set in registry + // @TODO Try to log it here + } // Is the value instance valid? if (is_null($this->valueInstance)) { @@ -208,10 +209,9 @@ class BaseHelper extends BaseFrameworkSystem { $extraInstance = Registry::getRegistry()->getInstance($extraKey); } // END - if - // Get the requested instance try { + // Get the requested instance $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($extraInstance)); - } catch (FrameworkException $e) { // Okay, nothing found so throw a null pointer exception here throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); @@ -244,7 +244,13 @@ class BaseHelper extends BaseFrameworkSystem { // Add the group to the stack $this->groups[$this->totalCounter] = $groupId; $this->groups[$groupId]['opened'] = true; - $this->groups[$groupId]['content'] = sprintf("%s\n", $groupId, strlen($content), $tag, $content); + $this->groups[$groupId]['content'] = sprintf( + "%s\n", + $groupId, + strlen($content), + $tag, + $content + ); $this->groups[$groupId]['tag'] = $tag; // Mark this group as previously opened @@ -259,7 +265,7 @@ class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found */ - public function closePreviousGroupByContent ($content = "") { + public function closePreviousGroupByContent ($content = '') { // Check if any sub group was opened before if ($this->ifSubGroupOpenedPreviously()) { // Close it automatically @@ -278,15 +284,25 @@ class BaseHelper extends BaseFrameworkSystem { // Is the content empty? if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) { // Get it from opener - $content = sprintf("", $groupId, $this->groups[$groupId]['tag']); + $content = sprintf( + "", + $groupId, + $this->groups[$groupId]['tag'] + ); } // END - if // Add content to it and mark it as closed - $this->groups[$groupId]['content'] .= sprintf("%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content); + $this->groups[$groupId]['content'] .= sprintf( + "%s\n", + $groupId, + strlen($content), + $this->groups[$groupId]['tag'], + $content + ); $this->groups[$groupId]['opened'] = false; // Mark previous group as closed - $this->setPreviousGroupId(""); + $this->setPreviousGroupId(''); //* DEBUG: */ echo "CLOSE:groupId={$groupId}
\n"; } @@ -330,7 +346,7 @@ class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found */ - public function closePreviousSubGroupByContent ($content = "") { + public function closePreviousSubGroupByContent ($content = '') { // Check if any sub group was opened before if ($this->ifSubGroupOpenedPreviously() === false) { // Then throw an exception @@ -351,7 +367,7 @@ class BaseHelper extends BaseFrameworkSystem { $this->subGroups[$subGroupId]['opened'] = false; // Mark previous sub group as closed - $this->setPreviousSubGroupId(""); + $this->setPreviousSubGroupId(''); //* DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}
\n"; } @@ -362,12 +378,12 @@ class BaseHelper extends BaseFrameworkSystem { */ public function renderContent () { // Initialize content - $content = ""; + $content = ''; // Is header content there? if (isset($this->groups['header'])) { // Then add it - $content .= $this->groups['header']['content']."\n"; + $content .= $this->groups['header']['content'] . "\n"; } // END - if // Initiate content @@ -395,7 +411,7 @@ class BaseHelper extends BaseFrameworkSystem { // Is footer content there? if (isset($this->groups['footer'])) { // Then add it - $content .= $this->groups['footer']['content']."\n"; + $content .= $this->groups['footer']['content'] . "\n"; } // END - if // Return it @@ -424,8 +440,13 @@ class BaseHelper extends BaseFrameworkSystem { * @return $fieldValue Value from field */ public function getValueField ($fieldName) { + // Construct the eval() command + $eval = sprintf("\$fieldValue = \$this->getValueInstance()->getField('%s');", + $fieldName + ); + // Get the field value - $fieldValue = call_user_func_array(array($this->valueInstance, 'getField'), array($fieldName)); + eval($eval); // Return it return $fieldValue;