Lines Matching refs:this

21     $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, '_parser', array());
23 $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, '_render', array());
24 $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'addbutton', array());
26 $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addsvgbutton', array());
53 if($this->getConf('showimportbutton') && $event->data['view'] == 'main') {
62 .'<a href='.wl($ID, $params).' class="action import_file" rel="nofollow" title="'.$this->getLang('import_button').'">'
63 .'<span>'.$this->getLang('import_button').'</span>'
77 if ( strpos( $this->getConf('formDisplayRule'), $event->data) === false ) return;
80 if ( page_exists( $ID ) ) echo p_render('xhtml',p_get_instructions( $this->getLang( 'formPageExistMessage' ) ), $info );
81 // Check auth user can edit this page
84 $message = $this->getConf('formIntroMessage');
85 if ( $message == 'default' ) $message = $this->getLang('formIntroMessage');
90 <legend>'.$this->getLang('formLegend').'</legend>
91 <input type="hidden" name="MAX_FILE_SIZE" value="'.$this->getConf('formMaxFileSize').'"/>
111 $this->debug = $this->getConf( 'debugLvl' );
113 if ( $this->debug >= 2 ) {
114 $this->logFile = $this->getConf( 'logFile' );
115 if ( isset( $this->logFile ) ) if ( file_exists( dirname( $this->logFile ) ) || mkdir( dirname( $this->logFile ) ) ) {
116 if ( ! ( $this->logFileHandle = @fopen( $this->logFile, 'a' ) ) ) unset( $this->logFileHandle, $this->logFile );
117 } else unset( $this->logFile );
118 if ( ! isset( $this->logFileHandle ) ) $this->_msg( 'er_logFile' );
126 $retour = $this->_odtplus2dw();
128 $this->_purge_env();
133 $event->data = $this->getConf('parserPostDisplay');
140 if ( isset( $this->logFileHandle ) ) @fclose( $this->logFileHandle );
152 //Table use to convert urn to url -> without this, xslProc won't parse correctly
154 $this->conversion = array(
190 $this->xmlFile = "content.xml";
195 if ( ! $this->pageName = $ID ) return $this->_msg('er_id');
196 $this->nsName = getNS($this->pageName);
199 if ( auth_quickaclcheck($ID) < AUTH_EDIT ) return $this->_msg('er_acl_edit');
201 if ( auth_quickaclcheck($ID) < AUTH_CREATE ) return $this->_msg('er_acl_create');
205 if ( ! $this->_checkUploadFile() ) return $this->_msg('er_checkUploadResult');
208 if ( ! $this->getConf( 'parserXslFile' ) ) return $this->_msg('er_xslFile_notset');
209 $this->xslFile = DOKU_PLUGIN.'odtplus2dw/'.$this->getConf('parserXslFile');
210 if ( ! file_exists($this->xslFile) ) return $this->_msg('er_xslFile_exists');
211 if ( ! is_file($this->xslFile) ) return $this->_msg('er_xslFile_isfile');
214 if ( ! class_exists( "XSLTProcessor" ) ) return $this->_msg('er_class_xsltProcessor');
215 if ( ! class_exists( "ZipArchive" ) ) return $this->_msg('er_class_zipArchive');
216 if ( ! class_exists( "DOMDocument" ) ) return $this->_msg('er_class_domDocument');
218 $this->XSLT = new XSLTProcessor;
219 $this->ZIP = new ZipArchive;
220 $this->XSL = new DOMDocument;
221 $this->XML = new DOMDocument;
224 if ( ! ($this->XSL->load( $this->xslFile ) ) ) return $this->_msg('er_loadXsl');
226 if ( ! $this->_set_xsltProcessor() ) return $this->_msg('er_xsltProc');
228 if ( ! $this->_unzip( $this->xmlFile ) ) return $this->_msg('er_file_unzip');
230 if ( ! $this->XML->load($this->uploadDir.'/'.$this->xmlFile) ) return $this->_msg('er_loadXml');
231 if ( ! $this->racine = $this->XML->getElementsByTagName('document-content')->item(0) ) return $this->_msg('er_invalidRoot');
233 foreach ( $this->conversion as $attr => $value ) if ( $this->racine->hasAttribute($attr) ) $this->racine->setAttributeNS( "http://www.w3.org/2000/xmlns/", $attr, $value );
235 $this->result = '====== '.basename($this->odtFileName,'.odt').' ======
237 if ( $this->getConf('parserLinkToOriginalFile') && auth_quickaclcheck($ID) >= AUTH_UPLOAD ) $this->result .= '<sub>{{'.$this->userFileName.'|'.$this->getLang('parserOriginalFile').'}}</sub>
245 set_time_limit( $this->getConf('parserCoreTimeOut') );
247 if ( ! $tmp = html_entity_decode($this->XSLT->transformToDoc( $this->XML )->saveHTML(), ENT_COMPAT, 'UTF-8') ) return $this->_msg('er_transform');
248 $this->result .= $tmp;
252 $this->_parse_image();
255 if ( ! $this->_apply_result() ) return $this->_msg('er_apply');
263 # * string : key for $this->getLang() function
265 # $message[0] : string : key for $this->getLang() function
286 if ( ! $output ) die( $this->getLang( 'er_msg_nomessage' ) );
303 // Dev debugging mode; manually set to 4; this dirtily display some informations
304 if ( $this->debug > 3 ) echo '<p>message : '.$message.' |output : '.$output.' |val : '.$val.' |err : '.$err.'</p>';
307 if ( !$force && $this->debug == 0 ) return ( $err == -1 ? false : true );
310 if ( !$force && $err != -1 && $this->debug < 3 ) return true;
312 $content = $output.' : '.$this->getLang( $output ).( is_array( $message ) ? ' : '.$message[1] : '' );
314 if ( isset( $this->logFileHandle ) ) fwrite( $this->logFileHandle, date(DATE_ATOM).':'.$_SERVER['REMOTE_USER'].':'.$content.'
330 if ( ! $_FILES['userFile'] ) return $this->_msg('er_file_miss');
332 if ( $_FILES['userFile']['error'] > 0 ) return $this->_msg( array( 'er_file_upload', $_FILES['userFile']['error'] ) );
334 if ( $this->getConf( 'parserMimeTypeAuthorized' ) != "" && strpos( $this->getConf( 'parserMimeTypeAuthorized' ), $_FILES['userFile']['type'] ) === false ) return $this->_msg( array( 'er_file_format', $_FILES['userFile']['type'] ) );
337 while ( file_exists( $this->uploadDir = $this->getConf( 'parserUploadDir' ).rand( 10000, 100000 ) ) ) {};
339 if ( ! mkdir( $this->uploadDir, 0777, true ) ) return $this->_msg( 'er_file_tmpDir' );
341 chmod( $this->uploadDir, 0777 );
343 $this->userFileName = $_FILES['userFile']['name'];
344 $this->userFile = $this->uploadDir.'/'.$this->userFileName;
345 if ( ! move_uploaded_file( $_FILES['userFile']['tmp_name'], $this->userFile ) ) return $this->_msg('er_file_getFromDownload');
349 $this->odtFileName = substr($this->userFileName, 0);
350 $this->odtFile = substr($this->userFile, 0);
353 if ( $this->getConf( 'parserMimeTypePandoc' ) != "" && strpos( $this->getConf( 'parserMimeTypePandoc' ), $_FILES['userFile']['type'] ) !== false ) {
355 $this->_prepareOdtFileName();
359 exec( 'pandoc -s -w odt -o "' . $this->odtFile . '" "' . $this->userFile . '"', $output, $return_var );
363 if ( $this->getConf( 'parserMimeTypeSOffice' ) != "" && strpos( $this->getConf( 'parserMimeTypeSOffice' ), $_FILES['userFile']['type'] ) !== false ) {
365 $this->_prepareOdtFileName();
369 exec( 'cd ' . $this->uploadDir . ' && sudo soffice --nofirststartwizard --headless --convert-to odt:"writer8" "' . $this->userFileName . '"', $output, $return_var );
378 $info = pathinfo($this->userFile);
379 $this->odtFileName = $info['filename'] . '.odt';
380 $this->odtFile = $this->uploadDir.'/'. $this->odtFileName;
389 // Perhaps this would not be needed if use temp dir.
394 if ( file_exists( $this->odtFile ) ) if ( ! @unlink( $this->odtFile ) ) $this->_msg( array( 'er_pg_file', $this->odtFile ) );
395 if ( file_exists( $this->userFile ) ) if ( ! @unlink( $this->userFile ) ) $this->_msg( array( 'er_pg_file', $this->userFile ) );
397 if ( $this->file_extract ) foreach ($this->file_extract as $file) if ( file_exists( $file ) ) if ( ! @unlink( $file ) ) $this->_msg( array( 'er_pg_file', $file ) );
399 if ( $this->file_import ) foreach ( $this->file_import as $file ) if ( file_exists( $this->uploadDir.'/'.$this->pictpath.'/'.$file ) ) if ( ! @unlink( $this->uploadDir.'/'.$this->pictpath.'/'.$file ) ) $this->_msg( array( 'er_pg_file', $this->uploadDir.'/'.$this->pictpath.'/'.$file ) );
401 if ( file_exists( $this->uploadDir.'/'.$this->pictpath) ) if ( ! @rmdir( $this->uploadDir.'/'.$this->pictpath ) ) $this->_msg( array( 'er_pg_dir', $this->uploadDir.'/'.$this->pictpath ) );
403 if ( file_exists( $this->uploadDir ) ) if ( ! @rmdir( $this->uploadDir ) ) $this->_msg( array( 'er_pg_dir', $this->uploadDir ) );
417 if ( ! $this->XSLT->importStylesheet( $this->XSL ) ) return $this->_msg('er_xslt_invalid');
419 if ( ! $this->XSLT->setParameter( '', $param, '1' ) ) return $this->_msg( array( 'inf_xslt_param', $param ), -1 );
421 $this->_msg( array( 'ok_infoPlugin', $param ), 1 );
424 foreach ( array('subtable_message') as $lang_elt ) if ( ! $this->XSLT->setParameter( '', $lang_elt, $this->getLang('xsl_'.$lang_elt ) ) ) $this->_msg( array( 'inf_xslt_lang', $param ), 0 );
435 saveWikiText( $this->pageName, $this->result, $this->getLang( 'parserSummary' ).$this->userFileName );
436 if ( ! page_exists($this->pageName) ) return $this->_msg('er_apply_content');
440 $destDir = mediaFN( $this->nsName );
441 if ( ! ( file_exists( $destDir ) || mkdir( $destDir, 0777, true ) ) ) return $this->_msg( array( 'er_apply_dirCreate' ) );
442 if ( $this->file_import ) foreach ( $this->file_import as $pict ) {
443 $destFile = mediaFN( $this->nsName.':'.$pict );
444 list( $ext, $mime ) = mimetype( $this->uploadDir.'/'.$this->pictpath.'/'.$pict );
445 if ( media_upload_finish($this->uploadDir.'/'.$this->pictpath.'/'.$pict, $destFile, $this->nsName, $mime, @file_exists($destFile), 'rename' ) != $this->nsName ) return $this->_msg( array( 'er_apply_img', $this->uploadDir.'/'.$this->pictpath.'/'.$pict ) );
448 $destFile = mediaFN( $this->nsName.':'.$this->userFileName );
449 list( $ext, $mime ) = mimetype( $this->uploadDir.'/'.$this->userFileName );
450 if ( media_upload_finish($this->uploadDir.'/'.$this->userFileName, $destFile, $this->nsName, $mime, @file_exists($destFile), 'rename' ) != $this->nsName ) return $this->_msg( array( 'er_apply_file' ) );
453 $this->_msg( 'inf_acl_upload', 0, true );
461 ### _parse_image : search dokuwiki img markup in $this->result than extract the img file and rename it to easier name ###
468 if ( preg_match_all( '|{{((?:[^/}]+/)*[^/}]+)/([0-9a-zA-Z]+)(\.[a-z]+)(\?[0-9]+(?:x[0-9]+)?)?}}|', $this->result, $imgs, PREG_SET_ORDER ) ) {
469 if ( auth_quickaclcheck( $ID ) < AUTH_UPLOAD ) return $this->_msg( 'er_acl_upload' );
470 $this->err['ok'] = array();
473 $this->pictpath = $value[1];
477 if ( $this->_unzip($this->pictpath.'/'.$pict) ) {
480 $newFileHash = hash_file('sha512', $this->uploadDir.'/'.$this->pictpath.'/'.$pict);
483 $newFileName = noNS($this->pageName).'_image_'.$key.$ext;
484 $existingFile = mediaFN( $this->nsName.':'.$newFileName);
488 if ( rename( $this->uploadDir.'/'.$this->pictpath.'/'.$pict, $this->uploadDir.'/'.$this->pictpath.'/'.$newFileName ) ) {
489 $this->result = str_replace( '{{'.$this->pictpath.'/'.$pict.$other.'}}' , '{{'.$newFileName.$other.'}}' , $this->result );
490 $this->file_import[] = $newFileName;
491 if ( $this->debug ) $this->err['ok'][] = $pict.' : '.$newFileName;
492 } else $this->err[$pict] = 'rename';
493 } else $this->err[$pict] = 'unzip';
496 if ( $this->err ) foreach ( $this->err as $key => $value ) {
499 foreach ( $value as $msg ) $this->_msg( array( 'ok_img', $msg ) );
503 $this->_msg( array( 'er_img_'.$value, $key ) );
509 ### _unzip : extract $entrie file from $this->odtFile to $this->uploadDir using $this->ZIP object instance of ZipArchive Class ###
515 if ( ! $this->ZIP ) return $this->_msg('er_unzip_object');
516 if ( ! file_exists( $this->odtFile ) ) return $this->_msg('er_unzip_nofile');
517 if ( ! ( $this->ZIP->open( $this->odtFile ) === true ) ) return $this->_msg( 'er_unzip_open' );
518 $res = $this->ZIP->extractTo( $this->uploadDir, $entrie );
519 $this->ZIP->close();
520 if ( ! $res ) return $this->_msg( array( 'er_unzip_error', $entrie ) );
521 $this->file_extract[] = $this->uploadDir.'/'.$entrie;
522 return $this->_msg( array( 'ok_unzip', $entrie ) );