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