Ahoy, ich nochmal,
Da dies mein wirklich absolutes Erstlingswerk an "Joomla-Code" darstellt, hierder Code sicherheitshalber zur Überprüfung.
PHP-Code:
<?php
/* SVN: $Id$ */
/**
* @package joomla.plugin
* @subpackage system.multisite
* @copyright Copyright (c) 2008 art-two [creative development]
* @author Guido Essing [ecomeback] <ecomeback@os-development.de>
* @version
* 0.1 - 04.01.2009 - pre alpha<br />
*/
// check global access point
defined('_JEXEC') or exit( 'forbidden' );
jimport( 'joomla.plugin.plugin' );
class plgSystemMultisite extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for
* plugins because func_get_args ( void ) returns a copy of all passed arguments
* NOT references. This causes problems with cross-referencing necessary for the
* observer design pattern.
*/
/**
* MultiDomain Switcher
* @return void
*/
function plgSystemMultisite(& $subject, $config)
{
parent::__construct(& $subject, $config);
}
function onAfterInitialise()
{
// frontend check
$application =& JFactory::getApplication();
if (!$application->isSite()) {
return true;
}
$config = JFactory::getConfig();
$uri = JFactory::getURI();
$menu = JSite::getMenu();
$host = $uri->getScheme() . '://' . $uri->getHost();
for ($i = 1; $i <= 15; $i++) {
$tmp = $this->params->get( 'pattern' . $i );
if ( !empty($tmp) && FALSE !== strpos( $host, $tmp ) ) {
$config->setValue('config.live_site', $host); // set live site
$tmp = $this->params->get( 'menu' . $i );
if ( !empty($tmp) ) $menu->setDefault($tmp); // set default menu id; id have to exists in #__menu
$tmp = $this->params->get( 'template' . $i );
if ( !empty($tmp) ) JRequest::setVar('template', $tmp ); // set template
$tmp = $this->params->get( 'sitename' . $i );
if ( !empty($tmp) ) $config->setValue('config.sitename', $tmp ); //enter sitename here or delete it
$tmp = $this->params->get( 'metadesc' . $i );
if ( !empty($tmp) ) $config->setValue('config.MetaDesc', $tmp );
$tmp = $this->params->get( 'metakeys' . $i );
if ( !empty($tmp) ) $config->setValue('config.MetaKeys', $tmp );
break;
}
}
}
}
?>
Kritik und Korrekturen sind willkommen,
Gruß, Ich
[Edit 14.08.2010: unten stehende Verbesserungsvorschläge eingearbeitet, läuft jetzt auch wieder unter 1.5.20]
Lesezeichen