Benutzer-Werkzeuge

Webseiten-Werkzeuge


users:werner:modirenden

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
users:werner:modirenden [2007-01-13 1759]
werner quotation statt quote
users:werner:modirenden [2007-01-13 1803] (aktuell)
werner typo
Zeile 1: Zeile 1:
 +====== A Renderer Plugin for DokuWiki ======
 +
 +...which does not run :-(
 +
 +I find it annoying that the quotation marks are hardcoded in DokuWiki's source code. At the moment, I have a workaround by abusing the [[doku>wiki:tpl:ach|ACH-Template]]:
 +
 +<code php>
 +      <?php
 +        ob_start();
 +        tpl_content();
 +        $myhtml = ob_get_contents();
 +        ob_end_clean();
 +        echo wfModiOut('screen', $myhtml);
 +       ?>
 +</code>
 +
 +Here ''wfModiOut()'' is a function, that consists mostly of those two lines:
 +
 +<code php>
 +      $retval = str_replace('&ldquo;', '&raquo;', $retval);
 +      $retval = str_replace('&rdquo;', '&laquo;', $retval);
 +</code>
 +
 +I thought that a renderer plugin would replace this, and so I started to work around my workaround by the following code:
 +
 +<code php>
 +<?php
 +
 +/**
 +    MODIfied RENDerer for XHTML output
 +    @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 +    @author Werner Flamme \<w.flamme@web.de>
 +**/
 +// the following lines are stolen from the s5 plugin of Harry Fuecks and Andi Gohr
 +// must be run within Dokuwiki
 +if(!defined('DOKU_INC')) die();
 +
 +// we inherit from the XHTML renderer instead directly of the base renderer
 +require_once DOKU_INC.'inc/parser/xhtml.php';
 +// stolen code ends here
 +
 +if (!defined('DOKU_PLUGIN'))
 +  define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
 +require_once DOKU_PLUGIN . 'modirend/conf/default.php';
 +
 +/**
 +    This class allow to change the double and single quotation marks,
 +    something I always wanted but what never got implemented.
 +    Instead of modifying 4 lines in DokuWikis source code
 +    I have to write a plugin :-(
 +**/
 +class Doku_Renderer_modirend extends Doku_Renderer_xhtml {
 +
 +    /**
 +        Return some info
 +    **/
 +    function getInfo(){
 +        return array(
 +                    'author' => 'Werner Flamme',
 +                    'email'  => 'w.flamme@web.de',
 +                    'date'   => '2007-01-13',
 +                    'name'   => 'MODIfied RENDerer',
 +                    'desc'   => 'Changes quote marks',
 +                    'url'    => 'http://www.wernerflamme.name/users:wflamme:modirend',
 +                    );
 +    } // function getInfo
 +
 +    /**
 +        add opening single quote to document's code
 +    **/
 +    function singlequoteopening()
 +    {
 +        global $conf;
 +        $this->doc .= $conf['modirend_sq_open'];
 +    }
 +
 +    /**
 +        add closing single quote to document's code
 +    **/
 +    function singlequoteclosing()
 +    {
 +        global $conf;
 +        $this->doc .= $conf['modirend_sq_close'];
 +    }
 +
 +    /**
 +        add opening double quote to document's code
 +    **/
 +    function doublequoteopening()
 +    {
 +        global $conf;
 +        $this->doc .= $conf['modirend_dq_open'];
 +    }
 +
 +    /**
 +        add closing double quote to document's code
 +    **/
 +    function doublequoteclosing()
 +    {
 +        global $conf;
 +        $this->doc .= $conf['modirend_dq_close'];
 +    }
 +}
 +
 +//Setup VIM: ex: et ts=4 enc=utf-8 :
 +</code>
 +
 +So I use the standard XHTML renderer of DokuWiki and overwrite 4 of its methods. When I append ''&do=export_modirend'' to the URL, I get "my" quotation marks (or when I use ''echo exportlink($ID, 'modirend');'' inside my template). This is the theory.
 +
 +Practically, the ''&do=export_modirend'' leads to displaying the document's content only, without any XHTML headers and other things that make a page look nice ;-). Without my quotation marks. When I add some output to ''$conf[...]'', this additional Text appears.
 +
 +Next, my Apache didn't show my pages correctly at all -- only fragments of them were shown, whether or not I added ''&do=export_modirend''. In the error log I only saw that Apache's child died unexpectedly (does Apache expect that the children die otherwise? ;-))
 +
 +Question: why don't I get the expected result -- a text (or a page) looking exactly like the other one, except for the modified quotation marks? How can I use the renderer plugin correctly?
  
users/werner/modirenden.txt · Zuletzt geändert: 2007-01-13 1803 von werner