Fixed: Fatal error: Access to undeclared static property: BaseFrameworkSystem::$hashL...
[core.git] / inc / classes / main / class_BaseFrameworkSystem.php
1 <?php
2 /**
3  * The simulator system class is the super class of all other classes. This
4  * class handles saving of games etc.
5  *
6  * @author              Roland Haeder <webmaster@shipsimu.org>
7  * @version             0.0.0
8  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
9  * @license             GNU GPL 3.0 or any newer version
10  * @link                http://www.shipsimu.org
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
26         /**
27          * Length of output from hash()
28          */
29         private static $hashLength = NULL;
30
31         /**
32          * The real class name
33          */
34         private $realClass = 'BaseFrameworkSystem';
35
36         /**
37          * Instance of a request class
38          */
39         private $requestInstance = NULL;
40
41         /**
42          * Instance of a response class
43          */
44         private $responseInstance = NULL;
45
46         /**
47          * Search criteria instance
48          */
49         private $searchInstance = NULL;
50
51         /**
52          * Update criteria instance
53          */
54         private $updateInstance = NULL;
55
56         /**
57          * The file I/O instance for the template loader
58          */
59         private $fileIoInstance = NULL;
60
61         /**
62          * Resolver instance
63          */
64         private $resolverInstance = NULL;
65
66         /**
67          * Template engine instance
68          */
69         private $templateInstance = NULL;
70
71         /**
72          * Database result instance
73          */
74         private $resultInstance = NULL;
75
76         /**
77          * Instance for user class
78          */
79         private $userInstance = NULL;
80
81         /**
82          * A controller instance
83          */
84         private $controllerInstance = NULL;
85
86         /**
87          * Instance of a RNG
88          */
89         private $rngInstance = NULL;
90
91         /**
92          * Instance of a crypto helper
93          */
94         private $cryptoInstance = NULL;
95
96         /**
97          * Instance of an Iterator class
98          */
99         private $iteratorInstance = NULL;
100
101         /**
102          * Instance of the list
103          */
104         private $listInstance = NULL;
105
106         /**
107          * Instance of a menu
108          */
109         private $menuInstance = NULL;
110
111         /**
112          * Instance of the image
113          */
114         private $imageInstance = NULL;
115
116         /**
117          * Instance of the stacker
118          */
119         private $stackerInstance = NULL;
120
121         /**
122          * A Compressor instance
123          */
124         private $compressorInstance = NULL;
125
126         /**
127          * A Parseable instance
128          */
129         private $parserInstance = NULL;
130
131         /**
132          * A ProtocolHandler instance
133          */
134         private $protocolInstance = NULL;
135
136         /**
137          * A database wrapper instance
138          */
139         private $databaseInstance = NULL;
140
141         /**
142          * A helper instance for the form
143          */
144         private $helperInstance = NULL;
145
146         /**
147          * An instance of a Sourceable class
148          */
149         private $sourceInstance = NULL;
150
151         /**
152          * An instance of a InputStream class
153          */
154         private $inputStreamInstance = NULL;
155
156         /**
157          * An instance of a OutputStream class
158          */
159         private $outputStreamInstance = NULL;
160
161         /**
162          * Networkable handler instance
163          */
164         private $handlerInstance = NULL;
165
166         /**
167          * Visitor handler instance
168          */
169         private $visitorInstance = NULL;
170
171         /**
172          * DHT instance
173          */
174         private $dhtInstance = NULL;
175
176         /**
177          * An instance of a database wrapper class
178          */
179         private $wrapperInstance = NULL;
180
181         /**
182          * An instance of a file I/O pointer class (not handler)
183          */
184         private $pointerInstance = NULL;
185
186         /**
187          * An instance of an Indexable class
188          */
189         private $indexInstance = NULL;
190
191         /**
192          * An instance of a Block class
193          */
194         private $blockInstance = NULL;
195
196         /**
197          * Thousands separator
198          */
199         private $thousands = '.'; // German
200
201         /**
202          * Decimal separator
203          */
204         private $decimals  = ','; // German
205
206         /**
207          * Socket resource
208          */
209         private $socketResource = FALSE;
210
211         /**
212          * Package data
213          */
214         private $packageData = array();
215
216         /**
217          * Generic array
218          */
219         private $genericArray = array();
220
221         /***********************
222          * Exception codes.... *
223          ***********************/
224
225         // @todo Try to clean these constants up
226         const EXCEPTION_IS_NULL_POINTER              = 0x001;
227         const EXCEPTION_IS_NO_OBJECT                 = 0x002;
228         const EXCEPTION_IS_NO_ARRAY                  = 0x003;
229         const EXCEPTION_MISSING_METHOD               = 0x004;
230         const EXCEPTION_CLASSES_NOT_MATCHING         = 0x005;
231         const EXCEPTION_INDEX_OUT_OF_BOUNDS          = 0x006;
232         const EXCEPTION_DIMENSION_ARRAY_INVALID      = 0x007;
233         const EXCEPTION_ITEM_NOT_TRADEABLE           = 0x008;
234         const EXCEPTION_ITEM_NOT_IN_PRICE_LIST       = 0x009;
235         const EXCEPTION_GENDER_IS_WRONG              = 0x00a;
236         const EXCEPTION_BIRTH_DATE_IS_INVALID        = 0x00b;
237         const EXCEPTION_EMPTY_STRUCTURES_ARRAY       = 0x00c;
238         const EXCEPTION_HAS_ALREADY_PERSONELL_LIST   = 0x00d;
239         const EXCEPTION_NOT_ENOUGTH_UNEMPLOYEES      = 0x00e;
240         const EXCEPTION_TOTAL_PRICE_NOT_CALCULATED   = 0x00f;
241         const EXCEPTION_HARBOR_HAS_NO_SHIPYARDS      = 0x010;
242         const EXCEPTION_CONTRACT_PARTNER_INVALID     = 0x011;
243         const EXCEPTION_CONTRACT_PARTNER_MISMATCH    = 0x012;
244         const EXCEPTION_CONTRACT_ALREADY_SIGNED      = 0x013;
245         const EXCEPTION_UNEXPECTED_EMPTY_STRING      = 0x014;
246         const EXCEPTION_PATH_NOT_FOUND               = 0x015;
247         const EXCEPTION_INVALID_PATH_NAME            = 0x016;
248         const EXCEPTION_READ_PROTECED_PATH           = 0x017;
249         const EXCEPTION_WRITE_PROTECED_PATH          = 0x018;
250         const EXCEPTION_DIR_POINTER_INVALID          = 0x019;
251         const EXCEPTION_FILE_POINTER_INVALID         = 0x01a;
252         const EXCEPTION_INVALID_RESOURCE             = 0x01b;
253         const EXCEPTION_UNEXPECTED_OBJECT            = 0x01c;
254         const EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED = 0x01d;
255         const EXCEPTION_GETTER_IS_MISSING            = 0x01e;
256         const EXCEPTION_ARRAY_EXPECTED               = 0x01f;
257         const EXCEPTION_ARRAY_HAS_INVALID_COUNT      = 0x020;
258         const EXCEPTION_ID_IS_INVALID_FORMAT         = 0x021;
259         const EXCEPTION_MD5_CHECKSUMS_MISMATCH       = 0x022;
260         const EXCEPTION_UNEXPECTED_STRING_SIZE       = 0x023;
261         const EXCEPTION_SIMULATOR_ID_INVALID         = 0x024;
262         const EXCEPTION_MISMATCHING_COMPRESSORS      = 0x025;
263         const EXCEPTION_CONTAINER_ITEM_IS_NULL       = 0x026;
264         const EXCEPTION_ITEM_IS_NO_ARRAY             = 0x027;
265         const EXCEPTION_CONTAINER_MAYBE_DAMAGED      = 0x028;
266         const EXCEPTION_INVALID_STRING               = 0x029;
267         const EXCEPTION_VARIABLE_NOT_SET             = 0x02a;
268         const EXCEPTION_ATTRIBUTES_ARE_MISSING       = 0x02b;
269         const EXCEPTION_ARRAY_ELEMENTS_MISSING       = 0x02c;
270         const EXCEPTION_TEMPLATE_ENGINE_UNSUPPORTED  = 0x02d;
271         const EXCEPTION_UNSPPORTED_OPERATION         = 0x02e;
272         const EXCEPTION_FACTORY_REQUIRE_PARAMETER    = 0x02f;
273         const EXCEPTION_MISSING_ELEMENT              = 0x030;
274         const EXCEPTION_HEADERS_ALREADY_SENT         = 0x031;
275         const EXCEPTION_DEFAULT_CONTROLLER_GONE      = 0x032;
276         const EXCEPTION_CLASS_NOT_FOUND              = 0x033;
277         const EXCEPTION_REQUIRED_INTERFACE_MISSING   = 0x034;
278         const EXCEPTION_FATAL_ERROR                  = 0x035;
279         const EXCEPTION_FILE_NOT_FOUND               = 0x036;
280         const EXCEPTION_ASSERTION_FAILED             = 0x037;
281         const EXCEPTION_FILE_CANNOT_BE_READ          = 0x038;
282         const EXCEPTION_DATABASE_UPDATED_NOT_ALLOWED = 0x039;
283         const EXCEPTION_FILTER_CHAIN_INTERCEPTED     = 0x03a;
284
285         /**
286          * Hexadecimal->Decimal translation array
287          */
288         private static $hexdec = array(
289                 '0' => 0,
290                 '1' => 1,
291                 '2' => 2,
292                 '3' => 3,
293                 '4' => 4,
294                 '5' => 5,
295                 '6' => 6,
296                 '7' => 7,
297                 '8' => 8,
298                 '9' => 9,
299                 'a' => 10,
300                 'b' => 11,
301                 'c' => 12,
302                 'd' => 13,
303                 'e' => 14,
304                 'f' => 15
305         );
306
307         /**
308          * Decimal->hexadecimal translation array
309          */
310         private static $dechex = array(
311                  0 => '0',
312                  1 => '1',
313                  2 => '2',
314                  3 => '3',
315                  4 => '4',
316                  5 => '5',
317                  6 => '6',
318                  7 => '7',
319                  8 => '8',
320                  9 => '9',
321                 10 => 'a',
322                 11 => 'b',
323                 12 => 'c',
324                 13 => 'd',
325                 14 => 'e',
326                 15 => 'f'
327         );
328
329         /**
330          * Startup time in miliseconds
331          */
332         private static $startupTime = 0;
333
334         /**
335          * Protected super constructor
336          *
337          * @param       $className      Name of the class
338          * @return      void
339          */
340         protected function __construct ($className) {
341                 // Set real class
342                 $this->setRealClass($className);
343
344                 // Set configuration instance if no registry ...
345                 if (!$this instanceof Register) {
346                         // ... because registries doesn't need to be configured
347                         $this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
348                 } // END - if
349
350                 // Is the startup time set? (0 cannot be TRUE anymore)
351                 if (self::$startupTime == 0) {
352                         // Then set it
353                         self::$startupTime = microtime(TRUE);
354                 } // END - if
355         }
356
357         /**
358          * Destructor for all classes
359          *
360          * @return      void
361          */
362         public function __destruct () {
363                 // Flush any updated entries to the database
364                 $this->flushPendingUpdates();
365
366                 // Is this object already destroyed?
367                 if ($this->__toString() != 'DestructedObject') {
368                         // Destroy all informations about this class but keep some text about it alive
369                         $this->setRealClass('DestructedObject');
370                 } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) {
371                         // Already destructed object
372                         self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] The object <span class="object_name">%s</span> is already destroyed.',
373                                 __CLASS__,
374                                 $this->__toString()
375                         ));
376                 } else {
377                         // Do not call this twice
378                         trigger_error(__METHOD__ . ': Called twice.');
379                         exit;
380                 }
381         }
382
383         /**
384          * The __call() method where all non-implemented methods end up
385          *
386          * @param       $methodName             Name of the missing method
387          * @args        $args                   Arguments passed to the method
388          * @return      void
389          */
390         public final function __call ($methodName, $args) {
391                 return self::__callStatic($methodName, $args);
392         }
393
394         /**
395          * The __callStatic() method where all non-implemented static methods end up
396          *
397          * @param       $methodName             Name of the missing method
398          * @args        $args                   Arguments passed to the method
399          * @return      void
400          */
401         public static final function __callStatic ($methodName, $args) {
402                 // Init argument string
403                 $argsString = '';
404
405                 // Is it empty or an array?
406                 if (empty($args)) {
407                         // No arguments
408                         $argsString = 'NULL';
409                 } elseif (is_array($args)) {
410                         // Some arguments are there
411                         foreach ($args as $arg) {
412                                 // Add the value itself if not array. This prevents 'array to string conversion' message
413                                 if (is_array($arg)) {
414                                         $argsString .= 'Array';
415                                 } else {
416                                         $argsString .= $arg;
417                                 }
418
419                                 // Add data about the argument
420                                 $argsString .= ' (' . gettype($arg);
421
422                                 if (is_string($arg)) {
423                                         // Add length for strings
424                                         $argsString .= ', ' . strlen($arg);
425                                 } elseif (is_array($arg)) {
426                                         // .. or size if array
427                                         $argsString .= ', ' . count($arg);
428                                 } elseif ($arg === TRUE) {
429                                         // ... is boolean 'TRUE'
430                                         $argsString .= ', TRUE';
431                                 } elseif ($arg === FALSE) {
432                                         // ... is boolean 'FALSE'
433                                         $argsString .= ', FALSE';
434                                 }
435
436                                 // Closing bracket
437                                 $argsString .= '), ';
438                         } // END - foreach
439
440                         // Remove last comma
441                         if (substr($argsString, -2, 1) == ',') {
442                                 $argsString = substr($argsString, 0, -2);
443                         } // END - if
444                 } else {
445                         // Invalid arguments!
446                         $argsString = '!INVALID:' . gettype($args) . '!';
447                 }
448
449                 // Output stub message
450                 // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class
451                 self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s',
452                         $methodName,
453                         $argsString
454                 ));
455
456                 // Return nothing
457                 return NULL;
458         }
459
460         /**
461          * Getter for $realClass
462          *
463          * @return      $realClass The name of the real class (not BaseFrameworkSystem)
464          */
465         public function __toString () {
466                 return $this->realClass;
467         }
468
469         /**
470          * Magic function to catch setting of missing but set class fields/attributes
471          *
472          * @param       $name   Name of the field/attribute
473          * @param       $value  Value to store
474          * @return      void
475          */
476         public final function __set ($name, $value) {
477                 $this->debugBackTrace(sprintf('Tried to set a missing field. name=%s, value[%s]=%s',
478                         $name,
479                         gettype($value),
480                         print_r($value, TRUE)
481                 ));
482         }
483
484         /**
485          * Magic function to catch getting of missing fields/attributes
486          *
487          * @param       $name   Name of the field/attribute
488          * @return      void
489          */
490         public final function __get ($name) {
491                 $this->debugBackTrace(sprintf('Tried to get a missing field. name=%s',
492                         $name
493                 ));
494         }
495
496         /**
497          * Magic function to catch unsetting of missing fields/attributes
498          *
499          * @param       $name   Name of the field/attribute
500          * @return      void
501          */
502         public final function __unset ($name) {
503                 $this->debugBackTrace(sprintf('Tried to unset a missing field. name=%s',
504                         $name
505                 ));
506         }
507
508         /**
509          * Setter for the real class name
510          *
511          * @param       $realClass      Class name (string)
512          * @return      void
513          */
514         public final function setRealClass ($realClass) {
515                 // Set real class
516                 $this->realClass = (string) $realClass;
517         }
518
519         /**
520          * Setter for database result instance
521          *
522          * @param       $resultInstance         An instance of a database result class
523          * @return      void
524          * @todo        SearchableResult and UpdateableResult shall have a super interface to use here
525          */
526         protected final function setResultInstance (SearchableResult $resultInstance) {
527                 $this->resultInstance =  $resultInstance;
528         }
529
530         /**
531          * Getter for database result instance
532          *
533          * @return      $resultInstance         An instance of a database result class
534          */
535         public final function getResultInstance () {
536                 return $this->resultInstance;
537         }
538
539         /**
540          * Setter for template engine instances
541          *
542          * @param       $templateInstance       An instance of a template engine class
543          * @return      void
544          */
545         protected final function setTemplateInstance (CompileableTemplate $templateInstance) {
546                 $this->templateInstance = $templateInstance;
547         }
548
549         /**
550          * Getter for template engine instances
551          *
552          * @return      $templateInstance       An instance of a template engine class
553          */
554         protected final function getTemplateInstance () {
555                 return $this->templateInstance;
556         }
557
558         /**
559          * Setter for search instance
560          *
561          * @param       $searchInstance         Searchable criteria instance
562          * @return      void
563          */
564         public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
565                 $this->searchInstance = $searchInstance;
566         }
567
568         /**
569          * Getter for search instance
570          *
571          * @return      $searchInstance         Searchable criteria instance
572          */
573         public final function getSearchInstance () {
574                 return $this->searchInstance;
575         }
576
577         /**
578          * Setter for update instance
579          *
580          * @param       $updateInstance         Searchable criteria instance
581          * @return      void
582          */
583         public final function setUpdateInstance (LocalUpdateCriteria $updateInstance) {
584                 $this->updateInstance = $updateInstance;
585         }
586
587         /**
588          * Getter for update instance
589          *
590          * @return      $updateInstance         Updateable criteria instance
591          */
592         public final function getUpdateInstance () {
593                 return $this->updateInstance;
594         }
595
596         /**
597          * Setter for resolver instance
598          *
599          * @param       $resolverInstance       Instance of a command resolver class
600          * @return      void
601          */
602         public final function setResolverInstance (Resolver $resolverInstance) {
603                 $this->resolverInstance = $resolverInstance;
604         }
605
606         /**
607          * Getter for resolver instance
608          *
609          * @return      $resolverInstance       Instance of a command resolver class
610          */
611         public final function getResolverInstance () {
612                 return $this->resolverInstance;
613         }
614
615         /**
616          * Setter for language instance
617          *
618          * @param       $configInstance         The configuration instance which shall
619          *                                                              be FrameworkConfiguration
620          * @return      void
621          */
622         public final function setConfigInstance (FrameworkConfiguration $configInstance) {
623                 Registry::getRegistry()->addInstance('config', $configInstance);
624         }
625
626         /**
627          * Getter for configuration instance
628          *
629          * @return      $configInstance         Configuration instance
630          */
631         public final function getConfigInstance () {
632                 $configInstance = Registry::getRegistry()->getInstance('config');
633                 return $configInstance;
634         }
635
636         /**
637          * Setter for debug instance
638          *
639          * @param       $debugInstance  The instance for debug output class
640          * @return      void
641          */
642         public final function setDebugInstance (DebugMiddleware $debugInstance) {
643                 Registry::getRegistry()->addInstance('debug', $debugInstance);
644         }
645
646         /**
647          * Getter for debug instance
648          *
649          * @return      $debugInstance  Instance to class DebugConsoleOutput or DebugWebOutput
650          */
651         public final function getDebugInstance () {
652                 // Get debug instance
653                 $debugInstance = Registry::getRegistry()->getInstance('debug');
654
655                 // Return it
656                 return $debugInstance;
657         }
658
659         /**
660          * Setter for web output instance
661          *
662          * @param       $webInstance    The instance for web output class
663          * @return      void
664          */
665         public final function setWebOutputInstance (OutputStreamer $webInstance) {
666                 Registry::getRegistry()->addInstance('web_output', $webInstance);
667         }
668
669         /**
670          * Getter for web output instance
671          *
672          * @return      $webOutputInstance - Instance to class WebOutput
673          */
674         public final function getWebOutputInstance () {
675                 $webOutputInstance = Registry::getRegistry()->getInstance('web_output');
676                 return $webOutputInstance;
677         }
678
679         /**
680          * Setter for database instance
681          *
682          * @param       $databaseInstance       The instance for the database connection (forced DatabaseConnection)
683          * @return      void
684          */
685         public final function setDatabaseInstance (DatabaseConnection $databaseInstance) {
686                 Registry::getRegistry()->addInstance('db_instance', $databaseInstance);
687         }
688
689         /**
690          * Getter for database layer
691          *
692          * @return      $databaseInstance       The database layer instance
693          */
694         public final function getDatabaseInstance () {
695                 // Get instance
696                 $databaseInstance = Registry::getRegistry()->getInstance('db_instance');
697
698                 // Return instance
699                 return $databaseInstance;
700         }
701
702         /**
703          * Setter for compressor channel
704          *
705          * @param       $compressorInstance             An instance of CompressorChannel
706          * @return      void
707          */
708         public final function setCompressorChannel (CompressorChannel $compressorInstance) {
709                 Registry::getRegistry()->addInstance('compressor', $compressorInstance);
710         }
711
712         /**
713          * Getter for compressor channel
714          *
715          * @return      $compressorInstance             The compressor channel
716          */
717         public final function getCompressorChannel () {
718                 $compressorInstance = Registry::getRegistry()->getInstance('compressor');
719                 return $compressorInstance;
720         }
721
722         /**
723          * Protected getter for a manageable application helper class
724          *
725          * @return      $applicationInstance    An instance of a manageable application helper class
726          */
727         protected final function getApplicationInstance () {
728                 $applicationInstance = Registry::getRegistry()->getInstance('application');
729                 return $applicationInstance;
730         }
731
732         /**
733          * Setter for a manageable application helper class
734          *
735          * @param       $applicationInstance    An instance of a manageable application helper class
736          * @return      void
737          */
738         public final function setApplicationInstance (ManageableApplication $applicationInstance) {
739                 Registry::getRegistry()->addInstance('application', $applicationInstance);
740         }
741
742         /**
743          * Setter for request instance
744          *
745          * @param       $requestInstance        An instance of a Requestable class
746          * @return      void
747          */
748         public final function setRequestInstance (Requestable $requestInstance) {
749                 $this->requestInstance = $requestInstance;
750         }
751
752         /**
753          * Getter for request instance
754          *
755          * @return      $requestInstance        An instance of a Requestable class
756          */
757         public final function getRequestInstance () {
758                 return $this->requestInstance;
759         }
760
761         /**
762          * Setter for response instance
763          *
764          * @param       $responseInstance       An instance of a Responseable class
765          * @return      void
766          */
767         public final function setResponseInstance (Responseable $responseInstance) {
768                 $this->responseInstance = $responseInstance;
769         }
770
771         /**
772          * Getter for response instance
773          *
774          * @return      $responseInstance       An instance of a Responseable class
775          */
776         public final function getResponseInstance () {
777                 return $this->responseInstance;
778         }
779
780         /**
781          * Private getter for language instance
782          *
783          * @return      $langInstance   An instance to the language sub-system
784          */
785         protected final function getLanguageInstance () {
786                 $langInstance = Registry::getRegistry()->getInstance('language');
787                 return $langInstance;
788         }
789
790         /**
791          * Setter for language instance
792          *
793          * @param       $langInstance   An instance to the language sub-system
794          * @return      void
795          * @see         LanguageSystem
796          */
797         public final function setLanguageInstance (ManageableLanguage $langInstance) {
798                 Registry::getRegistry()->addInstance('language', $langInstance);
799         }
800
801         /**
802          * Private getter for file IO instance
803          *
804          * @return      $fileIoInstance         An instance to the file I/O sub-system
805          */
806         protected final function getFileIoInstance () {
807                 return $this->fileIoInstance;
808         }
809
810         /**
811          * Setter for file I/O instance
812          *
813          * @param       $fileIoInstance         An instance to the file I/O sub-system
814          * @return      void
815          */
816         public final function setFileIoInstance (IoHandler $fileIoInstance) {
817                 $this->fileIoInstance = $fileIoInstance;
818         }
819
820         /**
821          * Protected setter for user instance
822          *
823          * @param       $userInstance   An instance of a user class
824          * @return      void
825          */
826         protected final function setUserInstance (ManageableAccount $userInstance) {
827                 $this->userInstance = $userInstance;
828         }
829
830         /**
831          * Getter for user instance
832          *
833          * @return      $userInstance   An instance of a user class
834          */
835         public final function getUserInstance () {
836                 return $this->userInstance;
837         }
838
839         /**
840          * Setter for controller instance (this surely breaks a bit the MVC patterm)
841          *
842          * @param       $controllerInstance             An instance of the controller
843          * @return      void
844          */
845         public final function setControllerInstance (Controller $controllerInstance) {
846                 $this->controllerInstance = $controllerInstance;
847         }
848
849         /**
850          * Getter for controller instance (this surely breaks a bit the MVC patterm)
851          *
852          * @return      $controllerInstance             An instance of the controller
853          */
854         public final function getControllerInstance () {
855                 return $this->controllerInstance;
856         }
857
858         /**
859          * Setter for RNG instance
860          *
861          * @param       $rngInstance    An instance of a random number generator (RNG)
862          * @return      void
863          */
864         protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
865                 $this->rngInstance = $rngInstance;
866         }
867
868         /**
869          * Getter for RNG instance
870          *
871          * @return      $rngInstance    An instance of a random number generator (RNG)
872          */
873         public final function getRngInstance () {
874                 return $this->rngInstance;
875         }
876
877         /**
878          * Setter for Cryptable instance
879          *
880          * @param       $cryptoInstance An instance of a Cryptable class
881          * @return      void
882          */
883         protected final function setCryptoInstance (Cryptable $cryptoInstance) {
884                 $this->cryptoInstance = $cryptoInstance;
885         }
886
887         /**
888          * Getter for Cryptable instance
889          *
890          * @return      $cryptoInstance An instance of a Cryptable class
891          */
892         public final function getCryptoInstance () {
893                 return $this->cryptoInstance;
894         }
895
896         /**
897          * Setter for the list instance
898          *
899          * @param       $listInstance   A list of Listable
900          * @return      void
901          */
902         protected final function setListInstance (Listable $listInstance) {
903                 $this->listInstance = $listInstance;
904         }
905
906         /**
907          * Getter for the list instance
908          *
909          * @return      $listInstance   A list of Listable
910          */
911         protected final function getListInstance () {
912                 return $this->listInstance;
913         }
914
915         /**
916          * Setter for the menu instance
917          *
918          * @param       $menuInstance   A RenderableMenu instance
919          * @return      void
920          */
921         protected final function setMenuInstance (RenderableMenu $menuInstance) {
922                 $this->menuInstance = $menuInstance;
923         }
924
925         /**
926          * Getter for the menu instance
927          *
928          * @return      $menuInstance   A RenderableMenu instance
929          */
930         protected final function getMenuInstance () {
931                 return $this->menuInstance;
932         }
933
934         /**
935          * Setter for image instance
936          *
937          * @param       $imageInstance  An instance of an image
938          * @return      void
939          */
940         public final function setImageInstance (BaseImage $imageInstance) {
941                 $this->imageInstance = $imageInstance;
942         }
943
944         /**
945          * Getter for image instance
946          *
947          * @return      $imageInstance  An instance of an image
948          */
949         public final function getImageInstance () {
950                 return $this->imageInstance;
951         }
952
953         /**
954          * Setter for stacker instance
955          *
956          * @param       $stackerInstance        An instance of an stacker
957          * @return      void
958          */
959         public final function setStackerInstance (Stackable $stackerInstance) {
960                 $this->stackerInstance = $stackerInstance;
961         }
962
963         /**
964          * Getter for stacker instance
965          *
966          * @return      $stackerInstance        An instance of an stacker
967          */
968         public final function getStackerInstance () {
969                 return $this->stackerInstance;
970         }
971
972         /**
973          * Setter for compressor instance
974          *
975          * @param       $compressorInstance     An instance of an compressor
976          * @return      void
977          */
978         public final function setCompressorInstance (Compressor $compressorInstance) {
979                 $this->compressorInstance = $compressorInstance;
980         }
981
982         /**
983          * Getter for compressor instance
984          *
985          * @return      $compressorInstance     An instance of an compressor
986          */
987         public final function getCompressorInstance () {
988                 return $this->compressorInstance;
989         }
990
991         /**
992          * Setter for Parseable instance
993          *
994          * @param       $parserInstance An instance of an Parseable
995          * @return      void
996          */
997         public final function setParserInstance (Parseable $parserInstance) {
998                 $this->parserInstance = $parserInstance;
999         }
1000
1001         /**
1002          * Getter for Parseable instance
1003          *
1004          * @return      $parserInstance An instance of an Parseable
1005          */
1006         public final function getParserInstance () {
1007                 return $this->parserInstance;
1008         }
1009
1010         /**
1011          * Setter for ProtocolHandler instance
1012          *
1013          * @param       $protocolInstance       An instance of an ProtocolHandler
1014          * @return      void
1015          */
1016         public final function setProtocolInstance (ProtocolHandler $protocolInstance = NULL) {
1017                 $this->protocolInstance = $protocolInstance;
1018         }
1019
1020         /**
1021          * Getter for ProtocolHandler instance
1022          *
1023          * @return      $protocolInstance       An instance of an ProtocolHandler
1024          */
1025         public final function getProtocolInstance () {
1026                 return $this->protocolInstance;
1027         }
1028
1029         /**
1030          * Setter for DatabaseWrapper instance
1031          *
1032          * @param       $wrapperInstance        An instance of an DatabaseWrapper
1033          * @return      void
1034          */
1035         public final function setWrapperInstance (DatabaseWrapper $wrapperInstance) {
1036                 $this->wrapperInstance = $wrapperInstance;
1037         }
1038
1039         /**
1040          * Getter for DatabaseWrapper instance
1041          *
1042          * @return      $wrapperInstance        An instance of an DatabaseWrapper
1043          */
1044         public final function getWrapperInstance () {
1045                 return $this->wrapperInstance;
1046         }
1047
1048         /**
1049          * Setter for socket resource
1050          *
1051          * @param       $socketResource         A valid socket resource
1052          * @return      void
1053          */
1054         public final function setSocketResource ($socketResource) {
1055                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource);
1056                 $this->socketResource = $socketResource;
1057         }
1058
1059         /**
1060          * Getter for socket resource
1061          *
1062          * @return      $socketResource         A valid socket resource
1063          */
1064         public final function getSocketResource () {
1065                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource);
1066                 return $this->socketResource;
1067         }
1068
1069         /**
1070          * Setter for helper instance
1071          *
1072          * @param       $helperInstance         An instance of a helper class
1073          * @return      void
1074          */
1075         protected final function setHelperInstance (Helper $helperInstance) {
1076                 $this->helperInstance = $helperInstance;
1077         }
1078
1079         /**
1080          * Getter for helper instance
1081          *
1082          * @return      $helperInstance         An instance of a helper class
1083          */
1084         public final function getHelperInstance () {
1085                 return $this->helperInstance;
1086         }
1087
1088         /**
1089          * Setter for a Sourceable instance
1090          *
1091          * @param       $sourceInstance The Sourceable instance
1092          * @return      void
1093          */
1094         protected final function setSourceInstance (Sourceable $sourceInstance) {
1095                 $this->sourceInstance = $sourceInstance;
1096         }
1097
1098         /**
1099          * Getter for a Sourceable instance
1100          *
1101          * @return      $sourceInstance The Sourceable instance
1102          */
1103         protected final function getSourceInstance () {
1104                 return $this->sourceInstance;
1105         }
1106
1107         /**
1108          * Getter for a InputStream instance
1109          *
1110          * @param       $inputStreamInstance    The InputStream instance
1111          */
1112         protected final function getInputStreamInstance () {
1113                 return $this->inputStreamInstance;
1114         }
1115
1116         /**
1117          * Setter for a InputStream instance
1118          *
1119          * @param       $inputStreamInstance    The InputStream instance
1120          * @return      void
1121          */
1122         protected final function setInputStreamInstance (InputStream $inputStreamInstance) {
1123                 $this->inputStreamInstance = $inputStreamInstance;
1124         }
1125
1126         /**
1127          * Getter for a OutputStream instance
1128          *
1129          * @param       $outputStreamInstance   The OutputStream instance
1130          */
1131         protected final function getOutputStreamInstance () {
1132                 return $this->outputStreamInstance;
1133         }
1134
1135         /**
1136          * Setter for a OutputStream instance
1137          *
1138          * @param       $outputStreamInstance   The OutputStream instance
1139          * @return      void
1140          */
1141         protected final function setOutputStreamInstance (OutputStream $outputStreamInstance) {
1142                 $this->outputStreamInstance = $outputStreamInstance;
1143         }
1144
1145         /**
1146          * Setter for handler instance
1147          *
1148          * @param       $handlerInstance        An instance of a Handleable class
1149          * @return      void
1150          */
1151         protected final function setHandlerInstance (Handleable $handlerInstance) {
1152                 $this->handlerInstance = $handlerInstance;
1153         }
1154
1155         /**
1156          * Getter for handler instance
1157          *
1158          * @return      $handlerInstance        A Networkable instance
1159          */
1160         protected final function getHandlerInstance () {
1161                 return $this->handlerInstance;
1162         }
1163
1164         /**
1165          * Setter for visitor instance
1166          *
1167          * @param       $visitorInstance        A Visitor instance
1168          * @return      void
1169          */
1170         protected final function setVisitorInstance (Visitor $visitorInstance) {
1171                 $this->visitorInstance = $visitorInstance;
1172         }
1173
1174         /**
1175          * Getter for visitor instance
1176          *
1177          * @return      $visitorInstance        A Visitor instance
1178          */
1179         protected final function getVisitorInstance () {
1180                 return $this->visitorInstance;
1181         }
1182
1183         /**
1184          * Setter for DHT instance
1185          *
1186          * @param       $dhtInstance    A Distributable instance
1187          * @return      void
1188          */
1189         protected final function setDhtInstance (Distributable $dhtInstance) {
1190                 $this->dhtInstance = $dhtInstance;
1191         }
1192
1193         /**
1194          * Getter for DHT instance
1195          *
1196          * @return      $dhtInstance    A Distributable instance
1197          */
1198         protected final function getDhtInstance () {
1199                 return $this->dhtInstance;
1200         }
1201
1202         /**
1203          * Setter for raw package Data
1204          *
1205          * @param       $packageData    Raw package Data
1206          * @return      void
1207          */
1208         public final function setPackageData (array $packageData) {
1209                 $this->packageData = $packageData;
1210         }
1211
1212         /**
1213          * Getter for raw package Data
1214          *
1215          * @return      $packageData    Raw package Data
1216          */
1217         public function getPackageData () {
1218                 return $this->packageData;
1219         }
1220
1221
1222         /**
1223          * Setter for Iterator instance
1224          *
1225          * @param       $iteratorInstance       An instance of an Iterator
1226          * @return      void
1227          */
1228         protected final function setIteratorInstance (Iterator $iteratorInstance) {
1229                 $this->iteratorInstance = $iteratorInstance;
1230         }
1231
1232         /**
1233          * Getter for Iterator instance
1234          *
1235          * @return      $iteratorInstance       An instance of an Iterator
1236          */
1237         public final function getIteratorInstance () {
1238                 return $this->iteratorInstance;
1239         }
1240
1241         /**
1242          * Setter for InputOutputPointer instance
1243          *
1244          * @param       $pointerInstance        An instance of an InputOutputPointer class
1245          * @return      void
1246          */
1247         protected final function setPointerInstance (InputOutputPointer $pointerInstance) {
1248                 $this->pointerInstance = $pointerInstance;
1249         }
1250
1251         /**
1252          * Getter for InputOutputPointer instance
1253          *
1254          * @return      $pointerInstance        An instance of an InputOutputPointer class
1255          */
1256         public final function getPointerInstance () {
1257                 return $this->pointerInstance;
1258         }
1259
1260         /**
1261          * Setter for Indexable instance
1262          *
1263          * @param       $indexInstance  An instance of an Indexable class
1264          * @return      void
1265          */
1266         protected final function setIndexInstance (Indexable $indexInstance) {
1267                 $this->indexInstance = $indexInstance;
1268         }
1269
1270         /**
1271          * Getter for Indexable instance
1272          *
1273          * @return      $indexInstance  An instance of an Indexable class
1274          */
1275         public final function getIndexInstance () {
1276                 return $this->indexInstance;
1277         }
1278
1279         /**
1280          * Setter for Block instance
1281          *
1282          * @param       $blockInstance  An instance of an Block class
1283          * @return      void
1284          */
1285         protected final function setBlockInstance (Block $blockInstance) {
1286                 $this->blockInstance = $blockInstance;
1287         }
1288
1289         /**
1290          * Getter for Block instance
1291          *
1292          * @return      $blockInstance  An instance of an Block class
1293          */
1294         public final function getBlockInstance () {
1295                 return $this->blockInstance;
1296         }
1297
1298         /**
1299          * Checks whether an object equals this object. You should overwrite this
1300          * method to implement own equality checks
1301          *
1302          * @param       $objectInstance         An instance of a FrameworkInterface object
1303          * @return      $equals                         Whether both objects equals
1304          */
1305         public function equals (FrameworkInterface $objectInstance) {
1306                 // Now test it
1307                 $equals = ((
1308                         $this->__toString() == $objectInstance->__toString()
1309                 ) && (
1310                         $this->hashCode() == $objectInstance->hashCode()
1311                 ));
1312
1313                 // Return the result
1314                 return $equals;
1315         }
1316
1317         /**
1318          * Generates a generic hash code of this class. You should really overwrite
1319          * this method with your own hash code generator code. But keep KISS in mind.
1320          *
1321          * @return      $hashCode       A generic hash code respresenting this whole class
1322          */
1323         public function hashCode () {
1324                 // Simple hash code
1325                 return crc32($this->__toString());
1326         }
1327
1328         /**
1329          * Formats computer generated price values into human-understandable formats
1330          * with thousand and decimal separators.
1331          *
1332          * @param       $value          The in computer format value for a price
1333          * @param       $currency       The currency symbol (use HTML-valid characters!)
1334          * @param       $decNum         Number of decimals after commata
1335          * @return      $price          The for the current language formated price string
1336          * @throws      MissingDecimalsThousandsSeparatorException      If decimals or
1337          *                                                                                              thousands separator
1338          *                                                                                              is missing
1339          */
1340         public function formatCurrency ($value, $currency = '&euro;', $decNum = 2) {
1341                 // Are all required attriutes set?
1342                 if ((!isset($this->decimals)) || (!isset($this->thousands))) {
1343                         // Throw an exception
1344                         throw new MissingDecimalsThousandsSeparatorException($this, self::EXCEPTION_ATTRIBUTES_ARE_MISSING);
1345                 } // END - if
1346
1347                 // Cast the number
1348                 $value = (float) $value;
1349
1350                 // Reformat the US number
1351                 $price = number_format($value, $decNum, $this->decimals, $this->thousands) . $currency;
1352
1353                 // Return as string...
1354                 return $price;
1355         }
1356
1357         /**
1358          * Appends a trailing slash to a string
1359          *
1360          * @param       $str    A string (maybe) without trailing slash
1361          * @return      $str    A string with an auto-appended trailing slash
1362          */
1363         public final function addMissingTrailingSlash ($str) {
1364                 // Is there a trailing slash?
1365                 if (substr($str, -1, 1) != '/') {
1366                         $str .= '/';
1367                 } // END - if
1368
1369                 // Return string with trailing slash
1370                 return $str;
1371         }
1372
1373         /**
1374          * Prepare the template engine (WebTemplateEngine by default) for a given
1375          * application helper instance (ApplicationHelper by default).
1376          *
1377          * @param               $applicationInstance    An application helper instance or
1378          *                                                                              null if we shall use the default
1379          * @return              $templateInstance               The template engine instance
1380          * @throws              NullPointerException    If the discovered application
1381          *                                                                              instance is still null
1382          */
1383         protected function prepareTemplateInstance (ManageableApplication $applicationInstance = NULL) {
1384                 // Is the application instance set?
1385                 if (is_null($applicationInstance)) {
1386                         // Get the current instance
1387                         $applicationInstance = $this->getApplicationInstance();
1388
1389                         // Still null?
1390                         if (is_null($applicationInstance)) {
1391                                 // Thrown an exception
1392                                 throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
1393                         } // END - if
1394                 } // END - if
1395
1396                 // Initialize the template engine
1397                 $templateInstance = ObjectFactory::createObjectByConfiguredName('web_template_class');
1398
1399                 // Return the prepared instance
1400                 return $templateInstance;
1401         }
1402
1403         /**
1404          * Debugs this instance by putting out it's full content
1405          *
1406          * @param       $message        Optional message to show in debug output
1407          * @return      void
1408          */
1409         public final function debugInstance ($message = '') {
1410                 // Restore the error handler to avoid trouble with missing array elements or undeclared variables
1411                 restore_error_handler();
1412
1413                 // Init content
1414                 $content = '';
1415
1416                 // Is a message set?
1417                 if (!empty($message)) {
1418                         // Construct message
1419                         $content = sprintf('<div class="debug_message">Message: %s</div>' . PHP_EOL, $message);
1420                 } // END - if
1421
1422                 // Generate the output
1423                 $content .= sprintf('<pre>%s</pre>',
1424                         trim(
1425                                 htmlentities(
1426                                         print_r($this, TRUE)
1427                                 )
1428                         )
1429                 );
1430
1431                 // Output it
1432                 ApplicationEntryPoint::app_exit(sprintf('<div class="debug_header">%s debug output:</div><div class="debug_content">%s</div>Loaded includes: <div class="debug_include_list">%s</div>',
1433                         $this->__toString(),
1434                         $content,
1435                         ClassLoader::getSelfInstance()->getPrintableIncludeList()
1436                 ));
1437         }
1438
1439         /**
1440          * Replaces control characters with printable output
1441          *
1442          * @param       $str    String with control characters
1443          * @return      $str    Replaced string
1444          */
1445         protected function replaceControlCharacters ($str) {
1446                 // Replace them
1447                 $str = str_replace(
1448                         chr(13), '[r]', str_replace(
1449                         chr(10), '[n]', str_replace(
1450                         chr(9) , '[t]',
1451                         $str
1452                 )));
1453
1454                 // Return it
1455                 return $str;
1456         }
1457
1458         /**
1459          * Output a partial stub message for the caller method
1460          *
1461          * @param       $message        An optional message to display
1462          * @return      void
1463          */
1464         protected function partialStub ($message = '') {
1465                 // Get the backtrace
1466                 $backtrace = debug_backtrace();
1467
1468                 // Generate the class::method string
1469                 $methodName = 'UnknownClass-&gt;unknownMethod';
1470                 if ((isset($backtrace[1]['class'])) && (isset($backtrace[1]['function']))) {
1471                         $methodName = $backtrace[1]['class'] . '-&gt;' . $backtrace[1]['function'];
1472                 } // END - if
1473
1474                 // Construct the full message
1475                 $stubMessage = sprintf('[%s:] Partial stub!',
1476                         $methodName
1477                 );
1478
1479                 // Is the extra message given?
1480                 if (!empty($message)) {
1481                         // Then add it as well
1482                         $stubMessage .= ' Message: ' . $message;
1483                 } // END - if
1484
1485                 // Debug instance is there?
1486                 if (!is_null($this->getDebugInstance())) {
1487                         // Output stub message
1488                         self::createDebugInstance(__CLASS__)->debugOutput($stubMessage);
1489                 } else {
1490                         // Trigger an error
1491                         trigger_error($stubMessage);
1492                         exit;
1493                 }
1494         }
1495
1496         /**
1497          * Outputs a debug backtrace and stops further script execution
1498          *
1499          * @param       $message        An optional message to output
1500          * @param       $doExit         Whether exit the program (TRUE is default)
1501          * @return      void
1502          */
1503         public function debugBackTrace ($message = '', $doExit = TRUE) {
1504                 // Sorry, there is no other way getting this nice backtrace
1505                 if (!empty($message)) {
1506                         // Output message
1507                         printf('Message: %s<br />' . chr(10), $message);
1508                 } // END - if
1509
1510                 print('<pre>');
1511                 debug_print_backtrace();
1512                 print('</pre>');
1513
1514                 // Exit program?
1515                 if ($doExit === TRUE) {
1516                         exit();
1517                 } // END - if
1518         }
1519
1520         /**
1521          * Creates an instance of a debugger instance
1522          *
1523          * @param       $className              Name of the class (currently unsupported)
1524          * @return      $debugInstance  An instance of a debugger class
1525          */
1526         public final static function createDebugInstance ($className) {
1527                 // Is the instance set?
1528                 if (!Registry::getRegistry()->instanceExists('debug')) {
1529                         // Init debug instance
1530                         $debugInstance = NULL;
1531
1532                         // Try it
1533                         try {
1534                                 // Get a debugger instance
1535                                 $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_class'));
1536                         } catch (NullPointerException $e) {
1537                                 // Didn't work, no instance there
1538                                 exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage());
1539                         }
1540
1541                         // Empty string should be ignored and used for testing the middleware
1542                         DebugMiddleware::getSelfInstance()->output('');
1543
1544                         // Set it in its own class. This will set it in the registry
1545                         $debugInstance->setDebugInstance($debugInstance);
1546                 } else {
1547                         // Get instance from registry
1548                         $debugInstance = Registry::getRegistry()->getDebugInstance();
1549                 }
1550
1551                 // Return it
1552                 return $debugInstance;
1553         }
1554
1555         /**
1556          * Simple output of a message with line-break
1557          *
1558          * @param       $message        Message to output
1559          * @return      void
1560          */
1561         public function outputLine ($message) {
1562                 // Simply output it
1563                 print($message . PHP_EOL);
1564         }
1565
1566         /**
1567          * Outputs a debug message whether to debug instance (should be set!) or
1568          * dies with or ptints the message. Do NEVER EVER rewrite the exit() call to
1569          * ApplicationEntryPoint::app_exit(), this would cause an endless loop.
1570          *
1571          * @param       $message        Message we shall send out...
1572          * @param       $doPrint        Whether print or die here (default: print)
1573          * @paran       $stripTags      Whether to strip tags (default: FALSE)
1574          * @return      void
1575          */
1576         public function debugOutput ($message, $doPrint = TRUE, $stripTags = FALSE) {
1577                 // Set debug instance to NULL
1578                 $debugInstance = NULL;
1579
1580                 // Try it:
1581                 try {
1582                         // Get debug instance
1583                         $debugInstance = $this->getDebugInstance();
1584                 } catch (NullPointerException $e) {
1585                         // The debug instance is not set (yet)
1586                 }
1587
1588                 // Is the debug instance there?
1589                 if (is_object($debugInstance)) {
1590                         // Use debug output handler
1591                         $debugInstance->output($message, $stripTags);
1592
1593                         if ($doPrint === FALSE) {
1594                                 // Die here if not printed
1595                                 exit();
1596                         } // END - if
1597                 } else {
1598                         // Are debug times enabled?
1599                         if ($this->getConfigInstance()->getConfigEntry('debug_output_timings') == 'Y') {
1600                                 // Prepent it
1601                                 $message = $this->getPrintableExecutionTime() . $message;
1602                         } // END - if
1603
1604                         // Put directly out
1605                         if ($doPrint === TRUE) {
1606                                 // Print message
1607                                 $this->outputLine($message);
1608                         } else {
1609                                 // Die here
1610                                 exit($message);
1611                         }
1612                 }
1613         }
1614
1615         /**
1616          * Converts e.g. a command from URL to a valid class by keeping out bad characters
1617          *
1618          * @param       $str            The string, what ever it is needs to be converted
1619          * @return      $className      Generated class name
1620          */
1621         public function convertToClassName ($str) {
1622                 // Init class name
1623                 $className = '';
1624
1625                 // Convert all dashes in underscores
1626                 $str = $this->convertDashesToUnderscores($str);
1627
1628                 // Now use that underscores to get classname parts for hungarian style
1629                 foreach (explode('_', $str) as $strPart) {
1630                         // Make the class name part lower case and first upper case
1631                         $className .= ucfirst(strtolower($strPart));
1632                 } // END - foreach
1633
1634                 // Return class name
1635                 return $className;
1636         }
1637
1638         /**
1639          * Converts dashes to underscores, e.g. useable for configuration entries
1640          *
1641          * @param       $str    The string with maybe dashes inside
1642          * @return      $str    The converted string with no dashed, but underscores
1643          */
1644         public final function convertDashesToUnderscores ($str) {
1645                 // Convert them all
1646                 $str = str_replace('-', '_', $str);
1647
1648                 // Return converted string
1649                 return $str;
1650         }
1651
1652         /**
1653          * Marks up the code by adding e.g. line numbers
1654          *
1655          * @param       $phpCode                Unmarked PHP code
1656          * @return      $markedCode             Marked PHP code
1657          */
1658         public function markupCode ($phpCode) {
1659                 // Init marked code
1660                 $markedCode = '';
1661
1662                 // Get last error
1663                 $errorArray = error_get_last();
1664
1665                 // Init the code with error message
1666                 if (is_array($errorArray)) {
1667                         // Get error infos
1668                         $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>',
1669                                 basename($errorArray['file']),
1670                                 $errorArray['line'],
1671                                 $errorArray['message'],
1672                                 $errorArray['type']
1673                         );
1674                 } // END - if
1675
1676                 // Add line number to the code
1677                 foreach (explode(chr(10), $phpCode) as $lineNo => $code) {
1678                         // Add line numbers
1679                         $markedCode .= sprintf('<span id="code_line">%s</span>: %s' . chr(10),
1680                                 ($lineNo + 1),
1681                                 htmlentities($code, ENT_QUOTES)
1682                         );
1683                 } // END - foreach
1684
1685                 // Return the code
1686                 return $markedCode;
1687         }
1688
1689         /**
1690          * Filter a given GMT timestamp (non Uni* stamp!) to make it look more
1691          * beatiful for web-based front-ends. If null is given a message id
1692          * null_timestamp will be resolved and returned.
1693          *
1694          * @param       $timestamp      Timestamp to prepare (filter) for display
1695          * @return      $readable       A readable timestamp
1696          */
1697         public function doFilterFormatTimestamp ($timestamp) {
1698                 // Default value to return
1699                 $readable = '???';
1700
1701                 // Is the timestamp null?
1702                 if (is_null($timestamp)) {
1703                         // Get a message string
1704                         $readable = $this->getLanguageInstance()->getMessage('null_timestamp');
1705                 } else {
1706                         switch ($this->getLanguageInstance()->getLanguageCode()) {
1707                                 case 'de': // German format is a bit different to default
1708                                         // Split the GMT stamp up
1709                                         $dateTime  = explode(' ', $timestamp  );
1710                                         $dateArray = explode('-', $dateTime[0]);
1711                                         $timeArray = explode(':', $dateTime[1]);
1712
1713                                         // Construct the timestamp
1714                                         $readable = sprintf($this->getConfigInstance()->getConfigEntry('german_date_time'),
1715                                                 $dateArray[0],
1716                                                 $dateArray[1],
1717                                                 $dateArray[2],
1718                                                 $timeArray[0],
1719                                                 $timeArray[1],
1720                                                 $timeArray[2]
1721                                         );
1722                                         break;
1723
1724                                 default: // Default is pass-through
1725                                         $readable = $timestamp;
1726                                         break;
1727                         } // END - switch
1728                 }
1729
1730                 // Return the stamp
1731                 return $readable;
1732         }
1733
1734         /**
1735          * Filter a given number into a localized number
1736          *
1737          * @param       $value          The raw value from e.g. database
1738          * @return      $localized      Localized value
1739          */
1740         public function doFilterFormatNumber ($value) {
1741                 // Generate it from config and localize dependencies
1742                 switch ($this->getLanguageInstance()->getLanguageCode()) {
1743                         case 'de': // German format is a bit different to default
1744                                 $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), ',', '.');
1745                                 break;
1746
1747                         default: // US, etc.
1748                                 $localized = number_format($value, $this->getConfigInstance()->getConfigEntry('decimals'), '.', ',');
1749                                 break;
1750                 } // END - switch
1751
1752                 // Return it
1753                 return $localized;
1754         }
1755
1756         /**
1757          * "Getter" for databse entry
1758          *
1759          * @return      $entry  An array with database entries
1760          * @throws      NullPointerException    If the database result is not found
1761          * @throws      InvalidDatabaseResultException  If the database result is invalid
1762          */
1763         protected final function getDatabaseEntry () {
1764                 // Is there an instance?
1765                 if (is_null($this->getResultInstance())) {
1766                         // Throw an exception here
1767                         throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
1768                 } // END - if
1769
1770                 // Rewind it
1771                 $this->getResultInstance()->rewind();
1772
1773                 // Do we have an entry?
1774                 if ($this->getResultInstance()->valid() === FALSE) {
1775                         throw new InvalidDatabaseResultException(array($this, $this->getResultInstance()), DatabaseResult::EXCEPTION_INVALID_DATABASE_RESULT);
1776                 } // END - if
1777
1778                 // Get next entry
1779                 $this->getResultInstance()->next();
1780
1781                 // Fetch it
1782                 $entry = $this->getResultInstance()->current();
1783
1784                 // And return it
1785                 return $entry;
1786         }
1787
1788         /**
1789          * Getter for field name
1790          *
1791          * @param       $fieldName              Field name which we shall get
1792          * @return      $fieldValue             Field value from the user
1793          * @throws      NullPointerException    If the result instance is null
1794          */
1795         public final function getField ($fieldName) {
1796                 // Default field value
1797                 $fieldValue = NULL;
1798
1799                 // Get result instance
1800                 $resultInstance = $this->getResultInstance();
1801
1802                 // Is this instance null?
1803                 if (is_null($resultInstance)) {
1804                         // Then the user instance is no longer valid (expired cookies?)
1805                         throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
1806                 } // END - if
1807
1808                 // Get current array
1809                 $fieldArray = $resultInstance->current();
1810                 //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':<pre>'.print_r($fieldArray, TRUE).'</pre>');
1811
1812                 // Convert dashes to underscore
1813                 $fieldName = $this->convertDashesToUnderscores($fieldName);
1814
1815                 // Does the field exist?
1816                 if (isset($fieldArray[$fieldName])) {
1817                         // Get it
1818                         $fieldValue = $fieldArray[$fieldName];
1819                 } else {
1820                         // Missing field entry, may require debugging
1821                         self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ':fieldname=' . $fieldName . ' not found!');
1822                 }
1823
1824                 // Return it
1825                 return $fieldValue;
1826         }
1827
1828         /**
1829          * Flushs all pending updates to the database layer
1830          *
1831          * @return      void
1832          */
1833         public function flushPendingUpdates () {
1834                 // Get result instance
1835                 $resultInstance = $this->getResultInstance();
1836
1837                 // Do we have data to update?
1838                 if ((is_object($resultInstance)) && ($resultInstance->ifDataNeedsFlush())) {
1839                         // Get wrapper class name config entry
1840                         $configEntry = $resultInstance->getUpdateInstance()->getWrapperConfigEntry();
1841
1842                         // Create object instance
1843                         $wrapperInstance = ObjectFactory::createObjectByConfiguredName($configEntry);
1844
1845                         // Yes, then send the whole result to the database layer
1846                         $wrapperInstance->doUpdateByResult($this->getResultInstance());
1847                 } // END - if
1848         }
1849
1850         /**
1851          * Outputs a deprecation warning to the developer.
1852          *
1853          * @param       $message        The message we shall output to the developer
1854          * @return      void
1855          * @todo        Write a logging mechanism for productive mode
1856          */
1857         public function deprecationWarning ($message) {
1858                 // Is developer mode active?
1859                 if (defined('DEVELOPER')) {
1860                         // Debug instance is there?
1861                         if (!is_null($this->getDebugInstance())) {
1862                                 // Output stub message
1863                                 self::createDebugInstance(__CLASS__)->debugOutput($message);
1864                         } else {
1865                                 // Trigger an error
1866                                 trigger_error($message . "<br />\n");
1867                                 exit;
1868                         }
1869                 } else {
1870                         // @TODO Finish this part!
1871                         $this->partialStub('Developer mode inactive. Message:' . $message);
1872                 }
1873         }
1874
1875         /**
1876          * Checks whether the given PHP extension is loaded
1877          *
1878          * @param       $phpExtension   The PHP extension we shall check
1879          * @return      $isLoaded       Whether the PHP extension is loaded
1880          */
1881         public final function isPhpExtensionLoaded ($phpExtension) {
1882                 // Is it loaded?
1883                 $isLoaded = in_array($phpExtension, get_loaded_extensions());
1884
1885                 // Return result
1886                 return $isLoaded;
1887         }
1888
1889         /**
1890          * "Getter" as a time() replacement but with milliseconds. You should use this
1891          * method instead of the encapsulated getimeofday() function.
1892          *
1893          * @return      $milliTime      Timestamp with milliseconds
1894          */
1895         public function getMilliTime () {
1896                 // Get the time of day as float
1897                 $milliTime = gettimeofday(TRUE);
1898
1899                 // Return it
1900                 return $milliTime;
1901         }
1902
1903         /**
1904          * Idles (sleeps) for given milliseconds
1905          *
1906          * @return      $hasSlept       Whether it goes fine
1907          */
1908         public function idle ($milliSeconds) {
1909                 // Sleep is fine by default
1910                 $hasSlept = TRUE;
1911
1912                 // Idle so long with found function
1913                 if (function_exists('time_sleep_until')) {
1914                         // Get current time and add idle time
1915                         $sleepUntil = $this->getMilliTime() + abs($milliSeconds) / 1000;
1916
1917                         // New PHP 5.1.0 function found, ignore errors
1918                         $hasSlept = @time_sleep_until($sleepUntil);
1919                 } else {
1920                         /*
1921                          * My Sun station doesn't have that function even with latest PHP
1922                          * package. :(
1923                          */
1924                         usleep($milliSeconds * 1000);
1925                 }
1926
1927                 // Return result
1928                 return $hasSlept;
1929         }
1930         /**
1931          * Converts a hexadecimal string, even with negative sign as first string to
1932          * a decimal number using BC functions.
1933          *
1934          * This work is based on comment #86673 on php.net documentation page at:
1935          * <http://de.php.net/manual/en/function.dechex.php#86673>
1936          *
1937          * @param       $hex    Hexadecimal string
1938          * @return      $dec    Decimal number
1939          */
1940         protected function hex2dec ($hex) {
1941                 // Convert to all lower-case
1942                 $hex = strtolower($hex);
1943
1944                 // Detect sign (negative/positive numbers)
1945                 $sign = '';
1946                 if (substr($hex, 0, 1) == '-') {
1947                         $sign = '-';
1948                         $hex = substr($hex, 1);
1949                 } // END - if
1950
1951                 // Decode the hexadecimal string into a decimal number
1952                 $dec = 0;
1953                 for ($i = strlen($hex) - 1, $e = 1; $i >= 0; $i--, $e = bcmul($e, 16)) {
1954                         $factor = self::$hexdec[substr($hex, $i, 1)];
1955                         $dec = bcadd($dec, bcmul($factor, $e));
1956                 } // END - for
1957
1958                 // Return the decimal number
1959                 return $sign . $dec;
1960         }
1961
1962         /**
1963          * Converts even very large decimal numbers, also signed, to a hexadecimal
1964          * string.
1965          *
1966          * This work is based on comment #97756 on php.net documentation page at:
1967          * <http://de.php.net/manual/en/function.hexdec.php#97756>
1968          *
1969          * @param       $dec            Decimal number, even with negative sign
1970          * @param       $maxLength      Optional maximum length of the string
1971          * @return      $hex    Hexadecimal string
1972          */
1973         protected function dec2hex ($dec, $maxLength = 0) {
1974                 // maxLength can be zero or devideable by 2
1975                 assert(($maxLength == 0) || (($maxLength % 2) == 0));
1976
1977                 // Detect sign (negative/positive numbers)
1978                 $sign = '';
1979                 if ($dec < 0) {
1980                         $sign = '-';
1981                         $dec = abs($dec);
1982                 } // END - if
1983
1984                 // Encode the decimal number into a hexadecimal string
1985                 $hex = '';
1986                 do {
1987                         $hex = self::$dechex[($dec % (2 ^ 4))] . $hex;
1988                         $dec /= (2 ^ 4);
1989                 } while ($dec >= 1);
1990
1991                 /*
1992                  * Leading zeros are required for hex-decimal "numbers". In some
1993                  * situations more leading zeros are wanted, so check for both
1994                  * conditions.
1995                  */
1996                 if ($maxLength > 0) {
1997                         // Prepend more zeros
1998                         $hex = str_pad($hex, $maxLength, '0', STR_PAD_LEFT);
1999                 } elseif ((strlen($hex) % 2) != 0) {
2000                         // Only make string's length dividable by 2
2001                         $hex = '0' . $hex;
2002                 }
2003
2004                 // Return the hexadecimal string
2005                 return $sign . $hex;
2006         }
2007
2008         /**
2009          * Converts a ASCII string (0 to 255) into a decimal number.
2010          *
2011          * @param       $asc    The ASCII string to be converted
2012          * @return      $dec    Decimal number
2013          */
2014         protected function asc2dec ($asc) {
2015                 // Convert it into a hexadecimal number
2016                 $hex = bin2hex($asc);
2017
2018                 // And back into a decimal number
2019                 $dec = $this->hex2dec($hex);
2020
2021                 // Return it
2022                 return $dec;
2023         }
2024
2025         /**
2026          * Converts a decimal number into an ASCII string.
2027          *
2028          * @param       $dec            Decimal number
2029          * @return      $asc    An ASCII string
2030          */
2031         protected function dec2asc ($dec) {
2032                 // First convert the number into a hexadecimal string
2033                 $hex = $this->dec2hex($dec);
2034
2035                 // Then convert it into the ASCII string
2036                 $asc = $this->hex2asc($hex);
2037
2038                 // Return it
2039                 return $asc;
2040         }
2041
2042         /**
2043          * Converts a hexadecimal number into an ASCII string. Negative numbers
2044          * are not allowed.
2045          *
2046          * @param       $hex    Hexadecimal string
2047          * @return      $asc    An ASCII string
2048          */
2049         protected function hex2asc ($hex) {
2050                 // Check for length, it must be devideable by 2
2051                 //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex);
2052                 assert((strlen($hex) % 2) == 0);
2053
2054                 // Walk the string
2055                 $asc = '';
2056                 for ($idx = 0; $idx < strlen($hex); $idx+=2) {
2057                         // Get the decimal number of the chunk
2058                         $part = hexdec(substr($hex, $idx, 2));
2059
2060                         // Add it to the final string
2061                         $asc .= chr($part);
2062                 } // END - for
2063
2064                 // Return the final string
2065                 return $asc;
2066         }
2067
2068         /**
2069          * Checks whether the given encoded data was encoded with Base64
2070          *
2071          * @param       $encodedData    Encoded data we shall check
2072          * @return      $isBase64               Whether the encoded data is Base64
2073          */
2074         protected function isBase64Encoded ($encodedData) {
2075                 // Determine it
2076                 $isBase64 = (@base64_decode($encodedData, TRUE) !== FALSE);
2077
2078                 // Return it
2079                 return $isBase64;
2080         }
2081
2082         /**
2083          * "Getter" to get response/request type from analysis of the system.
2084          *
2085          * @return      $responseType   Analyzed response type
2086          */
2087         protected function getResponseTypeFromSystem () {
2088                 // Default is console
2089                 $responseType = 'console';
2090
2091                 // Is 'HTTP_HOST' set?
2092                 if (isset($_SERVER['HTTP_HOST'])) {
2093                         // Then it is a HTTP response/request
2094                         $responseType = 'http';
2095                 } // END - if
2096
2097                 // Return it
2098                 return $responseType;
2099         }
2100
2101         /**
2102          * Gets a cache key from Criteria instance
2103          *
2104          * @param       $criteriaInstance       An instance of a Criteria class
2105          * @param       $onlyKeys                       Only use these keys for a cache key
2106          * @return      $cacheKey                       A cache key suitable for lookup/storage purposes
2107          */
2108         protected function getCacheKeyByCriteria (Criteria $criteriaInstance, array $onlyKeys = array()) {
2109                 // Generate it
2110                 $cacheKey = sprintf('%s@%s',
2111                         $this->__toString(),
2112                         $criteriaInstance->getCacheKey($onlyKeys)
2113                 );
2114
2115                 // And return it
2116                 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey);
2117                 return $cacheKey;
2118         }
2119
2120         /**
2121          * Getter for startup time in miliseconds
2122          *
2123          * @return      $startupTime    Startup time in miliseconds
2124          */
2125         protected function getStartupTime () {
2126                 return self::$startupTime;
2127         }
2128
2129         /**
2130          * "Getter" for a printable currently execution time in nice braces
2131          *
2132          * @return      $executionTime  Current execution time in nice braces
2133          */
2134         protected function getPrintableExecutionTime () {
2135                 // Caculate the execution time
2136                 $executionTime = microtime(TRUE) - $this->getStartupTime();
2137
2138                 // Pack it in nice braces
2139                 $executionTime = sprintf('[ %01.5f ] ', $executionTime);
2140
2141                 // And return it
2142                 return $executionTime;
2143         }
2144
2145         /**
2146          * Hashes a given string with a simple but stronger hash function (no salt)
2147          * and hex-encode it.
2148          *
2149          * @param       $str    The string to be hashed
2150          * @return      $hash   The hash from string $str
2151          */
2152         public static final function hash ($str) {
2153                 // Hash given string with (better secure) hasher
2154                 $hash = bin2hex(mhash(MHASH_SHA256, $str));
2155
2156                 // Return it
2157                 return $hash;
2158         }
2159
2160         /**
2161          * "Getter" for length of hash() output. This will be "cached" to speed up
2162          * things.
2163          *
2164          * @return      $length         Length of hash() output
2165          */
2166         public static final function getHashLength () {
2167                 // Is it cashed?
2168                 if (is_null(self::$hashLength)) {
2169                         // No, then hash a string and save its length.
2170                         self::$hashLength = strlen(self::hash('abc123'));
2171                 } // END - if
2172
2173                 // Return it
2174                 return self::$hashLength;
2175         }
2176
2177         /**
2178          * Checks whether the given number is really a number (only chars 0-9).
2179          *
2180          * @param       $num            A string consisting only chars between 0 and 9
2181          * @param       $castValue      Whether to cast the value to double. Do only use this to secure numbers from Requestable classes.
2182          * @param       $assertMismatch         Whether to assert mismatches
2183          * @return      $ret            The (hopefully) secured numbered value
2184          */
2185         public function bigintval ($num, $castValue = TRUE, $assertMismatch = FALSE) {
2186                 // Filter all numbers out
2187                 $ret = preg_replace('/[^0123456789]/', '', $num);
2188
2189                 // Shall we cast?
2190                 if ($castValue === TRUE) {
2191                         // Cast to biggest numeric type
2192                         $ret = (double) $ret;
2193                 } // END - if
2194
2195                 // Assert only if requested
2196                 if ($assertMismatch === TRUE) {
2197                         // Has the whole value changed?
2198                         assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
2199                 } // END - if
2200
2201                 // Return result
2202                 return $ret;
2203         }
2204
2205         /**
2206          * Checks whether the given hexadecimal number is really a hex-number (only chars 0-9,a-f).
2207          *
2208          * @param       $num    A string consisting only chars between 0 and 9
2209          * @param       $assertMismatch         Whether to assert mismatches
2210          * @return      $ret    The (hopefully) secured hext-numbered value
2211          */
2212         public function hexval ($num, $assertMismatch = FALSE) {
2213                 // Filter all numbers out
2214                 $ret = preg_replace('/[^0123456789abcdefABCDEF]/', '', $num);
2215
2216                 // Assert only if requested
2217                 if ($assertMismatch === TRUE) {
2218                         // Has the whole value changed?
2219                         assert(('' . $ret . '' != '' . $num . '') && (!is_null($num)));
2220                 } // END - if
2221
2222                 // Return result
2223                 return $ret;
2224         }
2225
2226         /**
2227          * Checks whether start/end marker are set
2228          *
2229          * @param       $data   Data to be checked
2230          * @return      $isset  Whether start/end marker are set
2231          */
2232         public final function ifStartEndMarkersSet ($data) {
2233                 // Determine it
2234                 $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER));
2235
2236                 // ... and return it
2237                 return $isset;
2238         }
2239
2240         /**
2241          * Determines if an element is set in the generic array
2242          *
2243          * @param       $keyGroup       Main group for the key
2244          * @param       $subGroup       Sub group for the key
2245          * @param       $key            Key to check
2246          * @param       $element        Element to check
2247          * @return      $isset          Whether the given key is set
2248          */
2249         protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
2250                 // Debug message
2251                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
2252
2253                 // Is it there?
2254                 $isset = isset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
2255
2256                 // Return it
2257                 return $isset;
2258         }
2259         /**
2260          * Determines if a key is set in the generic array
2261          *
2262          * @param       $keyGroup       Main group for the key
2263          * @param       $subGroup       Sub group for the key
2264          * @param       $key            Key to check
2265          * @return      $isset          Whether the given key is set
2266          */
2267         protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
2268                 // Debug message
2269                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2270
2271                 // Is it there?
2272                 $isset = isset($this->genericArray[$keyGroup][$subGroup][$key]);
2273
2274                 // Return it
2275                 return $isset;
2276         }
2277
2278
2279         /**
2280          * Determines if a group is set in the generic array
2281          *
2282          * @param       $keyGroup       Main group
2283          * @param       $subGroup       Sub group
2284          * @return      $isset          Whether the given group is set
2285          */
2286         protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) {
2287                 // Debug message
2288                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
2289
2290                 // Is it there?
2291                 $isset = isset($this->genericArray[$keyGroup][$subGroup]);
2292
2293                 // Return it
2294                 return $isset;
2295         }
2296
2297         /**
2298          * Getter for sub key group
2299          *
2300          * @param       $keyGroup       Main key group
2301          * @param       $subGroup       Sub key group
2302          * @return      $array          An array with all array elements
2303          */
2304         protected final function getGenericSubArray ($keyGroup, $subGroup) {
2305                 // Is it there?
2306                 if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
2307                         // No, then abort here
2308                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
2309                         exit;
2310                 } // END - if
2311
2312                 // Debug message
2313                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',value=' . print_r($this->genericArray[$keyGroup][$subGroup], TRUE));
2314
2315                 // Return it
2316                 return $this->genericArray[$keyGroup][$subGroup];
2317         }
2318
2319         /**
2320          * Unsets a given key in generic array
2321          *
2322          * @param       $keyGroup       Main group for the key
2323          * @param       $subGroup       Sub group for the key
2324          * @param       $key            Key to unset
2325          * @return      void
2326          */
2327         protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) {
2328                 // Debug message
2329                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2330
2331                 // Remove it
2332                 unset($this->genericArray[$keyGroup][$subGroup][$key]);
2333         }
2334
2335         /**
2336          * Unsets a given element in generic array
2337          *
2338          * @param       $keyGroup       Main group for the key
2339          * @param       $subGroup       Sub group for the key
2340          * @param       $key            Key to unset
2341          * @param       $element        Element to unset
2342          * @return      void
2343          */
2344         protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
2345                 // Debug message
2346                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
2347
2348                 // Remove it
2349                 unset($this->genericArray[$keyGroup][$subGroup][$key][$element]);
2350         }
2351
2352         /**
2353          * Append a string to a given generic array key
2354          *
2355          * @param       $keyGroup       Main group for the key
2356          * @param       $subGroup       Sub group for the key
2357          * @param       $key            Key to unset
2358          * @param       $value          Value to add/append
2359          * @return      void
2360          */
2361         protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
2362                 // Debug message
2363                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue);
2364
2365                 // Is it already there?
2366                 if ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2367                         // Append it
2368                         $this->genericArray[$keyGroup][$subGroup][$key] .= $appendGlue . (string) $value;
2369                 } else {
2370                         // Add it
2371                         $this->genericArray[$keyGroup][$subGroup][$key] = (string) $value;
2372                 }
2373         }
2374
2375         /**
2376          * Append a string to a given generic array element
2377          *
2378          * @param       $keyGroup       Main group for the key
2379          * @param       $subGroup       Sub group for the key
2380          * @param       $key            Key to unset
2381          * @param       $element        Element to check
2382          * @param       $value          Value to add/append
2383          * @return      void
2384          */
2385         protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
2386                 // Debug message
2387                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE) . ',appendGlue=' . $appendGlue);
2388
2389                 // Is it already there?
2390                 if ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
2391                         // Append it
2392                         $this->genericArray[$keyGroup][$subGroup][$key][$element] .= $appendGlue . (string) $value;
2393                 } else {
2394                         // Add it
2395                         $this->genericArray[$keyGroup][$subGroup][$key][$element] = (string) $value;
2396                 }
2397         }
2398
2399         /**
2400          * Initializes given generic array group
2401          *
2402          * @param       $keyGroup       Main group for the key
2403          * @param       $subGroup       Sub group for the key
2404          * @param       $key            Key to use
2405          * @param       $forceInit      Optionally force initialization
2406          * @return      void
2407          */
2408         protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = FALSE) {
2409                 // Debug message
2410                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit));
2411
2412                 // Is it already set?
2413                 if (($forceInit === FALSE) && ($this->isGenericArrayGroupSet($keyGroup, $subGroup))) {
2414                         // Already initialized
2415                         trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' already initialized.');
2416                         exit;
2417                 } // END - if
2418
2419                 // Initialize it
2420                 $this->genericArray[$keyGroup][$subGroup] = array();
2421         }
2422
2423         /**
2424          * Initializes given generic array key
2425          *
2426          * @param       $keyGroup       Main group for the key
2427          * @param       $subGroup       Sub group for the key
2428          * @param       $key            Key to use
2429          * @param       $forceInit      Optionally force initialization
2430          * @return      void
2431          */
2432         protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = FALSE) {
2433                 // Debug message
2434                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit));
2435
2436                 // Is it already set?
2437                 if (($forceInit === FALSE) && ($this->isGenericArrayKeySet($keyGroup, $subGroup, $key))) {
2438                         // Already initialized
2439                         trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' already initialized.');
2440                         exit;
2441                 } // END - if
2442
2443                 // Initialize it
2444                 $this->genericArray[$keyGroup][$subGroup][$key] = array();
2445         }
2446
2447         /**
2448          * Initializes given generic array element
2449          *
2450          * @param       $keyGroup       Main group for the key
2451          * @param       $subGroup       Sub group for the key
2452          * @param       $key            Key to use
2453          * @param       $element        Element to use
2454          * @param       $forceInit      Optionally force initialization
2455          * @return      void
2456          */
2457         protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = FALSE) {
2458                 // Debug message
2459                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit));
2460
2461                 // Is it already set?
2462                 if (($forceInit === FALSE) && ($this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element))) {
2463                         // Already initialized
2464                         trigger_error(__METHOD__ . ':keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' already initialized.');
2465                         exit;
2466                 } // END - if
2467
2468                 // Initialize it
2469                 $this->genericArray[$keyGroup][$subGroup][$key][$element] = array();
2470         }
2471
2472         /**
2473          * Pushes an element to a generic key
2474          *
2475          * @param       $keyGroup       Main group for the key
2476          * @param       $subGroup       Sub group for the key
2477          * @param       $key            Key to use
2478          * @param       $value          Value to add/append
2479          * @return      $count          Number of array elements
2480          */
2481         protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
2482                 // Debug message
2483                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2484
2485                 // Is it set?
2486                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2487                         // Initialize array
2488                         $this->initGenericArrayKey($keyGroup, $subGroup, $key);
2489                 } // END - if
2490
2491                 // Then push it
2492                 $count = array_push($this->genericArray[$keyGroup][$subGroup][$key], $value);
2493
2494                 // Return count
2495                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2496                 //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
2497                 return $count;
2498         }
2499
2500         /**
2501          * Pushes an element to a generic array element
2502          *
2503          * @param       $keyGroup       Main group for the key
2504          * @param       $subGroup       Sub group for the key
2505          * @param       $key            Key to use
2506          * @param       $element        Element to check
2507          * @param       $value          Value to add/append
2508          * @return      $count          Number of array elements
2509          */
2510         protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
2511                 // Debug message
2512                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2513
2514                 // Is it set?
2515                 if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
2516                         // Initialize array
2517                         $this->initGenericArrayElement($keyGroup, $subGroup, $key, $element);
2518                 } // END - if
2519
2520                 // Then push it
2521                 $count = array_push($this->genericArray[$keyGroup][$subGroup][$key][$element], $value);
2522
2523                 // Return count
2524                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2525                 //* DEBUG: */ print(__METHOD__ . ': count=' . $count . PHP_EOL);
2526                 return $count;
2527         }
2528
2529         /**
2530          * Pops an element from  a generic group
2531          *
2532          * @param       $keyGroup       Main group for the key
2533          * @param       $subGroup       Sub group for the key
2534          * @param       $key            Key to unset
2535          * @return      $value          Last "popped" value
2536          */
2537         protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) {
2538                 // Debug message
2539                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2540
2541                 // Is it set?
2542                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2543                         // Not found
2544                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
2545                         exit;
2546                 } // END - if
2547
2548                 // Then "pop" it
2549                 $value = array_pop($this->genericArray[$keyGroup][$subGroup][$key]);
2550
2551                 // Return value
2552                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2553                 //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
2554                 return $value;
2555         }
2556
2557         /**
2558          * Shifts an element from  a generic group
2559          *
2560          * @param       $keyGroup       Main group for the key
2561          * @param       $subGroup       Sub group for the key
2562          * @param       $key            Key to unset
2563          * @return      $value          Last "popped" value
2564          */
2565         protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) {
2566                 // Debug message
2567                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2568
2569                 // Is it set?
2570                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2571                         // Not found
2572                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' not found.');
2573                         exit;
2574                 } // END - if
2575
2576                 // Then "shift" it
2577                 $value = array_shift($this->genericArray[$keyGroup][$subGroup][$key]);
2578
2579                 // Return value
2580                 //* DEBUG: */ print(__METHOD__ . ': genericArray=' . print_r($this->genericArray[$keyGroup][$subGroup][$key], TRUE));
2581                 //* DEBUG: */ print(__METHOD__ . ': value[' . gettype($value) . ']=' . print_r($value, TRUE) . PHP_EOL);
2582                 return $value;
2583         }
2584
2585         /**
2586          * Count generic array group
2587          *
2588          * @param       $keyGroup       Main group for the key
2589          * @return      $count          Count of given group
2590          */
2591         protected final function countGenericArray ($keyGroup) {
2592                 // Debug message
2593                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
2594
2595                 // Is it there?
2596                 if (!isset($this->genericArray[$keyGroup])) {
2597                         // Abort here
2598                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' not found.');
2599                         exit;
2600                 } // END - if
2601
2602                 // Then count it
2603                 $count = count($this->genericArray[$keyGroup]);
2604
2605                 // Debug message
2606                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',count=' . $count);
2607
2608                 // Return it
2609                 return $count;
2610         }
2611
2612         /**
2613          * Count generic array sub group
2614          *
2615          * @param       $keyGroup       Main group for the key
2616          * @param       $subGroup       Sub group for the key
2617          * @return      $count          Count of given group
2618          */
2619         protected final function countGenericArrayGroup ($keyGroup, $subGroup) {
2620                 // Debug message
2621                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
2622
2623                 // Is it there?
2624                 if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
2625                         // Abort here
2626                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
2627                         exit;
2628                 } // END - if
2629
2630                 // Then count it
2631                 $count = count($this->genericArray[$keyGroup][$subGroup]);
2632
2633                 // Debug message
2634                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',count=' . $count);
2635
2636                 // Return it
2637                 return $count;
2638         }
2639
2640         /**
2641          * Count generic array elements
2642          *
2643          * @param       $keyGroup       Main group for the key
2644          * @param       $subGroup       Sub group for the key
2645          * @para        $key            Key to count
2646          * @return      $count          Count of given key
2647          */
2648         protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) {
2649                 // Debug message
2650                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2651
2652                 // Is it there?
2653                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2654                         // Abort here
2655                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' not found.');
2656                         exit;
2657                 } elseif (!$this->isValidGenericArrayGroup($keyGroup, $subGroup)) {
2658                         // Not valid
2659                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ' is not an array.');
2660                         exit;
2661                 }
2662
2663                 // Then count it
2664                 $count = count($this->genericArray[$keyGroup][$subGroup][$key]);
2665
2666                 // Debug message
2667                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',count=' . $count);
2668
2669                 // Return it
2670                 return $count;
2671         }
2672
2673         /**
2674          * Getter for whole generic group array
2675          *
2676          * @param       $keyGroup       Key group to get
2677          * @return      $array          Whole generic array group
2678          */
2679         protected final function getGenericArray ($keyGroup) {
2680                 // Debug message
2681                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup);
2682
2683                 // Is it there?
2684                 if (!isset($this->genericArray[$keyGroup])) {
2685                         // Then abort here
2686                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ' does not exist.');
2687                         exit;
2688                 } // END - if
2689
2690                 // Return it
2691                 return $this->genericArray[$keyGroup];
2692         }
2693
2694         /**
2695          * Setter for generic array key
2696          *
2697          * @param       $keyGroup       Key group to get
2698          * @param       $subGroup       Sub group for the key
2699          * @param       $key            Key to unset
2700          * @param       $value          Mixed value from generic array element
2701          * @return      void
2702          */
2703         protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
2704                 // Debug message
2705                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2706
2707                 // Set value here
2708                 $this->genericArray[$keyGroup][$subGroup][$key] = $value;
2709         }
2710
2711         /**
2712          * Getter for generic array key
2713          *
2714          * @param       $keyGroup       Key group to get
2715          * @param       $subGroup       Sub group for the key
2716          * @param       $key            Key to unset
2717          * @return      $value          Mixed value from generic array element
2718          */
2719         protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) {
2720                 // Debug message
2721                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2722
2723                 // Is it there?
2724                 if (!$this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) {
2725                         // Then abort here
2726                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ' does not exist.');
2727                         exit;
2728                 } // END - if
2729
2730                 // Return it
2731                 return $this->genericArray[$keyGroup][$subGroup][$key];
2732         }
2733
2734         /**
2735          * Sets a value in given generic array key/element
2736          *
2737          * @param       $keyGroup       Main group for the key
2738          * @param       $subGroup       Sub group for the key
2739          * @param       $key            Key to set
2740          * @param       $element        Element to set
2741          * @param       $value          Value to set
2742          * @return      void
2743          */
2744         protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
2745                 // Debug message
2746                 //* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, TRUE));
2747
2748                 // Then set it
2749                 $this->genericArray[$keyGroup][$subGroup][$key][$element] = $value;
2750         }
2751
2752         /**
2753          * Getter for generic array element
2754          *
2755          * @param       $keyGroup       Key group to get
2756          * @param       $subGroup       Sub group for the key
2757          * @param       $key            Key to look for
2758          * @param       $element        Element to look for
2759          * @return      $value          Mixed value from generic array element
2760          */
2761         protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
2762                 // Debug message
2763                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
2764
2765                 // Is it there?
2766                 if (!$this->isGenericArrayElementSet($keyGroup, $subGroup, $key, $element)) {
2767                         // Then abort here
2768                         trigger_error(__METHOD__ . ': keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ' does not exist.');
2769                         exit;
2770                 } // END - if
2771
2772                 // Return it
2773                 return $this->genericArray[$keyGroup][$subGroup][$key][$element];
2774         }
2775
2776         /**
2777          * Checks if a given sub group is valid (array)
2778          *
2779          * @param       $keyGroup       Key group to get
2780          * @param       $subGroup       Sub group for the key
2781          * @return      $isValid        Whether given sub group is valid
2782          */
2783         protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) {
2784                 // Debug message
2785                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
2786
2787                 // Determine it
2788                 $isValid = (($this->isGenericArrayGroupSet($keyGroup, $subGroup)) && (is_array($this->getGenericSubArray($keyGroup, $subGroup))));
2789
2790                 // Return it
2791                 return $isValid;
2792         }
2793
2794         /**
2795          * Checks if a given key is valid (array)
2796          *
2797          * @param       $keyGroup       Key group to get
2798          * @param       $subGroup       Sub group for the key
2799          * @param       $key            Key to check
2800          * @return      $isValid        Whether given sub group is valid
2801          */
2802         protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
2803                 // Debug message
2804                 //* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
2805
2806                 // Determine it
2807                 $isValid = (($this->isGenericArrayKeySet($keyGroup, $subGroup, $key)) && (is_array($this->getGenericArrayKey($keyGroup, $subGroup, $key))));
2808
2809                 // Return it
2810                 return $isValid;
2811         }
2812
2813         /**
2814          * Translates boolean TRUE to 'Y' and FALSE to 'N'
2815          *
2816          * @param       $boolean                Boolean value
2817          * @return      $translated             Translated boolean value
2818          */
2819         public static final function translateBooleanToYesNo ($boolean) {
2820                 // Make sure it is really boolean
2821                 assert(is_bool($boolean));
2822
2823                 // "Translate" it
2824                 $translated = ($boolean === TRUE) ? 'Y' : 'N';
2825
2826                 // ... and return it
2827                 return $translated;
2828         }
2829 }
2830
2831 // [EOF]
2832 ?>