*/
private $packageData = array();
+ /**
+ * Generic array
+ */
+ private $genericArray = array();
+
/***********************
* Exception codes.... *
***********************/
// ... and return it
return $isset;
}
+
+ /**
+ * 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
+ * @return $isset Whether the given key is set
+ */
+ protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+ // Is it there?
+ $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
+
+ // Return it
+ return $isset;
+ }
+
+ /**
+ * 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 isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+ // Is it there?
+ $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
+
+ // Return it
+ return $isset;
+ }
+
+ /**
+ * Determines if a group is set in the generic array
+ *
+ * @param $keyGroup Main group
+ * @param $subGroup Sub group
+ * @return $isset Whether the given group is set
+ */
+ protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) {
+ // Is it there?
+ $isset = isset($this->genericArray[$keyGroup][$subGroup]);
+
+ // Return it
+ return $isset;
+ }
+
+ /**
+ * Getter for sub key group
+ *
+ * @param $keyGroup Main key group
+ * @param $subGroup Sub key group
+ * @return $array An array with all array elements
+ */
+ protected final function getGenericSubArray ($keyGroup, $subGroup) {
+ // Is it there?
+ if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
+ // No, then abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+ } // END - if
+
+ // Return it
+ return $this->genericArray[$keyGroup][$subGroup];
+ }
+
+ /**
+ * Unsets a given key in generic array
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to unset
+ * @return void
+ */
+ protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key) {
+ // Remove it
+ unset($this->genericArray[$keyGroup][$subGroup][$key]);
+ }
+
+ /**
+ * Append a string to a given generic array key
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to unset
+ * @param $value Value to add/append
+ * @return void
+ */
+ protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
+ // Is it already there?
+ if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ // Append it
+ $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . (string) $value;
+ } else {
+ // Add it
+ $this->genericArray[$keyGroup][$subGroup][$key] = (string) $value;
+ }
+ }
+
+ /**
+ * Pushes an element to a generic key
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to use
+ * @param $value Value to add/append
+ * @return $count Number of array elements
+ */
+ protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $value) {
+ // Is it set?
+ if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ // Initialize array
+ $this->genericArray[$keyGroup][$subGroup][$key] = array();
+ } // END - if
+
+ // Then push it
+ $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
+
+ // Return count
+ return $count;
+ }
+
+ /**
+ * Sets a value in given generic array key/element
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to set
+ * @param $element Element to set
+ * @param $value Value to set
+ * @return void
+ */
+ protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+ // Then set it
+ $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value;
+ }
+
+ /**
+ * Pops an element from a generic group
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to unset
+ * @return $value Last "popped" value
+ */
+ protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) {
+ // Is it set?
+ if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ // Not found
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
+ } // END - if
+
+ // Then "pop" it
+ $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]);
+
+ // Return value
+ return $value;
+ }
+
+ /**
+ * Shifts an element from a generic group
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @param $key Key to unset
+ * @return $value Last "popped" value
+ */
+ protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) {
+ // Is it set?
+ if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ // Not found
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
+ } // END - if
+
+ // Then "shift" it
+ $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]);
+
+ // Return value
+ return $value;
+ }
+
+ /**
+ * Count generic array group
+ *
+ * @param $keyGroup Main group for the key
+ * @return $count Count of given group
+ */
+ protected final function countGenericArray ($keyGroup) {
+ // Is it there?
+ if (!isset($this->genericArray[$keyGroup])) {
+ // Abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
+ } // END - if
+
+ // Then count it
+ $count = count($this->genericArray[$keyGroup]);
+
+ // Return it
+ return $count;
+ }
+
+ /**
+ * Count generic array sub group
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @return $count Count of given group
+ */
+ protected final function countGenericArrayGroup ($keyGroup, $subGroup) {
+ // Is it there?
+ if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
+ // Abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+ } // END - if
+
+ // Then count it
+ $count = count($this->genericArray[$keyGroup][$subGroup]);
+
+ // Return it
+ return $count;
+ }
+
+ /**
+ * Count generic array elements
+ *
+ * @param $keyGroup Main group for the key
+ * @param $subGroup Sub group for the key
+ * @para $key Key to count
+ * @return $count Count of given key
+ */
+ protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) {
+ // Is it there?
+ if (!$this->isGenericArrayKeySet($keyGroup, $subGroup)) {
+ // Abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
+ } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
+ // Not valid
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.');
+ }
+
+ // Then count it
+ $count = count($this->genericArray[$keyGroup][$subGroup][$key]);
+
+ // Return it
+ return $count;
+ }
+
+ /**
+ * Getter for whole generic group array
+ *
+ * @param $keyGroup Key group to get
+ * @return $array Whole generic array group
+ */
+ protected final function getGenericArray ($keyGroup) {
+ // Is it there?
+ if (!isset($this->genericArray[$keyGroup])) {
+ // Then abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
+ } // END - if
+
+ // Return it
+ return $this->genericArray[$keyGroup];
+ }
+
+ /**
+ * Getter for generic array key
+ *
+ * @param $keyGroup Key group to get
+ * @param $subGroup Sub group for the key
+ * @param $key Key to unset
+ * @return $value Mixed value from generic array element
+ */
+ protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) {
+ // Is it there?
+ if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
+ // Then abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
+ } // END - if
+
+ // Return it
+ return $this->genericArray[$keyGroup][$subGroup][$key];
+ }
+
+ /**
+ * Getter for generic array element
+ *
+ * @param $keyGroup Key group to get
+ * @param $subGroup Sub group for the key
+ * @param $key Key to look for
+ * @param $element Element to look for
+ * @return $value Mixed value from generic array element
+ */
+ protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+ // Is it there?
+ if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
+ // Then abort here
+ trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
+ } // END - if
+
+ // Return it
+ return $this->genericArray[$keyGroup][$subGroup][$key][$element];
+ }
+
+ /**
+ * Checks if a given sub group is valid (array)
+ *
+ * @param $keyGroup Key group to get
+ * @param $subGroup Sub group for the key
+ * @return $isValid Whether given sub group is valid
+ */
+ protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) {
+ // Determine it
+ $isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup))));
+
+ // Return it
+ return $isValid;
+ }
}
// [EOF]
*/
private $wrapperConfigEntry = '';
- /**
- * Criteria to handle
- */
- private $criteria = array(
- // Default
- 'default' => array(),
- // Choice
- 'choice' => array(),
- // .. and exclude
- 'exclude' => array(),
- );
-
/**
* Protected constructor
*
assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE));
// Determine it
- $isSet = isset($this->criteria[$criteriaType][$criteriaKey]);
+ $isSet = $this->isGenericArrayKeySet('criteria', $criteriaType, $criteriaKey);
// Return it
return $isSet;
* @return $criteria
*/
public final function getCriteriaArray ($criteriaType = 'default') {
- return $this->criteria[$criteriaType];
+ return $this->getGenericSubArray('criteria', $criteriaType);
}
/**
$criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// "Walk" through all criterias
- foreach ($this->criteria as $criteriaType => $dummy) {
+ foreach ($this->getGenericArray('criteria') as $criteriaType => $dummy) {
// Remove it
- unset($this->criteria[$criteriaType][$criteriaKey]);
+ $this->unsetGenericArrayElement('criteria', $criteriaType, $criteriaKey);
} // END - foreach
}
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
- // Is it already there?
- if ($this->isKeySet($criteriaType, $criteriaKey)) {
- // Append it
- $this->criteria[$criteriaType][$criteriaKey] .= ',' . (string) $criteriaValue;
- } else {
- // Add it
- $this->criteria[$criteriaType][$criteriaKey] = (string) $criteriaValue;
- }
+ // Append it
+ $this->appendStringToGenericArrayElement('criteria', $criteriaType, $criteriaKey, $criteriaValue);
}
/**
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
// Add it
- array_push($this->criteria['choice'][$this->convertDashesToUnderscores($criteriaKey)], (string) $criteriaValue);
+ $this->pushValueToGenericArrayElement('criteria', 'choice', $this->convertDashesToUnderscores($criteriaKey), (string) $criteriaValue);
}
/**
$criteriaKey = $this->convertDashesToUnderscores($criteriaKey);
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteria()=' . count($this->criteria[$criteriaType]));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __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->criteria[$criteriaType][$criteriaKey];
+ $value = $this->getGenericArrayKey('criteria', $criteriaType, $criteriaKey);
} // END - if
// Return the value
$key = $this->convertDashesToUnderscores($key);
// Then walk through all search criteria
- foreach ($this->criteria[$criteriaType] as $criteriaKey => $criteriaValue) {
+ foreach ($this->getGenericSubArray('criteria', $criteriaType) 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 == count($this->criteria[$criteriaType]));
+ $matches = ($counted == $this->countGenericArrayGroup('criteria', $criteriaType)));
// Return the result
return $matches;
*/
public function getCacheKey ($onlyKeys = array(), $criteriaType = 'default') {
// Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': criteriaType=' . $criteriaType . ',count()=' . count($this->criteria));
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': criteriaType=' . $criteriaType . ',count()=' . $this->countGenericArray('criteria')));
// Make sure the criteria is there
- assert((isset($this->criteria[$criteriaType])) && (is_array($this->criteria[$criteriaType])));
+ assert($this->isValidGenericArrayGroup('criteria', $criteriaType));
// Initialize the key
$cacheKey = '';
// Now walk through all criterias
- foreach ($this->criteria[$criteriaType] as $criteriaKey => $criteriaValue) {
+ foreach ($this->getGenericSubArray('criteria', $criteriaType) as $criteriaKey => $criteriaValue) {
// Make sure no 'my-' or 'my_' passes this point
assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue)));
*/
public final function count ($criteriaType = 'default') {
// Return it
- return count($this->criteria[$criteriaType]);
+ return $this->countGenericArrayGroup('criteria', $criteriaType));
}
/**
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class FilterChain extends BaseFrameworkSystem implements Registerable {
- /**
- * All filters together
- */
- private $filters = array();
-
/**
* Protected constructor
*
* @return void
*/
public final function addFilter (Filterable $filterInstance) {
- array_push($this->filters, $filterInstance);
+ $this->pushValueToGenericArrayElement('filters', 'generic', 'dummy', $filterInstance);
}
/**
* @return $filters The filters array holding all filter instances
*/
protected function getFilters () {
- return $this->filters;
+ return $this->getGenericArray('filters');
}
/**
*/
public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Run all filters
- //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('COUNT=' . count($this->filters));
+ //* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('COUNT=' . $this->countGenericArray('filters'));
foreach ($this->getFilters() as $filterInstance) {
// Try to execute this filter
try {
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseMailer extends BaseFrameworkSystem {
- /**
- * Iterateable list of recipients
- */
- private $recipientList = array();
-
/**
* Template name
*/
$templateName = $this->getTemplateName();
// Is the list initialized?
- if (!isset($this->recipientList[$templateName]['recipients'])) {
- // Then initialize it here
- $this->recipientList[$templateName]['recipients'] = array();
- } // END - if
-
- // Add it as a recipient
- array_pushh($this->recipientList[$templateName]['recipients'], $userInstance);
+ $this->pushValueToGenericArrayElement('recipients', $templateName, 'recipients', $userInstance);
}
/**
* Adds a template variable (just the name) to the recipient list in given section of current template
*
- * @param $section Section can be "config" or "value" currently
+ * @param $section Section can be 'config' or "value" currently
* @param $variableName Template variable name to add
* @return void
*/
$sectionName = $section . '_vars';
// Is the list initialized?
- if (!isset($this->recipientList[$templateName][$sectionName])) {
- // Then initialize it here
- $this->recipientList[$templateName][$sectionName] = array();
- } // END - if
-
- // Add the variable to the list
- $this->recipientList[$templateName][$sectionName][$variableName] = 'OK';
+ $this->setGenericArrayElement('recipients', $templateName, $sectionName, $variableName, 'OK');
}
/**
* @return void
*/
public final function addConfigTemplateVariable ($variableName) {
- $this->addTemplateVariable("config", $variableName);
+ $this->addTemplateVariable('config', $variableName);
}
/**
- * Adds a "value" template variable to the recipient list of current template
+ * Adds a 'value' template variable to the recipient list of current template
*
* @param $variableName Template variable name to add
* @return void
*/
public final function addValueTemplateVariable ($variableName) {
- $this->addTemplateVariable("value", $variableName);
+ $this->addTemplateVariable('value', $variableName);
}
/**
* @return void
*/
public final function addValueInstance ($variableName, FrameworkInterface $valueInstance) {
- $this->recipientList[$this->getTemplateName()]['values'][$variableName] = $valueInstance;
+ $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'values', $variableName, $valueInstance);
}
/**
* @return void
*/
public final function setSubjectLine ($subjectLine) {
- $this->recipientList[$this->getTemplateName()]['subject'] = (string) $subjectLine;
+ ` $this->setGenericArrayElement('recipients', $this->getTemplateName(), 'generic', 'subject', $subjectLine);
}
/**
$templateName = $this->getTemplateName();
// Does the subject line exist?
- if ((!empty($templateName)) && (isset($this->recipientList[$templateName]['subject']))) {
+ if ((!empty($templateName)) && ($this->isGenericArrayElementSet('recipients', $templateName, 'generic', 'subject']))) {
// Then use it
- $subjectLine = $this->recipientList[$templateName]['subject'];
+ $subjectLine = $this->getGenericArrayElement('recipients', $templateName, 'generic', 'subject');
} // END - if
// Return it
* @return $recipientList Array with reciepients
*/
public final function getRecipientList () {
- return $this->recipientList;
+ return $this->getGenericArray('recipients');
}
}
*/
private static $registryInstance = NULL;
- /**
- * Instance registry
- */
- private $instanceRegistry = array();
-
- /**
- * Raw data entries (non-objects)
- */
- private $rawEntries = array();
-
/**
* Protected constructor
*
*/
public function instanceExists ($instanceKey) {
// Does this key exists?
- $exists = (isset($this->instanceRegistry[$instanceKey]));
+ $exists = $this->isGenericArrayKeySet('registry', 'instance', $instanceKey);
// Return the result
return $exists;
* @return void
*/
public function addInstance ($instanceKey, Registerable $objectInstance) {
- $this->instanceRegistry[$instanceKey] = $objectInstance;
+ $this->pushValueToGenericArrayElement('registry', 'instance', $instanceKey, $objectInstance);
}
/**
* @return $instanceRegistry The whole instance registry array
*/
public final function getInstanceRegistry () {
- return $this->instanceRegistry;
+ return $this->getGenericSubArray('registry', 'instance');
}
/**
* @return void
*/
public final function addEntry ($key, $value) {
- // Is the array there?
- if (!isset($this->rawEntries[$key])) {
- // Then intialize it here
- $this->rawEntries[$key] = array();
- } // END - if
-
- // Simply add it
- array_push($this->rawEntries[$key], $value);
+ // Push it
+ $this->pushValueToGenericArrayElement('raw', 'generic', $key, $value);
}
/**
*/
public final function getEntries ($key = NULL) {
// Default is whole array
- $entries = $this->rawEntries;
+ $entries = $this->getGenericArray('raw');
// Is $key set?
- if ((!is_null($key)) && (isset($this->rawEntries[$key]))) {
+ if (!is_null($key)) {
// Then use this entry
- $entries = $this->rawEntries[$key];
+ $entries = $this->getGenericArrayKey('raw', 'generic', $key);
} // END - if
// Return the array
} // END - if
// Get the instance
- $objectInstance = $this->instanceRegistry[$instanceKey];
+ $objectInstance = $this->getGenericArrayKey('registry', 'instance', $instanceKey);
// Return the result
return $objectInstance;
*/
private $templateInstance = NULL;
- /**
- * Fatal resolved messages from filters and so on
- */
- private $fatalMessages = array();
-
/**
* Protected constructor
*
*/
public final function addFatalMessage ($messageId) {
// Adds the resolved message id to the fatal message list
- array_push($this->fatalMessages, $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId));
+ $this->addFatalMessagePlain($this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId));
}
/**
*/
public final function addFatalMessagePlain ($message) {
// Adds the resolved message id to the fatal message list
- array_push($this->fatalMessages, $message);
+ $this->pushValueToGenericArrayElement('fatal_messages', 'generic', 'message', $message);
}
/**
}
// Are there some error messages?
- if (count($this->fatalMessages) == 0) {
+ if ($this->countGenericArrayElements('fatal_messages', 'generic', 'message') == 0) {
// Flush the output to the world
$this->getWebOutputInstance()->output($this->responseBody);
} else {
// Display all error messages
- $this->getApplicationInstance()->handleFatalMessages($this->fatalMessages);
+ $this->getApplicationInstance()->handleFatalMessages($this->getGenericArrayKey('fatal_messages', 'generic', 'message'));
// Send the error messages out to the world
$this->getWebOutputInstance()->output($this->responseBody);
const EXCEPTION_NO_STACKER_FOUND = 0x052;
const EXCEPTION_STACKER_IS_EMPTY = 0x053;
- /**
- * An array holding all stacks
- */
- private $stacks = array();
-
/**
* Protected constructor
*
} // END - if
// Initialize the given stack
- $this->stacks[$stackerName] = array(
- 'max_size' => $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size'),
- 'entries' => array()
- );
+ $this->pushValueToGenericArrayElement('stacks', $stackerName, 'max_size', $this->getConfigInstance()->getConfigEntry('stacker_' . $stackerName . '_max_size'));
}
/**
*/
public final function isStackInitialized ($stackerName) {
// Is is there?
- $isInitialized = ((isset($this->stacks[$stackerName])) && (is_array($this->stacks[$stackerName])));
+ $isInitialized = ($this->isValidGenericArrayGroup('stacks', $stackerName));
// Return result
return $isInitialized;
} // END - if
// Now, count the array of entries
- $count = count($this->stacks[$stackerName]['entries']);
+ $count = $this->countGenericArrayElements('stacks', $stackerName, 'entries');
// Return result
return $count;
}
// Now add the value to the stack
- array_push($this->stacks[$stackerName]['entries'], $value);
+ $this->pushValueToGenericArrayElement('stacks', $stackerName, 'entries', $value);
}
/**
}
// Now get the last value
- $value = $this->stacks[$stackerName]['entries'][$this->getStackCount($stackerName) - 1];
+ $value = $this->getGenericArrayKey('stacks', $stackerName, 'entries', $this->getStackCount($stackerName) - 1);
// Return it
return $value;
throw new EmptyStackerException(array($this, $stackerName), self::EXCEPTION_STACKER_IS_EMPTY);
}
- // Now get the last value
- $value = $this->stacks[$stackerName]['entries'][0];
+ // Now get the first value
+ $value = $this->getGenericArrayKey('stacks', $stackerName, 'entries', 0);
// Return it
return $value;
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
- array_pop($this->stacks[$stackerName]['entries']);
+ $this->popGenericArrayElement('stacks', $stackerName, 'entries');
}
/**
}
// Now, remove the last entry, we don't care about the return value here, see elseif() block above
- array_shift($this->stacks[$stackerName]['entries']);
+ $this->shiftGenericArrayElement('stacks', $stackerName, 'entries');
}
}
* @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
+ * @todo Out-dated since 0.6-BETA
*
* 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
$amount = isset($amount) ? $amount+0 : 0;
if ($amount < $this->config['mineinsatz']) {
- $this->setStatusMessage('low_stakes', sprintf("Dein Einsatz muss mindestens %d Wernis betragen.", $this->config['mineinsatz']));
+ $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
return false;
}
$amount = isset($amount) ? $amount+0 : 0;
if ($amount < $this->config['mineinsatz']) {
- $this->setStatusMessage('low_stakes', sprintf("Dein Einsatz muss mindestens %d Wernis betragen.", $this->config['mineinsatz']));
+ $this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
return false;
}
// Script abbrechen mit Zurueck-Buttom
public function ende () {
global $_CONFIG;
- include "templates/zurueck.html";
- include "templates/fuss.html";
+ include 'templates/zurueck.html';
+ include 'templates/fuss.html';
exit();
}
return $this->statusArray['message'];
} else {
// Fall-back to status
- return sprintf("Fehler-Code <u>%s</u> ist keiner Nachricht zugewiesen.", $this->getErrorCode());
+ return sprintf('Fehler-Code <u>%s</u> ist keiner Nachricht zugewiesen.', $this->getErrorCode());
}
}
if (!is_array($requestData)) {
// Then abort here!
return array(
- 'status' => "failed_general",
- 'message' => "API-Daten in <strong>config</strong> sind ungültig!"
+ 'status' => 'failed_general',
+ 'message' => 'API-Daten in <strong>config</strong> sind ungültig!'
);
}
if ((empty($this->config['wernis_api_id'])) || (empty($this->config['wernis_api_key']))) {
// Abort here...
return array(
- 'status' => "failed_general",
- 'message' => "API-Daten in config.php sind leer!"
+ 'status' => 'failed_general',
+ 'message' => 'API-Daten in config.php sind leer!'
);
}
// Construct the request string
- $requestString = $this->config['api_url'] . $scriptName."?api_id=".$this->config['wernis_api_id']."&api_key=".$this->config['wernis_api_key'];
+ $requestString = $this->config['api_url'] . $scriptName . '?api_id=' . $this->config['wernis_api_id'] . '&api_key='.$this->config['wernis_api_key'];
foreach ($requestData as $key => $value) {
$requestString .= '&' . $key . '=' . $value;
}
if (strpos($response[0], '200') === FALSE) {
// Something bad happend... :(
return array(
- 'status' => "request_error",
- 'message' => sprintf("Servermeldung <u>%s</u> von WDS66-API erhalten.", $response[0])
+ 'status' => 'request_error',
+ 'message' => sprintf('Servermeldung <u>%s</u> von WDS66-API erhalten.', $response[0])
);
}
$return = array();
// We use only the first two entries (which shall be fine)
- if ($data[0] === "error") {
+ if ($data[0] === 'error') {
// The request has failed... :(
switch ($data[1]) {
- case "404": // Invalid API ID
- case "AUTH": // Authorization has failed
+ case '404': // Invalid API ID
+ case 'AUTH': // Authorization has failed
$return = array(
- 'status' => "auth_failed",
- 'message' => "API-Daten scheinen nicht zu stimmen! (Access Denied)"
+ 'status' => 'auth_failed',
+ 'message' => 'API-Daten scheinen nicht zu stimmen! (Access Denied)'
);
break;
- case "LOCKED": // User account is locked!
- case "PASS": // Bad passphrase entered
- case "USER": // Missing account or invalid password
+ case 'LOCKED': // User account is locked!
+ case 'PASS': // Bad passphrase entered
+ case 'USER': // Missing account or invalid password
$return = array(
- 'status' => "user_failed",
- 'message' => "Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben."
+ 'status' => 'user_failed',
+ 'message' => 'Dein eingegebener WDS66-Username stimmt nicht, ist gesperrt oder du hast ein falsches Passwort eingegeben.'
);
break;
- case "OWN": // Transfer to own account
+ case 'OWN': // Transfer to own account
$return = array(
- 'status' => "own_failed",
- 'message' => "Du darfst dein eigenes Spiel leider nicht spielen."
+ 'status' => 'own_failed',
+ 'message' => 'Du darfst dein eigenes Spiel leider nicht spielen.'
);
break;
- case "AMOUNT": // Amount is depleted
+ case 'AMOUNT': // Amount is depleted
$return = array(
- 'status' => "amount_failed",
- 'message' => "Dein Guthaben reicht nicht aus, um das Spiel zu spielen."
+ 'status' => 'amount_failed',
+ 'message' => 'Dein Guthaben reicht nicht aus, um das Spiel zu spielen.'
);
break;
- case "AMOUNT-SEND": // API amount is depleted
+ case 'AMOUNT-SEND': // API amount is depleted
$return = array(
- 'status' => "api_amount_failed",
- 'message' => "Nicht genügend Guthaben auf dem API-Account."
+ 'status' => 'api_amount_failed',
+ 'message' => 'Nicht genügend Guthaben auf dem API-Account.'
);
break;
default: // Unknown error (maybe new?)
$return = array(
- 'status' => "request_failed",
- 'message' => sprintf("Unbekannter Fehler <u>%s</u> von API erhalten.", $data[1])
+ 'status' => 'request_failed',
+ 'message' => sprintf('Unbekannter Fehler <u>%s</u> von API erhalten.', $data[1])
);
break;
}
'sub_request' => 'receive',
't_uid' => $this->w_id,
't_md5' => $this->w_md5,
- 'r_uid' => (int)$this->config['wernis_refid'],
- 'amount' => (int)$amount,
+ 'r_uid' => (int) $this->config['wernis_refid'],
+ 'amount' => (int) $amount,
'purpose' => urlencode(base64_encode($purpose))
);
// Return the result from the lower functions
- $return = $this->sendRequest("book.php", $requestData);
+ $return = $this->sendRequest('book.php', $requestData);
if ($return['status'] == $this->statusOkay) {
// All fine!
'sub_request' => 'send',
't_uid' => $this->w_id,
't_md5' => $this->w_md5,
- 'r_uid' => (int)$this->config['wernis_refid'],
- 'amount' => (int)$amount,
+ 'r_uid' => (int) $this->config['wernis_refid'],
+ 'amount' => (int) $amount,
'purpose' => urlencode(base64_encode($purpose))
);
$url = $extract[0];
// Extract host name
- $host = str_replace("http://", '', $url);
+ $host = str_replace('http://', '', $url);
if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/'));
// Generate relative URL
}
// Generate request header
- $request = "GET /".trim($script)." HTTP/1.0\r\n";
- $request .= "Host: ".$host."\r\n";
+ $request = "GET /" . trim($script) . " HTTP/1.0\r\n";
+ $request .= "Host: " . $host . "\r\n";
$request .= sprintf("User-Agent: WernisApi/1.0 by Quix0r [Spieler: %d]\r\n\r\n", $this->w_id);
// Initialize array