*/
class NoShipyardsConstructedException extends FrameworkException {
public function __construct (FrameworkInterface $class, $code) {
+ // No class given
+ $message = sprintf("Please provide a class for <span id=\"exception_reason\">%s</span>", __CLASS__);
if (is_object($class)) {
// Add a message around the missing class
$message = sprintf("[%s:] Keine Werften gefunden!",
$class->__toString()
);
- } else {
- // No class given
- $message = sprintf("Please provide a class for <span id=\"exception_reason\">%s</span>", __CLASS__);
- }
+ } // END - if
// Call parent constructor
parent::__construct($message, $code);
$iterator->seek($pos);
// Is the current position valid?
- if ($iterator->valid()) {
- // Element holen
- $employee = $iterator->current();
- } else {
+ if (!$iterator->valid()) {
// Should normally not happen... :(
throw new StructuresOutOfBoundsException($idx, self::EXCEPTION_INDEX_OUT_OF_BOUNDS);
- }
- }
+ } // END - if
+
+ // Get current element
+ $employee = $iterator->current();
+ } // END - while
// A dummy just for the description and real class
$dummy = CompanyEmployee::createCompanyEmployee("", "", "M", 1970, 1, 1, $employee->isMarried(), 0);
* @throws MissingSimulatorIdException If an ID number was not found
*/
public final static function createSimulatorPersonellByID ($idNumber) {
+ // Use the direct ID number
+ $tempID = $idNumber;
+
// Add the class name if it was not found
if (count(explode("@", $idNumber)) < 2) {
// Add class name in front of the incomplete ID number
$tempID = sprintf("%s@%s", __CLASS__, $idNumber);
- } else {
- // Use the direct ID number
- $tempID = $idNumber;
- }
+ } // END - if
// Validate the ID number
if (!preg_match(sprintf("/%s\@([a-f0-9]){32}/i", __CLASS__), $tempID)) {
// Invalid format
throw new InvalidIDFormatException(new SimulatorPersonell(), self::EXCEPTION_ID_IS_INVALID_FORMAT);
- }
+ } // END - if
// Get instance
$personellInstance = new SimulatorPersonell(false);
if (!$dbInstance->isUniqueIdUsed($tempID)) {
// Entry not found!
throw new MissingSimulatorIdException(array($personellInstance, $idNumber), self::EXCEPTION_SIMULATOR_ID_INVALID);
- }
+ } // END - if
// Load the personell list and add it to this object
$personellInstance->loadPersonellList($tempID);
// Create personell list
public function createPersonellList () {
- if (is_null($this->personellList)) {
- $this->personellList = new FrameworkArrayObject("FakedPersonellList");
- } else {
+ // Is the list already created?
+ if ($this->personelllList instanceof FrameworkArrayObject) {
+ // Throw an exception
throw new PersonellListAlreadyCreatedException($this, self::EXCEPTION_DIMENSION_ARRAY_INVALID);
- }
+ } // END - if
+
+ // Initialize the array
+ $this->personellList = new FrameworkArrayObject("FakedPersonellList");
}
// Remove the personell list
- private function removePersonellList () {
+ private final function removePersonellList () {
unset($this->personellList);
}
}
// Ist the given birthday valid?
- if ($personellInstance->isDateValid($year, $month, $day)) {
- // Set birthday
- $personellInstance->setBirthday($year, $month, $day);
- } else {
+ if (!$personellInstance->isDateValid($year, $month, $day)) {
// Something is wrong ...
throw new BirthdayInvalidException(array($year, $month, $day), self::EXCEPTION_BIRTH_DATE_IS_INVALID);
}
+ // Set birthday
+ $personellInstance->setBirthday($year, $month, $day);
+
// Set as employed/marrital status
$personellInstance->setEmployed(true);
$personellInstance->setMarried($married);
));
// Ist die gewuenschte Klasse vorhanden?
- if (class_exists($partClass)) {
- // Get an instance back from our object factory
- $partInstance = ObjectFactory::createObjectByName($partClass);
- } else {
+ if (!class_exists($partClass)) {
// Nicht vorhanden, dann Ausnahme werfen!
throw new ClassNotFoundException($partClass, self::EXCEPTION_CLASS_NOT_FOUND);
- }
+ } // END - if
+
+ // Get an instance back from our object factory
+ $partInstance = ObjectFactory::createObjectByName($partClass);
// Das Einbauen versuchen...
try {
// Get new instance
$passInstance = new PassengerShip();
- // Debug message
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) {
- $passInstance->debugOutput(sprintf("[%s:%d] Ein Passagier-Schiff wird erstellt.",
- __CLASS__,
- __LINE__
- ));
- } // END - if
-
- // Set ship's name
+ // Set ship name
$passInstance->setShipName($shipName);
// Instanz zurueckgeben
}
// Anzahl Betten ermitteln
- final function calcTotalBeds () {
+ public final function calcTotalBeds () {
// Struktur-Array holen
$struct = $this->getStructuresArray();
if (!is_null($cab)) {
// Kabinenbeschreibung holen
$cabType = $cab->getObjectDescription();
- }
-
- // Debug-Meldung ausgeben
- $this->debugOutput(sprintf("[%s:%d] Es stehen <strong>%d</strong> Betten vom Kabinen-Typ <strong>%s</strong> bereit.",
- __CLASS__,
- __LINE__,
- $total,
- $cabType
- ));
- }
- } else {
- // Keine Kabine!
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] <strong>%s</strong> ist keine Kabine.",
- __CLASS__,
- __LINE__,
- $el->getObjectDescription()
- ));
- }
+ } // END - if
+ } // END - if
+ } // END - if
} // END - for
- if ((defined('DEBUG_SHIP')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Das <strong>%s</strong> mit dem Namen <strong>%s</strong> hat <strong>%d</strong> Betten.",
- __CLASS__,
- __LINE__,
- $this->getObjectDescription(),
- $this->getShipName(),
- $numBeds
- ));
-
// Anzahl zurueckliefern
return $numBeds;
}
// Maximum of allowed companies reached?
if ($linkInstance->getValueInstance()->ifUserCreatedMaximumAllowedCompanies()) {
// No more companies allowed to create
-} elseif ($linkInstance->getValueInstance()->ifUserPointsEnougth('found_new_company')) {
+} elseif ($linkInstance->getValueInstance()->ifUserPointsEnough('found_new_company')) {
// Enough money to found company
-} elseif ($linkInstance->getValueInstance()->ifUserPointsEnougth('write_applications')) {
+} elseif ($linkInstance->getValueInstance()->ifUserPointsEnough('write_applications')) {
// Enough money to write applications to other companies
} elseif ($linkInstance->getValueInstance()->ifGovermentPaysStartupHelp()) {
// Display link to goverment for startup help
* @return $dbInstance The database layer instance
*/
public final function getDatabaseInstance () {
+ // Default is invalid db instance
+ $dbInstance = null;
+
+ // Is the registry there and initialized?
if ((class_exists('Registry')) && (Registry::isInitialized() === true)) {
- return Registry::getRegistry()->getInstance('dbInstance');
- } else {
- return null;
- }
+ $dbInstance = Registry::getRegistry()->getInstance('dbInstance');
+ } // END - if
+
+ // Return instance
+ return $dbInstance;
}
/**
* @return $objectDescription The description of this simulation part
*/
public final function getObjectDescription () {
- if (isset($this->objectDescription)) {
- return $this->objectDescription;
- } else {
- return null;
- }
+ return $this->objectDescription;
}
/**
/**
* Compare if both simulation part description and class name matches
- * (shall be enougth)
+ * (shall be enough)
*
* @param $itemInstance An object instance to an other class
* @return boolean The result of comparing class name simulation part description
// Cast the string
$str = (string) $str;
+ // Default is the default salt ;-)
+ $salt = $this->salt;
+
// Is the old password set?
- if (empty($oldHash)) {
- // No, then use the current salt
- $salt = $this->salt;
- } else {
+ if (!empty($oldHash)) {
// Use the salt from hash, first get length
$length = $this->getConfigInstance()->readConfig('salt_length');
// Then extract the X first characters from the hash as our salt
$salt = substr($oldHash, 0, $length);
- }
+ } // END - if
// Hash the password with salt
//* DEBUG: */ echo "salt=".$salt."/plain=".$str."<br />\n";
throw new UserAuthorizationException($this, self::EXCEPTION_AUTH_DATA_INVALID);
} // END - if
+ // Regular user account
+ $className = $this->getConfigInstance()->readConfig('user_class');
+ $methodName = 'createMemberByUserName';
+
// Now, try to get a user or guest instance
if ($authLogin == $this->getConfigInstance()->readConfig('guest_login_user')) {
// Set class
$className = $this->getConfigInstance()->readConfig('guest_class');
$methodName = 'createGuestByUserName';
- } else {
- // Regular user account
- $className = $this->getConfigInstance()->readConfig('user_class');
- $methodName = 'createMemberByUserName';
- }
+ } // END - if
// Does the guest class exist?
if (!class_exists($className)) {
/**
* Protected constructor
+ *
+ * @return void
*/
protected function __construct () {
// Call parent constructor
/**
* Destructor for cleaning purposes, etc
+ *
+ * @return void
*/
public final function __destruct() {
// Is there a resource pointer? Then we have to close the file here!
* Create a file pointer based on the given file. The file will also
* be verified here.
*
- * @param $fileName The file name we shall pass
- * to fopen()
+ * @param $fileName The file name we shall pass to fopen()
* @throws FileIsEmptyException If the provided file name is empty.
- * @throws FilePointerNotOpenedException If fopen() returns not a
- * file resource
+ * @throws FilePointerNotOpenedException If fopen() returns not a
+ * file resource
* @return void
*/
public final static function createFrameworkFileInputPointer ($fileName) {
*
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setPointer()
* @throws InvalidFileResourceException If there is being set
* an invalid file resource
*/
*
* @return mixed The result of fread()
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setPointer()
* @throws InvalidFileResourceException If there is being set
* an invalid file resource
*/
*
* @return void
* @throws NullPointerException If the file pointer instance
- * is not set by setPointer()
+ * is not set by setPointer()
* @throws InvalidFileResourceException If there is being set
*/
public function closeFile () {
/**
* Setter for the file pointer
*
- * @param $filePointer File resource
+ * @param $filePointer File resource
* @return void
*/
public final function setPointer ($filePointer) {
* Getter for the file pointer
*
* @return $filePointer The file pointer which shall be a valid
- * file resource
+ * file resource
*/
public final function getPointer () {
return $this->filePointer;
/**
* Setter for file name
*
- * @param $fileName The new file name
+ * @param $fileName The new file name
* @return void
*/
public final function setFileName ($fileName) {
/**
* Getter for file name
*
- * @return $fileName The current file name
+ * @return $fileName The current file name
*/
public final function getFileName () {
return $this->fileName;
* Deliver email to the recipient(s)
*
* @return void
+ * @throws InvalidInterfaceException If the recipient instance does not implement ManageableMember
*/
public function deliverEmail () {
// Get template instance
// Walk through all recipients and "sent", or better print, it out
foreach ($recipientList['recipients'] as $recipientInstance) {
// The recipient should be a user instance, right?
- if ($recipientInstance instanceof ManageableMember) {
- // User class found, so entry is valid, first load the template
- $this->loadTemplate($templateName);
+ if (!$recipientInstance instanceof ManageableMember) {
+ // Invalid entry found!
+ throw new InvalidInterfaceException(array($this, 'ManageableMember'), self::EXCEPTION_REQUIRED_INTERFACE_MISSING);
+ }
- // Set subject line
- $templateInstance->assignVariable('subject', $this->getSubjectLine());
+ // User class found, so entry is valid, first load the template
+ $this->loadTemplate($templateName);
- // Walk through all variables, first config to assign them
- foreach ($recipientList['config_vars'] as $variable=>$dummy) {
- // Load the config value and set it
- $templateInstance->assignConfigVariable($variable);
- } // END - if
+ // Set subject line
+ $templateInstance->assignVariable('subject', $this->getSubjectLine());
+
+ // Walk through all variables, first config to assign them
+ foreach ($recipientList['config_vars'] as $variable=>$dummy) {
+ // Load the config value and set it
+ $templateInstance->assignConfigVariable($variable);
+ } // END - if
- // Now do the same with the values but ask the "value instance" instead!
- foreach ($recipientList['value_vars'] as $variable=>$dummy) {
- // Is the value instance there?
- if (!isset($recipientList['values'][$variable])) {
- // Throw exception
- throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
- } // END - if
+ // Now do the same with the values but ask the "value instance" instead!
+ foreach ($recipientList['value_vars'] as $variable=>$dummy) {
+ // Is the value instance there?
+ if (!isset($recipientList['values'][$variable])) {
+ // Throw exception
+ throw new NullPointerException ($this, self::EXCEPTION_IS_NULL_POINTER);
+ } // END - if
- // Get the field from the value instance
- $fieldValue = $recipientList['values'][$variable]->getField($variable);
+ // Get the field from the value instance
+ $fieldValue = $recipientList['values'][$variable]->getField($variable);
- // Set it in the template engine
- $templateInstance->assignVariable($variable, $fieldValue);
- }
+ // Set it in the template engine
+ $templateInstance->assignVariable($variable, $fieldValue);
+ }
- // Render the content
- $templateInstance->renderXmlContent();
+ // Render the content
+ $templateInstance->renderXmlContent();
- // Get responce instance
- $responseInstance = $this->getApplicationInstance()->getResponseInstance();
+ // Get responce instance
+ $responseInstance = $this->getApplicationInstance()->getResponseInstance();
- // Transfer the data to the response
- $this->getTemplateInstance()->transferToResponse($responseInstance);
- } else {
- // Invalid entry found!
- $this->partialStub("Handling of invalid recipient entries not yet finished.");
- }
+ // Transfer the data to the response
+ $this->getTemplateInstance()->transferToResponse($responseInstance);
} // END - foreach
} // END - foreach
}
/**
* Create a new web output system and set the content type
*
- * @param $contentType A valid content-type
- * @return $debugInstance An instance of this middleware class
+ * @param $contentType A valid content-type
+ * @return $debugInstance An instance of this middleware class
*/
public final static function createConsoleOutput ($contentType) {
// Cast the content-type to string
/**
* Getter for an instance of this class
*
- * @return $consoleInstance An instance of this class
+ * @return $consoleInstance An instance of this class
*/
public final static function getInstance() {
if (is_null(self::$consoleInstance)) {
/**
* Output the code
*
- * @param $outStream Something we shall sent to the console
+ * @param $outStream Something we shall sent to the console
* @return void
*/
public final function output ($outStream=false) {
/**
* Assigns a variable for output
*
- * @param $var The variable we shall assign
- * @param $value The value to store in the variable
+ * @param $var The variable we shall assign
+ * @param $value The value to store in the variable
* @return void
*/
public function assignVariable ($var, $value) {
// Do we have news?
if ($this->getConfigInstance()->readConfig('page_with_news') == $this->getApplicationInstance()->getRequestInstance()->getRequestElement('page')) {
// Yes, display news in home then set default controller with news
- $this->setClassName($this->controllerPrefix.'DefaultNewsController');
+ $this->setClassName($this->controllerPrefix . 'DefaultNewsController');
} else {
// No news at home page or non-news page
- $this->setClassName($this->controllerPrefix.'DefaultController');
+ $this->setClassName($this->controllerPrefix . 'DefaultController');
}
} else {
// All is tried, give it up here
$controllerInstance = null;
// Default controller
- $this->setClassName('ImageDefaultController');
+ $this->setClassName($defaultController);
// Generate the class name
//* DEBUG: */ echo __METHOD__.": Controller=".$controllerName;
$this->setClassName(sprintf("Image%sController",
$this->convertToClassName($controllerName)
));
- } else {
- // Default controller
- $this->setClassName('ImageDefaultController');
- }
+ } // END - if
//* DEBUG: */ echo ", controller=".$this->getClassName()."<br />\n";
// Is this class loaded?
// Is the file name really set?
if (!empty($inc)) {
+ // Base path is by default added
+ $fqfn = $inc;
+
// Base path added? (Uni* / Windows)
if ((substr($inc, 0, 1) != "/") && (substr($inc, 1, 1) != ":")) {
// Generate FQFN
$fqfn = sprintf("%s/inc/extra/%s", PATH, $inc);
- } else {
- // Base path is already added
- $fqfn = $inc;
- }
+ } // END - if
} // END - if
// Include them all here
*/
public function defineDatabaseType ($type) {
// Is it defined or not?
- if (!defined('_DB_TYPE')) {
- // Cast to string
- $type = (string) $type;
-
- // Set the constant
- define('_DB_TYPE', $type);
- } else {
+ if (defined('_DB_TYPE')) {
// Already defined! But we cannot throw an exception here... :(
ApplicationEntryPoint::app_die(sprintf("[%s:] Please define the database type only once in your application!",
__CLASS__
));
}
+
+ // Set the constant
+ define('_DB_TYPE', (string) $type);
}
/**
ApplicationEntryPoint::app_die(sprintf("[%s:] Invalid path (not found) specified. Please make sure it is created.",
__CLASS__
));
- } elseif (!defined('PATH')) {
- // Set the constant
- define('PATH', $path);
- } else {
+ } elseif (defined('PATH')) {
// Already defined! But we cannot throw an exception here... :(
ApplicationEntryPoint::app_die(sprintf("[%s:] Please define the local file path only once in your application.",
__CLASS__
));
}
+
+ // Define path here
+ define('PATH', $path);
}
/**