X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcriteria%2Fclass_BaseCriteria.php;h=400ed06c4b7f46417a721930e5e43a03946782f4;hb=0ccdb0379f308c6b7b5677b8b7c242df8e9dd300;hp=7ba2ea57aafe807744615af8b016f8774a5bfa06;hpb=01cc80f06529313b40cb6858eae3f361c8ed1aee;p=core.git diff --git a/inc/classes/main/criteria/class_BaseCriteria.php b/inc/classes/main/criteria/class_BaseCriteria.php index 7ba2ea57..400ed06c 100644 --- a/inc/classes/main/criteria/class_BaseCriteria.php +++ b/inc/classes/main/criteria/class_BaseCriteria.php @@ -2,11 +2,11 @@ /** * A general crtieria class * - * @author Roland Haeder + * @author Roland Haeder * @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 @@ -142,7 +142,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); // Convert dashes to underscore - $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); // "Walk" through all criterias foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) { @@ -165,13 +165,13 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue))); // Convert dashes to underscore - $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); + $criteriaKey = self::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); } /** @@ -187,10 +187,10 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { 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', self::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue); } /** @@ -232,10 +232,10 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE)); // Convert dashes to underscore - $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); + $criteriaKey = self::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; @@ -243,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 @@ -290,15 +290,15 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { assert((strpos($key, 'my-') === FALSE) && (strpos($key, 'my_') === FALSE)); // Convert dashes to underscore - $key = $this->convertDashesToUnderscores($key); + $key = self::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))); // Convert dashes to underscore - $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); + $criteriaKey = self::convertDashesToUnderscores($criteriaKey); // Is the element found and does it match? if (($key == $criteriaKey) && ($criteriaValue == $entry)) { @@ -355,17 +355,20 @@ 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))); + // $criteriaValue cannot be an array + assert(!is_array($criteriaValue)); + // Convert dashes to underscore - $criteriaKey = $this->convertDashesToUnderscores($criteriaKey); + $criteriaKey = self::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) ); @@ -380,7 +383,7 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria { // 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() );