00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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
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;
00084 }
00085
00086
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 }