Daswäre dieser hier
Code:
<?php
/**
*
* @version 1.0.0
* @package Joomla
* @copyright Copyright (C) 2008 Majunke Michael. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// Import library dependencies
jimport('joomla.plugin.plugin');
/**
* Slider plugin
* <br/>
* Use JavaScript with Mootools Lib
*
* <b>Usage:</b>
* <code><slider id="x" title="The page title" direction="0|1" {cssSuffix="suffix"} /></code>
*
* Must : id => an unique ID on Page
* Must : title => Slider title
* Must : direction => 0 means vertical / 1 means horizontal Slider
* Opt : cssSuffix => is appended to normal cssClasses
*/
class plgContentSlider extends JPlugin {
const PATTERN = '/{slider\s+id="([^"]+)"\s+title="([^"]+)"\s+direction="([^"]+)"(\s+cssSuffix="([^"]+)")?}/';
private $csspath = null ;
private $document = null ;
/**
*/
function plgContentSlider(&$subject, $config)
{
parent::__construct($subject, $config);
// Vars
$this->document = &JFactory::getDocument();
// DEBUG
// print_r( $config );
// Params
$this->csspath = JArrayHelper::getValue( $config, 'csspath', '' );
if (!empty($this->csspath)) {
// need . DS . ?
$this->document->addStyleSheet(
JURI::base() . $this->csspath . "/slider.css",
'text/css',
null,
array());
} else {
// need . DS . ?
$this->document->addStyleSheet(
JURI::base() . 'plugins/content/slider.css',
'text/css',
null,
array());
}
//
}
/**
* Plugin method with the same name as the event will be called automatically.
*/
function onPrepareContent(&$row, &$params)
{
JHTML::_('behavior.mootools');
//
$matches = array();
while (preg_match(plgContentSlider::PATTERN, $row->text, $matches)) {
//
$tag = $matches[0];
$id = $matches[1];
$title = $matches[2];
$direction = $matches[3];
$cssSuffix = $matches[5];
if (empty($cssSuffix)) {
$cssSuffix = '';
}
$modeValue = '';
if ($direction == 1) {
$modeValue = ", {mode: 'horizontal'}";
}
$replaceText = '<a id="toggleSlide' . $id . '" name="toggleSlide' . $id . '" class="slideBar' . $cssSuffix . '">' . $title . '</a>';
$replaceText .= '<div id="slide' . $id . '" class="slideText' . $cssSuffix . '">';
$row->text = str_replace($tag, $replaceText, $row->text);
$script = 'window.addEvent(\'domready\', function(){ ';
$script .= 'var mySlide' . $id . ' = new Fx.Slide(\'slide' . $id . '\' ' . $modeValue . '); ';
$script .= 'mySlide' . $id . '.hide(); ';
$script .= ' $(\'toggleSlide' . $id . '\').addEvent(\'mousedown\', function(e){ e = new Event(e); mySlide' . $id . '.toggle(); e.stop(); }); }); ';
$this->document->addScriptDeclaration($script);
}
$row->text = str_replace('{sliderEnd}', '</div>', $row->text);
return true;
}
}
Lesezeichen