[dokuwiki] Re: Changing the cache file name (solved)

  • From: Lars Paulsen <lars_paulsen@xxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sun, 22 Jan 2017 14:24:19 +0100

Hi All,

as suggested in my Iast mail I solved the problem by using two different classes/files for the modes 'export_odt' and 'export_odt_pdf'.
The mode is still changed in plugins/odt/action/export.php but it stays two different modes ('export_odt_page' and 'export_odt_pagepdf').
The rest is done by the cache automatically.

Conclusion:
It was not a good idea to handle the two modes in one class/file!

Best Regards,
Lars (LarsDW223)

Am 22.01.2017 um 09:37 schrieb Lars Paulsen:


Hi Gerrit,

thanks for the quick response. I still need to check your links to see if I find some help there.
But regarding your question about the cache name, it is:

MD5.odt_page

I think that is because in the file plugins/odt/action/export.php (see function 'convert()') the variable $ACT is changed:

    // check conversion format and adjust $ACT
    $format = 'odt';
    if ($odt_export && strpos($ACT, '_pdf') !== false) {
        $format = 'pdf';
        $ACT = str_replace ('_pdf', '', $ACT);
    }

    // single page export: rename to the actual renderer component
    if($ACT == 'export_odt') {
        $ACT = 'export_odt_page';
    }

That makes the single page rendering being done in plugins/odt/renderer/page.php.
And the rest like bookcreator and complete namespace rendering is done in plugins/odt/renderer/book.php (as you know of course).

So I guess another solution would probably be to change $ACT to 'export_odt_page_pdf' on PDF export,
create a new file plugins/odt/renderer/page_pdf.php with a class which is inherited from renderer_plugin_odt_page
that is doing the PDF conversion on top/at the end of the normal ODT export.

Best Regards,
Lars (LarsDW223)

Am 22.01.2017 um 01:46 schrieb Klap in:
Hi Larson,

A quick response.
I think your export was handled via
https://github.com/splitbrain/dokuwiki/blob/master/inc/actions.php#L671

That should already use your mode (odt or odt_pdf) as extension of the cache file.
What is the current cachefilename as stored in $cache->cache variable?

Two examples of cache influencing

https://github.com/samuelet/indexmenu/blob/master/action.php
https://github.com/splitbrain/dokuwiki-plugin-dw2pdf/blob/master/action.php#L214

For the indexmenu plugin you see that the key is modified, but it requires also redoing the work done by the constructor.

Success with this puzzle.
Kind regards,
Gerrit

Op za 21 jan. 2017 om 19:56 schreef Lars Paulsen <lars_paulsen@xxxxxx>

    Hi all,



    I need some help about using/modifying the cache:

    I try to change the file name of the cache file but I always fail.



    What do I want to achieve?

    The ODT plugin can deliver a page in ODT format or in PDF format.

    I recognized that if a page is cached, it will always be delivered in

    this format.



    So if I generate a page in ODT format (do=export_odt) and the
    same page

    later as PDF (do=export_odt_pdf) then I get the cached ODT file
    instead

    of a freshly generated PDF file or cached PDF file.



    I thought the solution would be to make the file format a part of the

    cache file name.

    But I am failing to do so.



    I registered to the event 'PARSER_CACHE_USE' to get the cache object:

    $controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this,

    'handle_cache_prepare');



    Then in function 'handle_cache_prepare()' I do something like this:



         $cache =& $event->data;

         // $format_ext would be 'odt' or 'pdf'

         $cache->cache = $cache->cache.$format_ext;



    But whatever I do it has no influence on the file name used for the

    cached file.

    What am I doing wrong? Help is highly appreciated. Thanks in advance.



    Best Regards,

    Lars (LarsDW223)



    --

    DokuWiki mailing list - more info at

    http://www.dokuwiki.org/mailinglist



Other related posts:

  • » [dokuwiki] Re: Changing the cache file name (solved) - Lars Paulsen