| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
| 3 |
* Component handler class |
* Some Components, Modules, Mambots and Templates classes |
| 4 |
* @package Mambo |
* @package Mambo |
| 5 |
|
* @copyright (C) 2005 - 2006 Mambo Foundation Inc. |
| 6 |
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 7 |
|
* @author Mambo Foundation Inc see README.php |
| 8 |
*/ |
*/ |
| 9 |
|
|
| 10 |
|
/** |
| 11 |
|
* Singleton class to handle with current component |
| 12 |
|
* |
| 13 |
|
* This class controls the start, end and send output buffer from current component |
| 14 |
|
* @package Mambo |
| 15 |
|
* @acces public |
| 16 |
|
*/ |
| 17 |
|
|
| 18 |
class mosComponentHandler { |
class mosComponentHandler { |
| 19 |
|
/** |
| 20 |
|
* stores the output from current component |
| 21 |
|
* |
| 22 |
|
* @acces private |
| 23 |
|
* @var string |
| 24 |
|
*/ |
| 25 |
var $_buffer = ''; |
var $_buffer = ''; |
| 26 |
|
/** |
| 27 |
|
* Return a reference to current handler |
| 28 |
|
* |
| 29 |
|
* This function returns a reference to current component handler, if none handler exists, |
| 30 |
|
* it creates one. |
| 31 |
|
* |
| 32 |
|
* Example of use: |
| 33 |
|
* |
| 34 |
|
* <code>$c_handler =& mosComponentHandler::getInstance();</code> |
| 35 |
|
* |
| 36 |
|
* @acces public |
| 37 |
|
* @return object reference to current singleton Handler |
| 38 |
|
*/ |
| 39 |
function &getInstance () { |
function &getInstance () { |
| 40 |
static $instance; |
static $instance; |
| 41 |
if (!is_object($instance)) $instance = new mosComponentHandler(); |
if (!is_object($instance)) $instance = new mosComponentHandler(); |
| 42 |
return $instance; |
return $instance; |
| 43 |
} |
} |
| 44 |
|
|
| 45 |
|
/** |
| 46 |
|
* Returns the admin parameters from a component |
| 47 |
|
* |
| 48 |
|
* This function returns a reference to specified component in $name param, if none parameters |
| 49 |
|
* are founded it returns null. |
| 50 |
|
* |
| 51 |
|
* Example of use: |
| 52 |
|
* |
| 53 |
|
* Obtains the admin parameters from the syndicate component. |
| 54 |
|
* |
| 55 |
|
* <code> |
| 56 |
|
* $c_handler =& mosComponentHandler::getInstance(); |
| 57 |
|
* $params =& $c_handler->getParamsByName("syndicate"); |
| 58 |
|
* </code> |
| 59 |
|
* |
| 60 |
|
* @acces public |
| 61 |
|
* @return object mosParameters object with parameters, null if none was founded. |
| 62 |
|
*/ |
| 63 |
function &getParamsByName ($name) { |
function &getParamsByName ($name) { |
| 64 |
$params = null; |
$params = null; |
| 65 |
$row = new mosComponent(); |
$row = new mosComponent(); |
| 78 |
return $params; |
return $params; |
| 79 |
} |
} |
| 80 |
|
|
| 81 |
|
/** |
| 82 |
|
* Writes the output from current component |
| 83 |
|
* |
| 84 |
|
* This function send to client browser the outputs from the component, it's |
| 85 |
|
* called by mosMainBody() global function. |
| 86 |
|
* |
| 87 |
|
* @acces private |
| 88 |
|
*/ |
| 89 |
function mosMainBody() { |
function mosMainBody() { |
| 90 |
// message passed via the url |
// message passed via the url |
| 91 |
$mosmsg = mosGetParam($_REQUEST, 'mosmsg', ''); |
$mosmsg = mosGetParam($_REQUEST, 'mosmsg', ''); |
| 98 |
// echo "\n<script language=\"javascript\">alert('$mosmsg');</script>"; |
// echo "\n<script language=\"javascript\">alert('$mosmsg');</script>"; |
| 99 |
} |
} |
| 100 |
|
|
| 101 |
|
/** |
| 102 |
|
* Start the use of buffer |
| 103 |
|
* |
| 104 |
|
* This function start the use of buffers to components output |
| 105 |
|
* |
| 106 |
|
* @acces private |
| 107 |
|
*/ |
| 108 |
function startBuffer () { |
function startBuffer () { |
| 109 |
$this->_buffer = ''; |
$this->_buffer = ''; |
| 110 |
ob_start(); |
ob_start(); |
| 111 |
} |
} |
| 112 |
|
|
| 113 |
|
/** |
| 114 |
|
* Ends the use of buffer |
| 115 |
|
* |
| 116 |
|
* This function ends the use of buffers to components output, all outputs |
| 117 |
|
* are stored in $this->_buffer |
| 118 |
|
* |
| 119 |
|
* @acces private |
| 120 |
|
*/ |
| 121 |
function endBuffer () { |
function endBuffer () { |
| 122 |
$this->_buffer = ob_get_contents(); |
$this->_buffer = ob_get_contents(); |
| 123 |
ob_end_clean(); |
ob_end_clean(); |
| 124 |
} |
} |
| 125 |
|
|
| 126 |
} |
} |
| 127 |
|
|
| 128 |
/** |
/** |
| 129 |
* Component database table class |
* Components database table class |
| 130 |
|
* |
| 131 |
|
* This class can be used to gain access to #_components database table |
| 132 |
|
* |
| 133 |
|
* Example of use: |
| 134 |
|
* |
| 135 |
|
* To load no core components... |
| 136 |
|
* |
| 137 |
|
* <code> |
| 138 |
|
* $row = new mosComponent(); |
| 139 |
|
* $query = "SELECT * FROM #__components AS a WHERE iscore = 0"; |
| 140 |
|
* $database =& mamboDatabase::getInstance(); |
| 141 |
|
* $database->setQuery( $query ); |
| 142 |
|
* if ($database->loadObject($row)) { |
| 143 |
|
* ... |
| 144 |
|
* } |
| 145 |
|
* </code> |
| 146 |
* @package Mambo |
* @package Mambo |
| 147 |
|
* @access public |
| 148 |
*/ |
*/ |
| 149 |
class mosComponent extends mosDBTable { |
class mosComponent extends mosDBTable { |
| 150 |
/** @var int Primary key */ |
/** @var int Primary key */ |
| 151 |
var $id=null; |
var $id=null; |
| 152 |
/** @var string */ |
/** @var string component name*/ |
| 153 |
var $name=null; |
var $name=null; |
| 154 |
/** @var string */ |
/** @var string component link*/ |
| 155 |
var $link=null; |
var $link=null; |
| 156 |
/** @var int */ |
/** @var int menu id*/ |
| 157 |
var $menuid=null; |
var $menuid=null; |
| 158 |
/** @var int */ |
/** @var int parent menu*/ |
| 159 |
var $parent=null; |
var $parent=null; |
| 160 |
/** @var string */ |
/** @var string component admin link*/ |
| 161 |
var $admin_menu_link=null; |
var $admin_menu_link=null; |
| 162 |
/** @var string */ |
/** @var string alternative text for admin menu*/ |
| 163 |
var $admin_menu_alt=null; |
var $admin_menu_alt=null; |
| 164 |
/** @var string */ |
/** @var string component option id*/ |
| 165 |
var $option=null; |
var $option=null; |
| 166 |
/** @var string */ |
/** @var string order*/ |
| 167 |
var $ordering=null; |
var $ordering=null; |
| 168 |
/** @var string */ |
/** @var string image from admin menu*/ |
| 169 |
var $admin_menu_img=null; |
var $admin_menu_img=null; |
| 170 |
/** @var int */ |
/** @var int 1 core component ,0 others */ |
| 171 |
var $iscore=null; |
var $iscore=null; |
| 172 |
/** @var string */ |
/** @var string component parameters*/ |
| 173 |
var $params=null; |
var $params=null; |
| 174 |
|
|
| 175 |
/** |
/** |
| 176 |
* @param database A database connector object |
* mosComponent class Contructor |
| 177 |
|
* @access private |
| 178 |
*/ |
*/ |
| 179 |
function mosComponent() { |
function mosComponent() { |
| 180 |
$db = mamboDatabase::getInstance(); |
$db = mamboDatabase::getInstance(); |
| 181 |
$this->mosDBTable( '#__components', 'id', $db ); |
$this->mosDBTable( '#__components', 'id', $db ); |
| 182 |
} |
} |
| 183 |
} |
} |
| 184 |
|
|
| 185 |
/** |
/** |
| 186 |
* Component common base class for both user and admin sides |
* Abstract component common base class for both user and admin sides |
| 187 |
|
* |
| 188 |
|
* Since 4.6 version a new way to develop components based in MVC pattern was included, |
| 189 |
|
* this requires that each component should to create a instance from mosComponentUserManager |
| 190 |
|
* to user(frontend) side and a instance from mosComponentAdminManager to admin(backend) side, |
| 191 |
|
* both classes are derived from this abstract class |
| 192 |
|
* |
| 193 |
* @package Mambo |
* @package Mambo |
| 194 |
|
* @access public |
| 195 |
*/ |
*/ |
| 196 |
class mosComponentManager { |
class mosComponentManager { |
| 197 |
|
/** @var string component name */ |
| 198 |
var $plugin_name = ''; |
var $plugin_name = ''; |
| 199 |
var $magic_quotes_value = 0; |
var $magic_quotes_value = 0; |
| 200 |
|
/** @var int current magic quotes value, used to restore it */ |
| 201 |
var $magic_quotes_restore = ''; |
var $magic_quotes_restore = ''; |
| 202 |
|
/** @var string component version*/ |
| 203 |
var $plugin_version = ''; |
var $plugin_version = ''; |
| 204 |
|
/** @var string option from URL*/ |
| 205 |
var $option = ''; |
var $option = ''; |
| 206 |
|
|
| 207 |
|
/** |
| 208 |
|
* mosComponentManager Class contructor |
| 209 |
|
* |
| 210 |
|
* This constructor initiates all necessary members, clear all magic quotes if |
| 211 |
|
* is present and load the language from component |
| 212 |
|
* |
| 213 |
|
* @access private |
| 214 |
|
* @param string $component_name component name |
| 215 |
|
* @param string $version component version |
| 216 |
|
*/ |
| 217 |
function mosComponentManager ($component_name, $version) { |
function mosComponentManager ($component_name, $version) { |
| 218 |
$this->text_name = $component_name; |
$this->text_name = $component_name; |
| 219 |
$this->plugin_name = strtolower(str_replace(' ', '', $component_name)); |
$this->plugin_name = strtolower(str_replace(' ', '', $component_name)); |
| 228 |
|
|
| 229 |
} |
} |
| 230 |
|
|
| 231 |
|
/** |
| 232 |
|
* remove magic quotes from Superglobals arrays |
| 233 |
|
* |
| 234 |
|
* This function removes the magic quotes if is present in $_REQUEST, $_GET |
| 235 |
|
* and $_POST arrays |
| 236 |
|
* |
| 237 |
|
* @access private |
| 238 |
|
*/ |
| 239 |
function noMagicQuotes () { |
function noMagicQuotes () { |
| 240 |
// Is magic quotes on? |
// Is magic quotes on? |
| 241 |
if (get_magic_quotes_gpc()) { |
if (get_magic_quotes_gpc()) { |
| 248 |
$this->magic_quotes_value = 0; |
$this->magic_quotes_value = 0; |
| 249 |
} |
} |
| 250 |
|
|
| 251 |
|
/** |
| 252 |
|
* remove magic quotes and slashes from a array |
| 253 |
|
* |
| 254 |
|
* This function removes the magic quotes if is present in passed array |
| 255 |
|
* |
| 256 |
|
* @access private |
| 257 |
|
* @param array $array array to strip quotes and slashes |
| 258 |
|
* @return array reference to converted array |
| 259 |
|
*/ |
| 260 |
function &remove_magic_quotes ($array) { |
function &remove_magic_quotes ($array) { |
| 261 |
foreach ($array as $k => $v) { |
foreach ($array as $k => $v) { |
| 262 |
if (is_array($v)) $array[$k] = $this->remove_magic_quotes($v); |
if (is_array($v)) $array[$k] = $this->remove_magic_quotes($v); |
| 265 |
return $array; |
return $array; |
| 266 |
} |
} |
| 267 |
|
|
| 268 |
|
/** |
| 269 |
|
* restore magic quotes from old value |
| 270 |
|
* |
| 271 |
|
* This function restore the old value of magic_quotes_runtime |
| 272 |
|
* |
| 273 |
|
* @access private |
| 274 |
|
*/ |
| 275 |
function restore_magic_quotes () { |
function restore_magic_quotes () { |
| 276 |
set_magic_quotes_runtime($this->magic_quotes_restore); |
set_magic_quotes_runtime($this->magic_quotes_restore); |
| 277 |
} |
} |
| 278 |
|
|
| 279 |
|
/** |
| 280 |
|
* checks for a method in a class |
| 281 |
|
* |
| 282 |
|
* This function returns TRUE when $method is a member of $object |
| 283 |
|
* |
| 284 |
|
* @access public |
| 285 |
|
* @param object &$object Reference to the object |
| 286 |
|
* @param string $method method name that is looking for |
| 287 |
|
* @return bool TRUE when $method exits |
| 288 |
|
*/ |
| 289 |
function checkCallable (&$object, $method) { |
function checkCallable (&$object, $method) { |
| 290 |
if (is_callable(array(&$object, $method))) return true; |
if (is_callable(array(&$object, $method))) return true; |
| 291 |
$name = get_class($object); |
$name = get_class($object); |
| 294 |
} |
} |
| 295 |
|
|
| 296 |
} |
} |
| 297 |
|
|
| 298 |
/** |
/** |
| 299 |
* Component base logic for user side |
* Component base controller for user(frontend) side |
| 300 |
|
* |
| 301 |
|
* Since 4.6 version a new way to develop components based in MVC pattern was included, |
| 302 |
|
* this requires that each component should to create a instance from mosComponentUserManager |
| 303 |
|
* to user(frontend) side. |
| 304 |
|
* |
| 305 |
|
* Example of use: |
| 306 |
|
* |
| 307 |
|
* <code> |
| 308 |
|
* $alternatives = array (); |
| 309 |
|
* $admin =& new mosComponentUserManager ('mycom', 'task', $alternatives, 'list', 'My Component', '1.0'); |
| 310 |
|
* </code> |
| 311 |
|
* |
| 312 |
* @package Mambo |
* @package Mambo |
| 313 |
|
* @access public |
| 314 |
*/ |
*/ |
| 315 |
class mosComponentUserManager extends mosComponentManager { |
class mosComponentUserManager extends mosComponentManager { |
| 316 |
|
|
| 317 |
|
/** |
| 318 |
|
* mosComponentUserManager Class contructor |
| 319 |
|
* |
| 320 |
|
* This constructor initiates all necessary members, sets the title to browser, |
| 321 |
|
* creates a new instance of the correct class and calls the action to do, finally |
| 322 |
|
* restore the magic quotes to it initial state |
| 323 |
|
* |
| 324 |
|
* @access private |
| 325 |
|
* @param string $component_name component name |
| 326 |
|
* @param string $control_name variable used as control |
| 327 |
|
* @param array $alternatives array whin alternavite names to actions methods |
| 328 |
|
* @param string $default default action to do |
| 329 |
|
* @param string $title browser title to show when the component is in use |
| 330 |
|
* @param string $version component version |
| 331 |
|
*/ |
| 332 |
function mosComponentUserManager ($component_name, $control_name, $alternatives, $default, $title, $version) { |
function mosComponentUserManager ($component_name, $control_name, $alternatives, $default, $title, $version) { |
| 333 |
mosComponentManager::mosComponentManager($component_name, $version); |
mosComponentManager::mosComponentManager($component_name, $version); |
| 334 |
$mainframe =& mosMainFrame::getInstance(); |
$mainframe =& mosMainFrame::getInstance(); |
| 346 |
$this->restore_magic_quotes(); |
$this->restore_magic_quotes(); |
| 347 |
} |
} |
| 348 |
|
|
| 349 |
|
/** |
| 350 |
|
* Loads and returns a class for render HTML (view Object) |
| 351 |
|
* |
| 352 |
|
* This function load a class for view html an associated controller is passed |
| 353 |
|
* |
| 354 |
|
* @access public |
| 355 |
|
* @param strinf $name HTML view class name |
| 356 |
|
* @param object &$controller reference to controller object |
| 357 |
|
* @param int $total_items not used |
| 358 |
|
* @param int $clist list of items to show |
| 359 |
|
* @return mixed a instance to the HTML class, FALSE if the class is not founded |
| 360 |
|
*/ |
| 361 |
function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
| 362 |
if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
| 363 |
trigger_error(sprintf(T_('Component %s error: attempt to use non-existent class %s'), $this->plugin_name, $name)); |
trigger_error(sprintf(T_('Component %s error: attempt to use non-existent class %s'), $this->plugin_name, $name)); |
| 365 |
} |
} |
| 366 |
|
|
| 367 |
} |
} |
| 368 |
|
|
| 369 |
/** |
/** |
| 370 |
* Component base logic for admin side |
* Component base controller for admin side |
| 371 |
|
* |
| 372 |
|
* Since 4.6 version a new way to develop components based in MVC pattern was included, |
| 373 |
|
* this requires that each component should to create a instance from mosComponentAdminManager |
| 374 |
|
* to admin(backend) side. |
| 375 |
|
* |
| 376 |
|
* Example of use: |
| 377 |
|
* |
| 378 |
|
* <code> |
| 379 |
|
* $admin =& new mosComponentAdminManager ('mycom', '1.0'); |
| 380 |
|
* </code> |
| 381 |
|
* |
| 382 |
* @package Mambo |
* @package Mambo |
| 383 |
|
* @access public |
| 384 |
*/ |
*/ |
| 385 |
class mosComponentAdminManager extends mosComponentManager { |
class mosComponentAdminManager extends mosComponentManager { |
| 386 |
|
/** @var string action executed */ |
| 387 |
var $act = ''; |
var $act = ''; |
| 388 |
|
/** @var string task executed */ |
| 389 |
var $task = ''; |
var $task = ''; |
| 390 |
|
/** @var int init offset to admin list*/ |
| 391 |
var $limitstart = 0; |
var $limitstart = 0; |
| 392 |
|
/** @var int quantity of elements to show in list*/ |
| 393 |
var $limit = 0; |
var $limit = 0; |
| 394 |
|
/** @var mixed id or id's of selected objects in admin list */ |
| 395 |
var $cfid = 0; |
var $cfid = 0; |
| 396 |
|
/** @var array order positions for all items */ |
| 397 |
var $order = 0; |
var $order = 0; |
| 398 |
|
/** @var int first element of cfid */ |
| 399 |
var $currid = 0; |
var $currid = 0; |
| 400 |
|
|
| 401 |
|
/** |
| 402 |
|
* mosComponentAdminManager Class contructor |
| 403 |
|
* |
| 404 |
|
* This constructor initiates all necessary members with values passed trought REQUEST |
| 405 |
|
* creates a new instance of the correct class and calls the task to do, finally |
| 406 |
|
* restore the magic quotes to it initial state. |
| 407 |
|
* |
| 408 |
|
* @param string $component_name component name |
| 409 |
|
* @param string $version component version |
| 410 |
|
* @access private |
| 411 |
|
*/ |
| 412 |
function mosComponentAdminManager ($component_name, $version) { |
function mosComponentAdminManager ($component_name, $version) { |
| 413 |
mosComponentManager::mosComponentManager($component_name, $version); |
mosComponentManager::mosComponentManager($component_name, $version); |
| 414 |
$this->act = mosGetParam ($_REQUEST, 'act', $this->plugin_name); |
$this->act = mosGetParam ($_REQUEST, 'act', $this->plugin_name); |
| 434 |
$this->restore_magic_quotes(); |
$this->restore_magic_quotes(); |
| 435 |
} |
} |
| 436 |
|
|
| 437 |
|
/** |
| 438 |
|
* Checks that at least one item selected |
| 439 |
|
* |
| 440 |
|
* @param string $text alert message |
| 441 |
|
* @access public |
| 442 |
|
*/ |
| 443 |
function check_selection ($text) { |
function check_selection ($text) { |
| 444 |
if (!is_array($this->cfid) OR count( $this->cfid ) < 1) { |
if (!is_array($this->cfid) OR count( $this->cfid ) < 1) { |
| 445 |
echo "<script> alert('".$text."'); window.history.go(-1);</script>\n"; |
echo "<script> alert('".$text."'); window.history.go(-1);</script>\n"; |
| 447 |
} |
} |
| 448 |
} |
} |
| 449 |
|
|
| 450 |
|
/** |
| 451 |
|
* returns the class name from the current action |
| 452 |
|
* |
| 453 |
|
* @return string class name from the current action |
| 454 |
|
* @access public |
| 455 |
|
*/ |
| 456 |
function getAction () { |
function getAction () { |
| 457 |
$actname = strtoupper(substr($this->act,0,1)).strtolower(substr($this->act,1)); |
$actname = strtoupper(substr($this->act,0,1)).strtolower(substr($this->act,1)); |
| 458 |
return strtolower($this->plugin_name).'Admin'.$actname; |
return strtolower($this->plugin_name).'Admin'.$actname; |
| 459 |
} |
} |
| 460 |
|
|
| 461 |
|
/** |
| 462 |
|
* Loads and returns a class for render HTML (view Object) |
| 463 |
|
* |
| 464 |
|
* This function load a class for view html an associated controller is passed |
| 465 |
|
* |
| 466 |
|
* @access public |
| 467 |
|
* @param strinf $name HTML view class name |
| 468 |
|
* @param object &$controller reference to controller object |
| 469 |
|
* @param int $total_items not used |
| 470 |
|
* @param int $clist list of items to show |
| 471 |
|
* @return mixed a instance to the HTML class, FALSE if the class is not founded |
| 472 |
|
*/ |
| 473 |
function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
function newHTMLClassCheck ($name, &$controller, $total_items, $clist) { |
| 474 |
$controller->makePageNav($this, $total_items); |
$controller->makePageNav($this, $total_items); |
| 475 |
if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
if (class_exists($name)) return new $name ($controller, $this->limit, $clist); |
| 478 |
} |
} |
| 479 |
|
|
| 480 |
} |
} |
| 481 |
|
|
| 482 |
/** |
/** |
| 483 |
* Component base class for admin side component controller logic |
* Abstract component base class for admin side component controller logic (not used yet) |
| 484 |
|
* |
| 485 |
* @package Mambo |
* @package Mambo |
| 486 |
|
* @access public |
| 487 |
|
* @todo This class is not used yet |
| 488 |
*/ |
*/ |
| 489 |
class mosComponentAdminControllers { |
class mosComponentAdminControllers { |
| 490 |
|
/** @var string action executed */ |
| 491 |
var $admin = ''; |
var $admin = ''; |
| 492 |
|
/** @var string curren user */ |
| 493 |
var $user = ''; |
var $user = ''; |
| 494 |
|
/** @var object Page navigation Object */ |
| 495 |
var $pageNav = ''; |
var $pageNav = ''; |
| 496 |
|
/** @var string curren root path */ |
| 497 |
var $rootPath = ''; |
var $rootPath = ''; |
| 498 |
|
/** @var string curren language */ |
| 499 |
var $language = ''; |
var $language = ''; |
| 500 |
|
|
| 501 |
|
/** |
| 502 |
|
* mosComponentAdminControllers Class contructor |
| 503 |
|
* |
| 504 |
|
* @param object $admin |
| 505 |
|
* @access private |
| 506 |
|
*/ |
| 507 |
function mosComponentAdminControllers ($admin) { |
function mosComponentAdminControllers ($admin) { |
| 508 |
$this->admin = $admin; |
$this->admin = $admin; |
| 509 |
$this->user = mamboCore::get('currentUser'); |
$this->user = mamboCore::get('currentUser'); |
| 511 |
$this->language = mamboCore::get('mosConfig_lang'); |
$this->language = mamboCore::get('mosConfig_lang'); |
| 512 |
} |
} |
| 513 |
|
|
| 514 |
|
/** |
| 515 |
|
* Creates a mosPageNav object |
| 516 |
|
* |
| 517 |
|
* @param object &$admin component name |
| 518 |
|
* @param int $total not used |
| 519 |
|
* @access public |
| 520 |
|
*/ |
| 521 |
function makePageNav (&$admin, $total) { |
function makePageNav (&$admin, $total) { |
| 522 |
require_once(mamboCore::get('mosConfig_absolute_path').'/administrator/includes/pageNavigation.php'); |
require_once(mamboCore::get('mosConfig_absolute_path').'/administrator/includes/pageNavigation.php'); |
| 523 |
$this->pageNav =& new mosPageNav( $total, $admin->limitstart, $admin->limit ); |
$this->pageNav =& new mosPageNav( $total, $admin->limitstart, $admin->limit ); |
| 526 |
} |
} |
| 527 |
|
|
| 528 |
/** |
/** |
| 529 |
* Template Table Class |
* Template database table class |
| 530 |
|
* |
| 531 |
|
* This class can be used to gain access to #_templates database table |
| 532 |
|
* |
| 533 |
|
* Example of use: |
| 534 |
* |
* |
| 535 |
* Provides access to the mos_templates table |
* To load all templates in a object.. |
| 536 |
|
* |
| 537 |
|
* <code> |
| 538 |
|
* $row = new mosTemplate(); |
| 539 |
|
* $query = "SELECT * FROM #__templates"; |
| 540 |
|
* $database =& mamboDatabase::getInstance(); |
| 541 |
|
* $database->setQuery( $query ); |
| 542 |
|
* if ($database->loadObject($row)) { |
| 543 |
|
* ... |
| 544 |
|
* } |
| 545 |
|
* </code> |
| 546 |
* @package Mambo |
* @package Mambo |
| 547 |
|
* @access public |
| 548 |
|
* @todo This class is not used yet |
| 549 |
*/ |
*/ |
| 550 |
|
|
| 551 |
class mosTemplate extends mosDBTable { |
class mosTemplate extends mosDBTable { |
| 552 |
/** @var int */ |
/** @var int table primary key */ |
| 553 |
var $id=null; |
var $id=null; |
| 554 |
/** @var string */ |
/** @var string is act*/ |
| 555 |
var $cur_template=null; |
var $cur_template=null; |
| 556 |
/** @var int */ |
/** @var int */ |
| 557 |
var $col_main=null; |
var $col_main=null; |
| 558 |
|
|
| 559 |
/** |
/** |
| 560 |
* @param database A database connector object |
* mosTemplate Class contructor |
| 561 |
|
* |
| 562 |
|
* Init a mosDBTable object. |
| 563 |
|
* |
| 564 |
|
* @param object &$database reference to current database object |
| 565 |
|
* @access private |
| 566 |
*/ |
*/ |
| 567 |
function mosTemplate( &$database ) { |
function mosTemplate( &$database ) { |
| 568 |
$this->mosDBTable( '#__templates', 'id', $database ); |
$this->mosDBTable( '#__templates', 'id', $database ); |
| 570 |
} |
} |
| 571 |
|
|
| 572 |
/** |
/** |
| 573 |
* Class mosMambot |
* Mambot database table class |
| 574 |
|
* |
| 575 |
|
* This class can be used to gain access to #_mambots database table |
| 576 |
|
* |
| 577 |
|
* Example of use: |
| 578 |
|
* |
| 579 |
|
* To load editor mambots in a object.. |
| 580 |
|
* |
| 581 |
|
* <code> |
| 582 |
|
* $row = new mosMambot(); |
| 583 |
|
* $query = "SELECT * FROM #_mambots WHERE folder = 'editors'"; |
| 584 |
|
* $database =& mamboDatabase::getInstance(); |
| 585 |
|
* $database->setQuery( $query ); |
| 586 |
|
* if ($database->loadObject($row)) { |
| 587 |
|
* ... |
| 588 |
|
* } |
| 589 |
|
* </code> |
| 590 |
* @package Mambo |
* @package Mambo |
| 591 |
|
* @access public |
| 592 |
*/ |
*/ |
| 593 |
class mosMambot extends mosDBTable { |
class mosMambot extends mosDBTable { |
| 594 |
/** @var int */ |
/** @var int table primary key */ |
| 595 |
var $id=null; |
var $id=null; |
| 596 |
/** @var varchar */ |
/** @var string mambot name */ |
| 597 |
var $name=null; |
var $name=null; |
| 598 |
/** @var varchar */ |
/** @var string element name */ |
| 599 |
var $element=null; |
var $element=null; |
| 600 |
/** @var varchar */ |
/** @var string mambot kind */ |
| 601 |
var $folder=null; |
var $folder=null; |
| 602 |
/** @var tinyint unsigned */ |
/** @var int access level 0 public, 1 registered, 2 special */ |
| 603 |
var $access=null; |
var $access=null; |
| 604 |
/** @var int */ |
/** @var int order lower first*/ |
| 605 |
var $ordering=null; |
var $ordering=null; |
| 606 |
/** @var tinyint */ |
/** @var int 1 published, 0 unpublished */ |
| 607 |
var $published=null; |
var $published=null; |
| 608 |
/** @var tinyint */ |
/** @var int 1 core mambots ,0 others */ |
| 609 |
var $iscore=null; |
var $iscore=null; |
| 610 |
/** @var tinyint */ |
/** @var int 1 admin mambot, 0 user mambot*/ |
| 611 |
var $client_id=null; |
var $client_id=null; |
| 612 |
/** @var int unsigned */ |
/** @var int id from the user that checkout, 0 checkin */ |
| 613 |
var $checked_out=null; |
var $checked_out=null; |
| 614 |
/** @var datetime */ |
/** @var datetime date and time from checkout*/ |
| 615 |
var $checked_out_time=null; |
var $checked_out_time=null; |
| 616 |
/** @var text */ |
/** @var string mambot parameters */ |
| 617 |
var $params=null; |
var $params=null; |
| 618 |
|
|
| 619 |
|
/** |
| 620 |
|
* mosMambot Class contructor |
| 621 |
|
* |
| 622 |
|
* Init a mosDBTable object. |
| 623 |
|
* |
| 624 |
|
* @param object &$db reference to current database object |
| 625 |
|
* @access private |
| 626 |
|
*/ |
| 627 |
function mosMambot( &$db ) { |
function mosMambot( &$db ) { |
| 628 |
$this->mosDBTable( '#__mambots', 'id', $db ); |
$this->mosDBTable( '#__mambots', 'id', $db ); |
| 629 |
} |
} |
| 630 |
} |
} |
| 631 |
|
|
| 632 |
|
/** |
| 633 |
|
* Singleton class to handle with modules |
| 634 |
|
* |
| 635 |
|
* This class loads, counts and caches modules for both sides, user and admin |
| 636 |
|
* |
| 637 |
|
* @package Mambo |
| 638 |
|
* @acces public |
| 639 |
|
*/ |
| 640 |
class mosModuleHandler { |
class mosModuleHandler { |
| 641 |
|
/** |
| 642 |
|
* @var object current database object |
| 643 |
|
* @access private |
| 644 |
|
*/ |
| 645 |
var $_db = null; |
var $_db = null; |
| 646 |
|
/** |
| 647 |
|
* @var object modules cached |
| 648 |
|
* @access private |
| 649 |
|
*/ |
| 650 |
var $_modules = null; |
var $_modules = null; |
| 651 |
|
/** |
| 652 |
|
* @var array unpublished modules |
| 653 |
|
* @access private |
| 654 |
|
*/ |
| 655 |
var $_unpublished = null; |
var $_unpublished = null; |
| 656 |
|
/** |
| 657 |
|
* @var bool TRUE when admin modules are loaded |
| 658 |
|
* @access private |
| 659 |
|
*/ |
| 660 |
var $_isAdmin = null; |
var $_isAdmin = null; |
| 661 |
|
|
| 662 |
|
/** |
| 663 |
|
* mosModuleHandler Class contructor |
| 664 |
|
* |
| 665 |
|
* Init the database object. |
| 666 |
|
* |
| 667 |
|
* @access private |
| 668 |
|
*/ |
| 669 |
function mosModuleHandler () { |
function mosModuleHandler () { |
| 670 |
$this->_db =& mamboDatabase::getInstance(); |
$this->_db =& mamboDatabase::getInstance(); |
| 671 |
} |
} |
| 672 |
|
|
| 673 |
|
/** |
| 674 |
|
* Returns a reference to current handler |
| 675 |
|
* |
| 676 |
|
* This function returns a reference to current modules handler, if none handler exists, |
| 677 |
|
* it creates one. |
| 678 |
|
* |
| 679 |
|
* Example of use: |
| 680 |
|
* |
| 681 |
|
* <code>$m_handler =& mosModuleHandler::getInstance();</code> |
| 682 |
|
* |
| 683 |
|
* @acces public |
| 684 |
|
* @return object reference to current singleton Handler |
| 685 |
|
*/ |
| 686 |
function &getInstance () { |
function &getInstance () { |
| 687 |
static $instance; |
static $instance; |
| 688 |
if (!is_object($instance)) $instance = new mosModuleHandler(); |
if (!is_object($instance)) $instance = new mosModuleHandler(); |
| 690 |
} |
} |
| 691 |
|
|
| 692 |
/** |
/** |
| 693 |
* Cache some modules information |
* Caches some modules information |
| 694 |
* @return array |
* |
| 695 |
|
* This function cache all modules, a $isAdmin bool value can be passed to select |
| 696 |
|
* the side (user/admin) by default user modules are loaded. |
| 697 |
|
* |
| 698 |
|
* @access private |
| 699 |
|
* @param bool $isAdmin TRUE when admin modules will loaded |
| 700 |
*/ |
*/ |
| 701 |
function initModules($isAdmin=false) { |
function initModules($isAdmin=false) { |
| 702 |
if (!isset($this->_modules) OR $isAdmin != $this->_isAdmin) { |
if (!isset($this->_modules) OR $isAdmin != $this->_isAdmin) { |
| 727 |
} |
} |
| 728 |
} |
} |
| 729 |
/** |
/** |
| 730 |
* @param string THe template position |
* Returns the number of modules in a specified position, this method is called by |
| 731 |
|
* mosCountModules global function |
| 732 |
|
* |
| 733 |
|
* Example of use. |
| 734 |
|
* |
| 735 |
|
* to count all modules in top position |
| 736 |
|
* |
| 737 |
|
* <code> |
| 738 |
|
* $handler =& mosModuleHandler::getInstance(); |
| 739 |
|
* $quan = $handler->mosCountModules('top'); |
| 740 |
|
* </code> |
| 741 |
|
* |
| 742 |
|
* @access public |
| 743 |
|
* @param string The template position |
| 744 |
|
* @param bool $isAdmin TRUE when admin modules will loaded |
| 745 |
*/ |
*/ |
| 746 |
function mosCountModules( $position='left', $isAdmin=false ) { |
function mosCountModules( $position='left', $isAdmin=false ) { |
| 747 |
$this->initModules($isAdmin); |
$this->initModules($isAdmin); |
| 749 |
} |
} |
| 750 |
|
|
| 751 |
/** |
/** |
| 752 |
|
* Returns a array with modules that match whit $name, when $unpublished is TRUE |
| 753 |
|
* unpublished modules are returned too. |
| 754 |
|
* |
| 755 |
|
* Example of use: |
| 756 |
|
* |
| 757 |
|
* To get all modules included unpublished called 'mod_mainmenu' you can.. |
| 758 |
|
* |
| 759 |
|
* <code> |
| 760 |
|
* $modulehandler =& mosModuleHandler::getInstance(); |
| 761 |
|
* $modMenus =& $modulehandler->getByName('mod_mainmenu', false, true); |
| 762 |
|
* </code> |
| 763 |
|
* |
| 764 |
|
* @access public |
| 765 |
* @param string Name of module required |
* @param string Name of module required |
| 766 |
|
* @param bool $isAdmin TRUE when admin modules will loaded |
| 767 |
|
* @param bool $unpublished TRUE whish to include unpublished modules too |
| 768 |
|
* @return array array with all modules that match |
| 769 |
*/ |
*/ |
| 770 |
function &getByName( $name, $isAdmin=false, $unpublished=false ) { |
function &getByName( $name, $isAdmin=false, $unpublished=false ) { |
| 771 |
$this->initModules($isAdmin); |
$this->initModules($isAdmin); |
| 778 |
} |
} |
| 779 |
|
|
| 780 |
/** |
/** |
| 781 |
* @param string The position |
* Loads all published modules from a specified position, a $style can be passed |
| 782 |
* @param int The style. 0=normal, 1=horiz, -1=no wrapper |
* to change the style of output |
| 783 |
|
* |
| 784 |
|
* @param string $position The position |
| 785 |
|
* @param int $style The style. 0=normal(default), 1=horiz, -1=no wrapper |
| 786 |
|
* @param bool $isAdmin TRUE when admin modules will loaded |
| 787 |
*/ |
*/ |
| 788 |
function mosLoadModules( $position='left', $style=0, $isAdmin=false ) { |
function mosLoadModules( $position='left', $style=0, $isAdmin=false ) { |
| 789 |
$Itemid = mamboCore::get('Itemid'); |
$Itemid = mamboCore::get('Itemid'); |
| 826 |
} |
} |
| 827 |
|
|
| 828 |
/** |
/** |
| 829 |
* Loads admin modules via module position |
* Loads admin modules from a specified position,a $style can be passed |
| 830 |
* @param string The position |
* to change the style of output |
| 831 |
* @param int 0 = no style, 1 = tabbed |
* |
| 832 |
|
* @param string $position The position |
| 833 |
|
* @param int $style 0 = no style(default), 1 = tabbed, 2 = use div |
| 834 |
*/ |
*/ |
| 835 |
function mosLoadAdminModules( $position='left', $style=0 ) { |
function mosLoadAdminModules( $position='left', $style=0 ) { |
| 836 |
global $my, $acl; |
global $my, $acl; |
| 884 |
} |
} |
| 885 |
|
|
| 886 |
/** |
/** |
| 887 |
* Module database table class |
* Modules database table class |
| 888 |
|
* |
| 889 |
|
* This class can be used to gain access to #_modules database table |
| 890 |
|
* |
| 891 |
|
* Example of use: |
| 892 |
|
* |
| 893 |
|
* To load all modules in a object.. |
| 894 |
|
* |
| 895 |
|
* <code> |
| 896 |
|
* $row = new mosModule(); |
| 897 |
|
* $query = "SELECT * FROM #_modules"; |
| 898 |
|
* $database =& mamboDatabase::getInstance(); |
| 899 |
|
* $database->setQuery( $query ); |
| 900 |
|
* if ($database->loadObject($row)) { |
| 901 |
|
* ... |
| 902 |
|
* } |
| 903 |
|
* </code> |
| 904 |
* @package Mambo |
* @package Mambo |
| 905 |
|
* @access public |
| 906 |
*/ |
*/ |
| 907 |
class mosModule extends mosDBTable { |
class mosModule extends mosDBTable { |
| 908 |
/** @var int Primary key */ |
/** @var int Primary key */ |
| 909 |
var $id=null; |
var $id=null; |
| 910 |
/** @var string */ |
/** @var string module title */ |
| 911 |
var $title=null; |
var $title=null; |
| 912 |
/** @var string */ |
/** @var bool TRUE show title, FALSE hide title*/ |
| 913 |
var $showtitle=null; |
var $showtitle=null; |
| 914 |
/** @var int */ |
/** @var string content to custom modules*/ |
| 915 |
var $content=null; |
var $content=null; |
| 916 |
/** @var int */ |
/** @var int order lower first*/ |
| 917 |
var $ordering=null; |
var $ordering=null; |
| 918 |
/** @var string */ |
/** @var string template position*/ |
| 919 |
var $position=null; |
var $position=null; |
| 920 |
/** @var boolean */ |
/** @var int id from the user that checkout, 0 checkin */ |
| 921 |
var $checked_out=null; |
var $checked_out=null; |
| 922 |
/** @var time */ |
/** @var int date and time from checkout */ |
| 923 |
var $checked_out_time=null; |
var $checked_out_time=null; |
| 924 |
/** @var boolean */ |
/** @var bool TRUE published, FALSE unpublished*/ |
| 925 |
var $published=null; |
var $published=null; |
| 926 |
/** @var string */ |
/** @var string module name*/ |
| 927 |
var $module=null; |
var $module=null; |
| 928 |
/** @var int */ |
/** @var int num of news from newsfeed modules*/ |
| 929 |
var $numnews=null; |
var $numnews=null; |
| 930 |
/** @var int */ |
/** @var int access level 0 public, 1 registered, 2 special */ |
| 931 |
var $access=null; |
var $access=null; |
| 932 |
/** @var string */ |
/** @var string module parameters*/ |
| 933 |
var $params=null; |
var $params=null; |
| 934 |
/** @var string */ |
/** @var int 1 core mambots ,0 others */ |
| 935 |
var $iscore=null; |
var $iscore=null; |
| 936 |
/** @var string */ |
/** @var int 1 admin module, 0 user module*/ |
| 937 |
var $client_id=null; |
var $client_id=null; |
| 938 |
|
|
| 939 |
/** |
/** |
| 940 |
* @param database A database connector object |
* mosModule Class contructor |
| 941 |
|
* |
| 942 |
|
* Init a mosDBTable object. |
| 943 |
|
* |
| 944 |
|
* @param object &$db reference to current database object |
| 945 |
|
* @access private |
| 946 |
*/ |
*/ |
| 947 |
function mosModule( &$db ) { |
function mosModule( &$db ) { |
| 948 |
$this->mosDBTable( '#__modules', 'id', $db ); |
$this->mosDBTable( '#__modules', 'id', $db ); |
| 949 |
} |
} |
| 950 |
// overloaded check function |
|
| 951 |
|
/** |
| 952 |
|
* overloaded check function |
| 953 |
|
* |
| 954 |
|
* @access private |
| 955 |
|
*/ |
| 956 |
function check() { |
function check() { |
| 957 |
// check for valid name |
// check for valid name |
| 958 |
if (trim( $this->title ) == '') { |
if (trim( $this->title ) == '') { |