From 50861b4a1cc38134c915eb989ad249bbe6c8e601 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Tue, 29 Mar 2011 12:30:00 +0000
Subject: [PATCH] New field/attribute 'cryptoInstance' introduced: -
 Getter/setter added for cryptoInstance field/attribute :-) - Deprecated
 rngInstance removed from CryptoHelper, it is encapsulated in class  
 BaseFrameworkSystem - TODOs.txt updated

---
 docs/TODOs.txt                                | 25 ++++-----
 .../main/class_BaseFrameworkSystem.php        | 55 ++++++++++++++-----
 .../main/crypto/class_CryptoHelper.php        |  5 --
 3 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/docs/TODOs.txt b/docs/TODOs.txt
index 5169e005..07e8e2c3 100644
--- a/docs/TODOs.txt
+++ b/docs/TODOs.txt
@@ -3,11 +3,10 @@
 ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo		Try to rewrite user/guest login classes and mark this exception as deprecated
 ./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo		Rename this class to NoFoundEntryException
 ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo		Find a better name for this interface
-./inc/classes/main/class_BaseFrameworkSystem.php:1133:	 * @todo	Write a logging mechanism for productive mode
-./inc/classes/main/class_BaseFrameworkSystem.php:1147:			// @TODO Finish this part!
-./inc/classes/main/class_BaseFrameworkSystem.php:154:	// @todo Try to clean these constants up
-./inc/classes/main/class_BaseFrameworkSystem.php:233:	 * @todo	This is old code. Do we still need this old lost code?
-./inc/classes/main/class_BaseFrameworkSystem.php:301:	 * @todo	SearchableResult and UpdateableResult shall have a super interface to use here
+./inc/classes/main/class_BaseFrameworkSystem.php:1141:	 * @todo	Write a logging mechanism for productive mode
+./inc/classes/main/class_BaseFrameworkSystem.php:1155:			// @TODO Finish this part!
+./inc/classes/main/class_BaseFrameworkSystem.php:159:	// @todo Try to clean these constants up
+./inc/classes/main/class_BaseFrameworkSystem.php:318:	 * @todo	SearchableResult and UpdateableResult shall have a super interface to use here
 ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64:	 * @todo	Add some stuff here: Some personal data, app/game related data
 ./inc/classes/main/commands/web/class_WebProblemCommand.php:58:	 * @todo	0% done
 ./inc/classes/main/commands/web/class_WebStatusCommand.php:58:	 * @todo	0% done
@@ -73,7 +72,7 @@
 ./inc/classes/main/response/image/class_ImageResponse.php:91:	 * @todo	this will send only one cookie out, the first one.
 ./inc/classes/main/result/class_DatabaseResult.php:226:	 * @todo	0% done
 ./inc/classes/main/result/class_DatabaseResult.php:379:4	 * @todo	Find a caching way without modifying the result array
