1*7d101cc1SGerry Weißbach<?php 2*7d101cc1SGerry Weißbachif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 3*7d101cc1SGerry Weißbachif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4*7d101cc1SGerry Weißbachrequire_once(DOKU_PLUGIN.'admin.php'); 5*7d101cc1SGerry Weißbachrequire_once(DOKU_PLUGIN.'siteexport/preload.php'); 6*7d101cc1SGerry Weißbach 7*7d101cc1SGerry Weißbach/** 8*7d101cc1SGerry Weißbach * All DokuWiki plugins to extend the admin function 9*7d101cc1SGerry Weißbach * need to inherit from this class 10*7d101cc1SGerry Weißbach */ 11*7d101cc1SGerry Weißbachclass admin_plugin_siteexport extends DokuWiki_Admin_Plugin { 12*7d101cc1SGerry Weißbach 13*7d101cc1SGerry Weißbach var $templateSwitching = false; 14*7d101cc1SGerry Weißbach var $pdfExport = false; 15*7d101cc1SGerry Weißbach var $usenumberedheading = false; 16*7d101cc1SGerry Weißbach var $cronEnabled = false; 17*7d101cc1SGerry Weißbach var $translationAvailable = false; 18*7d101cc1SGerry Weißbach 19*7d101cc1SGerry Weißbach /** 20*7d101cc1SGerry Weißbach * Constructor 21*7d101cc1SGerry Weißbach */ 22*7d101cc1SGerry Weißbach function __construct() { 23*7d101cc1SGerry Weißbach $this->setupLocale(); 24*7d101cc1SGerry Weißbach } 25*7d101cc1SGerry Weißbach 26*7d101cc1SGerry Weißbach /** 27*7d101cc1SGerry Weißbach * for backward compatability 28*7d101cc1SGerry Weißbach * @see inc/DokuWiki_Plugin#getInfo() 29*7d101cc1SGerry Weißbach */ 30*7d101cc1SGerry Weißbach function getInfo(){ 31*7d101cc1SGerry Weißbach if ( method_exists(parent, 'getInfo')) { 32*7d101cc1SGerry Weißbach $info = parent::getInfo(); 33*7d101cc1SGerry Weißbach } 34*7d101cc1SGerry Weißbach return is_array($info) ? $info : confToHash(dirname(__FILE__).'/plugin.info.txt'); 35*7d101cc1SGerry Weißbach } 36*7d101cc1SGerry Weißbach 37*7d101cc1SGerry Weißbach /** 38*7d101cc1SGerry Weißbach * return sort order for position in admin menu 39*7d101cc1SGerry Weißbach */ 40*7d101cc1SGerry Weißbach function getMenuSort() { 41*7d101cc1SGerry Weißbach return 100; 42*7d101cc1SGerry Weißbach } 43*7d101cc1SGerry Weißbach 44*7d101cc1SGerry Weißbach function forAdminOnly(){ 45*7d101cc1SGerry Weißbach return false; 46*7d101cc1SGerry Weißbach } 47*7d101cc1SGerry Weißbach 48*7d101cc1SGerry Weißbach /** 49*7d101cc1SGerry Weißbach * handle user request 50*7d101cc1SGerry Weißbach */ 51*7d101cc1SGerry Weißbach function handle() { 52*7d101cc1SGerry Weißbach 53*7d101cc1SGerry Weißbach if ( $functions=& plugin_load('preload', 'siteexport') && $functions->__create_preload_function() ) { 54*7d101cc1SGerry Weißbach $this->templateSwitching = true; 55*7d101cc1SGerry Weißbach } 56*7d101cc1SGerry Weißbach 57*7d101cc1SGerry Weißbach if ( $functions =& plugin_load('action', 'dw2pdf' ) ) { 58*7d101cc1SGerry Weißbach $this->pdfExport = true; 59*7d101cc1SGerry Weißbach } 60*7d101cc1SGerry Weißbach 61*7d101cc1SGerry Weißbach if ( $functions =& plugin_load('renderer', 'nodetailsxhtml' ) ) { 62*7d101cc1SGerry Weißbach $this->usenumberedheading = true; 63*7d101cc1SGerry Weißbach } 64*7d101cc1SGerry Weißbach 65*7d101cc1SGerry Weißbach if ( $functions =& plugin_load('cron', 'siteexport' ) ) { 66*7d101cc1SGerry Weißbach $this->cronEnabled = $functions->canWriteSettings(); 67*7d101cc1SGerry Weißbach } 68*7d101cc1SGerry Weißbach 69*7d101cc1SGerry Weißbach if ( $functions =& plugin_load('helper', 'translation' ) ) { 70*7d101cc1SGerry Weißbach $this->cronEnabled = true; 71*7d101cc1SGerry Weißbach } 72*7d101cc1SGerry Weißbach } 73*7d101cc1SGerry Weißbach 74*7d101cc1SGerry Weißbach /** 75*7d101cc1SGerry Weißbach * output appropriate html 76*7d101cc1SGerry Weißbach */ 77*7d101cc1SGerry Weißbach function html() { 78*7d101cc1SGerry Weißbach global $ID, $conf; 79*7d101cc1SGerry Weißbach 80*7d101cc1SGerry Weißbach if ( ! $functions=& plugin_load('helper', 'siteexport') ) { 81*7d101cc1SGerry Weißbach msg("Can't initialize"); 82*7d101cc1SGerry Weißbach return false; 83*7d101cc1SGerry Weißbach } 84*7d101cc1SGerry Weißbach 85*7d101cc1SGerry Weißbach $regenerateScript = ''; 86*7d101cc1SGerry Weißbach print $this->locale_xhtml('intro'); 87*7d101cc1SGerry Weißbach 88*7d101cc1SGerry Weißbach $form = new Doku_Form('siteexport', null, 'post'); 89*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('startingNamespace') ); 90*7d101cc1SGerry Weißbach 91*7d101cc1SGerry Weißbach $form->addElement(form_makeTextField('ns', $ID, $this->getLang('ns') . ':', 'ns')); 92*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 93*7d101cc1SGerry Weißbach $form->addElement(form_makeTextField('ens', $ID, $this->getLang('ens') . ':', 'ens')); 94*7d101cc1SGerry Weißbach 95*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 96*7d101cc1SGerry Weißbach $form->addElement(form_makeListboxField('depthType', array( "0.0" => $this->getLang('depth.pageOnly'), "1.0" => $this->getLang('depth.allSubNameSpaces'), "2.0" => $this->getLang('depth.specifiedDepth') ), (empty($_REQUEST['depthType']) ? $this->getLang('depth.allSubNameSpaces') : $_REQUEST['depthType']), $this->getLang('depthType') . ':', 'depthType', null, array_merge(array('class' => 'edit')))); 97*7d101cc1SGerry Weißbach 98*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 99*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag("div", array('style' => 'display:' . ($_REQUEST['depthType'] == "3" ? "block" : "none") . ';', 'id' => 'depthContainer'))); 100*7d101cc1SGerry Weißbach $form->addElement(form_makeTextField('depth', $this->getConf('depth'), $this->getLang('depth') . ':', 'depth')); 101*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag("div")); 102*7d101cc1SGerry Weißbach 103*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 104*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag("div", array('style' => 'display:none;', 'id' => 'depthContainer'))); 105*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('exportLinkedPages', 1, $this->getLang('exportLinkedPages') . ':', 'exportLinkedPages')); 106*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag("div")); 107*7d101cc1SGerry Weißbach 108*7d101cc1SGerry Weißbach $form->endFieldset(); 109*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 110*7d101cc1SGerry Weißbach 111*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('selectYourOptions') ); 112*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('absolutePath', 1, $this->getLang('absolutePath') . ':', 'absolutePath')); 113*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 114*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('exportBody', 1, $this->getLang('exportBody') . ':', 'exportBody')); 115*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 116*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('addParams', 1, $this->getLang('addParams') . ':', 'addParams', null, array_merge(array('checked' => ($conf['userewrite'] != 1 ? 'checked' : '' ) )))); 117*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 118*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 119*7d101cc1SGerry Weißbach $form->addElement(form_makeListboxField('renderer', array_merge(array('','xhtml'), plugin_list('renderer')), '', $this->getLang('renderer') . ':', 'renderer', null, array_merge(array('class' => 'edit')))); 120*7d101cc1SGerry Weißbach 121*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 122*7d101cc1SGerry Weißbach if ( $this->templateSwitching ) { 123*7d101cc1SGerry Weißbach $form->addElement(form_makeListboxField('template', $functions->__getTemplates(), $conf['template'], $this->getLang('template') . ':', 'template', null, array_merge(array('class' => 'edit')))); 124*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 125*7d101cc1SGerry Weißbach } else 126*7d101cc1SGerry Weißbach { 127*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 128*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('p', array('style' => 'color: #a00;' ))); 129*7d101cc1SGerry Weißbach $form->addElement('Can\'t create preload file in \'inc\' directory. Template switching is not available. Plugin disabling is not available.'); 130*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('p')); 131*7d101cc1SGerry Weißbach } 132*7d101cc1SGerry Weißbach 133*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 134*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('pdfExport', 1, $this->getLang('pdfExport') . ':', 'pdfExport', null, $this->pdfExport ? array() : array_merge(array('disabled' => 'disabled')) )); 135*7d101cc1SGerry Weißbach if ( !$this->pdfExport ) { 136*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('p', array('style' => 'color: #a00;' ))); 137*7d101cc1SGerry Weißbach $form->addElement('In order to use the PDF export, please '); 138*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('a', array('href' => 'http://www.dokuwiki.org/plugin:dw2pdf', 'alt' => 'install plugin', 'target' => '_blank'))); 139*7d101cc1SGerry Weißbach $form->addElement('install the dw2pdf plugin.'); 140*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('a')); 141*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('p')); 142*7d101cc1SGerry Weißbach } 143*7d101cc1SGerry Weißbach 144*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 145*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('usenumberedheading', 1, $this->getLang('usenumberedheading') . ':', 'usenumberedheading', null, $this->usenumberedheading ? array() : array_merge(array('disabled' => 'disabled')) )); 146*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 147*7d101cc1SGerry Weißbach 148*7d101cc1SGerry Weißbach if ( !$this->usenumberedheading ) { 149*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('p', array('style' => 'color: #a00;' ))); 150*7d101cc1SGerry Weißbach $form->addElement('In order to use numbered headings, please '); 151*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('a', array('href' => 'http://www.dokuwiki.org/plugin:nodetailsxhtml', 'alt' => 'install plugin', 'target' => '_blank'))); 152*7d101cc1SGerry Weißbach $form->addElement('install the nodetailsxhtml plugin.'); 153*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('a')); 154*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('p')); 155*7d101cc1SGerry Weißbach } 156*7d101cc1SGerry Weißbach 157*7d101cc1SGerry Weißbach $form->endFieldset(); 158*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 159*7d101cc1SGerry Weißbach 160*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('helpCreationOptions') ); 161*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('eclipseDocZip', 1, $this->getLang('eclipseDocZip') . ':', 'eclipseDocZip')); 162*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 163*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('JavaHelpDocZip', 1, $this->getLang('JavaHelpDocZip') . ':', 'JavaHelpDocZip')); 164*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 165*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('useTocFile', 1, $this->getLang('useTocFile') . ':', 'useTocFile')); 166*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 167*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('emptyTocElem', 1, $this->getLang('emptyTocElem') . ':', 'emptyTocElem')); 168*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 169*7d101cc1SGerry Weißbach if ( !$this->translationAvailable ) { 170*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField('TOCMapWithoutTranslation', 1, $this->getLang('TOCMapWithoutTranslation') . ':', 'TOCMapWithoutTranslation')); 171*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 172*7d101cc1SGerry Weißbach } 173*7d101cc1SGerry Weißbach $form->endFieldset(); 174*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 175*7d101cc1SGerry Weißbach 176*7d101cc1SGerry Weißbach if ( $this->templateSwitching ) 177*7d101cc1SGerry Weißbach { 178*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('disablePluginsOption') ); 179*7d101cc1SGerry Weißbach 180*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField("disableall", 1, 'Disable All:', "disableall", 'forceVisible')); 181*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 182*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 183*7d101cc1SGerry Weißbach 184*7d101cc1SGerry Weißbach list($allPlugins, $enabledPlugins) = $functions->__getPluginList(); 185*7d101cc1SGerry Weißbach foreach ( $allPlugins as $plugin ) { 186*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField("disableplugin[]", $plugin, $plugin . ':', "disableplugin_$plugin", null, (!in_array($plugin, $enabledPlugins) ? array('checked' => 'checked', 'disabled' => 'disabled') : array() ))); 187*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 188*7d101cc1SGerry Weißbach } 189*7d101cc1SGerry Weißbach 190*7d101cc1SGerry Weißbach $form->endFieldset(); 191*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 192*7d101cc1SGerry Weißbach } 193*7d101cc1SGerry Weißbach 194*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('customOptions') ); 195*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('p')); 196*7d101cc1SGerry Weißbach $form->addElement( $this->getLang('customOptionsDescription') ); 197*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('p')); 198*7d101cc1SGerry Weißbach 199*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('ul', array('id' => 'siteexport__customActions'))); 200*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('ul')); 201*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br', array('class'=>'clear'))); 202*7d101cc1SGerry Weißbach $form->addElement(form_makeButton('submit', 'addoption', $this->getLang('addCustomOption') , array('style' => 'float:right;') )); 203*7d101cc1SGerry Weißbach 204*7d101cc1SGerry Weißbach $form->endFieldset(); 205*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 206*7d101cc1SGerry Weißbach 207*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('startProcess') ); 208*7d101cc1SGerry Weißbach 209*7d101cc1SGerry Weißbach $form->addElement(form_makeTextField('copyurl', "", $this->getLang('directDownloadLink') . ':', 'copyurl', null, array('readonly' => 'readonly') )); 210*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 211*7d101cc1SGerry Weißbach $form->addElement(form_makeTextField('wgeturl', "", $this->getLang('wgetURLLink') . ':', 'wgeturl', null, array('readonly' => 'readonly') )); 212*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 213*7d101cc1SGerry Weißbach $form->addElement(form_makeTextField('curlurl', "", $this->getLang('curlURLLink') . ':', 'curlurl', null, array('readonly' => 'readonly') )); 214*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br', array('class'=>'clear'))); 215*7d101cc1SGerry Weißbach $form->addElement(form_makeButton('submit', 'siteexport', $this->getLang('start') , array('style' => 'float:right;'))); 216*7d101cc1SGerry Weißbach $form->endFieldset(); 217*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 218*7d101cc1SGerry Weißbach 219*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('status') ); 220*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('span', array('id' => 'siteexport__out'))); 221*7d101cc1SGerry Weißbach 222*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('span')); 223*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('span', array('class' => 'siteexport__throbber'))); 224*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('img', array('src' => DOKU_BASE.'lib/images/loading.gif', 'id' => 'siteexport__throbber'))); 225*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('span')); 226*7d101cc1SGerry Weißbach $form->endFieldset(); 227*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br')); 228*7d101cc1SGerry Weißbach 229*7d101cc1SGerry Weißbach if ( $this->cronEnabled ) 230*7d101cc1SGerry Weißbach { 231*7d101cc1SGerry Weißbach $form->startFieldset( $this->getLang('cronSaveProcess') ); 232*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('p')); 233*7d101cc1SGerry Weißbach $form->addElement( $this->getLang('cronDescription') ); 234*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('p')); 235*7d101cc1SGerry Weißbach 236*7d101cc1SGerry Weißbach $form->addElement(form_makeCheckboxField("cronOverwriteExisting", 1, $this->getLang('canOverwriteExisting'), "cronOverwriteExisting")); 237*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br', array('class'=>'clear'))); 238*7d101cc1SGerry Weißbach $form->addElement(form_makeButton('submit', 'cronDeleteAction', $this->getLang('cronDeleteAction') , array('id' => 'cronDeleteAction', 'style' => 'float:left;display:none') )); 239*7d101cc1SGerry Weißbach $form->addElement(form_makeButton('submit', 'cronSaveAction', $this->getLang('cronSaveAction') , array('id' => 'cronSaveAction', 'style' => 'float:right;') )); 240*7d101cc1SGerry Weißbach $form->addElement(form_makeTag('br', array('class'=>'clear'))); 241*7d101cc1SGerry Weißbach 242*7d101cc1SGerry Weißbach $form->addElement(form_makeOpenTag('a', array('href' => '#cronactions', 'alt' => 'show cron jobs', 'id' => 'showcronjobs', 'target' => '_blank', 'style' => 'float:right;'))); 243*7d101cc1SGerry Weißbach $form->addElement('show all cron jobs'); 244*7d101cc1SGerry Weißbach $form->addElement(form_makeCloseTag('a')); 245*7d101cc1SGerry Weißbach 246*7d101cc1SGerry Weißbach $form->endFieldset(); 247*7d101cc1SGerry Weißbach } 248*7d101cc1SGerry Weißbach 249*7d101cc1SGerry Weißbach $form->printForm(); 250*7d101cc1SGerry Weißbach } 251*7d101cc1SGerry Weißbach} 252*7d101cc1SGerry Weißbach//Setup VIM: ex: et ts=4 enc=utf-8 : 253