Not logged in. · Lost password · Register
Forum: Non-English Discussion German discussion RSS
Random Include Plugin (helper class) funktioniert nicht mehr
unter Release 2017-02-19b "Frusterick Manners"
Avatar
hillschmidt #1
Member since Feb 2013 · 189 posts
Group memberships: Members
Show profile · Link to this post
Subject: Random Include Plugin (helper class) funktioniert nicht mehr
Liebe Wiki-Anwender,

kann jemand bestätigen, daß das Plugin "Random Include Plugin (helper class)" unter Release 2017-02-19b "Frusterick Manners" nicht mehr funktioniert?

Ich nutze es auf http://pe.hillschmidt.de um eine zufällig ausgewählte Seite auf der Titelseite anzuzeigen - seit o.g. Release Update klappt das nicht mehr.

Das Plugin ist aus 2008 - funktionierte bisher aber problemlos. Eine Fehlermeldung sehe ich nicht. Aber es wird auch kein Artikel mehr angezeigt. Bin leider kein Coder ...

Bin für jeden Hinweis dankbar!

Es grüßt Andreas
Avatar
diltigug #2
Member since Feb 2017 · 152 posts
Group memberships: Members
Show profile · Link to this post
Hallo,

ich bin gestern erst auf das Plugin gestossen und würde das auch gern verwenden.
Im Prinzip scheint es bei mir zu funktionieren, allerdings wird in der Fußzeile das Datum nicht korrekt formatiert (%2017/%03/%20 %14:%Mar) und ein Link zu einer (bei uns) nicht existierenden Autorenseite wird angezeigt.

Außerdem finde ich es unpraktisch, das man m. W. nur einen Namensraum ansprechen kann.

Wäre toll, wenn sich jemand findet, der das Plugin mal updaten und um die Funktion mehrere Namensräume zu verwenden, erweitern kann. Ich kann das leider nicht.

Oder gibt es evtl. noch anderen alternativen zu dem Plugin?
Avatar
Defiance #3
Member since Jun 2017 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: Random Include Plugin not working anymore
Hi,

I've been using this plugin for more then a year as well. I was very happy with it. I coulnd't get the other Random Inc. plugin to work and this one actually gave no hassle. It would be great if someone could fix it up again. Also the the last update was a looonngggg time go so its maybe worth a check. Problem is though, that I'm not a programmer at all, only a user/content-generator.
Avatar
LarsDW223 #4
Member since Sep 2014 · 448 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Hi All,

I had a look at the plugin and I found out that it uses a no longer supported function. My apache error log showed the following line:

[Mon Jun 12 22:37:20.877899 2017] [:error] [pid 5306] [client 127.0.0.1:43988] PHP Warning:  preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /home/lars/public-html/dokuwiki/lib/plugins/randominc/helper.php on line 432

You can fix it this way: open the file helper.php, go to line 421. You should see this function:
  /**
   * Remove TOC, section edit buttons and tags
   */
  function _cleanXHTML($xhtml){
    $replace = array(
      '!<div class="toc">.*?(</div>\n</div>)!s'   => '', // remove toc
      '#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#e' => '', // remove section edit buttons
      '!<div class="tags">.*?(</div>)!s'          => '', // remove category tags
    );
    if ($this->clevel)
      $replace['#<div class="footnotes">#s'] = '<div class="footnotes level'.$this->clevel.'">';
    $xhtml  = preg_replace(array_keys($replace), array_values($replace), $xhtml);
    return $xhtml;
  }

Replace the function with this code:

  /**
   * Remove TOC, section edit buttons and tags
   */
  function _cleanXHTML($xhtml){
    $replace = array(
      '!<div class="toc">.*?(</div>\n</div>)!s'   => '', // remove toc
      '#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#' => '', // remove section edit buttons
      '!<div class="tags">.*?(</div>)!s'          => '', // remove category tags
    );
    if ($this->clevel)
      $replace['#<div class="footnotes">#s'] = '<div class="footnotes level'.$this->clevel.'">';
    $xhtml = preg_replace_callback(array_keys($replace),
                                   function ($m) { return ''; },
                                   $xhtml);
    return $xhtml;
  }

The code above needs a cleanup but it seemed tow work on my installation. So the problem seems th be related to the PHP version, not the DokWiki version. Did you also upgrade the PHP version?

To be more precise preg_replace(...) is still supported but not the option e (as used in the line '#<!-- SECTION "(.*?)" [(\d+-\d*)\] -->#e').

Please check out the code and give some feedback.

Kind Regards,
Lars
This post was edited on 2017-06-13, 00:14 by LarsDW223.
Avatar
turnermm (Moderator) #5
Member since Oct 2009 · 4741 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
Perhaps you can adopt this plugin and  update it for other future users.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
LarsDW223 #6
Member since Sep 2014 · 448 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
@turnermm:
I sent a mail to the author to suggest adoption of the plugin. Now I am waiting for a response.
Avatar
LarsDW223 #7
Member since Sep 2014 · 448 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Short update:
The author does not mind me to adopt the plugin. So on one of the next days I will adopt it (move the code to a github repository and change the links on the plugin page).
Avatar
diltigug #8
Member since Feb 2017 · 152 posts
Group memberships: Members
Show profile · Link to this post
I think that's great, thank you for your commitment.
Avatar
LarsDW223 #9
Member since Sep 2014 · 448 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
Hi All,

I adopted the plugin. It is now hosted on github. The download URL on the plugin page is changed so an update should give you the corrected code.

If there are any further issues/change requests please post them in the github issue tracker.

Cheers,
Lars
Avatar
LarsDW223 #10
Member since Sep 2014 · 448 posts · Location: Paderborn
Group memberships: Members
Show profile · Link to this post
A small addition:
It is now also added to the DokuWiki translation tool. More translations are welcome.
Avatar
hillschmidt #11
Member since Feb 2013 · 189 posts
Group memberships: Members
Show profile · Link to this post
PERFECT - works now as before! Danke für den Update - Thanks for the update!
Avatar
Defiance #12
Member since Jun 2017 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: Appreciation
Dear Lars, thank you a lot. Your efforts are very much appreciated. I'll digg up the plugin and update it. Many thanks!
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-12-14, 08:55:46 (UTC +01:00)