| 15 |
***/ |
***/ |
| 16 |
|
|
| 17 |
class mosBasicXML { |
class mosBasicXML { |
| 18 |
|
var $xmlfile = ''; |
| 19 |
var $opentags = array(); |
var $opentags = array(); |
| 20 |
var $opencount; |
var $opencount; |
| 21 |
var $accept = array(); |
var $accept = array(); |
| 27 |
var $name = ''; |
var $name = ''; |
| 28 |
|
|
| 29 |
function mosBasicXML ($file, $mosParameter=null, $name='params') { |
function mosBasicXML ($file, $mosParameter=null, $name='params') { |
| 30 |
|
//echo $file.'<br />'; |
| 31 |
$this->modParameter = $mosParameter; |
$this->xmlfile = $file; |
| 32 |
|
$this->mosParameter = $mosParameter; |
| 33 |
$this->name = $name; |
$this->name = $name; |
| 34 |
$this->setTree(); |
$this->setTree(); |
| 35 |
$parser = xml_parser_create(); |
$parser = xml_parser_create(); |
| 36 |
xml_set_element_handler ($parser, array ($this, 'start_element'), array ($this, 'end_element')); |
$startfunc = array (&$this, 'start_element'); |
| 37 |
xml_set_character_data_handler ($parser, array ($this, 'character_data')); |
$endfunc = array (&$this, 'end_element'); |
| 38 |
|
$charfunc = array (&$this, 'character_data'); |
| 39 |
|
xml_set_element_handler ($parser, $startfunc, $endfunc); |
| 40 |
|
xml_set_character_data_handler ($parser, $charfunc); |
| 41 |
$fp = fopen($file, 'rb'); |
$fp = fopen($file, 'rb'); |
| 42 |
while ($data = fread($fp, 4096) AND !$this->terminalError) { |
while ($data = fread($fp, 4096) AND !$this->terminalError) { |
| 43 |
$data = str_replace('&', ' ampersand ', $data); |
$data = str_replace('&', ' ampersand ', $data); |
| 55 |
|
|
| 56 |
function setTree () { |
function setTree () { |
| 57 |
$this->accept['MOSINSTALL'] = array ('NAME', 'CREATIONDATE', 'AUTHOR', 'COPYRIGHT', |
$this->accept['MOSINSTALL'] = array ('NAME', 'CREATIONDATE', 'AUTHOR', 'COPYRIGHT', |
| 58 |
'LICENSE', 'AUTHOREMAIL', 'AUTHORURL', 'VERSION', 'DESCRIPTION', 'FILES', 'GROUP', |
'LICENSE', 'AUTHOREMAIL', 'AUTHORURL', 'VERSION', 'DESCRIPTION', 'FILES', 'MEDIA', |
| 59 |
'PARAMS', 'INSTALL', 'UNINSTALL', 'INSTALLFILE', 'UNINSTALLFILE', 'ADMINISTRATION', |
'PARAMS', 'INSTALL', 'UNINSTALL', 'INSTALLFILE', 'UNINSTALLFILE', 'ADMINISTRATION', |
| 60 |
'IMAGES', 'CSS'); |
'IMAGES', 'CSS'); |
| 61 |
$this->accept['PARAMS'] = array ('PARAM'); |
$this->accept['PARAMS'] = array ('PARAM'); |
| 64 |
$this->accept['INSTALL'] = array ('QUERIES'); |
$this->accept['INSTALL'] = array ('QUERIES'); |
| 65 |
$this->accept['UNINSTALL'] = array ('QUERIES'); |
$this->accept['UNINSTALL'] = array ('QUERIES'); |
| 66 |
$this->accept['QUERIES'] = array ('QUERY'); |
$this->accept['QUERIES'] = array ('QUERY'); |
| 67 |
$this->accept['ADMINISTRATION'] = array ('FILES', 'IMAGES', 'MENU'); |
$this->accept['ADMINISTRATION'] = array ('FILES', 'IMAGES', 'MENU', 'SUBMENU'); |
| 68 |
$this->accept['IMAGES'] = array ('FILENAME'); |
$this->accept['IMAGES'] = array ('FILENAME'); |
|
$this->accept['MENU'] = array ('SUBMENU'); |
|
| 69 |
$this->accept['SUBMENU'] = array('MENU'); |
$this->accept['SUBMENU'] = array('MENU'); |
| 70 |
|
$this->accept['MEDIA'] = array('FILENAME'); |
| 71 |
$this->accept['CSS'] = array('FILENAME'); |
$this->accept['CSS'] = array('FILENAME'); |
| 72 |
} |
} |
| 73 |
|
|
| 74 |
function start_element ($parser, $element_name, $element_attrs) { |
function start_element ($parser, $element_name, $element_attrs) { |
| 75 |
if ($this->terminalError) return; |
if ($this->terminalError) return; |
|
$method = 'element_'.$element_name; |
|
|
|
|
|
$specific = array ($this, $method); |
|
|
if (is_callable($specific)) $this->$method($element_attrs); |
|
| 76 |
if ($this->mosinstall) { |
if ($this->mosinstall) { |
| 77 |
$container = $this->opentags[0]; |
$container = $this->opentags[0]; |
| 78 |
if (!isset($this->accept[$container]) OR !is_array($this->accept[$container])) trigger_error ("XML error $container is not a valid containing element"); |
if (!isset($this->accept[$container]) OR !is_array($this->accept[$container])) trigger_error ("XML error $container is not a valid containing element"); |
| 80 |
} |
} |
| 81 |
if ($this->mosinstall OR $element_name == 'MOSINSTALL') { |
if ($this->mosinstall OR $element_name == 'MOSINSTALL') { |
| 82 |
$this->opencount = array_unshift ($this->opentags, $element_name); |
$this->opencount = array_unshift ($this->opentags, $element_name); |
|
dump($this->opentags); |
|
|
$setdata = array ($this, 'set_data'); |
|
|
if (is_callable($setdata)) $this->set_data($element_attrs); |
|
| 83 |
$this->mosinstall = true; |
$this->mosinstall = true; |
| 84 |
|
$method = 'element_'.$element_name; |
| 85 |
|
$specific = array (&$this, $method); |
| 86 |
|
if (is_callable($specific)) $this->$method($element_attrs); |
| 87 |
} |
} |
| 88 |
else trigger_error ("XML expected MOSINSTALL but found $element_name"); |
else trigger_error ("XML expected MOSINSTALL but found $element_name"); |
| 89 |
// echo '<br />Start of '.$element_name; |
// echo '<br />Start of '.$element_name; |
| 91 |
|
|
| 92 |
function end_element ($parser, $element_name) { |
function end_element ($parser, $element_name) { |
| 93 |
if ($this->terminalError) return; |
if ($this->terminalError) return; |
| 94 |
$check = array_shift ($this->opentags); |
if ($this->opentags[0] != $element_name) { |
|
dump($this); |
|
|
if ($check != $element_name) { |
|
|
$this->opencount = array_unshift ($this->opentags, $check); |
|
| 95 |
trigger_error("XML last open tag was $check, but found end of $element_name"); |
trigger_error("XML last open tag was $check, but found end of $element_name"); |
| 96 |
|
return; |
| 97 |
} |
} |
|
else $this->opencount--; |
|
| 98 |
$method = 'end_element_'.$element_name; |
$method = 'end_element_'.$element_name; |
| 99 |
$specific = array ($this, $method); |
$specific = array (&$this, $method); |
| 100 |
if (is_callable($specific)) $this->$method(); |
if (is_callable($specific)) $this->$method(); |
| 101 |
|
array_shift ($this->opentags); |
| 102 |
|
$this->opencount--; |
| 103 |
// echo '<br />End of '.$element_name; |
// echo '<br />End of '.$element_name; |
| 104 |
} |
} |
| 105 |
|
|
| 390 |
* @param string THe template position |
* @param string THe template position |
| 391 |
*/ |
*/ |
| 392 |
function mosCountAdminModules( $position='left' ) { |
function mosCountAdminModules( $position='left' ) { |
| 393 |
global $database, $my, $Itemid; |
$handler = mosModuleHandler::getInstance(); |
| 394 |
|
return $handler->mosCountModules($position, true); |
|
$query = "SELECT COUNT(m.id)" |
|
|
. "\nFROM #__modules AS m" |
|
|
. "\nWHERE m.published='1' AND m.position='$position' AND m.client_id='1'"; |
|
|
|
|
|
$database->setQuery( $query ); |
|
|
return $database->loadResult(); |
|
| 395 |
} |
} |
| 396 |
/** |
/** |
| 397 |
* Loads admin modules via module position |
* Loads admin modules via module position |
| 399 |
* @param int 0 = no style, 1 = tabbed |
* @param int 0 = no style, 1 = tabbed |
| 400 |
*/ |
*/ |
| 401 |
function mosLoadAdminModules( $position='left', $style=0 ) { |
function mosLoadAdminModules( $position='left', $style=0 ) { |
| 402 |
global $database, $my, $acl; |
$handler = mosModuleHandler::getInstance(); |
| 403 |
|
return $handler->mosLoadAdminModules($position, $style); |
|
$cache =& mosCache::getCache( 'com_content' ); |
|
|
|
|
|
$query = "SELECT id, title, module, position, content, showtitle, params" |
|
|
. "\n FROM #__modules AS m" |
|
|
. "\n WHERE m.published = '1'" |
|
|
. "\n AND m.position='$position'" |
|
|
. "\n AND (m.client_id = 1)" |
|
|
. "\n ORDER BY m.ordering"; |
|
|
|
|
|
$database->setQuery( $query ); |
|
|
$modules = $database->loadObjectList(); |
|
|
if($database->getErrorNum()) { |
|
|
echo "MA ".$database->stderr(true); |
|
|
return; |
|
|
} |
|
|
if (!$modules) $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; |
|
|
} |
|
| 404 |
} |
} |
| 405 |
/** |
/** |
| 406 |
* Loads an admin module |
* Loads an admin module |
| 407 |
*/ |
*/ |
| 408 |
function mosLoadAdminModule( $name, $params=NULL ) { |
function mosLoadAdminModule( $name, $params=NULL ) { |
| 409 |
global $mosConfig_absolute_path, $mosConfig_live_site; |
global $mosConfig_absolute_path, $mosConfig_live_site; |
| 410 |
global $database, $my, $mainframe, $option, $acl; |
global $database, $acl, $my, $mainframe, $option; |
| 411 |
|
global $task, $act; |
|
$task = mosGetParam( $_REQUEST, 'task', '' ); |
|
|
// legacy support for $act |
|
|
$act = mosGetParam( $_REQUEST, 'act', '' ); |
|
| 412 |
|
|
| 413 |
$name = str_replace( '/', '', $name ); |
$name = str_replace( '/', '', $name ); |
| 414 |
$name = str_replace( '\\', '', $name ); |
$name = str_replace( '\\', '', $name ); |
| 415 |
$path = "$mosConfig_absolute_path/administrator/modules/mod_$name.php"; |
$path = mamboCore::get('mosConfig_absolute_path')."/administrator/modules/mod_$name.php"; |
| 416 |
if (file_exists( $path )) { |
if (file_exists($path)) require $path; |
|
require $path; |
|
|
} |
|
| 417 |
} |
} |
| 418 |
|
|
| 419 |
function mosLoadCustomModule( &$module, &$params ) { |
function mosLoadCustomModule( &$module, &$params ) { |
| 437 |
$cacheDir = $mosConfig_absolute_path .'/cache/'; |
$cacheDir = $mosConfig_absolute_path .'/cache/'; |
| 438 |
if (!is_writable( $cacheDir )) { |
if (!is_writable( $cacheDir )) { |
| 439 |
echo '<tr>'; |
echo '<tr>'; |
| 440 |
echo '<td>Please make cache directory writable.</td>'; |
echo '<td>'.T_('Please make cache directory writable.').'</td>'; |
| 441 |
echo '</tr>'; |
echo '</tr>'; |
| 442 |
} else { |
} else { |
| 443 |
$LitePath = $mosConfig_absolute_path .'/includes/Cache/Lite.php'; |
$LitePath = $mosConfig_absolute_path .'/includes/Cache/Lite.php'; |