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