class_BaseFrameworkSystem.php

Go to the documentation of this file.
00001 <?php
00025 class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
00029         private static $applicationInstance = null;
00030 
00034         private static $langInstance = null;
00035 
00039         private static $debugInstance = null;
00040 
00044         private $requestInstance = null;
00045 
00049         private $responseInstance = null;
00050 
00054         private $searchInstance = null;
00055 
00059         private $fileIoInstance = null;
00060 
00064         private $resolverInstance = null;
00065 
00069         private $templateInstance = null;
00070 
00074         private $resultInstance = null;
00075 
00079         private $userInstance = null;
00080 
00084         private $controllerInstance = null;
00085 
00089         private $realClass      = "FrameworkSystem";
00090 
00094         private $thousands = "."; // German
00095 
00099         private $decimals  = ","; // German
00100 
00101         /***********************
00102          * Exception codes.... *
00103          ***********************/
00104 
00105         const EXCEPTION_IS_NULL_POINTER              = 0x001;
00106         const EXCEPTION_IS_NO_OBJECT                 = 0x002;
00107         const EXCEPTION_IS_NO_ARRAY                  = 0x003;
00108         const EXCEPTION_MISSING_METHOD               = 0x004;
00109         const EXCEPTION_CLASSES_NOT_MATCHING         = 0x005;
00110         const EXCEPTION_INDEX_OUT_OF_BOUNDS          = 0x006;
00111         const EXCEPTION_DIMENSION_ARRAY_INVALID      = 0x007;
00112         const EXCEPTION_ITEM_NOT_TRADEABLE           = 0x008;
00113         const EXCEPTION_ITEM_NOT_IN_PRICE_LIST       = 0x009;
00114         const EXCEPTION_GENDER_IS_WRONG              = 0x00a;
00115         const EXCEPTION_BIRTH_DATE_IS_INVALID        = 0x00b;
00116         const EXCEPTION_EMPTY_STRUCTURES_ARRAY       = 0x00c;
00117         const EXCEPTION_HAS_ALREADY_PERSONELL_LIST   = 0x00d;
00118         const EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES      = 0x00e;
00119         const EXCEPTION_TOTAL_PRICE_NOT_CALCULATED   = 0x00f;
00120         const EXCEPTION_HARBOR_HAS_NO_SHIPYARDS      = 0x010;
00121         const EXCEPTION_CONTRACT_PARTNER_INVALID     = 0x011;
00122         const EXCEPTION_CONTRACT_PARTNER_MISMATCH    = 0x012;
00123         const EXCEPTION_CONTRACT_ALREADY_SIGNED      = 0x013;
00124         const EXCEPTION_UNEXPECTED_EMPTY_STRING      = 0x014;
00125         const EXCEPTION_PATH_NOT_FOUND               = 0x015;
00126         const EXCEPTION_INVALID_PATH_NAME            = 0x016;
00127         const EXCEPTION_READ_PROTECED_PATH           = 0x017;
00128         const EXCEPTION_WRITE_PROTECED_PATH          = 0x018;
00129         const EXCEPTION_DIR_POINTER_INVALID          = 0x019;
00130         const EXCEPTION_FILE_POINTER_INVALID         = 0x01a;
00131         const EXCEPTION_INVALID_DIRECTORY_POINTER    = 0x01b;
00132         const EXCEPTION_UNEXPECTED_OBJECT            = 0x01c;
00133         const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d;
00134         const EXCEPTION_GETTER_IS_MISSING            = 0x01e;
00135         const EXCEPTION_ARRAY_EXPECTED               = 0x01f;
00136         const EXCEPTION_ARRAY_HAS_INVALID_COUNT      = 0x020;
00137         const EXCEPTION_ID_IS_INVALID_FORMAT         = 0x021;
00138         const EXCEPTION_MD5_CHECKSUMS_MISMATCH       = 0x022;
00139         const EXCEPTION_UNEXPECTED_STRING_SIZE       = 0x023;
00140         const EXCEPTION_SIMULATOR_ID_INVALID         = 0x024;
00141         const EXCEPTION_MISMATCHING_COMPRESSORS      = 0x025;
00142         const EXCEPTION_CONTAINER_ITEM_IS_NULL       = 0x026;
00143         const EXCEPTION_ITEM_IS_NO_ARRAY             = 0x027;
00144         const EXCEPTION_CONTAINER_MAYBE_DAMAGED      = 0x028;
00145         const EXCEPTION_INVALID_STRING               = 0x029;
00146         const EXCEPTION_VARIABLE_NOT_SET             = 0x02a;
00147         const EXCEPTION_ATTRIBUTES_ARE_MISSING       = 0x02b;
00148         const EXCEPTION_ARRAY_ELEMENTS_MISSING       = 0x02c;
00149         const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED  = 0x02d;
00150         const EXCEPTION_MISSING_LANGUAGE_HANDLER     = 0x02e;
00151         const EXCEPTION_MISSING_FILE_IO_HANDLER      = 0x02f;
00152         const EXCEPTION_MISSING_ELEMENT              = 0x030;
00153         const EXCEPTION_HEADERS_ALREADY_SENT         = 0x031;
00154         const EXCEPTION_DEFAULT_CONTROLLER_GONE      = 0x032;
00155         const EXCEPTION_CLASS_NOT_FOUND              = 0x033;
00156         const EXCEPTION_REQUIRED_INTERFACE_MISSING   = 0x034;
00157         const EXCEPTION_FATAL_ERROR                  = 0x035;
00158         const EXCEPTION_FILE_NOT_FOUND               = 0x036;
00159         const EXCEPTION_ASSERTION_FAILED             = 0x037;
00160         const EXCEPTION_FILE_CANNOT_BE_READ          = 0x038;
00161         const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
00162 
00172         private $systemClasses = array(
00173                 "DebugMiddleware",                              // Debug middleware output sub-system
00174                 "Registry",                                             // Object registry
00175                 "ObjectFactory",                                // Object factory
00176                 "DebugWebOutput",                               // Debug web output sub-system
00177                 "WebOutput",                                    // Web output sub-system
00178                 "CompressorChannel",                    // Compressor sub-system
00179                 "DebugConsoleOutput",                   // Debug console output sub-system
00180                 "DebugErrorLogOutput",                  // Debug error_log() output sub-system
00181                 "FrameworkDirectoryPointer",    // Directory handler sub-system
00182                 "NullCompressor",                               // Null compressor
00183                 "Bzip2Compressor",                              // BZIP2 compressor
00184                 "GzipCompressor",                               // GZIP compressor
00185         );
00186 
00187         /* No longer used:
00188         */
00189 
00196         protected function __construct ($className) {
00197                 // Set real class
00198                 $this->setRealClass($className);
00199 
00200                 // Initialize the class if class Registry is there
00201                 if ((class_exists('Registry')) && (Registry::isInitialized() === false)) {
00202                         // Initialize the registry automatically
00203                         $this->initInstance();
00204                 } // END - if
00205         }
00206 
00213         public function __destruct() {
00214                 // Is this object already destroyed?
00215                 if ($this->__toString() != 'DestructedObject') {
00216                         // Destroy all informations about this class but keep some text about it alive
00217                         $this->setRealClass('DestructedObject');
00218                 } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
00219                         // Already destructed object
00220                         $this->debugOutput(sprintf("[%s:] The object <span class=\"object_name\">%s</span> is already destroyed.",
00221                                 __CLASS__, $this->__toString()
00222                         ));
00223                 }
00224         }
00225 
00231         public final function __call ($methodName, $args) {
00232                 // Implode all given arguments
00233                 $argsString = "";
00234                 if (empty($args)) {
00235                         // No arguments
00236                         $argsString = "NULL";
00237                 } elseif (is_array($args)) {
00238                         // Some arguments are there
00239                         foreach ($args as $arg) {
00240                                 // Add the type
00241                                 $argsString .= $arg." (".gettype($arg);
00242 
00243                                 // Add length if type is string
00244                                 if (gettype($arg) == 'string') $argsString .= ", ".strlen($arg);
00245 
00246                                 // Closing bracket
00247                                 $argsString .= "), ";
00248                         } // END - foreach
00249 
00250                         // Remove last comma
00251                         if (substr($argsString, -2, 1) === ",") {
00252                                 $argsString = substr($argsString, 0, -2);
00253                         } // END - if
00254                 } else {
00255                         // Invalid arguments!
00256                         $argsString = sprintf("!INVALID:%s!", $args);
00257                 }
00258 
00259                 // Output stub message
00260                 $this->debugOutput(sprintf("[%s-&gt;%s] Stub! Args: %s",
00261                         $this->__toString(),
00262                         $methodName,
00263                         $argsString
00264                 ));
00265 
00266                 // Return nothing
00267                 return null;
00268         }
00269 
00275         private final function initInstance () {
00276                 // Is this a system class?
00277                 if (!in_array($this->__toString(), $this->systemClasses)) {
00278                         // Set configuration instance
00279                         $this->setConfigInstance(FrameworkConfiguration::getInstance());
00280 
00281                         // Add application helper to our class
00282                         $this->systemclasses[] = $this->getConfigInstance()->readConfig('app_helper_class');
00283 
00284                         // Set debug instance
00285                         $this->setDebugInstance(DebugMiddleware::createDebugMiddleware($this->getConfigInstance()->readConfig('debug_class')));
00286 
00287                         // Get output instance and set it
00288                         $outputInstance = ObjectFactory::createObjectByConfiguredName('web_engine', array($this->getConfigInstance()->readConfig('web_content_type')));
00289                         $this->setWebOutputInstance($outputInstance);
00290 
00291                         // Set the compressor channel
00292                         $this->setCompressorChannel(CompressorChannel::createCompressorChannel(sprintf("%s%s",
00293                                 $this->getConfigInstance()->readConfig('base_path'),
00294                                 $this->getConfigInstance()->readConfig('compressor_base_path')
00295                         )));
00296 
00297                         // Initialization done! :D
00298                         Registry::isInitialized('OK');
00299                 } elseif ($this->__toString() == 'DebugMiddleware') {
00300                         // Set configuration instance
00301                         $this->setConfigInstance(FrameworkConfiguration::getInstance());
00302                 }
00303         }
00304 
00312         protected final function setResultInstance (SearchableResult $resultInstance) {
00313                 $this->resultInstance =  $resultInstance;
00314         }
00315 
00321         public final function getResultInstance () {
00322                 return $this->resultInstance;
00323         }
00324 
00331         protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
00332                 $this->templateInstance = $templateInstance;
00333         }
00334 
00340         protected final function getTemplateInstance () {
00341                 return $this->templateInstance;
00342         }
00343 
00350         public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
00351                 $this->searchInstance = $searchInstance;
00352         }
00353 
00359         public final function getSearchInstance () {
00360                 return $this->searchInstance;
00361         }
00362 
00369         public final function setResolverInstance (Resolver $resolverInstance) {
00370                 $this->resolverInstance = $resolverInstance;
00371         }
00372 
00378         public final function getResolverInstance () {
00379                 return $this->resolverInstance;
00380         }
00381 
00389         public final function setConfigInstance (FrameworkConfiguration $configInstance) {
00390                 Registry::getRegistry()->addInstance('config', $configInstance);
00391         }
00392 
00398         public final function getConfigInstance () {
00399                 $cfgInstance = Registry::getRegistry()->getInstance('config');
00400                 return $cfgInstance;
00401         }
00402 
00409         public final function setDebugInstance (DebugMiddleware $debugInstance) {
00410                 self::$debugInstance = $debugInstance;
00411         }
00412 
00418         public final function getDebugInstance () {
00419                 return self::$debugInstance;
00420         }
00421 
00428         public final function setWebOutputInstance (OutputStreamer $webInstance) {
00429                 Registry::getRegistry()->addInstance('web_output', $webInstance);
00430         }
00431 
00437         public final function getWebOutputInstance () {
00438                 return Registry::getRegistry()->getInstance('web_output');
00439         }
00440 
00448         public final function setDatabaseInstance (DatabaseConnection $dbInstance) {
00449                 Registry::getRegistry()->addInstance('dbInstance', $dbInstance);
00450         }
00451 
00457         public final function getDatabaseInstance () {
00458                 // Default is invalid db instance
00459                 $dbInstance = null;
00460 
00461                 // Is the registry there and initialized?
00462                 if ((class_exists('Registry')) && (Registry::isInitialized() === true)) {
00463                         $dbInstance = Registry::getRegistry()->getInstance('dbInstance');
00464                 } // END - if
00465 
00466                 // Return instance
00467                 return $dbInstance;
00468         }
00469 
00476         public final function setCompressorChannel (CompressorChannel $compressorChannel) {
00477                 Registry::getRegistry()->addInstance('compressor', $compressorChannel);
00478         }
00479 
00485         public final function getCompressorChannel () {
00486                 return Registry::getRegistry()->getInstance('compressor');
00487         }
00488 
00494         protected final function getApplicationInstance () {
00495                 return self::$applicationInstance;
00496         }
00497 
00504         public final function setApplicationInstance (ManageableApplication $applicationInstance) {
00505                 self::$applicationInstance = $applicationInstance;
00506         }
00507 
00514         public final function setRequestInstance (Requestable $requestInstance) {
00515                 $this->requestInstance = $requestInstance;
00516         }
00517 
00523         public final function getRequestInstance () {
00524                 return $this->requestInstance;
00525         }
00526 
00533         public final function setResponseInstance (Responseable $responseInstance) {
00534                 $this->responseInstance = $responseInstance;
00535         }
00536 
00542         public final function getResponseInstance () {
00543                 return $this->responseInstance;
00544         }
00545 
00551         public final function __toString () {
00552                 return $this->realClass;
00553         }
00554 
00561         public final function setRealClass ($realClass) {
00562                 // Cast to string
00563                 $realClass = (string) $realClass;
00564 
00565                 // Set real class
00566                 $this->realClass = $realClass;
00567         }
00568 
00575         public final function isClass ($className) {
00576                 return ($this->__toString() == $className);
00577         }
00578 
00585         public function isCabin () {
00586                 return false;
00587         }
00588 
00596         public function isTradeable () {
00597                 return false;
00598         }
00599 
00612         public function formatCurrency ($value, $currency = "&euro;", $decNum = 2) {
00613                 // Are all required attriutes set?
00614                 if ((!isset($this->decimals)) || (!isset($this->thousands))) {
00615                         // Throw an exception
00616                         throw new MissingDecimalsThousandsSeperatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING);
00617                 }
00618 
00619                 // Cast the number
00620                 $value = (float) $value;
00621 
00622                 // Reformat the US number
00623                 $price = sprintf("%s %s",
00624                         number_format($value, $decNum, $this->decimals, $this->thousands),
00625                         $currency
00626                 );
00627 
00628                 // Return as string...
00629                 return $price;
00630         }
00631 
00637         public final function removeNumberFormaters () {
00638                 unset($this->thousands);
00639                 unset($this->decimals);
00640         }
00641 
00647         protected final function getLanguageInstance () {
00648                 return self::$langInstance;
00649         }
00650 
00658         public final function setLanguageInstance (ManageableLanguage $langInstance) {
00659                 self::$langInstance = $langInstance;
00660         }
00661 
00667         public final function removeSystemArray () {
00668                 unset($this->systemClasses);
00669         }
00670 
00677         public final function addMissingTrailingSlash ($str) {
00678                 // Is there a trailing slash?
00679                 if (substr($str, -1, 1) != "/") $str .= "/";
00680                 return $str;
00681         }
00682 
00688         protected final function getFileIoInstance () {
00689                 return $this->fileIoInstance;
00690         }
00691 
00698         public final function setFileIoInstance (FileIoHandler $fileIoInstance) {
00699                 $this->fileIoInstance = $fileIoInstance;
00700         }
00701 
00718         protected function prepareTemplateInstance (BaseFrameworkSystem $appInstance=null) {
00719                 // Is the application instance set?
00720                 if (is_null($appInstance)) {
00721                         // Get the current instance
00722                         $appInstance = $this->getApplicationInstance();
00723 
00724                         // Still null?
00725                         if (is_null($appInstance)) {
00726                                 // Thrown an exception
00727                                 throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
00728                         } // END - if
00729                 } // END - if
00730 
00731                 // Generate FQFN for all application templates
00732                 $fqfn = sprintf("%s%s/%s",
00733                         $this->getConfigInstance()->readConfig('application_path'),
00734                         strtolower($appInstance->getAppShortName()),
00735                         $this->getConfigInstance()->readConfig('tpl_base_path')
00736                 );
00737 
00738                 // Are both instances set?
00739                 if ($appInstance->getLanguageInstance() === null) {
00740                         // Invalid language instance
00741                         throw new MissingLanguageHandlerException($appInstance, self::EXCEPTION_MISSING_LANGUAGE_HANDLER);
00742                 } elseif ($appInstance->getFileIoInstance() === null) {
00743                         // Invalid language instance
00744                         throw new MissingFileIoHandlerException($appInstance, self::EXCEPTION_MISSING_FILE_IO_HANDLER);
00745                 }
00746 
00747                 // Initialize the template engine
00748                 $templateInstance = ObjectFactory::createObjectByConfiguredName('template_class', array($fqfn, $appInstance->getLanguageInstance(), $appInstance->getFileIoInstance()));
00749 
00750                 // Return the prepared instance
00751                 return $templateInstance;
00752         }
00753 
00760         public final function debugInstance ($message = "") {
00761                 // Restore the error handler to avoid trouble with missing array elements or undeclared variables
00762                 restore_error_handler();
00763 
00764                 // Init content
00765                 $content = "";
00766 
00767                 // Is a message set?
00768                 if (!empty($message)) {
00769                         // Construct message
00770                         $content = sprintf("<div class=\"debug_message\">Message: %s</div>\n", $message);
00771                 } // END - if
00772 
00773                 // Generate the output
00774                 $content .= sprintf("<pre>%s</pre>",
00775                         trim(
00776                                 htmlentities(
00777                                         print_r($this, true)
00778                                 )
00779                         )
00780                 );
00781 
00782                 // Output it
00783                 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>",
00784                         $this->__toString(),
00785                         $content,
00786                         ClassLoader::getInstance()->getPrintableIncludeList()
00787                 ));
00788         }
00789 
00796         protected function partialStub ($message = "") {
00797                 // Get the backtrace
00798                 $backtrace = debug_backtrace();
00799 
00800                 // Generate the class::method string
00801                 $methodName = "UnknownClass-&gt;unknownMethod";
00802                 if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
00803                         $methodName = $backtrace[1]['class']."-&gt;".$backtrace[1]['function'];
00804                 } // END - if
00805 
00806                 // Construct the full message
00807                 $stubMessage = sprintf("[%s:] Partial stub!",
00808                         $methodName
00809                 );
00810 
00811                 // Is the extra message given?
00812                 if (!empty($message)) {
00813                         // Then add it as well
00814                         $stubMessage .= sprintf(" Message: <span id=\"stub_message\">%s</span>", $message);
00815                 } // END - if
00816 
00817                 // Debug instance is there?
00818                 if (!is_null($this->getDebugInstance())) {
00819                         // Output stub message
00820                         $this->debugOutput($stubMessage);
00821                 } else {
00822                         // Trigger an error
00823                         trigger_error($stubMessage."<br />\n");
00824                 }
00825         }
00826 
00832         public function debugBackTrace () {
00833                 // Sorry, there is no other way getting this nice backtrace
00834                 print("<pre>\n");
00835                 debug_print_backtrace();
00836                 print("</pre>");
00837                 exit();
00838         }
00839 
00847         public function debugOutput ($message, $doPrint = true) {
00848                 // Get debug instance
00849                 $debugInstance = $this->getDebugInstance();
00850 
00851                 // Is the debug instance there?
00852                 if (is_object($debugInstance)) {
00853                         // Use debug output handler
00854                         $debugInstance->output($message);
00855                         if ($doPrint === false) die(); // Die here if not printed
00856                 } else {
00857                         // Put directly out
00858                         if ($doPrint) {
00859                                 print($message);
00860                         } else {
00861                                 // DO NOT REWRITE THIS TO app_die() !!!
00862                                 die($message);
00863                         }
00864                 }
00865         }
00866 
00873         public function convertToClassName ($str) {
00874                 // Init class name
00875                 $className = "";
00876 
00877                 // Convert all dashes in underscores
00878                 $str = str_replace("-", "_", $str);
00879 
00880                 // Now use that underscores to get classname parts for hungarian style
00881                 foreach (explode("_", $str) as $strPart) {
00882                         // Make the class name part lower case and first upper case
00883                         $className .= ucfirst(strtolower($strPart));
00884                 } // END - foreach
00885 
00886                 // Return class name
00887                 return $className;
00888         }
00889 
00896         public function markupCode ($phpCode) {
00897                 // Init marked code
00898                 $markedCode = "";
00899 
00900                 // Get last error
00901                 $errorArray = error_get_last();
00902 
00903                 // Init the code with error message
00904                 if (is_array($errorArray)) {
00905                         // Get error infos
00906                         $markedCode = sprintf("<div id=\"error_header\">File: <span id=\"error_data\">%s</span>, Line: <span id=\"error_data\">%s</span>, Message: <span id=\"error_data\">%s</span>, Type: <span id=\"error_data\">%s</span></div>",
00907                                 basename($errorArray['file']),
00908                                 $errorArray['line'],
00909                                 $errorArray['message'],
00910                                 $errorArray['type']
00911                         );
00912                 } // END - if
00913 
00914                 // Add line number to the code
00915                 foreach (explode("\n", $phpCode) as $lineNo => $code) {
00916                         // Add line numbers
00917                         $markedCode .= sprintf("<span id=\"code_line\">%s</span>: %s\n",
00918                                 ($lineNo + 1),
00919                                 htmlentities($code, ENT_QUOTES)
00920                         );
00921                 } // END - foreach
00922 
00923                 // Return the code
00924                 return $markedCode;
00925         }
00926 
00935         public function doFilterFormatTimestamp ($timestamp) {
00936                 // Default value to return
00937                 $readable = "???";
00938 
00939                 // Is the timestamp null?
00940                 if (is_null($timestamp)) {
00941                         // Get a message string
00942                         $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
00943                 } else {
00944                         switch ($this->getLanguageInstance()->getLanguageCode()) {
00945                                 case "de": // German format is a bit different to default
00946                                         // Split the GMT stamp up
00947                                         $dateTime = explode(" ", $timestamp);
00948                                         $dateArray = explode("-", $dateTime[0]);
00949                                         $timeArray = explode(":", $dateTime[1]);
00950 
00951                                         // Construct the timestamp
00952                                         $readable = sprintf($this->getConfigInstance()->readConfig('german_date_time'),
00953                                                 $dateArray[0],
00954                                                 $dateArray[1],
00955                                                 $dateArray[2],
00956                                                 $timeArray[0],
00957                                                 $timeArray[1],
00958                                                 $timeArray[2]
00959                                         );
00960                                         break;
00961 
00962                                 default: // Default is pass-through
00963                                         $readable = $timestamp;
00964                                         break;
00965                         }
00966                 }
00967 
00968                 // Return the stamp
00969                 return $readable;
00970         }
00971 
00979         protected final function getDatabaseEntry () {
00980                 // Is there an instance?
00981                 if (is_null($this->getResultInstance())) {
00982                         // Throw an exception here
00983                         throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
00984                 } // END - if
00985 
00986                 // Rewind it
00987                 $this->getResultInstance()->rewind();
00988 
00989                 // Do we have an entry?
00990                 if ($this->getResultInstance()->valid() === false) {
00991                         throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
00992                 } // END - if
00993 
00994                 // Get next entry
00995                 $this->getResultInstance()->next();
00996 
00997                 // Fetch it
00998                 $entry = $this->getResultInstance()->current();
00999 
01000                 // And return it
01001                 return $entry;
01002         }
01003 
01011         public final function getField ($fieldName) {
01012                 // Default field value
01013                 $fieldValue = null;
01014 
01015                 // Get result instance
01016                 $resultInstance = $this->getResultInstance();
01017 
01018                 // Is this instance null?
01019                 if (is_null($resultInstance)) {
01020                         // Then the user instance is no longer valid (expired cookies?)
01021                         throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
01022                 } // END - if
01023 
01024                 // Get current array
01025                 $fieldArray = $resultInstance->current();
01026 
01027                 // Does the field exist?
01028                 if (isset($fieldArray[$fieldName])) {
01029                         // Get it
01030                         $fieldValue = $fieldArray[$fieldName];
01031                 } // END - if
01032 
01033                 // Return it
01034                 return $fieldValue;
01035         }
01036 
01043         protected final function setUserInstance (ManageableAccount $userInstance) {
01044                 $this->userInstance = $userInstance;
01045         }
01046 
01052         public final function getUserInstance () {
01053                 return $this->userInstance;
01054         }
01055 
01062         public final function setControllerInstance (Controller $controllerInstance) {
01063                 $this->controllerInstance = $controllerInstance;
01064         }
01065 
01071         public final function getControllerInstance () {
01072                 return $this->controllerInstance;
01073         }
01074 }
01075 
01076 // [EOF]
01077 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6