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