1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Esther Brunner <wikidesign@gmail.com> 5 */ 6 7// must be run within Dokuwiki 8if (!defined('DOKU_INC')) die(); 9 10if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 11if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 12if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13 14require_once(DOKU_PLUGIN.'action.php'); 15 16class action_plugin_lastfm extends DokuWiki_Action_Plugin{ 17 18 function getInfo() { 19 return array( 20 'author' => 'Michael Klier', 21 'email' => 'chi@chimeric.de', 22 'date' => @file_get_contents(DOKU_PLUGIN.'lastfm/VERSION'), 23 'name' => 'LastFM Plugin (action component)', 24 'desc' => 'Display Last.fm stats on a wiki page', 25 'url' => 'http://dokuwiki.org/plugin:lastfm', 26 ); 27 } 28 29 function register(&$contr) { 30 $contr->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call', array()); 31 } 32 33 /** 34 * Preview Comments 35 * 36 * @author Michael Klier <chi@chimeric.de> 37 */ 38 function handle_ajax_call(&$event, $params) { 39 if($event->data != 'plugin_lastfm') return; 40 $event->preventDefault(); 41 $event->stopPropagation(); 42 43 require_once(DOKU_PLUGIN.'lastfm/inc/lastfmutils.php'); 44 45 // import variables 46 $chart = $_REQUEST['plugin_lastfm_chart']; 47 $user = $_REQUEST['plugin_lastfm_user']; 48 $limit = $_REQUEST['plugin_lastfm_limit']; 49 $cols = $_REQUEST['plugin_lastfm_cols']; 50 $imgonly = $_REQUEST['plugin_lastfm_imgonly']; 51 52 $dformat = $this->getConf('dformat'); 53 $utc_offset = $this->getconf('utc_offset'); 54 55 // maybe the whole thing could be done in a cleaner fashion 56 $chart = preg_replace("/plugin_lastfm_/",'',$chart); 57 58 // get chart 59 lastfm_xhtml($user, $chart, $limit, $dformat, $utc_offset, $cols, $imgonly); 60 } 61} 62 63// vim:ts=4:sw=4:et:enc=utf-8: 64