aliroRequest.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*******************************************************************************
00004  * Aliro - the modern, accessible content management system
00005  *
00006  * Aliro is open source software, free to use, and licensed under GPL.
00007  * You can find the full licence at http://www.gnu.org/copyleft/gpl.html GNU/GPL
00008  *
00009  * The author freely draws attention to the fact that Aliro derives from Mambo,
00010  * software that is controlled by the Mambo Foundation.  However, this section
00011  * of code is totally new.  If it should contain any fragments that are similar
00012  * to Mambo, please bear in mind (1) there are only so many ways to do things
00013  * and (2) the author of Aliro is also the author and copyright owner for large
00014  * parts of Mambo 4.6.
00015  *
00016  * Tribute should be paid to all the developers who took Mambo to the stage
00017  * it had reached at the time Aliro was created.  It is a feature rich system
00018  * that contains a good deal of innovation.
00019  *
00020  * Your attention is also drawn to the fact that Aliro relies on other items of
00021  * open source software, which is very much in the spirit of open source.  Aliro
00022  * wishes to give credit to those items of code.  Please refer to
00023  * http://aliro.org/credits for details.  The credits are not included within
00024  * the Aliro package simply to avoid providing a marker that allows hackers to
00025  * identify the system.
00026  *
00027  * Copyright in this code is strictly reserved by its author, Martin Brampton.
00028  * If it seems appropriate, the copyright will be vested in the Aliro Organisation
00029  * at a suitable time.
00030  *
00031  * Copyright (c) 2007 Martin Brampton
00032  *
00033  * http://aliro.org
00034  *
00035  * counterpoint@aliro.org
00036  *
00037  * aliroAbstractRequest is the abstract class that contains the central control logic for
00038  * Aliro.  There are two classes that extend aliroAbstractRequest, aliroUserRequest and
00039  * aliroAdminRequest.  They are instantiated very quickly by whichever index.php
00040  * is selected.  The admin side index.php will invoke aliroAdminRequest and the
00041  * user side (the root of the site) index.php will invoke aliroUserRequest.
00042  *
00043  * mosRequest is kept to provide backwards compatibility.
00044  *
00045  * aliroRequest is a factory class that provides the appropriate kind of
00046  * aliroAbstractRequest object, and also houses a very few static methods.
00047  *
00048  */
00049 
00050 function T_($message) {
00051     return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->gettext($message) : $message;
00052 }
00053 function Tn_($msg1, $msg2, $count) {
00054     return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->ngettext($msg1, $msg2, $count) : $msg1;
00055 }
00056 function Td_($domain, $message) {
00057     return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->dgettext($domain, $message) : $message;
00058 }
00059 function Tdn_($domain, $msg1, $msg2, $count) {
00060     return defined('_ALIRO_LANGUAGE') ? PHPGettext::getInstance()->dngettext($domain, $msg1, $msg2, $count) : $msg1;
00061 }
00062 
00063 
00064 class aliroRequest {
00065     private static $instance = null;
00066 
00067     public static function getInstance () {
00068         if (null == self::$instance) {
00069             $info = criticalInfo::getInstance();
00070             if ($info->isAdmin) self::$instance = aliroAdminRequest::getInstance();
00071             else self::$instance = aliroUserRequest::getInstance();
00072         }
00073         return self::$instance;
00074     }
00075 
00076     public static function mosMakeHtmlSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' ) {
00077         if (is_object($mixed)) foreach (get_object_vars( $mixed ) as $k => $v) {
00078             if (is_array($v) OR is_object($v) OR $v == NULL OR substr($k, 1, 1) == '_' OR (is_string($exclude_keys) AND $k == $exclude_keys) OR (is_array( $exclude_keys ) AND in_array( $k, $exclude_keys )));
00079             else $mixed->$k = htmlspecialchars($v, $quote_style);
00080         }
00081     }
00082 
00083     public static function trace ($error=true) {
00084         static $counter = 0;
00085         $html = '';
00086         foreach(debug_backtrace() as $back) {
00087             if (isset($back['file']) AND $back['file']) {
00088                 $html .= '<br />'.$back['file'].':'.$back['line'];
00089             }
00090         }
00091         if ($error) $counter++;
00092         if (1000 < $counter) {
00093             echo $html;
00094             die (T_('Program killed - Probably looping'));
00095         }
00096         return $html;
00097     }
00098 
00099 }
00100 
00101 class mosRequest extends aliroRequest {
00102 
00103 }

Generated on Wed May 14 13:01:56 2008 for ALIRO by  doxygen 1.5.5