View of /mambo/branches/4.6/includes/cmtclasses.php
Parent Directory
|
Revision Log
Revision 129 -
(download)
(annotate)
Sat Jan 14 18:19:40 2006 UTC (7 years, 4 months ago) by csouza
File size: 9905 byte(s)
Sat Jan 14 18:19:40 2006 UTC (7 years, 4 months ago) by csouza
File size: 9905 byte(s)
csouza - Merging 4.5.4 changes (revisions 118 to 127) into 4.6.
<?php
class mosComponentHandler {
var $_buffer = '';
function &getInstance () {
static $instance;
if (!is_object($instance)) $instance = new mosComponentHandler();
return $instance;
}
function &getParamsByName ($name) {
$params = null;
$row = new mosComponent( $database );
$query = "SELECT a.params, a.option"
. "\n FROM #__components AS a"
. "\n WHERE a.name = '$name'"
;
$database = mamboDatabase::getInstance();
$database->setQuery( $query );
// load the row from the db table
if ($database->loadObject($row)) {
// get params definitions
$mainframe = mosMainFrame::getInstance();
$params =& new mosParameters( $row->params, $mainframe->getPath( 'com_xml', $row->option ), 'component' );
}
return $params;
}
function mosMainBody() {
// message passed via the url
$mosmsg = mosGetParam($_REQUEST, 'mosmsg', '');
if ($mosmsg) {
if (!get_magic_quotes_gpc()) $mosmsg = addslashes( $mosmsg );
echo "\n<div class=\"message\">$mosmsg</div>";
}
echo $this->_buffer;
// Alternative if "popmessages" - apparently never implemented
// echo "\n<script language=\"javascript\">alert('$mosmsg');</script>";
}
function startBuffer () {
$this->_buffer = '';
ob_start();
}
function endBuffer () {
$this->_buffer = ob_get_contents();
ob_end_clean();
}
}
/**
* Component database table class
* @package Mambo
*/
class mosComponent extends mosDBTable {
/** @var int Primary key */
var $id=null;
/** @var string */
var $name=null;
/** @var string */
var $link=null;
/** @var int */
var $menuid=null;
/** @var int */
var $parent=null;
/** @var string */
var $admin_menu_link=null;
/** @var string */
var $admin_menu_alt=null;
/** @var string */
var $option=null;
/** @var string */
var $ordering=null;
/** @var string */
var $admin_menu_img=null;
/** @var int */
var $iscore=null;
/** @var string */
var $params=null;
/**
* @param database A database connector object
*/
function mosComponent( &$db ) {
$this->mosDBTable( '#__components', 'id', $db );
}
}
/**
* Template Table Class
*
* Provides access to the mos_templates table
* @package Mambo
*/
class mosTemplate extends mosDBTable {
/** @var int */
var $id=null;
/** @var string */
var $cur_template=null;
/** @var int */
var $col_main=null;
/**
* @param database A database connector object
*/
function mosTemplate( &$database ) {
$this->mosDBTable( '#__templates', 'id', $database );
}
}
/**
* Class mosMambot
* @package Mambo
*/
class mosMambot extends mosDBTable {
/** @var int */
var $id=null;
/** @var varchar */
var $name=null;
/** @var varchar */
var $element=null;
/** @var varchar */
var $folder=null;
/** @var tinyint unsigned */
var $access=null;
/** @var int */
var $ordering=null;
/** @var tinyint */
var $published=null;
/** @var tinyint */
var $iscore=null;
/** @var tinyint */
var $client_id=null;
/** @var int unsigned */
var $checked_out=null;
/** @var datetime */
var $checked_out_time=null;
/** @var text */
var $params=null;
function mosMambot( &$db ) {
$this->mosDBTable( '#__mambots', 'id', $db );
}
}
class mosModuleHandler {
var $_db = null;
var $_modules = null;
function mosModuleHandler () {
$this->_db = mamboDatabase::getInstance();
}
function &getInstance () {
static $instance;
if (!is_object($instance)) $instance = new mosModuleHandler();
return $instance;
}
/**
* Cache some modules information
* @return array
*/
function initModules($isAdmin=false) {
if (!isset($this->_modules)) {
if ($isAdmin) {
$query = "SELECT id, title, module, position, content, showtitle, params"
. "\n FROM #__modules AS m"
. "\n WHERE m.published = '1'"
. "\n AND (m.client_id = 1)"
. "\n ORDER BY m.ordering";
}
else {
$my = mamboCore::get('currentUser');
$Itemid = mamboCore::get('Itemid');
$query = "SELECT id, title, module, position, content, showtitle, params"
."\nFROM #__modules AS m, #__modules_menu AS mm"
. "\nWHERE m.published='1' AND m.access <= '$my->gid' AND m.client_id='0'"
. "\nAND mm.moduleid=m.id"
. "\nAND (mm.menuid = '$Itemid' OR mm.menuid = '0')"
. "\nORDER BY ordering";
}
$this->_db->setQuery( $query );
$modules = $this->_db->loadObjectList();
foreach ($modules as $module) {
$this->_modules[$module->position][] = $module;
}
}
}
/**
* @param string THe template position
*/
function mosCountModules( $position='left', $isAdmin=false ) {
$this->initModules($isAdmin);
return isset($this->_modules[$position]) ? count($this->_modules[$position]) : 0;
}
/**
* @param string The position
* @param int The style. 0=normal, 1=horiz, -1=no wrapper
*/
function mosLoadModules( $position='left', $style=0, $isAdmin=false ) {
$Itemid = mamboCore::get('Itemid');
$tp = mosGetParam( $_GET, 'tp', 0 );
if ($tp) {
echo '<div style="height:50px;background-color:#eee;margin:2px;padding:10px;border:1px solid #f00;color:#700;">';
echo $position;
echo '</div>';
return;
}
$style = intval($style);
$cache =& mosCache::getCache('com_content');
require_once( mamboCore::get('mosConfig_absolute_path').'/includes/frontend.html.php');
$this->initModules($isAdmin);
if (isset($this->_modules[$position] )) $modules = $this->_modules[$position];
else {
$modules = array();
$style = 0;
}
if ($style == 1) {
echo "<table cellspacing=\"1\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
echo "<tr>\n";
}
$prepend = ($style == 1) ? "<td valign=\"top\">\n" : '';
$postpend = ($style == 1) ? "</td>\n" : '';
$count = 1;
foreach ($modules as $module) {
$params =& new mosParameters($module->params);
echo $prepend;
if ((substr("$module->module",0,4))=="mod_") $modfunc = 'module2';
else $modfunc = 'module';
if ($params->get('cache') == 1 AND mamboCore::get('mosConfig_caching') == 1) {
$cache->call("modules_html::$modfunc", $module, $params, $Itemid, $style );
}
else modules_html::$modfunc($module, $params, $Itemid, $style, $count);
echo $postpend;
$count++;
}
if ($style == 1) echo "</tr>\n</table>\n";
}
/**
* Loads admin modules via module position
* @param string The position
* @param int 0 = no style, 1 = tabbed
*/
function mosLoadAdminModules( $position='left', $style=0 ) {
global $my, $acl;
$this->initModules(true);
$cache =& mosCache::getCache( 'com_content' );
if (isset($this->_modules[$position] )) $modules = $this->_modules[$position];
else $modules = array();
switch ($style) {
case 0:
default:
foreach ($modules as $module) {
$params =& new mosParameters( $module->params );
if ( $module->module == '' ) mosLoadCustomModule( $module, $params );
else mosLoadAdminModule( substr( $module->module, 4 ), $params );
}
break;
case 1:
// Tabs
$tabs = new mosTabs(1);
$tabs->startPane( 'modules-' . $position );
foreach ($modules as $module) {
$params =& new mosParameters( $module->params );
$editAllComponents = $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' );
// $authoriser = new mosAuthoriser($database);
// $editAllComponents = $authoriser->checkPermission('mosUser', $my->id, 'edit', 'editAllComponents', 0);
// special handling for components module
if ( $module->module != 'mod_components' || ( $module->module == 'mod_components' && $editAllComponents ) ) {
$tabs->startTab( $module->title, 'module' . $module->id );
if ( $module->module == '' ) mosLoadCustomModule( $module, $params );
else mosLoadAdminModule( substr( $module->module, 4 ), $params );
$tabs->endTab();
}
}
$tabs->endPane();
break;
case 2:
// Div'd
foreach ($modules as $module) {
$params =& new mosParameters( $module->params );
echo '<div>';
if ( $module->module == '' ) mosLoadCustomModule( $module, $params );
else mosLoadAdminModule( substr( $module->module, 4 ), $params );
echo '</div>';
}
break;
}
}
}
/**
* Module database table class
* @package Mambo
*/
class mosModule extends mosDBTable {
/** @var int Primary key */
var $id=null;
/** @var string */
var $title=null;
/** @var string */
var $showtitle=null;
/** @var int */
var $content=null;
/** @var int */
var $ordering=null;
/** @var string */
var $position=null;
/** @var boolean */
var $checked_out=null;
/** @var time */
var $checked_out_time=null;
/** @var boolean */
var $published=null;
/** @var string */
var $module=null;
/** @var int */
var $numnews=null;
/** @var int */
var $access=null;
/** @var string */
var $params=null;
/** @var string */
var $iscore=null;
/** @var string */
var $client_id=null;
/**
* @param database A database connector object
*/
function mosModule( &$db ) {
$this->mosDBTable( '#__modules', 'id', $db );
}
// overloaded check function
function check() {
// check for valid name
if (trim( $this->title ) == '') {
$this->_error = "Your Module must contain a title.";
return false;
}
// limitation has been removed
// check for existing title
//$this->_db->setQuery( "SELECT id FROM #__modules"
//. "\nWHERE title='$this->title'"
//);
// check for module of same name
//$xid = intval( $this->_db->loadResult() );
//if ($xid && $xid != intval( $this->id )) {
// $this->_error = "There is a module already with that name, please try again.";
// return false;
//}
return true;
}
}
?>
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

