try {
ClassLoader::getInstance()->loadClasses(sprintf("inc/classes/%s/", $className));
} catch (PathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <span class=\"exception_data\">%s</span> for the follwing reason: <span class=\"exception_reason\">%s</span>",
$className
));
} catch (PathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <span class=\"exception_data\">%s</span> for the follwing reason: <span class=\"exception_reason\">%s</span>",
$className
));
} catch (PathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <span class=\"exception_data\">%s</span> for the follwing reason: <span class=\"exception_reason\">%s</span>",
$className
));
} catch (DirPointerNotOpenedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <strong>%s</strong> for the follwing reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Could not load framework classes from path <span class=\"exception_data\">%s</span> for the follwing reason: <span class=\"exception_reason\">%s</span>",
$className
));
}
*/
public function __construct(array $msgArray, $code) {
// Prepare the message
- $message = sprintf("[%s:%d] Cannot resolve action <span id=\"exception_reason\">%s</span>.",
+ $message = sprintf("[%s:%d] Cannot resolve action <span class=\"exception_reason\">%s (%s)</span>.",
$msgArray[0]->__toString(),
$this->getLine(),
- $msgArray[1]
+ $msgArray[1],
+ $msgArray[0]->getClassName()
);
// Call parent contructor with message
*/
public function __construct(Filterable $filterInstance, $code) {
// Construct the message
- $message = sprintf("[%s:%d] Authorization has failed. Error code <span id=\"exception_reason\">%s</span>",
+ $message = sprintf("[%s:%d] Authorization has failed. Error code <span class=\"exception_reason\">%s</span>",
$filterInstance->__toString(),
$this->getLine(),
$this->getHexCode($code)
);
// End here
- exit;
+ exit();
} // END - if
-
// Make sure everything is assigned properly
parent::__construct($message, $code);
+
+ // Log it away if DEBUG_ALL is set
+ if (defined('DEBUG_ALL')) {
+ // Log the error
+ error_log(sprintf("[%s:] %s (%s)",
+ $this->__toString(),
+ $message,
+ $this->getHexCode()
+ ));
+ } // END - if
}
/**
} // END - if
// Prepare argument infos
- $info = "<em id=\"debug_args\">{$info}</em>";
+ $info = "<em id=\"debug_args_".$dbgIndex."\">{$info}</em>";
// File detection
$file = "Unknown file";
} // END - if
// The message
- $dbgMsg .= "\t at <em id=\"debug_id\">".$dbgIndex."</em> <em id=\"debug_file\">".$file."</em> (<em id=\"debug_line\">".$line."</em>) -> ".$dbgInfo['function']."(".$info.")<br />\n";
+ $dbgMsg .= "\t at <em id=\"debug_id_".$dbgIndex."\">".$dbgIndex."</em> <em id=\"debug_file_".$dbgIndex."\">".$file."</em> (<em id=\"debug_line_".$dbgIndex."\">".$line."</em>) -> ".$dbgInfo['function']."(".$info.")<br />\n";
} // END - if
$dbgMsg .= "Debug backtrace end<br />\n";
*/
public function __construct (array $array, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Der Kompressor <span id=\"exception_reason\">%s</span> zu den geladenen Daten aus <span id=\"exception_reason\">%s</span> und der aktuell verwendete Kompressor <span id=\"exception_reason\">%s</span> stimmen nicht überein!",
+ $message = sprintf("[%s:%d] Der Kompressor <span class=\"exception_reason\">%s</span> zu den geladenen Daten aus <span class=\"exception_reason\">%s</span> und der aktuell verwendete Kompressor <span class=\"exception_reason\">%s</span> stimmen nicht überein!",
$array[0]->__toString(),
$this->getLine(),
strtoupper($array[1]),
*/
public function __construct(array $msgArray, $code) {
// Prepare the message
- $message = sprintf("[%s:%d] Cannot resolve controller <span id=\"exception_reason\">%s (class name: %s)</span>.",
+ $message = sprintf("[%s:%d] Cannot resolve controller <span class=\"exception_reason\">%s (class name: %s)</span>.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1],
*/
public function __construct (array $msgArray, $code) {
// Construct the message
- $message = sprintf("[%s:%d] SQL error detected. Message from database: <span id=\"exception_reason\">%s</span>, code: <span id=\"exception_reason\">%s</span>.",
+ $message = sprintf("[%s:%d] SQL error detected. Message from database: <span class=\"exception_reason\">%s</span>, code: <span class=\"exception_reason\">%s</span>.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1],
*/
public function __construct ($path, $code) {
// Add a message around the missing class
- $message = sprintf("Der angegebene Speicherpfad <span id=\"exception_reason\">%s</span> ist ungütig (kein Pfad).", $path);
+ $message = sprintf("Der angegebene Speicherpfad <span class=\"exception_reason\">%s</span> ist ungütig (kein Pfad).", $path);
// Call parent constructor
parent::__construct($message, $code);
*/
public function __construct ($path, $code) {
// Add a message around the missing class
- $message = sprintf("Der Pfad <span id=\"exception_reason\">%s</span> ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path);
+ $message = sprintf("Der Pfad <span class=\"exception_reason\">%s</span> ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path);
// Call parent constructor
parent::__construct($message, $code);
*/
public function __construct ($path, $code) {
// Add a message around the missing class
- $message = sprintf("Der angegebene Speicherpfad <span id=\"exception_reason\">%s</span> ist schreibgeschützt. Bitte Zugriffsrechte (CHMOD) entsprechend setzen.", $path);
+ $message = sprintf("Der angegebene Speicherpfad <span class=\"exception_reason\">%s</span> ist schreibgeschützt. Bitte Zugriffsrechte (CHMOD) entsprechend setzen.", $path);
// Call parent constructor
parent::__construct($message, $code);
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
- *
+ * @todo This class is no longer used
+ * @deprecated
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Username <span id=\"exception_reason\">%s</span> was not found. Requesting class: <span id=\"exception_reason\">%s</span>",
+ $message = sprintf("[%s:%d] Username <span class=\"exception_reason\">%s</span> was not found. Requesting class: <span class=\"exception_reason\">%s</span>",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]->getUserName(),
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Could not add form element <span id=\"exception_reason\">%s</span> because form is closed.",
+ $message = sprintf("[%s:%d] Could not add form element <span class=\"exception_reason\">%s</span> because form is closed.",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Could not add sub group <span id=\"exception_reason\">%s</span> because no form group has been opened before.",
+ $message = sprintf("[%s:%d] Could not add sub group <span class=\"exception_reason\">%s</span> because no form group has been opened before.",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Sub group not opened before. Raw text follows: <span id=\"exception_reason\">%s</span>",
+ $message = sprintf("[%s:%d] Sub group not opened before. Raw text follows: <span class=\"exception_reason\">%s</span>",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Group not opened before. Raw text follows: <span id=\"exception_reason\">%s</span>",
+ $message = sprintf("[%s:%d] Group not opened before. Raw text follows: <span class=\"exception_reason\">%s</span>",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Registry key <span id=\"exception_reason\">%s</span> does not include a class with implemented interface <u>Manageable(User|Guest)</u>.",
+ $message = sprintf("[%s:%d] Registry key <span class=\"exception_reason\">%s</span> does not include a class with implemented interface <u>Manageable(User|Guest)</u>.",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct ($path, $code) {
// Add a message around the missing class
- $message = sprintf("Für den Pfad <span id=\"exception_reason\">%s</span> konnte kein Pointer initialisiert werden.", $path);
+ $message = sprintf("Für den Pfad <span class=\"exception_reason\">%s</span> konnte kein Pointer initialisiert werden.", $path);
// Call parent constructor
parent::__construct($message, $code);
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
- *
+ * @todo Rename this class to FileIoException
+ * @deprecated
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
*/
public function __construct ($fqfn, $code) {
// Add a message around the missing class
- $message = sprintf("The requested file <span id=\"exception_reason\">%s</span> was not found.",
+ $message = sprintf("The requested file <span class=\"exception_reason\">%s</span> was not found.",
$fqfn
);
*/
public function __construct ($fqfn, $code) {
// Add a message around the missing class
- $message = sprintf("Not able to initialize a pointer for the file <span id=\"exception_reason\">%s</span>. Maybe the file is missing.", $fqfn);
+ $message = sprintf("Not able to initialize a pointer for the file <span class=\"exception_reason\">%s</span>. Maybe the file is missing.", $fqfn);
// Call parent constructor
parent::__construct($message, $code);
*/
public function __construct ($fileName, $code) {
// Add a message around the missing class
- $message = sprintf("File <span id=\"exception_reason\">%s</span> is read-protected. Please set read access rights (CHMOD).", $fileName);
+ $message = sprintf("File <span class=\"exception_reason\">%s</span> is read-protected. Please set read access rights (CHMOD).", $fileName);
// Call parent constructor
parent::__construct($message, $code);
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Eine unerwartete Datenlänge von <span id=\"exception_reason\">%s</span> Byte ist aufgetreten. <span id=\"exception_reason\">%s</span> wurden erwartet!",
+ $message = sprintf("[%s:%d] Eine unerwartete Datenlänge von <span class=\"exception_reason\">%s</span> Byte ist aufgetreten. <span class=\"exception_reason\">%s</span> wurden erwartet!",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1],
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Die MD5-Prüfsummen <span id=\"exception_reason\">%s</span> und <span id=\"exception_reason\">%s</span> stimmen nicht überein!",
+ $message = sprintf("[%s:%d] Die MD5-Prüfsummen <span class=\"exception_reason\">%s</span> und <span class=\"exception_reason\">%s</span> stimmen nicht überein!",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1],
*/
public function __construct ($path, $code) {
// Add a message around the missing class
- $message = sprintf("Der angegebene Pfad <span id=\"exception_reason\">%s</span> ist ungütig (kein Pfad).", $path);
+ $message = sprintf("Der angegebene Pfad <span class=\"exception_reason\">%s</span> ist ungütig (kein Pfad).", $path);
// Call parent constructor
parent::__construct($message, $code);
*/
public function __construct ($path, $code) {
// Add a message around the missing class
- $message = sprintf("Der Pfad <span id=\"exception_reason\">%s</span> ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path);
+ $message = sprintf("Der Pfad <span class=\"exception_reason\">%s</span> ist lese-geschützt. Bitte Zugriffsrechte (CHMOD) zum Lesen setzen.", $path);
// Call parent constructor
parent::__construct($message, $code);
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] <span id=\"exception_reason\">%s</span> is not a string with path!",
+ $message = sprintf("[%s:%d] <span class=\"exception_reason\">%s</span> is not a string with path!",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Der Sprach-Basispfad <span id=\"exception_reason\">%s</span> existiert nicht oder ist eine Datei!",
+ $message = sprintf("[%s:%d] Der Sprach-Basispfad <span class=\"exception_reason\">%s</span> existiert nicht oder ist eine Datei!",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Base language path <span id=\"exception_reason\">%s</span> is read-protected. Please change access rights (CHMOD).",
+ $message = sprintf("[%s:%d] Base language path <span class=\"exception_reason\">%s</span> is read-protected. Please change access rights (CHMOD).",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("The class <span id=\"exception_reason\">%s</span> does not match class <span id=\"exception_reason\">%s</span>.",
+ $message = sprintf("The class <span class=\"exception_reason\">%s</span> does not match class <span class=\"exception_reason\">%s</span>.",
$classArray[0],
$classArray[1]
);
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
- *
+ * @todo Rename this class to NoClassException
+ * @deprecated
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Internal class <span id=\"exception_reason\">%s</span> not found.",
+ $message = sprintf("[%s:%d] Internal class <span class=\"exception_reason\">%s</span> not found.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
- *
+ * @todo Rename this class to NoFoundEntryException
+ * @deprecated
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Configuration entry <span id=\"exception_reason\">%s</span> not found.",
+ $message = sprintf("[%s:%d] Configuration entry <span class=\"exception_reason\">%s</span> not found.",
$classArray[0],
$this->getLine(),
$classArray[1]
);
} else {
// No class given
- $message = sprintf("Please provide a class for <span id=\"exception_reason\">%s</span>", __CLASS__);
+ $message = sprintf("Please provide a class for <span class=\"exception_reason\">%s</span>", __CLASS__);
}
// Call parent constructor
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Variable <span id=\"exception_reason\">%s</span> is not set.",
+ $message = sprintf("[%s:%d] Variable <span class=\"exception_reason\">%s</span> is not set.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
- *
+ * @todo Is this exception still needed???
+ * @deprecated
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Exception <span id=\"exception_reason\">%s</span> not found.",
+ $message = sprintf("[%s:%d] Exception <span class=\"exception_reason\">%s</span> not found.",
$classArray[0],
$this->getLine(),
$classArray[1]
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
- *
+ * @todo This class is no longer needed!
+ * @deprecated
+ *
* 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
* the Free Software Foundation, either version 3 of the License, or
* @param $code Code number for the exception
* @return void
*/
- public function __construct ($dataArray, $code) {
- // Cast the array
- $dataArray = (array) $dataArray;
-
+ public function __construct (array $dataArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Getter-Methode für Attribut <span id=\"exception_reason\">%s</span> nicht gefunden.",
+ $message = sprintf("[%s:%d] Getter-Methode für Attribut <span class=\"exception_reason\">%s</span> nicht gefunden.",
$dataArray[0]->__toString(),
$this->getLine(),
$dataArray[1]
*/
public function __construct (array $array, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] <span id=\"exception_reason\">%s</span> hat <u>%d</u> Elemente, soll aber <u>%d</u> enthalten!",
+ $message = sprintf("[%s:%d] <span class=\"exception_reason\">%s</span> hat <u>%d</u> Elemente, soll aber <u>%d</u> enthalten!",
$array[0]->__toString(),
$this->getLine(),
$array[1],
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Invalid command <span id=\"exception_reason\">%s (class %s)</span> detected.",
+ $message = sprintf("[%s:%d] Invalid command <span class=\"exception_reason\">%s (class %s)</span> detected.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1],
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Invalid command <span id=\"exception_reason\">%s</span> detected.",
+ $message = sprintf("[%s:%d] Invalid command <span class=\"exception_reason\">%s</span> detected.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Object does not implement expected interface <span id=\"exception_reason\">.",
+ $message = sprintf("[%s:%d] Object does not implement expected interface <span class=\"exception_reason\">%s</span>.",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
}
// Add a message around the missing class
- $message = sprintf("[%s:%d] Array <u>%s()</u> Does not have these elements: <span id=\"exception_reason\">%s</span>",
+ $message = sprintf("[%s:%d] Array <u>%s()</u> Does not have these elements: <span class=\"exception_reason\">%s</span>",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1],
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
+ * @todo This class is no longer needed
+ * @deprecated
*
* 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
*/
public function __construct (array $array, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] <span id=\"exception_reason\">%s</span> ist kein erstelltes Objekt.",
+ $message = sprintf("[%s:%d] <span class=\"exception_reason\">%s</span> ist kein erstelltes Objekt.",
$array[0]->__toString(),
$this->getLine(),
$array[1]
*/
public function __construct ($string, $code) {
// Add a message around the missing class
- $message = sprintf("<span id=\"exception_reason\">%s</span> ist kein Array!",
+ $message = sprintf("<span class=\"exception_reason\">%s</span> ist kein Array!",
$string
);
*/
public function __construct ($string, $code) {
// Add a message around the missing class
- $message = sprintf("<span id=\"exception_reason\">%s</span> ist kein Objekt!",
+ $message = sprintf("<span class=\"exception_reason\">%s</span> ist kein Objekt!",
$string
);
*/
public function __construct (array $array, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Bei der Initialisierung der Applikation <span id=\"exception_reason\">%s</span> wurde keine Variable <span id=\"exception_reason\">%s</span> erzeugt.",
+ $message = sprintf("[%s:%d] Bei der Initialisierung der Applikation <span class=\"exception_reason\">%s</span> wurde keine Variable <span class=\"exception_reason\">%s</span> erzeugt.",
$array[0]->__toString(),
$this->getLine(),
$array[1],
*/
public function __construct(array $msgArray, $code) {
// Construct the message
- $message = sprintf("[%s:%d] Database instance <span id=\"exception_reason\">%s</span> contains invalid entries.",
+ $message = sprintf("[%s:%d] Database instance <span class=\"exception_reason\">%s</span> contains invalid entries.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]->__toString()
<?php
/**
- * An exception thrown if the result was not updated
+ * An exception thrown if result was not updated.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Der Template-Basispfad <span id=\"exception_reason\">%s</span> existiert nicht oder ist eine Datei!",
+ $message = sprintf("[%s:%d] Der Template-Basispfad <span class=\"exception_reason\">%s</span> existiert nicht oder ist eine Datei!",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Der Template-Basispfad <span id=\"exception_reason\">%s</span> ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.",
+ $message = sprintf("[%s:%d] Der Template-Basispfad <span class=\"exception_reason\">%s</span> ist lesegeschützt! Bitte Zugriffsrechte (CHMOD) ändern.",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $classArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] <span id=\"exception_reason\">%s</span> is not a string with a base path!",
+ $message = sprintf("[%s:%d] <span class=\"exception_reason\">%s</span> is not a string with a base path!",
$classArray[0]->__toString(),
$this->getLine(),
$classArray[1]
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:%d] Der Template-Typ <span id=\"exception_reason\">%s</span> entspricht nicht dem erwartetem Template-Typ <span id=\"exception_reason\">%s</span>.",
+ $message = sprintf("[%s:%d] Der Template-Typ <span class=\"exception_reason\">%s</span> entspricht nicht dem erwartetem Template-Typ <span class=\"exception_reason\">%s</span>.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1],
* @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
+ * @todo Rename this class to NoViewHelperException
+ * @deprecated
*
* 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
*/
public function __construct (array $msgArray, $code) {
// Add a message around the missing class
- $message = sprintf("[%s:] View-Helper <span id=\"exception_reason\">%s</span> ist ungültig.",
+ $message = sprintf("[%s:] View-Helper <span class=\"exception_reason\">%s</span> ist ungültig.",
$msgArray[0]->__toString(),
$msgArray[1]
);
*/
public function __construct(array $msgArray, $code = 0) {
// Create the message
- $message = sprintf("[%s:%d] User email <span id=\"exception_reason\">%s</span> was not found.",
+ $message = sprintf("[%s:%d] User email <span class=\"exception_reason\">%s</span> was not found.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
*/
public function __construct(array $msgArray, $code = 0) {
// Create the message
- $message = sprintf("[%s:%d] Supplied password for user <span id=\"exception_reason\">%s</span> did not match with stored password.",
+ $message = sprintf("[%s:%d] Supplied password for user <span class=\"exception_reason\">%s</span> did not match with stored password.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]->getUserName()
*/
public function __construct(array $msgArray, $code = 0) {
// Create the message
- $message = sprintf("[%s:%d] Username <span id=\"exception_reason\">%s</span> was not found.",
+ $message = sprintf("[%s:%d] Username <span class=\"exception_reason\">%s</span> was not found.",
$msgArray[0]->__toString(),
$this->getLine(),
$msgArray[1]
/**
* Hashes a string with salt and returns the hash. If an old previous hash
* is supplied the method will use the first X chars of that hash for hashing
- * the password. This is useful if you want to check if the password is
- * identical for authorization purposes.
+ * the password. This is useful if you want to check if password is identical
+ * for authorization purposes.
*
* @param $str Unhashed string
* @param $oldHash A hash from previous hashed string
*/
interface UserRegister extends FrameworkInterface {
/**
- * Encrypt the given request key or throws an exception if the key was not
- * found in the request
+ * Encrypt given request key or throws an exception if key was not found in
+ * request.
*
* @param $requestKey Key in request class
* @return void
/**
* Checks wether an instance key was found
*
- * @param $instanceKey The key holding an instance in the registry
- * @return $exists Wether the key exists in the registry
+ * @param $instanceKey The key holding an instance in registry
+ * @return $exists Wether the key exists in registry
*/
function instanceExists ($instanceKey);
function isRequestElementSet ($element);
/**
- * Getter for request element or 'null' if the element was not found
+ * Getter for request element or 'null' if element was not found
*
* @param $element Name of the request element we want to check
* @return $value Value of the found request element or 'null' if the
function getParameterNames ();
/**
- * Getter for a header element or 'null' if the header was not found
+ * Getter for a header element or 'null' if header was not found
*
* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
*
* @param $actionName The default action we shall execute
* @return $isValid Wether the given action is valid
- * @throws EmptyVariableException Thrown if the given action is not set
+ * @throws EmptyVariableException Thrown if given action is not set
*/
function isActionValid ($actionName);
}
*
* @param $commandName The default command we shall execute
* @return $isValid Wether the given command is valid
- * @throws EmptyVariableException Thrown if the given command is not set
+ * @throws EmptyVariableException Thrown if given command is not set
*/
function isCommandValid ($commandName);
}
* @return $result Found result entry
*/
function searchEntry (LocalSearchCriteria $criteriaInstance);
+
+ /**
+ * Solver for result index value with call-back method
+ *
+ * @param $databaseColumn Database column where the index might be found
+ * @para $callBack Call-back object for setting the index
+ * @return void
+ */
+ function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack);
}
// [EOF]
function ifEmailAddressExists ();
/**
- * Checks if the supplied password hash in request matches with the stored
- * in database.
+ * Checks if supplied password hash in request matches with stored in
+ * database.
*
* @param $requestInstance A requestable class instance
* @return $matches Wether the supplied password hash matches
<?php
/**
- * A general action class
+ * A general action class. You shall extend this class if you are going to write
+ * your own action classes even when this class has no real content in it. We
+ * just handle the removal of some attributed here which you really don't need.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
if ($loginInstance->ifLoginWasSuccessfull()) {
// Try to redirect here
try {
+ // Redirect...
$responseInstance->redirectToConfiguredUrl('app_login_url');
+
+ // Stop here
+ exit();
} catch (FrameworkException $e) {
// Something went wrong here!
$responseInstance->addFatalMessage($e->getMessage());
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
// Add user status filter here
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter', array($controllerInstance)));
}
}
* Setter for cache offset
*
* @param $offset The offset we shall set
- * @param $data Data to store in the cache
+ * @param $data Data to store in cache
* @return void
*/
public final function offsetSet ($offset, $data) {
* Getter for cache offset or "null" if not found
*
* @param $offset The offset we shall set
- * @return $data Data to store in the cache
+ * @return $data Data to store in cache
*/
public final function offsetGet ($offset) {
// Default is offset not found
*/
private $userInstance = null;
+ /**
+ * A controller instance
+ */
+ private $controllerInstance = null;
+
/**
* The real class name
*/
// Set real class
$this->setRealClass($className);
- // Initialize the class if the registry is there
+ // Initialize the class if class Registry is there
if ((class_exists('Registry')) && (Registry::isInitialized() === false)) {
+ // Initialize the registry automatically
$this->initInstance();
} // END - if
}
$this->setRealClass('DestructedObject');
} elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
// Already destructed object
- $this->debugOutput(sprintf("[%s:] The object <strong>%s</strong> is already destroyed.",
+ $this->debugOutput(sprintf("[%s:] The object <span class=\"object_name\">%s</span> is already destroyed.",
__CLASS__, $this->__toString()
));
}
private final function initInstance () {
// Is this a system class?
if (!in_array($this->__toString(), $this->systemClasses)) {
+ // Set configuration instance
+ $this->setConfigInstance(FrameworkConfiguration::getInstance());
+
// Add application helper to our class
$this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class');
Registry::isInitialized('OK');
} elseif ($this->__toString() == 'DebugMiddleware') {
// Set configuration instance
- $this->setConfigInstance(FrameworkConfiguration::createFrameworkConfiguration());
+ $this->setConfigInstance(FrameworkConfiguration::getInstance());
}
}
* Stub method (only real cabins shall override it)
*
* @return boolean false = is no cabin, true = is a cabin
+ * @deprecated
*/
public function isCabin () {
return false;
*
* @return boolean false = is not tradeable by the Merchant class,
* true = is a tradeable object
+ * @deprecated
*/
public function isTradeable () {
return false;
/**
* Debugs this instance by putting out it's full content
*
+ * @param $message Optional message to show in debug output
* @return void
*/
- public final function debugInstance () {
+ public final function debugInstance ($message = "") {
// Restore the error handler to avoid trouble with missing array elements or undeclared variables
restore_error_handler();
+ // Init content
+ $content = "";
+
+ // Is a message set?
+ if (!empty($message)) {
+ // Construct message
+ $content = sprintf("<div class=\"debug_message\">Message: %s</div>\n", $message);
+ } // END - if
+
// Generate the output
- $content = sprintf("<pre>%s</pre>",
+ $content .= sprintf("<pre>%s</pre>",
trim(
htmlentities(
print_r($this, true)
);
// Output it
- ApplicationEntryPoint::app_die(sprintf("<strong>%s debug output:</strong><div id=\"debug_content\">%s</div>\nLoaded includes: <div id=\"debug_include_list\">%s</div>",
+ ApplicationEntryPoint::app_die(sprintf("<div class=\"debug_header\">%s debug output:</div><div class=\"debug_content\">%s</div>\nLoaded includes: <div class=\"debug_include_list\">%s</div>",
$this->__toString(),
$content,
ClassLoader::getInstance()->getPrintableIncludeList()
*/
public function debugBackTrace () {
// Sorry, there is no other way getting this nice backtrace
- print "<pre>\n";
+ print("<pre>\n");
debug_print_backtrace();
- print "</pre>";
- exit;
+ print("</pre>");
+ exit();
}
/**
if (is_object($debugInstance)) {
// Use debug output handler
$debugInstance->output($message);
- if (!$doPrint) die(); // Die here if not printed
+ if ($doPrint === false) die(); // Die here if not printed
} else {
// Put directly out
if ($doPrint) {
$this->getResultInstance()->rewind();
// Do we have an entry?
- if (!$this->getResultInstance()->valid()) {
+ if ($this->getResultInstance()->valid() === false) {
throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
} // END - if
public final function getUserInstance () {
return $this->userInstance;
}
+
+ /**
+ * Setter for controller instance (this surely breaks a bit the MVC patterm)
+ *
+ * @param $controllerInstance An instance of the controller
+ * @return void
+ */
+ public final function setControllerInstance (Controller $controllerInstance) {
+ $this->controllerInstance = $controllerInstance;
+ }
+
+ /**
+ * Getter for controller instance (this surely breaks a bit the MVC patterm)
+ *
+ * @return $controllerInstance An instance of the controller
+ */
+ public final function getControllerInstance () {
+ return $this->controllerInstance;
+ }
}
// [EOF]
<?php
/**
* Class for saving arrays as an object. We need this little extension for
- * some common methods used in the whole application. Please see below if you
+ * some common methods used in whole application. Please see below if you
* need more details.
*
* @author Roland Haeder <webmaster@ship-simu.org>
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
/**
- * Adds extra filters to the given controller instance
+ * Adds extra filters to the given controller instance. An corresponding action class must now exist!
*
* @param $controllerInstance A controller instance
* @param $requestInstance An instance of a class with an Requestable interface
// Default is no action
$actionInstance = null;
+ // Get registry
+ $registryInstance = Registry::getRegistry();
+
+ // Get our application instance from the registry
+ $appInstance = $registryInstance->getInstance('application');
+
// Default action is the one from configuration
- $this->actionName = sprintf("login_%s", $this->getConfigInstance()->readConfig('login_default_action'));
+ $this->actionName = sprintf("%s_login_%s",
+ str_replace("-", "_", $appInstance->getAppShortName()),
+ $this->getConfigInstance()->readConfig('login_default_action')
+ );
// Get "action" from request
$actReq = $requestInstance->getRequestElement('action');
// Do we have a "action" parameter set?
if ((is_string($actReq)) && (!empty($actReq))) {
// Then use it with prefix
- $this->actionName = sprintf("login_%s", $actReq);
+ $this->actionName = sprintf("%s_login_%s",
+ str_replace("-", "_", $appInstance->getAppShortName()),
+ $actReq
+ );
} // END - if
// Get application instance
$applicationInstance = $this->getResolverInstance()->getApplicationInstance();
- // Try to get an action resolver for the given action
- try {
- // Get a resolver
- $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
+ // Get a resolver
+ $actionResolver = WebActionResolver::createWebActionResolver($this->actionName, $applicationInstance);
- // Resolve the action
- $actionInstance = $actionResolver->resolveAction();
+ // Resolve the action
+ $actionInstance = $actionResolver->resolveAction();
- // Add more action-specific filters
- $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
+ // Add more action-specific filters
+ $actionInstance->addExtraFilters($controllerInstance, $requestInstance);
- // Remember this action in registry
- Registry::getRegistry()->addInstance('action', $actionInstance);
- } catch (InvalidActionException $e) {
- // Silently ignored because no special action was found
- }
+ // Remember this action in registry
+ Registry::getRegistry()->addInstance('action', $actionInstance);
}
}
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
// Redirect to "logout done" page
$responseInstance->redirectToConfiguredUrl('logout_done_url');
+
+ // Exit here
+ exit();
}
/**
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
// these two calls to cache compiled templates.
$templateInstance->compileVariables();
- // Get the content back from the template engine and put it in the response class
+ // Get the content back from the template engine and put it in response class
$templateInstance->transferToResponse($responseInstance);
}
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
// Filter for checking if account is unconfirmed
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter', array($controllerInstance)));
}
}
// Read the file
$hostname = trim($io->readFromFile());
- $helper->debugOutput(sprintf("[%s:] Our host name is: <strong>%s</strong>",
+ $helper->debugOutput(sprintf("[%s:] Our host name is: <span class=\"data\">%s</span>",
$helper->__toString(),
$hostname
));
$ip = $ipResolved;
// Debug message
- $helper->debugOutput(sprintf("[%s:] Resolved IP address is: <strong>%s</strong>\n",
+ $helper->debugOutput(sprintf("[%s:] Resolved IP address is: <span class=\"data\">%s</span>\n",
$helper->__toString(),
$ip
));
$controllerInstance->setResolverInstance($resolverInstance);
// Add filter for checking the "encrypt" string
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_encrypt_validator_filter', array($controllerInstance)));
// Return the prepared instance
return $controllerInstance;
*/
class BaseController extends BaseFrameworkSystem implements Registerable {
/**
- * Pre filter chain instance
+ * Generic filter chains
*/
- private $preFilterChain = null;
-
- /**
- * Post filter chain instance
- */
- private $postFilterChain = null;
+ private $filterChains = array();
/**
* Protected constructor
$this->removeSystemArray();
// Initialize both filter chains
- $this->preFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
- $this->postFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
+ $this->initFilterChain('pre');
+ $this->initFilterChain('post');
// Add this controller to the registry
Registry::getRegistry()->addInstance('controller', $this);
}
+ /**
+ * Private method to initialize a given filter chain
+ *
+ * @param $filterChain Name of the filter chain
+ * @return void
+ */
+ private function initFilterChain ($filterChain) {
+ $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
+ }
+
/**
* Adds a filter to the pre filter chain
*
*/
public function addPreFilter (Filterable $filterInstance) {
// Add the pre filter
- $this->preFilterChain->addFilter($filterInstance);
+ $this->filterChains['pre']->addFilter($filterInstance);
}
/**
*/
public function addPostFilter (Filterable $filterInstance) {
// Add the post filter
- $this->postFilterChain->addFilter($filterInstance);
+ $this->filterChains['post']->addFilter($filterInstance);
}
/**
*/
protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Execute all pre filters
- $this->preFilterChain->processFilters($requestInstance, $responseInstance);
+ $this->filterChains['pre']->processFilters($requestInstance, $responseInstance);
}
/**
*/
protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
// Execute all post filters
- $this->postFilterChain->processFilters($requestInstance, $responseInstance);
+ $this->filterChains['post']->processFilters($requestInstance, $responseInstance);
}
}
// Set resolver instance
$controllerInstance->setResolverInstance($resolverInstance);
- // We need the controller instance in the resolver class so set it here
+ // We need the controller instance in resolver class so set it here
$resolverInstance->setControllerInstance($controllerInstance);
// Return the prepared instance
} catch (UserAuthorizationException $e) {
// Redirect to main page
$responseInstance->redirectToConfiguredUrl('login_failed_url');
+
+ // Exit here
+ exit();
}
// Is the request still valid? Post filters shall only be executed of
*
* @param $resolverInstance An instance of a command resolver class
* @return $controllerInstance A prepared instance of this class
+ * @todo Add some morer filters to this controller
*/
public final static function createWebLoginAreaController (CommandResolver $resolverInstance) {
// Create the instance
$controllerInstance->setResolverInstance($resolverInstance);
// User auth filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter', array($controllerInstance)));
// User update filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_update_filter', array($controllerInstance)));
// News fetcher filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter', array($controllerInstance)));
// News proccess/display-preparation
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class'));
-
- /* @todo: Add some filters to this controller */
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter', array($controllerInstance)));
// Return the prepared instance
return $controllerInstance;
} catch (UserAuthorizationException $e) {
// Redirect to main page
$responseInstance->redirectToConfiguredUrl('login_failed_url');
+
+ // Exit here
+ exit();
}
// This request was valid! :-D
$controllerInstance->setResolverInstance($resolverInstance);
// Add filters for handling confirmation code and username
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_class'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_class'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_class'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('username_verifier_filter', array($controllerInstance)));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_unconfirmed_filter', array($controllerInstance)));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('confirm_code_verifier_filter', array($controllerInstance)));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_confirmed_filter', array($controllerInstance)));
// Return the prepared instance
return $controllerInstance;
$controllerInstance->setResolverInstance($resolverInstance);
// Add news filters to this controller
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_class'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter', array($controllerInstance)));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter', array($controllerInstance)));
// Return the prepared instance
return $controllerInstance;
$controllerInstance->setResolverInstance($resolverInstance);
// Add user auth filter (we don't need an update of the user here because it will be redirected)
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter', array($controllerInstance)));
// User status filter
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_class'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter', array($controllerInstance)));
// Return the prepared instance
return $controllerInstance;
* @param $criteriaValue Criteria value
* @return void
*/
- public function addCriteria ($criteriaKey, $criteriaValue) {
- $this->searchCriteria[$criteriaKey] = $criteriaValue;
+ public final function addCriteria ($criteriaKey, $criteriaValue) {
+ $this->searchCriteria[(string)$criteriaKey] = (string)$criteriaValue;
}
/**
* @param $configEntry Configuration entry
* @return void
*/
- public function addConfiguredCriteria ($criteriaKey, $configEntry) {
+ public final function addConfiguredCriteria ($criteriaKey, $configEntry) {
// Add the configuration entry as a criteria
$value = $this->getConfigInstance()->readConfig($configEntry);
$this->addCriteria($criteriaKey, $value);
*
* @param $limit Search limit
* @return void
+ * @todo Find a nice casting here. (int) allows until and including 32766.
*/
public final function setLimit ($limit) {
$this->limit = $limit;
*
* @param $skip Search skip
* @return void
+ * @todo Find a nice casting here. (int) allows until and including 32766.
*/
public final function setSkip ($skip) {
$this->skip = $skip;
} // END - foreach
} // END - foreach
- // Now check if the criteria matches
+ // Now check if expected criteria counts match
$matches = ($counted == count($this->searchCriteria));
// Return the result
/**
* Hashes a string with salt and returns the hash. If an old previous hash
* is supplied the method will use the first X chars of that hash for hashing
- * the password. This is useful if you want to check if the password is
- * identical for authorization purposes.
+ * the password. This is useful if you want to check if password is identical
+ * for authorization purposes.
*
* @param $str Unhashed string
* @param $oldHash A hash from previous hashed string
// Get the real string out
$strArray = explode("|", $garbageString);
+
+ // Does the element count match?
+ assert(count($strArray) == 3);
+
+ // Decode the string
$str = base64_decode($strArray[1]);
// Trim trailing nulls away
*/
private $tableInfo = array();
+ /**
+ * Element for index
+ */
+ private $indexKey = "__idx";
+
/**
* The protected constructor. Do never instance from outside! You need to
* set a local file path. The class will then validate it.
/**
* Setter for the last read file
*
- * @param $fqfn The FQFN of the last read file
+ * @param $fqfn The FQFN of the last read file
* @return void
*/
private final function setLastFile ($fqfn) {
- // Cast string
- $fqfn = (string) $fqfn;
- $this->lastFile = $fqfn;
+ // Cast string and set it
+ $this->lastFile = (string) $fqfn;
}
/**
* @param $contents An array with header and data elements
* @return void
*/
- private final function setLastFileContents ($contents) {
- // Cast array
- $contents = (array) $contents;
+ private final function setLastFileContents (array $contents) {
+ // Set array
$this->lastContents = $contents;
}
return $this->fileExtension;
}
+ /**
+ * Getter for index key
+ *
+ * @return $indexKey Index key
+ */
+ public final function getIndexKey () {
+ return $this->indexKey;
+ }
+
/**
* Reads a local data file and returns it's contents in an array
*
}
/**
- * Getter for table information file contents or an empty if the info file was not created
+ * Getter for table information file contents or an empty if info file was not created
*
* @param $dataSetInstance An instance of a database set class
* @return $infoArray An array with all table informations
// Initialize limit/skip
$limitFound = 0;
$skipFound = 0;
+ $idx = 1;
// Read the directory with some exceptions
while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
// Skip this file!
continue;
- }
+ } // END - if
// Read the file
$dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
} // END - if
} // END - if
+ // Set id number
+ $dataArray[$this->getIndexKey()] = $idx;
+
// Entry found!
$resultData['rows'][] = $dataArray;
+
+ // Count found entries up
$limitFound++;
break;
} // END - if
// Throw an exception here
throw new SqlException(array($this, sprintf("File '%s' contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY);
}
+
+ // Count entry up
+ $idx++;
} // END - while
// Close directory and throw the instance away
const EXCEPTION_CLIENT_USERNAME_NOT_FOUND = 0x180;
// Constants for database columns
+ const DB_COLUMN_USERID = "userid";
const DB_COLUMN_USERNAME = "username";
const DB_COLUMN_EMAIL = "email";
const DB_COLUMN_CONFIRM_HASH = "confirm_hash";
* Creates an instance of this database wrapper by a provided user class
*
* @return $wrapperInstance An instance of the created wrapper class
- * @throws WrapperUserNameNotFoundException If the supplied username
- * does not exist
*/
public final static function createUserDatabaseWrapper () {
// Get a new instance
return $wrapperInstance;
}
+ /**
+ * Getter for index key
+ *
+ * @return $indexKey Index key
+ */
+ public final function getIndexKey () {
+ return $this->getDatabaseInstance()->getIndexKey();
+ }
+
/**
* Handles inserting the registration data from a registration instance into the database
*
* @return void
*/
public final function outputStream ($output) {
- print(html_entity_decode(strip_tags($output)));
+ print(html_entity_decode(strip_tags(stripslashes($output))));
}
/**
public final function outputStream ($output) {
// Strip out <br />
$output = str_replace("<br />", "", $output);
- print($output."<br />\n");
+ print(stripslashes($output)."<br />\n");
}
/**
throw new ClassNotFoundException(array($factoryInstance, $className), self::EXCEPTION_CLASS_NOT_FOUND);
}
- // Then Prepare the call-back function
- $callback = sprintf("%s::create%s",
- $className,
+ // Create method name
+ $methodName = sprintf("create%s",
$className
);
// Run the user function
- $objectInstance = call_user_func_array($callback, $args);
+ $objectInstance = call_user_func_array(array($className, $methodName), $args);
// Count generated objects up
self::$total++;
* @return $factoryInstance An instance of a WebNewsFactory class
*/
public final static function createFactoryByRequest (Requestable $requestInstance) {
+ // Set default news reader class
+ $configEntry = "news_reader_class";
+
+ // Get "page"
+ $page = $requestInstance->getRequestElement('page');
+
+ // Is "page" used?
+ if (!empty($page)) {
+ // Then add it
+ $configEntry = sprintf("news_reader_%s_class", $page);
+
+ // Get "action"
+ $action = $requestInstance->getRequestElement('action');
+
+ // Is it also there?
+ if (!empty($action)) {
+ // Then use both for config entry
+ $configEntry = sprintf("news_reader_%s_%s_class", $page, $action);
+ } // END - if
+ } // END - if
+
// Get the news reader class name from config
- $className = $requestInstance->getConfigInstance()->readConfig('news_reader_class');
+ $className = $requestInstance->getConfigInstance()->readConfig($configEntry);
// Once we have that name, try to load initialize it
$newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserAuthFilter () {
+ public final static function createUserAuthFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserAuthFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Set default auth method
$filterInstance->setDefaultAuthMethod();
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class EmailChangeFilter extends BaseFrameworkSystem implements Filterable {
+class EmailChangeFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createEmailChangeFilter () {
+ public final static function createEmailChangeFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new EmailChangeFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
return false;
} // END - if
+ // Are email and confirmation empty?
+ if ((empty($email1)) && (empty($email2))) {
+ // No email change required!
+ return true;
+ } // END - if
+
// Now, get a user instance for comparison
$userInstance = Registry::getRegistry()->getInstance('user');
$userEmail = $userInstance->getField('email');
// Are they different?
- if ($userEmail != $email1) {
- // Update the "new_email" field
- $this->partialStub("Unfinished part.");
+ if ($userEmail == $email1) {
+ // Nothing has been changed is fine...
+ return true;
} // END - if
+
+ // Update the "new_email" field
+ $this->partialStub("Unfinished part.");
}
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class PasswordChangeFilter extends BaseFrameworkSystem implements Filterable {
+class PasswordChangeFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createPasswordChangeFilter () {
+ public final static function createPasswordChangeFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new PasswordChangeFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
return false;
} // END - if
+ // Are password and confirmation empty?
+ if ((empty($pass1)) && (empty($pass2))) {
+ // Don't change password here
+ return true;
+ } // END - if
+
// Do both match?
if ($pass1 != $pass2) {
// Request is invalid!
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createRulesAcceptedFilter () {
+ public final static function createRulesAcceptedFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new RulesAcceptedFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
-
- // Clean up a little
- $this->removeNumberFormaters();
- $this->removeSystemArray();
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function create???Filter () {
+ public final static function create???Filter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new ???Filter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
/**
* Execute the inner filter
*
- * @param<->$requestInstance<-->An instance of a request class
- * @param<->$responseInstance<->An instance of a response class
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
* @return void
*/
public final function execute (Requestable $requestInstance, Responseable $responseInstance) {
/**
* Do the execution of the filter
*
- * @param<->$requestInstance<-->An instance of a request class
- * @param<->$responseInstance<->An instance of a response class
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
* @return void
*/
abstract public function doExecute (Requestable $requestInstance, Responseable $responseInstance);
<?php
/**
- * A filter for checking if the "encrypt" value is set and fine
+ * A filter for checking if value "encrypt" is set and fine
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class CaptchaEncryptFilter extends BaseFrameworkSystem implements Filterable {
+class CaptchaEncryptFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createCaptchaEncryptFilter () {
+ public final static function createCaptchaEncryptFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new CaptchaEncryptFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
<?php
/**
- * A filter for checking if the username "guest" has been choosen as configured.
- * If so the password will be set to the configured password.
+ * A filter for checking if username "guest" has been choosen as configured. If
+ * so the password will be set to the configured password.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserNameIsGuestFilter () {
+ public final static function createUserNameIsGuestFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserNameIsGuestFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createNewsDownloadFilter () {
+ public final static function createNewsDownloadFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new NewsDownloadFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createNewsProcessFilter () {
+ public final static function createNewsProcessFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new NewsProcessFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createNullFilter () {
+ public final static function createNullFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new NullFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class UserStatusConfimedUpdateFilter extends BaseFrameworkSystem implements Filterable {
+class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserStatusConfimedUpdateFilter () {
+ public final static function createUserStatusConfimedUpdateFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserStatusConfimedUpdateFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class UserUpdateFilter extends BaseFrameworkSystem implements Filterable {
+class UserUpdateFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserUpdateFilter () {
+ public final static function createUserUpdateFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserUpdateFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
<?php
/**
* A concrete filter for validating the email address. This filter may intercept
- * the filter chain if no email address is given or if the supplied email has an
- * invalid form. It could also intercept the filter chain if the email address
- * is already used by some one if configuration requires this.
+ * the filter chain if no email address is given or if supplied email has an
+ * invalid form. It could also intercept our filter chain if email address is
+ * already used by some one if configuration requires this.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createEmailValidatorFilter () {
+ public final static function createEmailValidatorFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new EmailValidatorFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
}
// Does the email exist?
- if (!$userInstance->ifEmailAddressExists()) {
+ if ($userInstance->ifEmailAddressExists() === false) {
// This email has not being used yet
$alreadyTaken = false;
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createPasswordValidatorFilter () {
+ public final static function createPasswordValidatorFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new PasswordValidatorFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
<?php
/**
* A concrete filter for validating the username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username is
- * already taken.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username is already taken.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserNameValidatorFilter () {
+ public final static function createUserNameValidatorFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserNameValidatorFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
}
// Does the username exist?
- if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+ if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
// This username is still available
$alreadyTaken = false;
} // END - if
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createAccountPasswordVerifierFilter () {
+ public final static function createAccountPasswordVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new AccountPasswordVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
* @throws AccountPasswordMismatchException If the account password does not match
+ * @todo Rewrite handling of different password fields
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get password
// Is the password still not set?
if (is_null($password)) {
- // Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ // Get password from alternative location
+ $password = $requestInstance->getRequestElement('password');
- // Add a message to the response
- $responseInstance->addFatalMessage('pass_old_unset');
+ // Is the password still not set?
+ if (is_null($password)) {
+ // Not found in form so stop the filtering process
+ $requestInstance->requestIsValid(false);
- // Abort here
- return false;
- } elseif (empty($password)) {
+ // Add a message to the response
+ $responseInstance->addFatalMessage('password_unset');
+
+ // Abort here
+ return false;
+ } // END - if
+ } // END - if
+
+ if (empty($password)) {
// Password is empty
$requestInstance->requestIsValid(false);
// Add a message to the response
- $responseInstance->addFatalMessage('pass_old_empty');
+ $responseInstance->addFatalMessage('password_empty');
// Abort here
return false;
// Get a user instance
$userInstance = Registry::getRegistry()->getInstance('user');
- // Get old hash
- $oldHash = $userInstance->getField('pass_hash');
+ // Get current hash
+ $currentHash = $userInstance->getField('pass_hash');
// Get an encryption helper and encrypt the password
- $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $oldHash);
+ $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash);
// Does it match?
- if ($oldHash != $passHash) {
+ if ($currentHash != $passHash) {
// Throw an exception here to stop the proccessing
throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH);
} // END - if
<?php
/**
- * A filter for checking if the the supplied confirmation code is valid
+ * A filter for checking if supplied confirmation code is valid.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createConfirmCodeVerifierFilter () {
+ public final static function createConfirmCodeVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new ConfirmCodeVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
$responseInstance->redirectToConfiguredUrl('confirm_code_invalid_url');
// Stop processing here
- exit;
+ exit();
} // END - if
}
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createGraphicalCodeCaptchaVerifierFilter () {
+ public final static function createGraphicalCodeCaptchaVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new GraphicalCodeCaptchaVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createPasswordGuestVerifierFilter () {
+ public final static function createPasswordGuestVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new PasswordGuestVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createPasswordVerifierFilter () {
+ public final static function createPasswordVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new PasswordVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
<?php
/**
* A concrete filter for verfying the guest username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username was
- * not found.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username was not found.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserGuestVerifierFilter () {
+ public final static function createUserGuestVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserGuestVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
$requestInstance->requestIsValid(false);
// Add a message to the response
- $responseInstance->addFatalMessage('username_unset');
+ $responseInstance->addFatalMessage('username_guest_unset');
// Abort here
return false;
$requestInstance->requestIsValid(false);
// Add a message to the response
- $responseInstance->addFatalMessage('username_empty');
+ $responseInstance->addFatalMessage('username_guest_empty');
// Abort here
return false;
- } elseif (!$this->ifUserGuestIsTaken($userName)) {
+ } elseif ($this->ifUserGuestIsTaken($userName) === false) {
// Username is already taken
$requestInstance->requestIsValid(false);
// Add a message to the response
- $responseInstance->addFatalMessage('username_not_found');
+ $responseInstance->addFatalMessage('username_guest_not_found');
// Abort here
return false;
}
// Does the username exist?
- if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+ if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
// This username is still available
$alreadyTaken = false;
}
<?php
/**
* A concrete filter for verfying the username. This filter may intercept the
- * filter chain if no username is given or if the supplied username has an
- * invalid form. It could also intercept the filter chain if the username was
- * not found.
+ * filter chain if no username is given or if supplied username has an invalid
+ * form. It could also intercept our filter chain if username was not found.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserNameVerifierFilter () {
+ public final static function createUserNameVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserNameVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
// Abort here
return false;
- } elseif (!$this->ifUserNameIsTaken($userName)) {
+ } elseif ($this->ifUserNameIsTaken($userName) === false) {
// Username is already taken
$requestInstance->requestIsValid(false);
}
// Does the username exist?
- if ((is_null($userInstance)) || (!$userInstance->ifUsernameExists())) {
+ if ((is_null($userInstance)) || ($userInstance->ifUsernameExists() === false)) {
// This username is still available
$alreadyTaken = false;
} // END - if
<?php
/**
- * A filter for checking if the user status is GUEST or CONFIRMED
+ * A filter for checking if user status is GUEST or CONFIRMED.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class UserStatusVerifierFilter extends BaseFrameworkSystem implements Filterable {
+class UserStatusVerifierFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserStatusVerifierFilter () {
+ public final static function createUserStatusVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserStatusVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
<?php
/**
- * A filter for checking if the user status is UNCONFIRMED
+ * A filter for checking if user status is UNCONFIRMED.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class UserUnconfirmedVerifierFilter extends BaseFrameworkSystem implements Filterable {
+class UserUnconfirmedVerifierFilter extends BaseFilter implements Filterable {
/**
* Protected constructor
*
/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createUserUnconfirmedVerifierFilter () {
+ public final static function createUserUnconfirmedVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new UserUnconfirmedVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
$userInstance = call_user_func_array(array($userClass, 'createMemberByRequest'), array($requestInstance));
// Is the email address valid?
- if (!$userInstance->ifEmailAddressExists()) {
+ if ($userInstance->ifEmailAddressExists() === false) {
// Request is invalid!
$requestInstance->requestIsValid(false);
/**
* Setter for image message string
*
- * @param $imageString A message to display in the image
+ * @param $imageString A message to display in image
* @return void
*/
public final function setImageString ($imageString) {
/**
* Getter for image message string
*
- * @return $imageString A message to display in the image
+ * @return $imageString A message to display in image
*/
public final function getImageString () {
return $this->imageStrings[$this->currString]['string'];
*
* @param $groupId Group id to open
* @param $content Initial content to add to the group
+ * @param $tag HTML tag used to open this group
* @return void
* @throws HelperGroupAlreadyCreatedException If the group was already created before
*/
- protected function openGroupByIdContent ($groupId, $content) {
- //* DEBUG: */ echo "OPEN:groupId={$groupId}<br />\n";
+ protected function openGroupByIdContent ($groupId, $content, $tag) {
+ //* DEBUG: */ echo "OPEN:groupId={$groupId},content=<pre>".htmlentities($content)."</pre>\n";
// Is the group already there?
if (isset($this->groups[$groupId])) {
// Then throw an exception here
// Add the group to the stack
$this->groups[$this->totalCounter] = $groupId;
$this->groups[$groupId]['opened'] = true;
- $this->groups[$groupId]['content'] = $content."\n";
+ $this->groups[$groupId]['content'] = sprintf("<!-- group %s opened (length: %s, tag: %s) //-->%s\n", $groupId, strlen($content), $tag, $content);
+ $this->groups[$groupId]['tag'] = $tag;
// Mark this group as previously opened
$this->setPreviousGroupId($groupId);
* Closes the previously opened group by added given content to it or
* throws an exception if no previous group was opened
*
- * @param $content Content for previously opened grouop
+ * @param $content Content for previously opened group, or empty to use tag of opener
* @return void
* @throws HelperNoPreviousOpenedGroupException If no previously opened group was found
*/
- public function closePreviousGroupByContent ($content) {
+ public function closePreviousGroupByContent ($content = "") {
+ // Check if any sub group was opened before
+ if ($this->ifSubGroupOpenedPreviously()) {
+ // Close it automatically
+ $this->closePreviousSubGroupByContent();
+ } // END - if
+
// Check if any group was opened before
- if (!$this->ifGroupOpenedPreviously()) {
+ if ($this->ifGroupOpenedPreviously() === false) {
// Then throw an exception
throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
} // END - if
// Get previous group
$groupId = $this->getPreviousGroupId();
+ // Is the content empty?
+ if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) {
+ // Get it from opener
+ $content = sprintf("<!-- group %s auto-closed //--></%s>", $groupId, $this->groups[$groupId]['tag']);
+ } // END - if
+
// Add content to it and mark it as closed
- $this->groups[$groupId]['content'] .= $content."\n";
+ $this->groups[$groupId]['content'] .= sprintf("<!-- group %s closed (length: %s, tag: %s) //-->%s\n", $groupId, strlen($content), $this->groups[$groupId]['tag'], $content);
$this->groups[$groupId]['opened'] = false;
// Mark previous group as closed
*
* @param $subGroupId Sub group id to open
* @param $content Initial content to add to the sub group
+ * @param $tag HTML tag used to open this group
* @return void
* @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before
*/
- protected function openSubGroupByIdContent ($subGroupId, $content) {
+ protected function openSubGroupByIdContent ($subGroupId, $content, $tag) {
//* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
// Is the group already there?
if (isset($this->subGroups[$subGroupId])) {
// Add the group to the stack
$this->subGroups[$this->totalCounter] = $subGroupId;
$this->subGroups[$subGroupId]['opened'] = true;
- $this->subGroups[$subGroupId]['content'] = $content."\n";
+ $this->subGroups[$subGroupId]['content'] = sprintf("<!-- sub-group %s opened (length: %s, tag: %s) //-->%s\n", $subGroupId, strlen($content), $tag, $content);
+ $this->subGroups[$subGroupId]['tag'] = $tag;
// Mark this group as previously opened
$this->setPreviousSubGroupId($subGroupId);
* Closes the previously opened sub group by added given content to it or
* throws an exception if no previous sub group was opened
*
- * @param $content Content for previously opened sub grouop
+ * @param $content Content for previously opened sub group, or leave empty to use div/span of openener
* @return void
* @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
*/
- public function closePreviousSubGroupByContent ($content) {
+ public function closePreviousSubGroupByContent ($content = "") {
// Check if any sub group was opened before
- if (!$this->ifSubGroupOpenedPreviously()) {
+ if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception
throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
} // END - if
// Get previous sub group
$subGroupId = $this->getPreviousSubGroupId();
+ // Is the content empty?
+ if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) {
+ // Get it from opener
+ $content = sprintf("<!-- sub-group %s auto-closed //--></%s>", $subGroupId, $this->subGroups[$subGroupId]['tag']);
+ } // END - if
+
// Add content to it and mark it as closed
- $this->subGroups[$subGroupId]['content'] .= $content."\n";
+ $this->subGroups[$subGroupId]['content'] .= sprintf("<!-- sub-group %s closed (length: %s, tag: %s) //-->%s\n", $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content);
$this->subGroups[$subGroupId]['opened'] = false;
// Mark previous sub group as closed
// Is this a group and is it closed?
if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) {
// Then add it's content
- $groupContent = $this->groups[$this->groups[$idx]]['content'];
+ $groupContent = trim($this->groups[$this->groups[$idx]]['content']);
//* DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
$content .= $groupContent;
} elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) {
// Then add it's content
$subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content'];
//* DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
- $content .= $subGroupContent;
+ $content .= trim($subGroupContent);
} else {
// Something went wrong
- $this->debugInstance();
+ $this->debugInstance(__METHOD__."(): Something unexpected happened here.");
}
-
} // END - for
// Is footer content there?
return $required;
}
+ /**
+ * Checks wether for birthday shall be asked
+ *
+ * @return $required Wether birthday shall be asked
+ */
+ public function ifProfileIncludesBirthDay () {
+ $required = ($this->getConfigInstance()->readConfig('profile_includes_birthday') === "Y");
+ return $required;
+ }
+
/**
* Checks wether email addresses can only be once used
*
} // END - if
// At least the group name should be set
- if ((empty($groupId)) && (!$this->ifGroupOpenedPreviously())) {
+ if ((empty($groupId)) && ($this->ifGroupOpenedPreviously() === false)) {
// Throw exception here
throw new EmptyVariableException(array($this, 'groupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} elseif (empty($groupId)) {
}
// Same group to open?
- if ((!$this->ifGroupOpenedPreviously()) && ($groupId == $this->getPreviousGroupId())) {
+ if (($this->ifGroupOpenedPreviously() === false) && ($groupId === $this->getPreviousGroupId())) {
// Abort here silently
return false;
} // END - if
$content = " </div>\n</div><!-- Group - CLOSE //-->";
// Is this group opened?
- if (!$this->ifGroupOpenedPreviously()) {
+ if ($this->ifGroupOpenedPreviously() === false) {
// Begin the div/span blocks
$content = sprintf("<!-- Group %s - OPEN //-->
<div class=\"group_box\" id=\"%s_group_box\">
);
// Switch the state
- $this->openGroupByIdContent($groupId, $content);
+ $this->openGroupByIdContent($groupId, $content, "div");
} else {
// Is a sub group opened?
if ($this->ifSubGroupOpenedPreviously()) {
// Switch the state
$this->closePreviousGroupByContent($content);
- // All call it again if the group name is not empty
+ // All call it again if group name is not empty
if ((!empty($groupId)) && ($groupId != $prevGroupId)) {
//* DEBUG: */ echo $groupId."/".$prevGroupId."<br />\n";
$this->addFormGroup($groupId, $groupText);
/**
* Add a form sub group or close an already opened and open a new one or
- * throws an exception if no group has been opened before or if the sub
- * group name is empty.
+ * throws an exception if no group has been opened before or if sub group
+ * name is empty.
*
* @param $subGroupId Name of the group or last opened if empty
* @param $subGroupText Text including HTML to show above this group
*/
public function addFormSubGroup ($subGroupId = "", $subGroupText = "") {
// Is a group opened?
- if (!$this->ifGroupOpenedPreviously()) {
+ if ($this->ifGroupOpenedPreviously() === false) {
// Throw exception here
throw new FormFormClosedException(array($this, $subGroupId), self::EXCEPTION_UNEXPECTED_CLOSED_GROUP);
} // END - if
// At least the sub group name should be set
- if ((empty($subGroupId)) && (!$this->ifSubGroupOpenedPreviously())) {
+ if ((empty($subGroupId)) && ($this->ifSubGroupOpenedPreviously() === false)) {
// Throw exception here
throw new EmptyVariableException(array($this, 'subGroupId'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} elseif (empty($subGroupId)) {
}
// Same sub group to open?
- if ((!$this->ifSubGroupOpenedPreviously()) && ($subGroupId == $this->getPreviousSubGroupId())) {
+ if (($this->ifSubGroupOpenedPreviously() === false) && ($subGroupId == $this->getPreviousSubGroupId())) {
// Abort here silently
return false;
} // END - if
$content = " </div>\n</div><!-- Sub group- CLOSE //-->";
// Is this group opened?
- if (!$this->ifSubGroupOpenedPreviously()) {
+ if ($this->ifSubGroupOpenedPreviously() === false) {
// Begin the span block
$content = sprintf("<!-- Sub group %s - OPEN //-->
<div class=\"subgroup_box\" id=\"%s_subgroup_box\">
);
// Switch the state and remeber the name
- $this->openSubGroupByIdContent($subGroupId, $content);
+ $this->openSubGroupByIdContent($subGroupId, $content, "div");
} else {
// Get previous sub group id
$prevSubGroupId = $this->getPreviousSubGroupId();
throw new FormClosedException (array($this, "form_notes"), self::EXCEPTION_CLOSED_FORM);
} // END - if
- // Is a group open?
- if ($this->ifGroupOpenedPreviously()) {
- // Then automatically close it here
- $this->addFormGroup();
- } // END - if
-
// Generate the content
$inputContent = sprintf(" <div id=\"form_note_%s\">
%s
} // END - if
// Shall we close or open the sub group?
- if ((!$this->ifSubGroupOpenedPreviously()) && ($this->getPreviousSubGroupId() !== $selectId)) {
+ if (($this->ifSubGroupOpenedPreviously() === false) && ($this->getPreviousSubGroupId() !== $selectId)) {
// Initialize first entry (which might be non-selectable if content is provided
if (!empty($firstEntry)) {
// Add selection around it
);
// Open the sub group
- $this->openSubGroupByIdContent($selectId, $content);
+ $this->openSubGroupByIdContent($selectId, $content, "select");
} elseif ($this->getPreviousSubGroupId() != $selectId) {
// Something went wrong!
- $this->debugInstance();
+ $this->debugInstance(__METHOD__."(): Previous sub group id {$this->getPreviousSubGroupId()} does not match current id {$selectId}.");
} else {
// Close the sub group
$this->closePreviousSubGroupByContent("</select>");
*/
public function addSelectSubOption ($subName, $subValue) {
// Is there a sub group (shall be a selection box!)
- if (!$this->ifSubGroupOpenedPreviously()) {
+ if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception here
throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
} // END - if
// Render the content
- $content = sprintf("<option value=\"%s\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
- $subName,
+ $content = sprintf("<option value=\"invalid\" class=\"suboption suboption_%s\" disabled=\"disabled\">%s</option>\n",
$subName,
$subValue
);
*/
public function addSelectOption ($optionName, $optionValue) {
// Is there a sub group (shall be a selection box!)
- if (!$this->ifSubGroupOpenedPreviously()) {
+ if ($this->ifSubGroupOpenedPreviously() === false) {
// Then throw an exception here
throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
} // END - if
// Set link base
$helperInstance->setLinkBase($linkBase);
+ // Add default group
+ $helperInstance->openGroupByIdContent('main', "", "");
+
// Return the prepared instance
return $helperInstance;
}
// Is a previous opened group still open?
if ($this->ifGroupOpenedPreviously()) {
// Then close it
- $this->closePreviousGroupByContent("</div>");
+ $this->closePreviousGroupByContent("");
} // END - if
// Get the content
*
* @param $groupId Id string of the group
* @param $groupText Text for this group to add
+ * @param $groupCode Code to open and close groups
* @return void
*/
- public function addLinkGroup ($groupId, $groupText) {
+ public function addLinkGroup ($groupId, $groupText, $groupCode = "div") {
// Is a group with that name open?
- if ($this->ifGroupIsOpened($groupId)) {
+ if ($this->ifGroupOpenedPreviously()) {
// Then close it here
- $this->closePreviousGroupByContent("</div>");
- } else {
- // Is a previous opened group still open?
- if ($this->ifGroupOpenedPreviously()) {
- // Then close it
- $this->closePreviousGroupByContent("</div>");
- } // END - if
-
- // Generate the group content
- $content = sprintf("<div id=\"group_%s_%s\">%s",
- $this->getLinkName(),
- $groupId,
- $groupText
- );
-
- // Open the new group
- $this->openGroupByIdContent($groupId, $content);
- }
+ $this->closePreviousGroupByContent("");
+ } // END - if
+
+ // Generate the group content
+ $content = sprintf("<{$groupCode} id=\"group_%s_%s\">%s",
+ $this->getLinkName(),
+ $groupId,
+ $groupText
+ );
+
+ // Open the new group
+ $this->openGroupByIdContent($groupId, $content, $groupCode);
}
/**
* Adds text (note) to the previously opened group or throws an exception
* if no previous group was opened.
*
+ * @param $groupId Group id to set
* @param $groupNote Note to be added to a group
+ * @param $groupCode Code to open and close groups
* @return void
* @throws NoGroupOpenedException If no previous group was opened
*/
- public function addLinkNote ($groupNote) {
+ public function addLinkNote ($groupId, $groupNote, $groupCode = "div") {
// Check if a previous group was opened
- if (!$this->ifGroupOpenedPreviously()) {
+ if ($this->ifGroupOpenedPreviously() === false) {
// No group was opened before!
throw new NoGroupOpenedException(array($this, $groupNote), self::EXCEPTION_GROUP_NOT_OPENED);
} // END - if
- // Add the content to the previous group
- $this->addContentToPreviousGroup($groupNote);
+ // Is a previous sub group open?
+ if ($this->ifSubGroupOpenedPreviously()) {
+ // Then close it
+ $this->closePreviousSubGroupByContent("</{$groupCode}>");
+ } // END - if
+
+ // Generate the group content
+ $content = sprintf("<{$groupCode} id=\"subgroup_%s_%s\">%s",
+ $this->getLinkName(),
+ $groupId,
+ $groupNote
+ );
+
+ // Open the sub group
+ $this->openSubGroupByIdContent($groupId, $content, $groupCode);
}
/**
*/
public function addActionLink ($linkAction, $linkText) {
// Check if a previous group was opened
- if (!$this->ifGroupOpenedPreviously()) {
+ if ($this->ifGroupOpenedPreviously() === false) {
// No group was opened before!
throw new NoGroupOpenedException(array($this, $linkAction."(".$linkText.")"), self::EXCEPTION_GROUP_NOT_OPENED);
} // END - if
$this->addContentToPreviousGroup($linkContent);
}
+ /**
+ * Adds a link to the previously opened group with a text from language system
+ *
+ * @param $linkAction Action (action=xxx) value for the link
+ * @param $languageId Language id string to use
+ * @return void
+ */
+ public function addActionLinkById ($linkAction, $languageId) {
+ // Resolve the language string
+ $languageResolved = $this->getLanguageInstance()->getMessage($languageId);
+
+ // Add the action link
+ $this->addActionLink($linkAction, $languageResolved);
+ }
+
/**
* Adds a default link (no extra parameters) to the content with specified
* language id string.
* @return void
*/
public final function setPointer ($dirPointer) {
- // Sanity-check if the pointer is a valid directory resource
+ // Sanity-check if pointer is a valid directory resource
if (is_resource($dirPointer) || is_null($dirPointer)) {
// Is a valid resource
$this->dirPointer = $dirPointer;
* @return void
*/
public final function setPointer ($filePointer) {
- // Sanity-check if the pointer is a valid file resource
+ // Sanity-check if pointer is a valid file resource
if (is_resource($filePointer) || is_null($filePointer)) {
// Is a valid resource
$this->filePointer = $filePointer;
* @return void
*/
public final function setPointer ($filePointer) {
- // Sanity-check if the pointer is a valid file resource
+ // Sanity-check if pointer is a valid file resource
if (is_resource($filePointer) || is_null($filePointer)) {
// Is a valid resource
$this->filePointer = $filePointer;
// Get the field from the value instance
$fieldValue = $recipientList['values'][$variable]->getField($variable);
- // Set it in the template engine
+ // Set it in template engine
$templateInstance->assignVariable($variable, $fieldValue);
}
}
} else {
// Output it to the console
- printf("%s\n", trim(html_entity_decode(strip_tags($outStream))));
+ printf("%s\n", trim(html_entity_decode(strip_tags(stripslashes($outStream)))));
}
}
* @return void
*/
public final function output ($outStream=false) {
- print($outStream);
+ print(stripslashes($outStream));
}
}
// Now get a search criteria and set the user's name as criteria
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
- $criteriaInstance->addCriteria('points_uid', $this->getUserInstance()->getUserName());
+ $criteriaInstance->addCriteria("points_uid", $this->getUserInstance()->getUserName());
$criteriaInstance->setLimit(1);
// Get result back
// Do we have an entry?
if ($resultInstance->next()) {
- // Load points here - TODO!
+ // @TODO Load points here
$this->partialStub("Load points here for comparison.");
} // END - if
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the page as criteria to it at lease
- $criteriaInstance->addCriteria('page', $page);
+ $criteriaInstance->addCriteria("page", $page);
// Add limitation from config
$criteriaInstance->setLimit($this->getConfigInstance()->readConfig("news_{$page}_limit"));
<?php
/**
- * A general registration class
+ * A general registration class.
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-abstract class BaseRegistration extends BaseFrameworkSystem implements UserRegister {
+class BaseRegistration extends BaseFrameworkSystem {
/**
* Pre-registration filter chain
*/
/**
* Checks wether an instance key was found
*
- * @param $instanceKey The key holding an instance in the registry
- * @return $exists Wether the key exists in the registry
+ * @param $instanceKey The key holding an instance in registry
+ * @return $exists Wether the key exists in registry
*/
public function instanceExists ($instanceKey) {
// Does this key exists?
* @return $objectInstance An instance we shall store
*/
public function getInstance ($instanceKey) {
- // By default the instance is not in the registry
+ // By default the instance is not in registry
$objectInstance = null;
// Is the instance there?
*/
public function isRequestElementSet ($element) {
// Is this element found?
- if (!isset($this->requestData[$element])) {
- // Then return false
- return false;
- } // END - if
+ $isSet = isset($this->requestData[$element]);
- // All clear
- return true;
+ // Return result
+ return $isSet;
}
/**
- * Getter for request element or 'null' if the element was not found
+ * Getter for request element or 'null' if element was not found
*
* @param $element Name of the request element we want to check
* @return $value Value of the found request element or 'null' if the
* @return void
*/
public function setRequestElement ($element, $value) {
- error_log(__METHOD__.":{$element}={$value}");
$this->requestData[$element] = $value;
}
}
/**
- * Getter for a header element or 'null' if the header was not found
+ * Getter for a header element or 'null' if header was not found
*
* @param $headerName Name of the header
* @return $headerValue Value of the header or 'null' if not found
* @return void
*/
protected final function setActionName ($actionName) {
- $this->actionName = $actionName;
+ $this->actionName = (string) $actionName;
}
/**
*
* @return $actionName Last validated action name
*/
- protected final function getActionName () {
+ public final function getActionName () {
return $this->actionName;
}
*
* @param $actionName The default action we shall execute
* @return $isValid Wether the given action is valid
- * @throws EmptyVariableException Thrown if the given action is not set
+ * @throws EmptyVariableException Thrown if given action is not set
*/
public function isActionValid ($actionName) {
// By default nothing shall be valid
* "Loads" current action and instances it if not yet cached
*
* @return $actionInstance A loaded action instance
- * @throws InvalidActionException Thrown if even the default
- * action class is missing (bad!)
*/
protected function loadAction () {
// Init action instance
* @param $actionName The default action we shall execute
* @param $appInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared action resolver instance
- * @throws EmptyVariableException Thrown if the default action is not set
- * @throws InvalidActionException Thrown if the default action is invalid
+ * @throws EmptyVariableException Thrown if default action is not set
+ * @throws InvalidActionException Thrown if default action is invalid
*/
public final static function createWebActionResolver ($actionName, ManageableApplication $appInstance) {
// Create the new instance
if (empty($actionName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'defaultAction'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif (!$resolverInstance->isActionValid($actionName)) {
+ } elseif ($resolverInstance->isActionValid($actionName) === false) {
// Invalid action found
throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION);
}
// Is the action empty? Then fall back to default action
if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action');
- // Check if the action is valid
- if (!$this->isActionValid($actionName)) {
+ // Check if action is valid
+ if ($this->isActionValid($actionName) === false) {
// This action is invalid!
throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
} // END - if
// Is the action empty? Then fall back to default action
if (empty($actionName)) $actionName = $this->getConfigInstance()->readConfig('default_action');
- // Check if the action is valid
- if (!$this->isActionValid($actionName)) {
+ // Check if action is valid
+ if ($this->isActionValid($actionName) === false) {
// This action is invalid!
throw new InvalidActionException(array($this, $actionName), self::EXCEPTION_INVALID_ACTION);
}
*/
private $commandName = "";
- /**
- * A controller instance
- */
- private $controllerInstance = null;
-
/**
* Protected constructor
*
return $this->commandName;
}
- /**
- * Setter for controller instance (this surely breaks a bit the MVC patterm)
- *
- * @param $controllerInstance An instance of the controller
- * @return void
- */
- public final function setControllerInstance (Controller $controllerInstance) {
- $this->controllerInstance = $controllerInstance;
- }
-
- /**
- * Getter for controller instance (this surely breaks a bit the MVC patterm)
- *
- * @return $controllerInstance An instance of the controller
- */
- public final function getControllerInstance () {
- return $this->controllerInstance;
- }
-
/**
* Checks wether the given command is valid
*
* @param $commandName The default command we shall execute
* @return $isValid Wether the given command is valid
- * @throws EmptyVariableException Thrown if the given command is not set
+ * @throws EmptyVariableException Thrown if given command is not set
*/
public function isCommandValid ($commandName) {
// By default nothing shall be valid
* @param $commandName The default command we shall execute
* @param $appInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared command resolver instance
- * @throws EmptyVariableException Thrown if the default command is not set
- * @throws InvalidCommandException Thrown if the default command is invalid
+ * @throws EmptyVariableException Thrown if default command is not set
+ * @throws InvalidCommandException Thrown if default command is invalid
*/
public final static function createImageCommandResolver ($commandName, ManageableApplication $appInstance) {
// Create the new instance
if (empty($commandName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif (!$resolverInstance->isCommandValid($commandName)) {
+ } elseif ($resolverInstance->isCommandValid($commandName) === false) {
// Invalid command found
throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
// Is the command empty? Then fall back to default command
if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command');
- // Check if the command is valid
- if (!$this->isCommandValid($commandName)) {
+ // Check if command is valid
+ if ($this->isCommandValid($commandName) === false) {
// This command is invalid!
throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
} // END - if
// Is the command empty? Then fall back to default command
if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_image_command');
- // Check if the command is valid
- if (!$this->isCommandValid($commandName)) {
+ // Check if command is valid
+ if ($this->isCommandValid($commandName) === false) {
// This command is invalid!
throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
* @param $commandName The default command we shall execute
* @param $appInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared command resolver instance
- * @throws EmptyVariableException Thrown if the default command is not set
- * @throws InvalidCommandException Thrown if the default command is invalid
+ * @throws EmptyVariableException Thrown if default command is not set
+ * @throws InvalidCommandException Thrown if default command is invalid
*/
public final static function createWebCommandResolver ($commandName, ManageableApplication $appInstance) {
// Create the new instance
if (empty($commandName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif (!$resolverInstance->isCommandValid($commandName)) {
+ } elseif ($resolverInstance->isCommandValid($commandName) === false) {
// Invalid command found
throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
// Is the command empty? Then fall back to default command
if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command');
- // Check if the command is valid
- if (!$this->isCommandValid($commandName)) {
+ // Check if command is valid
+ if ($this->isCommandValid($commandName) === false) {
// This command is invalid!
throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
} // END - if
// Is the command empty? Then fall back to default command
if (empty($commandName)) $commandName = $this->getConfigInstance()->readConfig('default_web_command');
- // Check if the command is valid
- if (!$this->isCommandValid($commandName)) {
+ // Check if command is valid
+ if ($this->isCommandValid($commandName) === false) {
// This command is invalid!
throw new InvalidCommandException(array($this, $commandName), self::EXCEPTION_INVALID_COMMAND);
}
*
* @param $controllerName The default controller we shall execute
* @return $isValid Wether the given controller is valid
- * @throws EmptyVariableException Thrown if the given controller is not set
- * @throws DefaultControllerException If the default controller was not found
+ * @throws EmptyVariableException Thrown if given controller is not set
+ * @throws DefaultControllerException Thrown if default controller was not found
*/
public function isControllerValid ($controllerName) {
// By default nothing shall be valid
));
// Try it hard to get an controller
- while (!$isValid) {
+ while ($isValid === false) {
// Is this class already loaded?
if (class_exists($this->getClassName())) {
// This class does exist. :-)
* @param $controllerName The controller we shall resolve
* @param $appInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if the default command is not set
- * @throws InvalidControllerException Thrown if the default controller is invalid
+ * @throws EmptyVariableException Thrown if default command is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
*/
public final static function createImageControllerResolver ($controllerName, ManageableApplication $appInstance) {
// Create the new instance
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif (!$resolverInstance->isControllerValid($controllerName)) {
+ } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
// Invalid command found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
* @param $controllerName The controller we shall resolve
* @param $appInstance An instance of a manageable application helper class
* @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if the default command is not set
- * @throws InvalidControllerException Thrown if the default controller is invalid
+ * @throws EmptyVariableException Thrown if default command is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
*/
public final static function createWebControllerResolver ($controllerName, ManageableApplication $appInstance) {
// Create the new instance
if (empty($controllerName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif (!$resolverInstance->isControllerValid($controllerName)) {
+ } elseif ($resolverInstance->isControllerValid($controllerName) === false) {
// Invalid command found
throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
}
throw new InvalidControllerException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
} // END - if
+ // Set default resolver config name
+ $resolverConfigEntry = "";
+
+ // Try to read a config entry for our resolver including controller name... ;-)
+ try {
+ // Create the resolver name
+ $resolverConfigEntry = sprintf("web_cmd_%s_resolver_class", strtolower($controllerName));
+
+ // Get the config, this will throw an exception if there is no special command resolver
+ $resolverClass = $this->getConfigInstance()->readConfig($resolverConfigEntry);
+ } catch (ConfigEntryNotFoundException $e) {
+ // Use default resolver entry
+ $resolverConfigEntry = "web_cmd_resolver_class";
+ }
+
// Initiate the resolver and controller
- $resolverInstance = ObjectFactory::createObjectByConfiguredName('web_cmd_resolver_class', array($controllerName, $this->getApplicationInstance()));
+ $resolverInstance = ObjectFactory::createObjectByConfiguredName($resolverConfigEntry, array($controllerName, $this->getApplicationInstance()));
$controllerInstance = ObjectFactory::createObjectByName($this->getClassName(), array($resolverInstance));
- // Remove resolver
+ // Remove resolver (we don't need it anymore)
unset($resolverInstance);
// Return the result
$this->fatalMessages[] = $this->getApplicationInstance()->getLanguageInstance()->getMessage($messageId);
}
+ /**
+ * Adds a plain fatal message id to the response
+ *
+ * @param $message The plain message we shall add
+ * @return void
+ */
+ public final function addFatalMessagePlain ($message) {
+ // Adds the resolved message id to the fatal message list
+ $this->fatalMessages[] = $message;
+ }
+
/**
* Flushs the cached HTTP response to the outer world
*
* already sent
*/
public function flushBuffer ($force = false) {
- if ((headers_sent()) && (!$force)) {
+ if ((headers_sent()) && ($force === false)) {
// Headers are already sent!
throw new ResponseHeadersAlreadySentException($this, self::EXCEPTION_HEADERS_ALREADY_SENT);
} elseif (!headers_sent()) {
*/
private $affectedRows = 0;
+ /**
+ * Found value
+ */
+ private $foundValue = "";
+
/**
* Protected constructor
*
/**
* "Iterator" method next() to advance to the next valid entry. This method
- * does also check if the result is invalid
+ * does also check if result is invalid
*
* @return $nextValid Wether the next entry is valid
*/
}
/**
- * Rewind to the beginning
+ * Rewind to the beginning and clear array $currentRow
*
* @return void
*/
public function rewind () {
$this->currentPos = -1;
+ $this->currentRow = array();
}
/**
- * Searches for an entry in the data result and returns it
+ * Searches for an entry in data result and returns it
*
* @param $criteriaInstance The criteria to look inside the data set
* @return $result Found result entry
return $this->affectedRows;
}
+ /**
+ * Getter for found value of previous found() call
+ *
+ * @return $foundValue Found value of previous found() call
+ */
+ public final function getFoundValue () {
+ return $this->foundValue;
+ }
+
/**
* Checks wether we have out-dated entries or not
*
* @return void
*/
public function addElementsToDataSet (StoreableCriteria $criteriaInstance) {
+ // Walk only through out-dated columns
+ foreach ($this->outDated as $key => $dummy) {
+ // Does this key exist?
+ //* DEBUG: */ echo "outDated: {$key}<br />\n";
+ if ($this->find($key)) {
+ // Then update it
+ $criteriaInstance->addCriteria($key, $this->getFoundValue());
+ } // END - if
+ } // END - foreach
+ }
+
+ /**
+ * Find a key inside the result array
+ *
+ * @param $key The key we shall find
+ * @return $found Wether the key was found or not
+ */
+ public function find ($key) {
+ // By default nothing is found
+ $found = false;
+
// Rewind the pointer
$this->rewind();
// Walk through all entries
while ($this->valid()) {
- // Get next entry
+ // Advance to next entry
$this->next();
+
+ // Get the whole array
$currentEntry = $this->current();
- // Walk only through out-dated columns
- foreach ($this->outDated as $key => $dummy) {
- // Does this key exist?
- //* DEBUG: */ echo "outDated: {$key}<br />\n";
- if (isset($currentEntry[$key])) {
- // Then update it
- $criteriaInstance->addCriteria($key, $currentEntry[$key]);
- } // END - foreach
- } // END - foreach
+ // Is the element there?
+ if (isset($currentEntry[$key])) {
+ // Okay, found!
+ $found = true;
+
+ // So "cache" it
+ $this->foundValue = $currentEntry[$key];
+
+ // And stop searching
+ break;
+ } // END - if
} // END - while
+
+ // Return the result
+ return $found;
+ }
+
+ /**
+ * Solver for result index value with call-back method
+ *
+ * @param $databaseColumn Database column where the index might be found
+ * @param $wrapperInstance The wrapper instance to ask for array element
+ * @para $callBack Call-back object for setting the index;
+ * 0=object instance,1=method name
+ * @return void
+4 * @todo Find a caching way without modifying the result array
+ */
+ public function solveResultIndex ($databaseColumn, BaseDatabaseWrapper $wrapperInstance, array $callBack) {
+ // By default nothing is found
+ $indexValue = 0;
+
+ // Is the element in result itself found?
+ if ($this->find($databaseColumn)) {
+ // Use this value
+ $indexValue = $this->getFoundValue();
+ } elseif ($this->find($wrapperInstance->getIndexKey())) {
+ // Use this value
+ $indexValue = $this->getFoundValue();
+ }
+
+ // Set the index
+ call_user_func_array($callBack, array($indexValue));
}
}
default: // Unknown type found
// Construct message
- $msg = sprintf("[%s->%s] Unknown/unsupported template type <strong>%s</strong> detected.",
+ $msg = sprintf("[%s->%s] Unknown/unsupported template type <span class=\"data\">%s</span> detected.",
$this->__toString(),
__FUNCTION__,
$this->getTemplateType()
* @return void
*/
public function transferToResponse (Responseable $responseInstance) {
- // Get the content and set it in the response class
+ // Get the content and set it in response class
$responseInstance->writeToBody($this->getCompiledData());
}
*/
private $userName = "";
+ /**
+ * User id of current user
+ */
+ private $userId = 0;
+
/**
* Email of current user
*/
* @return void
*/
public final function setUserName ($userName) {
- $this->userName = $userName;
+ $this->userName = (string) $userName;
}
/**
- * Setter for email
+ * Getter for username
*
- * @param $email The email to set
+ * @return $userName The username to get
+ */
+ public final function getUserName () {
+ return $this->userName;
+ }
+
+ /**
+ * Setter for user id
+ *
+ * @param $userId The user id to set
* @return void
+ * @todo Find a way of casting here. "(int)" might destroy the user id > 32766
*/
- protected final function setEmail ($email) {
- $this->email = $email;
+ public final function setUserId ($userId) {
+ $this->userId = $userId;
}
/**
- * Getter for username
+ * Getter for user id
*
- * @return $userName The username to get
+ * @return $userId The user id to get
*/
- public final function getUsername () {
- return $this->userName;
+ public final function getUserId () {
+ return $this->userId;
+ }
+
+ /**
+ * Setter for email
+ *
+ * @param $email The email to set
+ * @return void
+ */
+ protected final function setEmail ($email) {
+ $this->email = (string) $email;
}
/**
$criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
+ $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
$criteriaInstance->setLimit(1);
// Get a search result
- $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
- } else {
- // Rewind it
- $this->getResultInstance()->rewind();
- }
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Set the index "solver"
+ $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+
+ // And finally set it
+ $this->setResultInstance($resultInstance);
+ } // END - if
+
+ // Rewind it
+ $this->getResultInstance()->rewind();
// Search for it
if ($this->getResultInstance()->next()) {
$criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
$criteriaInstance->setLimit(1);
- // Get a search resultInstance
- $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
- } else {
- // Rewind it
- $this->getResultInstance()->rewind();
- }
+ // Get a search result
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Set the index "solver"
+ $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
+
+ // And finally set it
+ $this->setResultInstance($resultInstance);
+ } // END - if
+
+ // Rewind it
+ $this->getResultInstance()->rewind();
// Search for it
if ($this->getResultInstance()->next()) {
}
/**
- * Checks if the supplied password hash in request matches with the stored
- * in database.
+ * Checks if supplied password hash in request matches with the stored in
+ * database.
*
* @param $requestInstance A requestable class instance
* @return $matches Wether the supplied password hash matches
// By default nothing matches... ;)
$matches = false;
- // Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+ // Is a previous result there?
+ if (is_null($this->getResultInstance())) {
+ // Get a UserDatabaseWrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+ // Create a search criteria
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add the username as a criteria and set limit to one entry
+ $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $criteriaInstance->setLimit(1);
+
+ // Get a search result
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
- // Create a search criteria
- $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ // Set the index "solver"
+ $resultInstance->solveResultIndex(UserDatabaseWrapper::DB_COLUMN_USERID, $wrapperInstance, array($this, 'setUserId'));
- // Add the username as a criteria and set limit to one entry
- $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
- $criteriaInstance->setLimit(1);
+ // And finally set it
+ $this->setResultInstance($resultInstance);
+ } // END - if
- // Get a search resultInstance
- $this->setResultInstance($wrapperInstance->doSelectByCriteria($criteriaInstance));
+ // Rewind it
+ $this->getResultInstance()->rewind();
// Search for it
- if ($this->getResultInstance()->next()) {
- // Get the current entry (can only be one!)
- $entry = $this->getResultInstance()->current();
-
+ if ($this->getResultInstance()->find('pass_hash')) {
// So does the hashes match?
//* DEBUG: */ echo $requestInstance->getRequestElement('pass_hash')."/".$entry['pass_hash'];
- $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
+ $matches = ($requestInstance->getRequestElement('pass_hash') === $this->getResultInstance()->getFoundValue());
} // END - if
// Return the status
/**
* Creates an instance of this user class by a provided username. This
- * factory method will check if the username is already taken and if not
- * so it will throw an exception.
+ * factory method will check if username is already taken and if not so it
+ * will throw an exception.
*
* @param $userName Username we need a class instance for
* @return $userInstance An instance of this user class
// Set the username
$userInstance->setUserName($userName);
- // Check if the username exists
- if (!$userInstance->ifUsernameExists()) {
+ // Check if username exists
+ if ($userInstance->ifUsernameExists() === false) {
// Throw an exception here
throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
- }
+ } // END - if
// Return the instance
return $userInstance;
/**
* Creates an instance of this user class by a provided email address. This
- * factory method will not check if the email address is there.
+ * factory method will not check if email address is there.
*
* @param $email Email address of the user
* @return $userInstance An instance of this user class
/**
* Creates an instance of this user class by a provided username. This
- * factory method will check if the username is already taken and if not
- * so it will throw an exception.
+ * factory method will check if username is already taken and if not so it
+ * will throw an exception.
*
* @param $userName Username we need a class instance for
* @return $userInstance An instance of this user class
// Set the username
$userInstance->setUserName($userName);
- // Check if the username exists
- if (!$userInstance->ifUsernameExists()) {
+ // Check if username exists
+ if ($userInstance->ifUsernameExists() === false) {
// Throw an exception here
throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
- }
+ } // END - if
// Return the instance
return $userInstance;
/**
* Creates an instance of this user class by a provided email address. This
- * factory method will not check if the email address is there.
+ * factory method will not check if email address is there.
*
* @param $email Email address of the user
* @return $userInstance An instance of this user class
$updateInstance = ObjectFactory::createObjectByConfiguredName('update_criteria_class');
// And add our both entries
- $updateInstance->addCriteria('last_activity', date("Y-m-d H:i:s", time()));
- $updateInstance->addCriteria('last_action', $lastAction);
+ $updateInstance->addCriteria("last_activity", date("Y-m-d H:i:s", time()));
+ $updateInstance->addCriteria("last_action", $lastAction);
// Add the search criteria for searching for the right entry
$updateInstance->setSearchInstance($searchInstance);
// Read all directories but no sub directories
while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess", ".svn"))) {
// Is this a class file?
- if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == FrameworkConfiguration::getInstance()->readConfig('php_extension'))) {
+ if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == ".php")) {
// Get the compressor's name. That's why you must name
// your files like your classes and also that's why you
// must keep on class in one file.
$this->dbLayer = $dbLayer;
}
+ /**
+ * Getter for index key
+ *
+ * @return $indexKey Index key
+ */
+ public final function getIndexKey () {
+ return $this->dbLayer->getIndexKey();
+ }
+
/**
* Runs a "select" statement on the database layer with given table name
* and criteria. If this doesn't fail the result will be returned
@require_once(dirname(__FILE__) . '/config/class_FrameworkConfiguration.php');
// Get a new configuration instance
-$cfg = FrameworkConfiguration::createFrameworkConfiguration();
+$cfg = FrameworkConfiguration::getInstance();
// CFG: SERVER-PATH
-$cfg->setConfigEntry('base_path', (dirname(dirname(__FILE__)) . '/')); // DON'T MISS THE TRAILING SLASH!!!
+$cfg->setConfigEntry('base_path', (dirname(dirname(__FILE__)) . '/'));
// CFG: BASE-URL
$cfg->setConfigEntry('base_url', $cfg->detectBaseUrl());
// CFG: MAGIC-QUOTES-RUNTIME
$cfg->setMagicQuotesRuntime(false);
-// CFG: PHP-SCRIPT-EXTENSION
-$cfg->setConfigEntry('php_extension', ".php");
-
// CFG: CLASS-PREFIX
$cfg->setConfigEntry('class_prefix', "class_");
$cfg->setConfigEntry('entry_method', "entryPoint");
// CFG: TEMPLATE-BASE-PATH
-$cfg->setConfigEntry('tpl_base_path', "templates/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('tpl_base_path', "templates/");
// CFG: LANGUAGE-BASE-PATH
-$cfg->setConfigEntry('lang_base_path', "inc/language/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('lang_base_path', "inc/language/");
// CFG: COMPRESSOR-BASE-PATH
-$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compressor_base_path', "inc/classes/main/compressor/");
// CFG: APPLICATION-PATH
$cfg->setConfigEntry('application_path', $cfg->readConfig('base_path') . "application/");
// CFG: COMPILE-OUTPUT-PATH
-$cfg->setConfigEntry('compile_output_path', "templates/_compiled/"); // DON'T MISS THE TRAILING SLASH!
+$cfg->setConfigEntry('compile_output_path', "templates/_compiled/");
// CFG: TEMPLATE-ENGINE
$cfg->setConfigEntry('template_class', "WebTemplateEngine");
// CFG: FILE-OUTPUT-STREAM
$cfg->setConfigEntry('file_output_class', "FileIoStream");
-// CFG: EMAIL-VALIDATOR
-$cfg->setConfigEntry('email_validator_class', "EmailValidatorFilter");
+// CFG: EMAIL-VALIDATOR-FILTER
+$cfg->setConfigEntry('email_validator_filter', "EmailValidatorFilter");
-// CFG: USERNAME-VALIDATOR
-$cfg->setConfigEntry('username_validator_class', "UserNameValidatorFilter");
+// CFG: USERNAME-VALIDATOR-FILTER
+$cfg->setConfigEntry('username_validator_filter', "UserNameValidatorFilter");
-// CFG: USERNAME-IS-GUEST
-$cfg->setConfigEntry('username_is_guest_class', "UserNameIsGuestFilter");
+// CFG: USERNAME-IS-GUEST-FILTER
+$cfg->setConfigEntry('username_is_guest_filter', "UserNameIsGuestFilter");
-// CFG: PASSWORD-VALIDATOR
-$cfg->setConfigEntry('password_validator_class', "PasswordValidatorFilter");
+// CFG: PASSWORD-VALIDATOR-FILTER
+$cfg->setConfigEntry('password_validator_filter', "PasswordValidatorFilter");
-// CFG: RULES-ACCEPTED-CLASS
-$cfg->setConfigEntry('rules_accepted_class', "RulesAcceptedFilter");
+// CFG: RULES-ACCEPTED-FILTER
+$cfg->setConfigEntry('rules_accepted_filter', "RulesAcceptedFilter");
-// CFG: USERNAME-VERIFIER-CLASS
-$cfg->setConfigEntry('username_verifier_class', "UserNameVerifierFilter");
+// CFG: USERNAME-VERIFIER-FILTER
+$cfg->setConfigEntry('username_verifier_filter', "UserNameVerifierFilter");
-// CFG: USER-GUEST-VERIFIER-CLASS
-$cfg->setConfigEntry('user_guest_verifier_class', "UserGuestVerifierFilter");
+// CFG: USER-GUEST-VERIFIER-FILTER
+$cfg->setConfigEntry('user_guest_verifier_filter', "UserGuestVerifierFilter");
-// CFG: EMAIL-VERIFIER
-$cfg->setConfigEntry('email_verifier_class', "EmailVerifierFilter");
+// CFG: EMAIL-VERIFIER-FILTER
+$cfg->setConfigEntry('email_verifier_filter', "EmailVerifierFilter");
-// CFG: PASSWORD-VERIFIER-CLASS
-$cfg->setConfigEntry('password_verifier_class', "PasswordVerifierFilter");
+// CFG: PASSWORD-VERIFIER-FILTER
+$cfg->setConfigEntry('password_verifier_filter', "PasswordVerifierFilter");
-// CFG: PASSWD-GUEST-VERIFIER-CLASS
-$cfg->setConfigEntry('passwd_guest_verifier_class', "PasswordGuestVerifierFilter");
+// CFG: PASSWD-GUEST-VERIFIER-FILTER
+$cfg->setConfigEntry('passwd_guest_verifier_filter', "PasswordGuestVerifierFilter");
-// CFG: EMAIL-CHANGE-CLASS
-$cfg->setConfigEntry('email_change_class', "EmailChangeFilter");
+// CFG: EMAIL-CHANGE-FILTER
+$cfg->setConfigEntry('email_change_filter', "EmailChangeFilter");
-// CFG: PASSWORD-CHANGE-CLASS
-$cfg->setConfigEntry('password_change_class', "PasswordChangeFilter");
+// CFG: PASSWORD-CHANGE-FILTER
+$cfg->setConfigEntry('password_change_filter', "PasswordChangeFilter");
-// CFG: ACCOUNT-PASSWORD-CLASS
-$cfg->setConfigEntry('account_password_class', "AccountPasswordVerifierFilter");
+// CFG: ACCOUNT-PASSWORD-FILTER
+$cfg->setConfigEntry('account_password_filter', "AccountPasswordVerifierFilter");
-// CFG: USER-STATUS-CLASS
-$cfg->setConfigEntry('user_status_class', "UserStatusVerifierFilter");
+// CFG: USER-STATUS-FILTER
+$cfg->setConfigEntry('user_status_filter', "UserStatusVerifierFilter");
-// CFG: USER-UNCONFIRMED-CLASS
-$cfg->setConfigEntry('user_unconfirmed_class', "UserUnconfirmedVerifierFilter");
+// CFG: USER-UNCONFIRMED-FILTER
+$cfg->setConfigEntry('user_unconfirmed_filter', "UserUnconfirmedVerifierFilter");
// CFG: CRYPTO-CLASS
$cfg->setConfigEntry('crypto_class', "CryptoHelper");
$cfg->setConfigEntry('cookie_expire', (60*60*2)); // Two hours!
// CFG: COOKIE-PATH
-$cfg->setConfigEntry('cookie_path', dirname($_SERVER['SCRIPT_NAME']) . "/");
+$cfg->setConfigEntry('cookie_path', $cfg->detectScriptPath() . "/");
// CFG: COOKIE-DOMAIN
$cfg->setConfigEntry('cookie_domain', $cfg->detectDomain()); // Is mostly the same...
// CFG: GERMAN-DATE-TIME
$cfg->setConfigEntry('german_date_time', "%3\$s.%2\$s.%1\$s, %4\$s:%5\$s:%6\$s");
+// CFG: PRODUCT-INSTALL-MODE
+$cfg->setConfigEntry('product_install_mode', "debug");
+
// [EOF]
?>
/**
* A class for the configuration stuff implemented in a singleton design paddern
*
- * NOTE: We cannot put this in inc/classes/ because it would be loaded (again)
- * in the class loader. See inc/loader/class_ClassLoader.php for instance
+ * NOTE: We cannot put this in inc/classes/ because it would be loaded (again) in
+ * class loader. See inc/loader/class_ClassLoader.php for instance
*
* @see ClassLoader
* @author Roland Haeder <webmaster@ship-simu.org>
// Empty for now
}
- /**
- * "Create" a configuration instance
- *
- * @param $enableDebug Wether enable debug mode (default: off)
- * @return $cfgInstance An instance of this configuration class
- */
- public final static function createFrameworkConfiguration ($enableDebug = false) {
- /**
- * For singleton design pattern because we only need a one-time-run
- * through the initial configuration.
- */
- if (is_null(self::$cfgInstance)) {
- // CFG: ERROR-REPORTING
- @error_reporting(E_ALL | E_STRICT);
-
- /**
- * Shall we enable the debug mode?
- */
- if ($enableDebug) {
- define('DEBUG_MODE', true);
- }
-
- /**
- * Crate a config instance
- */
- self::$cfgInstance = new FrameworkConfiguration();
- }
-
- /**
- * Return the instance
- */
- return self::$cfgInstance;
- }
-
/**
* Getter for an instance of this class
*
* @return $cfgInstance An instance of this class
*/
public final static function getInstance () {
+ // is the instance there?
+ if (is_null(self::$cfgInstance)) {
+ // Create a config instance
+ self::$cfgInstance = new FrameworkConfiguration();
+ } // END - if
+
return self::$cfgInstance;
}
} // END - if
// Construct the full URL now and secure it against CSRF attacks
- $baseUrl = $baseUrl . "://" . $this->detectDomain() . dirname($_SERVER['SCRIPT_NAME']);
+ $baseUrl = $baseUrl . "://" . $this->detectDomain() . $this->detectScriptPath();
// Return the URL
return $baseUrl;
return $fullDomain;
}
+ /**
+ * Detect safely the script path without trailing slash which is the part
+ * between "http://your-domain.invalid/" and "script-name.php"
+ */
+ public function detectScriptPath () {
+ // Default is empty
+ $scriptPath = "";
+
+ // Is the scriptname set?
+ if (isset($_SERVER['SCRIPT_NAME'])) {
+ // Get dirname of it
+ $scriptPath = dirname($_SERVER['SCRIPT_NAME']);
+ } // END - if
+
+ // Return it
+ return $scriptPath;
+ }
+
/**
* Getter for field name
*
$cfg = FrameworkConfiguration::getInstance();
// Generate FQFN for the database layer
-$INC = sprintf("%sinc/database/lib-%s%s",
+$INC = sprintf("%sinc/database/lib-%s.php",
$cfg->readConfig('base_path'),
- $cfg->readConfig('db_type'),
- $cfg->readConfig('php_extension')
+ $cfg->readConfig('db_type')
);
// Load the database layer include
try {
$db = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $layerInstance);
} catch (NullPointerException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <span class=\"exception_reason\">%s</span><br />\n",
$e->getMessage()
));
} catch (InvalidDirectoryResourceException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <span class=\"exception_reason\">%s</span><br />\n",
$e->getMessage()
));
} catch (PathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <span class=\"exception_reason\">%s</span><br />\n",
$e->getMessage()
));
} catch (PathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <span class=\"exception_reason\">%s</span><br />\n",
$e->getMessage()
));
} catch (PathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <span class=\"exception_reason\">%s</span><br />\n",
$e->getMessage()
));
} catch (DirPointerNotOpenedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <strong>%s</strong><br />\n",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database sub-system not initialized for the follwing reason: <span class=\"exception_reason\">%s</span><br />\n",
$e->getMessage()
));
}
+// Is the app variable there and valid?
+if (is_object($app)) $app->setDatabaseInstance($db);
+
// Datenbankobjekt debuggen
if (defined('DEBUG_DATABASE_OBJ')) {
DebugMiddleware::getInstance()->output(sprintf("The database sub-system does now look like this:<br />
try {
$layerInstance = LocalFileDatabase::createLocalFileDatabase(FrameworkConfiguration::getInstance()->readConfig('local_db_path'), FileIoHandler::getInstance());
} catch (SavePathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (SavePathNotFoundException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (SavePathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (SavePathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (SavePathWriteProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer could not be initialized. Reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
}
// Get the instance
$io = ObjectFactory::createObjectByConfiguredName('file_io_class');
+// Is the app variable there and valid?
+if (is_object($app)) $app->setFileIoInstance($io);
+
// [EOF]
?>
$cfg = FrameworkConfiguration::getInstance();
// Include the class loader function
-require(sprintf("%sinc/loader/class_ClassLoader%s", $cfg->readConfig('base_path'), $cfg->readConfig('php_extension')));
+require(sprintf("%sinc/loader/class_ClassLoader.php", $cfg->readConfig('base_path')));
// Does the user has an application specified?
if (!empty($_GET['app'])) {
FrameworkConfiguration::getInstance()->readConfig('lang_base_path')
));
} catch (LanguagePathIsEmptyException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (InvalidLanguagePathStringException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (LanguagePathIsNoDirectoryException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
} catch (LanguagePathReadProtectedException $e) {
- ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <strong>%s</strong>",
+ ApplicationEntryPoint::app_die(sprintf("[Main:] The language sub-system could not be initialized for the following reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
}
+// Is the app variable there and valid?
+if (is_object($app)) $app->setLanguageInstance($lang);
+
// [EOF]
?>
$configAppIncludes = array(
sprintf("class_%s", $cfg->readConfig('app_helper_class')), // The ApplicationHelper class
"config", // The application's own configuration
+ "data", // Application data
"init", // The application initializer
"loader", // The application's class loader
"debug", // Some debugging stuff
}
// Generate a FQFN for the helper class
- $fqfn = sprintf("%s%s/%s%s",
+ $fqfn = sprintf("%s%s/%s.php",
$cfg->readConfig('application_path'),
$cfg->readConfig('app_name'),
- $inc,
- $cfg->readConfig('php_extension')
+ $inc
);
// Does the include file exists?
require_once($fqfn);
} elseif ($cfg->readConfig('verbose_level') > 0) {
// File is missing
- trigger_error(sprintf("Cannot load application script %s! File is missing or read-protected.",
- $inc . $cfg->readConfig('php_extension')
+ trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.",
+ $inc
));
}
}
/**
* The application's emergency exit
*
- * @param $message The optional message we shall output on exit
- * @param $code Error code from exception
- * @param $extraData Extra information from exceptions
+ * @param $message The optional message we shall output on exit
+ * @param $code Error code from exception
+ * @param $extraData Extra information from exceptions
+ * @param $silentMode Wether not silent mode is turned on
* @return void
*/
- public static function app_die ($message = "", $code = false, $extraData = "") {
+ public static function app_die ($message = "", $code = false, $extraData = "", $silentMode = false) {
// Is this method already called?
if (defined('EMERGENCY_EXIT_CALLED')) {
// Then output the text directly
if (empty($message)) {
// No message provided
$message = "No message provided!";
- }
+ } // END - if
+
+ // Get config instance
+ $configInstance = FrameworkConfiguration::getInstance();
+
+ // Do we have debug installation?
+ if (($configInstance->readConfig('product_install_mode') == "productive") || ($silentMode === true)) {
+ // Abort here
+ die();
+ } // END - if
// Get some instances
$tpl = FrameworkConfiguration::getInstance()->readConfig('template_class');
// Get the template instance from our object factory
$templateInstance = ObjectFactory::createObjectByName($tpl, array(FrameworkConfiguration::getInstance()->readConfig('tpl_base_path'), $lang, $io));
} catch (FrameworkException $e) {
- die(sprintf("[Main:] Could not initialize template engine for reason: <strong>%s</strong>",
+ die(sprintf("[Main:] Could not initialize template engine for reason: <span class=\"exception_reason\">%s</span>",
$e->getMessage()
));
}
// Get and prepare backtrace for output
$backtraceArray = debug_backtrace();
$backtrace = "";
- foreach ($backtraceArray as $key=>$trace) {
+ foreach ($backtraceArray as $key => $trace) {
if (!isset($trace['file'])) $trace['file'] = __FILE__;
if (!isset($trace['line'])) $trace['line'] = __LINE__;
if (!isset($trace['args'])) $trace['args'] = array();
$backtrace .= "<span class=\"backtrace_file\">".basename($trace['file'])."</span>:".$trace['line'].", <span class=\"backtrace_function\">".$trace['function']."(".count($trace['args']).")</span><br />";
} // END - foreach
+ // Init application instance
+ $appInstance = null;
+
+ // Is the class there?
+ if (class_exists('ApplicationHelper')) {
+ // Get application instance
+ $appInstance = ApplicationHelper::getInstance();
+
+ // Assign application data
+ $templateInstance->assignApplicationData($appInstance);
+ } // END - if
+
// Assign variables
$templateInstance->assignVariable('message', $message);
$templateInstance->assignVariable('code', $code);