1<?php 2/** 3 * Plugin: RSS Ticker (Ajax invocation) 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Marcel Steinger <sourcecode@steinger.ch> 7 */ 8 9// must be run within DokuWiki 10if(!defined('DOKU_INC')) die(); 11if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 12require_once DOKU_PLUGIN.'syntax.php'; 13 14/** 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_rssticker extends DokuWiki_Syntax_Plugin { 19 20 function getType() { return 'substition'; } 21 function getSort() { return 314; } 22 23 function connectTo($mode) { 24 $this->Lexer->addSpecialPattern('\{\{rssticker>[^}]*\}\}',$mode,'plugin_rssticker'); 25 } 26 27 /** 28 * Handle the match 29 */ 30 function handle($match, $state, $pos, &$handler) { 31 32 $match = substr($match,12,-2); 33 list($title,$url,$cachetime,$css,$delay,$optionalswitch,$align) = explode(',',$match); 34 if ( empty($title)) { $title = "none";} 35 if ( empty($url)) { $url = "none";} 36 if ( empty($cachetime)) {$cachetime = 600;} 37 if ( empty($css)) { $css = "rss";} 38 if ( empty($delay)) { $delay = 3000;} 39 if ( empty($optionalswitch)) { $optionalswitch = "date";} 40 if ( empty($align)) { $align = "left";} 41 return array($title,$url,$cachetime,$css,$delay,$optionalswitch,$align); 42 } 43 /** 44 * Create output 45 */ 46 function render($mode, &$renderer, $data) { 47 if($mode == 'xhtml'){ 48 $linkscript = DOKU_URL."lib/plugins/rssticker/rssticker.js"; 49 $renderer->doc .= "<script src='$linkscript' type='text/javascript'></script>"; 50 $renderer->doc .= "<div class=\"rssticker\" align='$data[6]'>"; 51 $renderer->doc .= "<script type='text/javascript' charset='UTF-8'>"; 52 $renderer->doc .= "document.write('<div class=\"rsshead\">$data[0]:</div>')\n"; 53 $renderer->doc .= "new rssticker_ajax('$data[1]', $data[2], '$data[3]box', '$data[3]class', $data[4], '$data[5]')"; 54 $renderer->doc .= "</script></div><div class=\"clearer\"></div>"; 55 return true; 56 } 57 return false; 58 } 59} 60?> 61