mosMainFrame.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  * mosMainFrame is purely for backwards compatibility with Mambo 4.5+ and
00038  * Joomla! 1.0.x.
00039  *
00040  */
00041 
00042 class mosMainFrame {
00043     private static $instance = __CLASS__;
00044     private $request = null;
00045 
00046     private function __construct () {
00047         $this->request = aliroRequest::getInstance();
00048     }
00049 
00050     private function __clone () {
00051         // Enforces singleton
00052     }
00053 
00054     public static function getInstance () {
00055         return is_object(self::$instance) ? self::$instance : (self::$instance = new self::$instance());
00056     }
00057 
00058     public function __call ($method, $args) {
00059         return call_user_func_array(array($this->request, $method), $args);
00060     }
00061 
00062     function initSession() {
00063         $session = aliroSessionFactory::getSession();
00064         return $session;
00065     }
00066 
00067     function getTemplate () {
00068         return $this->request->getTemplate();
00069     }
00070 
00077     function ImageCheck( $file, $directory='/images/M_images/', $param=NULL, $param_directory='/images/M_images/', $alt=NULL, $name='image', $type=1, $align='middle' ) {
00078         $basepath = aliroCore::get('mosConfig_live_site');
00079         if ($param) $image = $basepath.$param_directory.$param;
00080         else {
00081             $endpath = '/templates/'.$this->request->getTemplate().'/images/'.$file;
00082             if (file_exists(aliroCore::get('mosConfig_absolute_path').$endpath)) $image = $basepath.$endpath;
00083             else $image = $basepath.$directory.$file;  // outputs only path to image
00084         }
00085         // outputs actual html <img> tag
00086         //if ($type) $image = '<img src="'. $image .'" alt="'. $alt .'" align="'. $align .'" name="'. $name .'" border="0" />';
00087         if ($type) $image = '<img src="'. $image .'" alt="'. $alt .'" />';
00088         return $image;
00089     }
00090 
00095     function tryFiles ($first_choice, $second_choice=null, $third_choice=null) {
00096         if (file_exists($first_choice)) return $first_choice;
00097         elseif ($second_choice AND file_exists($second_choice)) return $second_choice;
00098         elseif ($third_choice AND file_exists($third_choice)) return $third_choice;
00099         else return null;
00100     }
00101 
00106     function getPath( $varname, $option='' ) {
00107         $base = $this->request->absolute_path;
00108         $origoption = $option;
00109         if (!$option) $option = $this->request->getParam($_REQUEST, 'option');
00110         $name = substr($option,4);
00111         $bac_admin = "$base/administrator/components/com_admin/";
00112         $baco = "$base/administrator/components/$option/";
00113         $bacc = "$base/administrator/core/$option/";
00114         $bttc = "$base/templates/".$this->request->getTemplate()."/components/";
00115         $bco = "$base/components/$option/";
00116         $bai = "$base/administrator/includes/";
00117         $bi = "$base/includes/";
00118         switch ($varname) {
00119             case 'front': return $this->tryFiles ($bco."$name.php");
00120             case 'front_html': return $this->tryFiles ($bttc."$name.html.php", $bco."$name.html.php");
00121             case 'admin': return $this->tryFiles ($baco."admin.$name.php", $bac_admin.'admin.admin.php');
00122             case 'core': return $this->tryFiles ($bacc."admin.$name.php");
00123             case 'admin_html': return $this->tryFiles ($baco."admin.$name.html.php", $bac_admin.'admin.admin.html.php');
00124             case 'toolbar': return $this->tryFiles ($baco."toolbar.$name.php", $bacc."toolbar.$name.php");
00125             case 'toolbar_html': return $this->tryFiles ($baco."toolbar.$name.html.php", $bacc."toolbar.$name.html.php");
00126             case 'toolbar_default': return $this->tryFiles ($bai.'toolbar.html.php');
00127             case 'class': return $this->tryFiles ($bco."$name.class.php", $baco."$name.class.php", $bi."$name.php");
00128             case 'com_xml': return $this->tryFiles ($baco."$name.xml", $bco."$name.xml");
00129             case 'mod0_xml':
00130             if ($origoption) $path = $base."/modules/$option.xml";
00131             else $path = $base.'/modules/custom.xml';
00132             return $this->tryFiles ($path);
00133             case 'mod1_xml':
00134             if ($origoption) $path = $base."/administrator/modules/$option.xml";
00135             else $path = $base.'/administrator/modules/custom.xml';
00136             return $this->tryFiles ($path);
00137             case 'bot_xml': return $this->tryFiles ($base."/mambots/$option.xml");
00138             case 'menu_xml': return $this->tryFiles ($base."/administrator/components/com_menus/$option/$option.xml");
00139             case 'installer_html': return $this->tryFiles($base."/administrator/components/com_installer/$option/$option.html.php");
00140             case 'installer_class': return $this->tryFiles($base."/administrator/components/com_installer/$option/$option.class.php");
00141         }
00142     }
00143 
00144 }

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