18fce80b1SAndreas Gohr<?php 28fce80b1SAndreas Gohr/** 38fce80b1SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 48fce80b1SAndreas Gohr */ 58fce80b1SAndreas Gohr 68fce80b1SAndreas Gohr// must be run within Dokuwiki 78fce80b1SAndreas Gohrif (!defined('DOKU_INC')) die(); 82e820792SAndreas Gohrrequire_once(DOKU_INC.'inc/plugin.php'); 98fce80b1SAndreas Gohr 108fce80b1SAndreas Gohrclass helper_plugin_qc extends DokuWiki_Plugin { 118fce80b1SAndreas Gohr 128fce80b1SAndreas Gohr function tpl(){ 138fce80b1SAndreas Gohr global $ACT,$INFO,$ID; 14d2a33339SDominik Eckelmann if (!function_exists('gd_info')) { 15d2a33339SDominik Eckelmann msg('You have to install php-gd lib to use the QC plugin.'); 16d2a33339SDominik Eckelmann return; 17d2a33339SDominik Eckelmann } 188fce80b1SAndreas Gohr if($ACT != 'show' || !$INFO['exists']) return; 1932905264SAndreas Gohr if(p_get_metadata($ID, 'relation qcplugin_disabled')) return; 20c8193605SDominik Eckelmann if ($this->getConf('adminonly')) { 21c8193605SDominik Eckelmann if (!isset($_SERVER['REMOTE_USER']) || !auth_isadmin()) 22c8193605SDominik Eckelmann return; 23c8193605SDominik Eckelmann } 24*193c8bebSJana Deutschländer echo '<div id="plugin__qc__wrapper" data-id="'.$ID.'">'; 2563ee528dSAndreas Gohr echo '<img src="'.DOKU_BASE.'lib/plugins/qc/icon.php?id='.$ID.'" width="600" height="25" alt="" id="plugin__qc__icon" />'; 268fce80b1SAndreas Gohr echo '<div id="plugin__qc__out" style="display:none"></div>'; 279068e431SAndreas Gohr echo '</div>'; 288fce80b1SAndreas Gohr } 298fce80b1SAndreas Gohr 308fce80b1SAndreas Gohr 318fce80b1SAndreas Gohr function getQCData($theid){ 328fce80b1SAndreas Gohr global $ID; 338fce80b1SAndreas Gohr $oldid = $ID; 348fce80b1SAndreas Gohr $ID = $theid; 358437661aSAdrian Lang require_once DOKU_INC.'inc/parserutils.php'; 368437661aSAdrian Lang $data = unserialize(p_cached_output(wikiFN($ID), 'qc', $ID)); 378fce80b1SAndreas Gohr $ID = $oldid; 388fce80b1SAndreas Gohr return $data; 398fce80b1SAndreas Gohr } 408fce80b1SAndreas Gohr 41*193c8bebSJana Deutschländer /** 42*193c8bebSJana Deutschländer * same function as tpl(), built markup contains additional data-attribute data-errors, which shows the current 43*193c8bebSJana Deutschländer * error count 44*193c8bebSJana Deutschländer */ 45*193c8bebSJana Deutschländer function tplErrorCount(){ 46*193c8bebSJana Deutschländer global $ACT,$INFO,$ID; 47*193c8bebSJana Deutschländer if (!function_exists('gd_info')) { 48*193c8bebSJana Deutschländer msg('You have to install php-gd lib to use the QC plugin.'); 49*193c8bebSJana Deutschländer return; 50*193c8bebSJana Deutschländer } 51*193c8bebSJana Deutschländer if($ACT != 'show' || !$INFO['exists']) return; 52*193c8bebSJana Deutschländer if(p_get_metadata($ID, 'relation qcplugin_disabled')) return; 53*193c8bebSJana Deutschländer if ($this->getConf('adminonly')) { 54*193c8bebSJana Deutschländer if (!isset($_SERVER['REMOTE_USER']) || !auth_isadmin()) 55*193c8bebSJana Deutschländer return; 56*193c8bebSJana Deutschländer } 57*193c8bebSJana Deutschländer $qc_data = $this->getQCData($ID); 58*193c8bebSJana Deutschländer if($qc_data){ 59*193c8bebSJana Deutschländer $num = $qc_data[score]; 60*193c8bebSJana Deutschländer } 61*193c8bebSJana Deutschländer echo '<div id="plugin__qc__wrapper" data-errors='.$num .'>'; 62*193c8bebSJana Deutschländer echo '<img src="'.DOKU_BASE.'lib/plugins/qc/icon.php?id='.$ID.'" width="600" height="25" alt="" id="plugin__qc__icon" />'; 63*193c8bebSJana Deutschländer echo '<div id="plugin__qc__out"></div>'; 64*193c8bebSJana Deutschländer echo '</div>'; 65*193c8bebSJana Deutschländer } 66*193c8bebSJana Deutschländer 678fce80b1SAndreas Gohr} 688fce80b1SAndreas Gohr// vim:ts=4:sw=4:et:enc=utf-8: 69