| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* Component handler class |
| 4 |
|
* @package Mambo |
| 5 |
|
*/ |
| 6 |
class mosComponentHandler { |
class mosComponentHandler { |
| 7 |
var $_buffer = ''; |
var $_buffer = ''; |
| 8 |
|
|
| 14 |
|
|
| 15 |
function &getParamsByName ($name) { |
function &getParamsByName ($name) { |
| 16 |
$params = null; |
$params = null; |
| 17 |
$row = new mosComponent( $database ); |
$row = new mosComponent(); |
| 18 |
$query = "SELECT a.params, a.option" |
$query = "SELECT a.params, a.option" |
| 19 |
. "\n FROM #__components AS a" |
. "\n FROM #__components AS a" |
| 20 |
. "\n WHERE a.name = '$name'" |
. "\n WHERE a.name = '$name'" |
| 53 |
} |
} |
| 54 |
|
|
| 55 |
} |
} |
|
|
|
| 56 |
/** |
/** |
| 57 |
* Component database table class |
* Component database table class |
| 58 |
* @package Mambo |
* @package Mambo |
| 86 |
/** |
/** |
| 87 |
* @param database A database connector object |
* @param database A database connector object |
| 88 |
*/ |
*/ |
| 89 |
function mosComponent( &$db ) { |
function mosComponent() { |
| 90 |
|
$db = mamboDatabase::getInstance(); |
| 91 |
$this->mosDBTable( '#__components', 'id', $db ); |
$this->mosDBTable( '#__components', 'id', $db ); |
| 92 |
} |
} |
| 93 |
} |
} |
| 94 |
|
/** |
| 95 |
|
* Component common base class for both user and admin sides |
| 96 |
|
* @package Mambo |
| 97 |
|
*/ |
| 98 |
|
class mosComponentManager { |
| 99 |
|
var $plugin_name = ''; |
| 100 |
|
var $magic_quotes_value = 0; |
| 101 |
|
|
| 102 |
|
function noMagicQuotes () { |
| 103 |
|
// Is magic quotes on? |
| 104 |
|
if (get_magic_quotes_gpc()) { |
| 105 |
|
// Yes? Strip the added slashes |
| 106 |
|
$_REQUEST =& $this->remove_magic_quotes($_REQUEST); |
| 107 |
|
$_GET =& $this->remove_magic_quotes($_GET); |
| 108 |
|
$_POST =& $this->remove_magic_quotes($_POST); |
| 109 |
|
} |
| 110 |
|
$this->magic_quotes_value = set_magic_quotes_runtime(0); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
function &remove_magic_quotes ($array) { |
| 114 |
|
foreach ($array as $k => $v) { |
| 115 |
|
if (is_array($v)) $array[$k] = $this->remove_magic_quotes($v); |
| 116 |
|
else $array[$k] = stripslashes($v); |
| 117 |
|
} |
| 118 |
|
return $array; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
function restore_magic_quotes () { |
| 122 |
|
set_magic_quotes_runtime($this->magic_quotes_value); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
function checkCallable (&$object, $method) { |
| 126 |
|
if (is_callable(array(&$object, $method))) return true; |
| 127 |
|
$name = get_class($object); |
| 128 |
|
trigger_error (sprintf(T_('Component %s error: attempt to use non-existent class %s in %s'), $this->plugin_name, $method, $name)); |
| 129 |
|
return false; |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
} |
| 133 |
|
/** |
| 134 |
|
* Component base logic for user side |
| 135 |
|
* @package Mambo |
| 136 |
|
*/ |
| 137 |
|
class mosComponentUserManager extends mosComponentManager { |
| 138 |
|
var $option = ''; |
| 139 |
|
|
| 140 |
|
function mosComponentUserManager ($component, $control_name, $alternatives, $default, $title) { |
| 141 |
|
$this->plugin_name = $component; |
| 142 |
|
$this->option = mamboCore::get('option'); |
| 143 |
|
$this->noMagicQuotes(); |
| 144 |
|
$mainframe =& mosMainFrame::getInstance(); |
| 145 |
|
$mainframe->SetPageTitle($title); |
| 146 |
|
$func = mosGetParam ($_REQUEST, $control_name, $default); |
| 147 |
|
if (isset($alternatives[$func])) $method = $alternatives[$func]; |
| 148 |
|
else $method = $func; |
| 149 |
|
$classname = $component.'_'.$method.'_Controller'; |
| 150 |
|
if (class_exists($classname)) { |
| 151 |
|
$controller =& new $classname($this); |
| 152 |
|
if (is_callable(array(&$controller,$method))) $controller->$method($func); |
| 153 |
|
else trigger_error (sprintf(T_('Component %s error: attempt to use non-existent method %s in %s'), $component, $method, $controller)); |
| 154 |
|
} |
| 155 |
|
else trigger_error("Component $component error: attempt to use non-existent class $classname"); |
| 156 |
|
$this->restore_magic_quotes(); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
| 160 |
|
if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
| 161 |
|
trigger_error("Component $this->plugin_name error: attempt to use non-existent class ".$name); |
| 162 |
|
return false; |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
} |
| 166 |
|
/** |
| 167 |
|
* Component base logic for admin side |
| 168 |
|
* @package Mambo |
| 169 |
|
*/ |
| 170 |
|
class mosComponentAdminManager extends mosComponentManager { |
| 171 |
|
var $act = ''; |
| 172 |
|
var $task = ''; |
| 173 |
|
var $limitstart = 0; |
| 174 |
|
var $limit = 0; |
| 175 |
|
var $cfid = 0; |
| 176 |
|
var $order = 0; |
| 177 |
|
var $currid = 0; |
| 178 |
|
|
| 179 |
|
function mosComponentAdminManager ($plugin_name) { |
| 180 |
|
$this->plugin_name = $plugin_name; |
| 181 |
|
$this->noMagicQuotes(); |
| 182 |
|
if ($this->act = mosGetParam ($_REQUEST, 'act', 'containers')); |
| 183 |
|
else $this->act = 'containers'; |
| 184 |
|
if ($this->task = mosGetParam($_REQUEST, 'task', 'list')); |
| 185 |
|
else $this->task = 'list'; |
| 186 |
|
$mainframe = mosMainFrame::getInstance(); |
| 187 |
|
$default_limit = $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', 20 ); |
| 188 |
|
$this->limit = intval( mosGetParam( $_REQUEST, 'limit', $default_limit ) ); |
| 189 |
|
$this->limitstart = mosGetParam($_REQUEST, 'limitstart', 0 ); |
| 190 |
|
$this->cfid = mosGetParam($_REQUEST, 'cfid', array(0)); |
| 191 |
|
if (is_array($this->cfid)) foreach ($this->cfid as $i=>$id) $this->cfid[$i] = intval($id); |
| 192 |
|
$this->order= mosGetParam($_REQUEST, 'order', array()); |
| 193 |
|
if (is_array( $this->cfid )) $this->currid=intval($this->cfid[0]); |
| 194 |
|
else $this->currid=intval($this->cfid); |
| 195 |
|
$name = $this->getAction(); |
| 196 |
|
if (class_exists($name)) { |
| 197 |
|
$controller =& new $name($this); |
| 198 |
|
$task = $this->task.'Task'; |
| 199 |
|
if (is_callable(array(&$controller, 'getRequestData'))) $controller->getRequestData(); |
| 200 |
|
if (is_callable(array(&$controller,$task))) $controller->$task(); |
| 201 |
|
else trigger_error(sprintf(T_('MOS error in %s: method %s not found in class %s'), $this->plugin_name, $task, $name)); |
| 202 |
|
} |
| 203 |
|
else trigger_error(sprintf(T_('MOS error in %s: class not found %s'), $this->plugin_name, $name)); |
| 204 |
|
$this->restore_magic_quotes(); |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
function check_selection ($text) { |
| 208 |
|
if (!is_array($this->cfid) OR count( $this->cfid ) < 1) { |
| 209 |
|
echo "<script> alert('".$text."'); window.history.go(-1);</script>\n"; |
| 210 |
|
exit; |
| 211 |
|
} |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
function getAction () { |
| 215 |
|
$actname = strtoupper(substr($this->act,0,1)).strtolower(substr($this->act,1)); |
| 216 |
|
return strtolower($this->plugin_name).'Admin'.$actname; |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
| 220 |
|
$controller->makePageNav($this, $total_items); |
| 221 |
|
if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
| 222 |
|
trigger_error(sprintf(T_('Component %s error: attempt to use non-existent class %s'), $this->plugin_name, $name)); |
| 223 |
|
return false; |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
} |
| 227 |
|
/** |
| 228 |
|
* Component base class for admin side component controller logic |
| 229 |
|
* @package Mambo |
| 230 |
|
*/ |
| 231 |
|
class mosComponentAdminControllers { |
| 232 |
|
var $admin = ''; |
| 233 |
|
var $user = ''; |
| 234 |
|
var $pageNav = ''; |
| 235 |
|
|
| 236 |
|
function mosComponentAdminControllers ($admin) { |
| 237 |
|
$this->admin = $admin; |
| 238 |
|
$this->user = mamboCore::get('currentUser'); |
| 239 |
|
} |
| 240 |
|
|
| 241 |
|
function makePageNav (&$admin, $total) { |
| 242 |
|
require_once(mamboCore::get('mosConfig_absolute_path').'/administrator/includes/pageNavigation.php'); |
| 243 |
|
$this->pageNav =& new mosPageNav( $total, $admin->limitstart, $admin->limit ); |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
} |
| 247 |
|
|
| 248 |
/** |
/** |
| 249 |
* Template Table Class |
* Template Table Class |
| 355 |
} |
} |
| 356 |
|
|
| 357 |
/** |
/** |
| 358 |
|
* @param string Name of module required |
| 359 |
|
*/ |
| 360 |
|
function &getByName( $name, $isAdmin=false ) { |
| 361 |
|
$this->initModules($isAdmin); |
| 362 |
|
$modules = array(); |
| 363 |
|
foreach ($this->_modules as $position) { |
| 364 |
|
foreach ($position as $module) if ($module->module == $name) $modules[] = $module; |
| 365 |
|
} |
| 366 |
|
return $modules; |
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
/** |
| 370 |
* @param string The position |
* @param string The position |
| 371 |
* @param int The style. 0=normal, 1=horiz, -1=no wrapper |
* @param int The style. 0=normal, 1=horiz, -1=no wrapper |
| 372 |
*/ |
*/ |