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 */ 1433274f74SAndreas 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>'; 21*393c144dSAndreas Gohr echo '<aside class="qc-output"></aside>'; 229068e431SAndreas Gohr echo '</div>'; 238fce80b1SAndreas Gohr } 248fce80b1SAndreas Gohr 251c845774SAndreas Gohr /** 265d41541bSAndreas Gohr * Should the QC plugin be shown? 275d41541bSAndreas Gohr * 2833274f74SAndreas Gohr * It checks if the page exists, if QC was disabled for this page, general 2933274f74SAndreas Gohr * settings and ACLs 3033274f74SAndreas Gohr * 3133274f74SAndreas Gohr * This may be called from page context as well as from AJAX. In AJAX context 3233274f74SAndreas Gohr * the page id needs to be passed as parameter 3333274f74SAndreas Gohr * 3433274f74SAndreas Gohr * @param string $id the page ID, defaults to global $ID 355d41541bSAndreas Gohr * @return bool 365d41541bSAndreas Gohr */ 3733274f74SAndreas Gohr public function shouldShow($id='') { 385d41541bSAndreas Gohr global $ACT, $INFO, $ID; 3933274f74SAndreas Gohr if($id === '') $id = $ID; 4033274f74SAndreas Gohr if(isset($ACT) && $ACT != 'show') return false; 4133274f74SAndreas Gohr if(isset($INFO)) { 4233274f74SAndreas Gohr $exists = $INFO['exists']; 4333274f74SAndreas Gohr } else { 4433274f74SAndreas Gohr $exists = page_exists($id); 4533274f74SAndreas Gohr } 4633274f74SAndreas Gohr if(!$exists) return false; 4733274f74SAndreas Gohr 4833274f74SAndreas Gohr if(auth_quickaclcheck($id) < AUTH_READ) return false; 4933274f74SAndreas Gohr 5033274f74SAndreas 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 */ 6833274f74SAndreas 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