/**
* 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
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 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
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
}
/**
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;
* @return $criteria
*/
public final function getCriteriaArray ($criteriaType = 'default') {
- return $this->getGenericSubArray('criteria', $criteriaType);
+ return $this->getGenericArrayKey('criteria', $criteriaType, 'entries');
}
/**
// "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
}
$criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
// Append it
- $this->appendStringToGenericArrayElement('criteria', $criteriaType, $criteriaKey, $criteriaValue);
+ $this->appendStringToGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
}
/**
assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue)));
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __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);
}
/**
$criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType)));
// Default is not found
$value = FALSE;
// 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
$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)));
} // END - foreach
// Now check if expected criteria counts match
- $matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType)));
+ $matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType));
// Return the result
return $matches;
$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)));
+ // $criteriaValue cannot be an array
+ assert(!is_array($criteriaValue));
+
// Convert dashes to underscore
$criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Is the value in array or is $onlyKeys empty?
if ((isset($onlyKeys[$criteriaKey])) || (count($onlyKeys) == 0)) {
// Add the value URL encoded to avoid any trouble with special characters
- $cacheKey .= sprintf("%s=%s;",
+ $cacheKey .= sprintf('%s=%s;',
$criteriaKey,
urlencode($criteriaValue)
);
// Check if 'limit' and 'skip' are in
if (((isset($onlyKeys['limit'])) && (isset($onlyKeys['skip']))) || (count($onlyKeys) == 0)) {
// Add limit and skip values
- $cacheKey .= sprintf(";%%limit%%=%s;%%skip%%=%s",
+ $cacheKey .= sprintf(';%%limit%%=%s;%%skip%%=%s',
$this->getLimit(),
$this->getSkip()
);
*/
public final function count ($criteriaType = 'default') {
// Return it
- return $this->countGenericArrayGroup('criteria', $criteriaType));
+ return $this->countGenericArrayGroup('criteria', $criteriaType);
}
/**