-./inc/classes/main/rng/class_RandomNumberGenerator.php:150:	 * @todo	I had a better random number generator here but now it is somewhere lost :(
+./inc/classes/main/rng/class_RandomNumberGenerator.php:152:	 * @todo	I had a better random number generator here but now it is somewhere lost :(
 ./inc/classes/main/rng/class_RandomNumberGenerator.php:83:	 * @todo	Add site key for stronger salt!
 ./inc/classes/main/template/class_BaseTemplateEngine.php:1055:			// @TODO This silent abort should be logged, maybe.
 ./inc/classes/main/template/class_BaseTemplateEngine.php:1063:			// @TODO Old behaviour, will become obsolete!
@@ -83,14 +82,14 @@
 ./inc/classes/main/template/class_BaseTemplateEngine.php:961:	 * @todo	Unfinished work or don't die here.
 ./inc/classes/main/template/class_BaseTemplateEngine.php:978:				// @TODO Non-string found so we need some deeper analysis...
 ./inc/classes/main/template/console/class_ConsoleTemplateEngine.php:10: * @todo		This template engine does not make use of setTemplateType()
-./inc/classes/main/template/image/class_ImageTemplateEngine.php:213:	 * @todo	Find something usefull with this!
-./inc/classes/main/template/image/class_ImageTemplateEngine.php:233:	 * @todo	Add cache creation here
+./inc/classes/main/template/image/class_ImageTemplateEngine.php:215:	 * @todo	Find something usefull with this!
+./inc/classes/main/template/image/class_ImageTemplateEngine.php:235:	 * @todo	Add cache creation here
 ./inc/classes/main/template/mail/class_MailTemplateEngine.php:10: * @todo		This template engine does not make use of setTemplateType()
-./inc/classes/main/template/mail/class_MailTemplateEngine.php:226:	 * @todo	Add cache creation here
-./inc/classes/main/template/mail/class_MailTemplateEngine.php:236:	 * @todo	Should we call back the mailer class here?
-./inc/classes/main/template/mail/class_MailTemplateEngine.php:317:	 * @todo	0% done
-./inc/classes/main/template/menu/class_MenuTemplateEngine.php:265:	 * @todo	Find something useful with this!
-./inc/classes/main/template/menu/class_MenuTemplateEngine.php:311:	 * @todo	Add cache creation here
+./inc/classes/main/template/mail/class_MailTemplateEngine.php:228:	 * @todo	Add cache creation here
+./inc/classes/main/template/mail/class_MailTemplateEngine.php:238:	 * @todo	Should we call back the mailer class here?
+./inc/classes/main/template/mail/class_MailTemplateEngine.php:319:	 * @todo	0% done
+./inc/classes/main/template/menu/class_MenuTemplateEngine.php:267:	 * @todo	Find something useful with this!
+./inc/classes/main/template/menu/class_MenuTemplateEngine.php:313:	 * @todo	Add cache creation here
 ./inc/classes/main/user/class_BaseUser.php:308:	 * @todo	Try to make this method more generic so we can move it in BaseFrameworkSystem
 ./inc/classes/main/user/class_BaseUser.php:80:	 * @todo	Find a way of casting here. "(int)" might destroy the user id > 32766
 ./inc/classes/main/user/member/class_Member.php:84:	 * @todo	Add more ways over creating user classes
diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php
index 6cc07b23..c890cc23 100644
--- a/inc/classes/main/class_BaseFrameworkSystem.php
+++ b/inc/classes/main/class_BaseFrameworkSystem.php
@@ -78,6 +78,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 	 */
 	private $rngInstance = null;
 
+	/**
+	 * Instance of a crypto helper
+	 */
+	private $cryptoInstance = null;
+
 	/**
 	 * Instance of an Iterator class
 	 */
@@ -219,9 +224,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 		// Set real class
 		$this->setRealClass($className);
 
-		// Set configuration instance if no registry
+		// Set configuration instance if no registry ...
 		if (!$this instanceof Register) {
-			// Because registries doesn't need to be configured
+			// ... because registries doesn't need to be configured
 			$this->setConfigInstance(FrameworkConfiguration::getInstance());
 		} // END - if
 	}
@@ -230,7 +235,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 	 * Destructor reached...
 	 *
 	 * @return	void
-	 * @todo	This is old code. Do we still need this old lost code?
 	 */
 	public function __destruct() {
 		// Flush any updated entries to the database
@@ -250,8 +254,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 	}
 
 	/**
-	 * The call method where all non-implemented methods end up
+	 * The __call() method where all non-implemented methods end up
 	 *
+	 * @param	$methodName		Name of the missing method
+	 * @args	$args			Arguments passed to the method
 	 * @return	void
 	 */
 	public final function __call ($methodName, $args) {
@@ -267,7 +273,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 				$argsString .= $this->replaceControlCharacters($arg) . ' (' . gettype($arg);
 
 				// Add length if type is string
-				if (gettype($arg) == 'string') $argsString .= ', '.strlen($arg);
+				if (is_string($arg)) {
+					$argsString .= ', '.strlen($arg);
+				} // END - if
 
 				// Closing bracket
 				$argsString .= '), ';
@@ -293,6 +301,15 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 		return null;
 	}
 
+	/**
+	 * Getter for $realClass
+	 *
+	 * @return	$realClass The name of the real class (not BaseFrameworkSystem)
+	 */
+	public function __toString () {
+		return $this->realClass;
+	}
+
 	/**
 	 * Setter for database result instance
 	 *
@@ -554,15 +571,6 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 		return $this->responseInstance;
 	}
 
-	/**
-	 * Getter for $realClass
-	 *
-	 * @return	$realClass The name of the real class (not BaseFrameworkSystem)
-	 */
-	public function __toString () {
-		return $this->realClass;
-	}
-
 	/**
 	 * Setter for the real class name
 	 *
@@ -1182,6 +1190,25 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 		return $this->rngInstance;
 	}
 
+	/**
+	 * Setter for Cryptable instance
+	 *
+	 * @param	$cryptoInstance	An instance of a Cryptable class
+	 * @return	void
+	 */
+	protected final function setCryptoInstance (Cryptable $cryptoInstance) {
+		$this->cryptoInstance = $cryptoInstance;
+	}
+
+	/**
+	 * Getter for Cryptable instance
+	 *
+	 * @return	$cryptoInstance	An instance of a Cryptable class
+	 */
+	public final function getCryptoInstance () {
+		return $this->cryptoInstance;
+	}
+
 	/**
 	 * Setter for Iterator instance
 	 *
diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php
index 5e405606..f377a575 100644
--- a/inc/classes/main/crypto/class_CryptoHelper.php
+++ b/inc/classes/main/crypto/class_CryptoHelper.php
@@ -31,11 +31,6 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
 	 */
 	private static $selfInstance = null;
 
-	/**
-	 * Instance of the random number generator
-	 */
-	private $rngInstance = null;
-
 	/**
 	 * Instance of the crypto stream
 	 */
-- 
2.39.5