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(); 88fce80b1SAndreas Gohr 98fce80b1SAndreas Gohrclass helper_plugin_qc extends DokuWiki_Plugin { 108fce80b1SAndreas Gohr 111c845774SAndreas Gohr /** 121c845774SAndreas Gohr * Output the standard quality header. Needs to be called formt he template 131c845774SAndreas Gohr */ 14*33274f74SAndreas Gohr public function tpl() { 155d41541bSAndreas Gohr if(!$this->shouldShow()) return; 161c845774SAndreas Gohr 17f7678e42SJana Deutschländer echo '<div id="plugin__qc__wrapper">'; 181c845774SAndreas Gohr echo '<div class="summary">'; 191c845774SAndreas Gohr echo $this->getLang('i_qcscore'); 201c845774SAndreas Gohr echo '</div>'; 21992bd36bSAndreas Gohr echo '<div class="qc-output"></div>'; 229068e431SAndreas Gohr echo '</div>'; 238fce80b1SAndreas Gohr } 248fce80b1SAndreas Gohr 251c845774SAndreas Gohr /** 265d41541bSAndreas Gohr * Should the QC plugin be shown? 275d41541bSAndreas Gohr * 28*33274f74SAndreas Gohr * It checks if the page exists, if QC was disabled for this page, general 29*33274f74SAndreas Gohr * settings and ACLs 30*33274f74SAndreas Gohr * 31*33274f74SAndreas Gohr * This may be called from page context as well as from AJAX. In AJAX context 32*33274f74SAndreas Gohr * the page id needs to be passed as parameter 33*33274f74SAndreas Gohr * 34*33274f74SAndreas Gohr * @param string $id the page ID, defaults to global $ID 355d41541bSAndreas Gohr * @return bool 365d41541bSAndreas Gohr */ 37*33274f74SAndreas Gohr public function shouldShow($id='') { 385d41541bSAndreas Gohr global $ACT, $INFO, $ID; 39*33274f74SAndreas Gohr if($id === '') $id = $ID; 40*33274f74SAndreas Gohr if(isset($ACT) && $ACT != 'show') return false; 41*33274f74SAndreas Gohr if(isset($INFO)) { 42*33274f74SAndreas Gohr $exists = $INFO['exists']; 43*33274f74SAndreas Gohr } else { 44*33274f74SAndreas Gohr $exists = page_exists($id); 45*33274f74SAndreas Gohr } 46*33274f74SAndreas Gohr if(!$exists) return false; 47*33274f74SAndreas Gohr 48*33274f74SAndreas Gohr if(auth_quickaclcheck($id) < AUTH_READ) return false; 49*33274f74SAndreas Gohr 50*33274f74SAndreas Gohr if(p_get_metadata($id, 'relation qcplugin_disabled')) return false; 515d41541bSAndreas Gohr if($this->getConf('adminonly')) { 525d41541bSAndreas Gohr if(!isset($_SERVER['REMOTE_USER']) || !auth_isadmin()) { 535d41541bSAndreas Gohr return false; 545d41541bSAndreas Gohr } 555d41541bSAndreas Gohr } 565d41541bSAndreas Gohr 575d41541bSAndreas Gohr return true; 585d41541bSAndreas Gohr } 595d41541bSAndreas Gohr 605d41541bSAndreas Gohr /** 611c845774SAndreas Gohr * Return the raw quality data 621c845774SAndreas Gohr * 631c845774SAndreas Gohr * Always call this asynchronly! 641c845774SAndreas Gohr * 651c845774SAndreas Gohr * @param $theid 661c845774SAndreas Gohr * @return array 671c845774SAndreas Gohr */ 68*33274f74SAndreas Gohr public function getQCData($theid) { 698fce80b1SAndreas Gohr global $ID; 708fce80b1SAndreas Gohr $oldid = $ID; 718fce80b1SAndreas Gohr $ID = $theid; 728437661aSAdrian Lang $data = unserialize(p_cached_output(wikiFN($ID), 'qc', $ID)); 738fce80b1SAndreas Gohr $ID = $oldid; 748fce80b1SAndreas Gohr return $data; 758fce80b1SAndreas Gohr } 76193c8bebSJana Deutschländer} 77