Added option parameter 'forceInit'
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
index 09d13a5786c2faae223e49a2559654226ae28587..0fb474dcb865fafa32ceb60749b6428817b2439b 100644 (file)
@@ -2119,38 +2119,38 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
        }
 
        /**
-        * Determines if a key is set in the generic array
+        * Determines if an element is set in the generic array
         *
         * @param       $keyGroup       Main group for the key
         * @param       $subGroup       Sub group for the key
         * @param       $key            Key to check
+        * @param       $element        Element to check
         * @return      $isset          Whether the given key is set
         */
-       protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+       protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
                // Is it there?
-               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
+               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
 
                // Return it
                return $isset;
        }
-
        /**
-        * Determines if an element is set in the generic array
+        * Determines if a key is set in the generic array
         *
         * @param       $keyGroup       Main group for the key
         * @param       $subGroup       Sub group for the key
         * @param       $key            Key to check
-        * @param       $element        Element to check
         * @return      $isset          Whether the given key is set
         */
-       protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+       protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
                // Is it there?
-               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+               $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
 
                // Return it
                return $isset;
        }
 
+
        /**
         * Determines if a group is set in the generic array
         *
@@ -2181,6 +2181,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Return it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' returning!' . PHP_EOL);
                return $this->genericArray[$keyGroup][$subGroup];
        }
 
@@ -2194,6 +2195,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         */
        protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key) {
                // Remove it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' unset!' . PHP_EOL);
                unset($this->genericArray[$keyGroup][$subGroup][$key]);
        }
 
@@ -2223,16 +2225,18 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
         * @param       $keyGroup       Main group for the key
         * @param       $subGroup       Sub group for the key
         * @param       $key            Key to use
+        * @param       $forceInit      Optionally force initialization
         * @return      void
         */
-       protected final function initGenericArray ($keyGroup, $subGroup, $key) {
+       protected final function initGenericArray ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
                // Is it already set?
-               if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+               if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
                        // Already initialized
                        trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
                } // END - if
 
                // Initialize it
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . PHP_EOL);
                $this->genericArray[$keyGroup][$subGroup][$key] = array();
        }
 
@@ -2253,7 +2257,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                } // END - if
 
                // Then push it
-               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value=' . $value . PHP_EOL);
+               //* DEBUG: */ print(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
                $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
 
                // Return count
@@ -2283,7 +2287,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
 
                // Return value
                //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
-               //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . $value . PHP_EOL);
+               //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
                return $value;
        }
 
@@ -2478,6 +2482,22 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                // Return it
                return $isValid;
        }
+
+       /**
+        * Checks if a given key is valid (array)
+        *
+        * @param       $keyGroup       Key group to get
+        * @param       $subGroup       Sub group for the key
+        * @param       $key            Key to check
+        * @return      $isValid        Whether given sub group is valid
+        */
+       protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
+               // Determine it
+               $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key))));
+
+               // Return it
+               return $isValid;
+       }
 }
 
 // [EOF]