Updated domain without a dash :(
[core.git] / inc / classes / main / criteria / class_BaseCriteria.php
index aa8a401b7afe9d7e2cc49b5cf5d6e2164030fe94..929b048f9c84815ab6edcc17e4fad281bbc30fa5 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A general crtieria class
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,12 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
+
+               // Initialize all criteria arrays
+               foreach (array('default', 'choice', 'exclude') as $criteriaType) {
+                       // Init it
+                       $this->initGenericArrayKey('criteria', $criteriaType, 'entries');
+               } // END - foreach
        }
 
        /**
@@ -50,7 +56,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE));
 
                // Determine it
-               $isSet = $this->isGenericArrayKeySet('criteria', $criteriaType, $criteriaKey);
+               $isSet = $this->isGenericArrayElementSet('criteria', $criteriaType, 'entries', $criteriaKey);
 
                // Return it
                return $isSet;
@@ -104,7 +110,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
         * @return      $criteria
         */
        public final function getCriteriaArray ($criteriaType = 'default') {
-               return $this->getGenericSubArray('criteria', $criteriaType);
+               return $this->getGenericArrayKey('criteria', $criteriaType, 'entries');
        }
 
        /**
@@ -141,7 +147,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                // "Walk" through all criterias
                foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) {
                        // Remove it
-                       $this->unsetGenericArrayElement('criteria', $criteriaType, $criteriaKey);
+                       $this->unsetGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
                } // END - foreach
        }
 
@@ -165,7 +171,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
 
                // Append it
-               $this->appendStringToGenericArrayElement('criteria', $criteriaType, $criteriaKey, $criteriaValue);
+               $this->appendStringToGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
        }
 
        /**
@@ -184,7 +190,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
 
                // Add it
-               $this->pushValueToGenericArrayElement('criteria', 'choice', $this->convertDashesToUnderscores($criteriaKey), (string) $criteriaValue);
+               $this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', $this->convertDashesToUnderscores($criteriaKey), (string) $criteriaValue);
        }
 
        /**
@@ -237,7 +243,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                // Is the criteria there?
                if ($this->isKeySet($criteriaType, $criteriaKey)) {
                        // Then use it
-                       $value = $this->getGenericArrayKey('criteria', $criteriaType, $criteriaKey);
+                       $value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
                } // END - if
 
                // Return the value
@@ -287,7 +293,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                        $key = $this->convertDashesToUnderscores($key);
 
                        // Then walk through all search criteria
-                       foreach ($this->getGenericSubArray('criteria', $criteriaType) as $criteriaKey => $criteriaValue) {
+                       foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) {
                                // Make sure no 'my-' or 'my_' passes this point
                                assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue)));
 
@@ -349,9 +355,10 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                $cacheKey = '';
 
                // Now walk through all criterias
-               foreach ($this->getGenericSubArray('criteria', $criteriaType) as $criteriaKey => $criteriaValue) {
+               foreach ($this->getGenericArrayKey('criteria', $criteriaType, 'entries') as $criteriaKey => $criteriaValue) {
                        // Make sure no 'my-' or 'my_' passes this point
                        assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue)));
+                       assert(!is_array($criteriaValue));
 
                        // Convert dashes to underscore
                        $criteriaKey = $this->convertDashesToUnderscores($criteriaKey);