From aaeb1211faccebd27b0c5c83c973838d969bb6b6 Mon Sep 17 00:00:00 2001 From: Christoph Scholz Date: Tue, 18 Feb 2025 16:30:41 +0100 Subject: [PATCH] use local version of ptln() --- action.php | 50 ++++++++++++++++++++++++++------------------------ admin.php | 48 +++++++++++++++++++++++++----------------------- lptln.php | 26 ++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 47 deletions(-) create mode 100644 lptln.php diff --git a/action.php b/action.php index b33f240..51bcf59 100644 --- a/action.php +++ b/action.php @@ -8,6 +8,8 @@ use dokuwiki\Subscriptions\SubscriberManager; use dokuwiki\Utf8\PhpString; +include_once 'lptln.php'; + /** * Class action_plugin_discussion * @@ -435,11 +437,11 @@ protected function showDiscussionSection($reply = null, $edit = null) $show = true; // section title $title = (!empty($data['title']) ? hsc($data['title']) : $this->getLang('discussion')); - ptln('
'); // the id value is used for visibility toggling the section - ptln('

', 2); - ptln($title, 4); - ptln('

', 2); - ptln('
', 2); + lptln('
'); // the id value is used for visibility toggling the section + lptln('

', 2); + lptln($title, 4); + lptln('

', 2); + lptln('
', 2); } // now display the comments @@ -466,8 +468,8 @@ protected function showDiscussionSection($reply = null, $edit = null) } if ($show) { - ptln('
', 2); // level2 hfeed - ptln('
'); // comment_wrapper + lptln('
', 2); // level2 hfeed + lptln('
'); // comment_wrapper } // check for toggle print configuration @@ -824,9 +826,9 @@ protected function showComment($cid, $data, $reply, $isVisible) $class .= ' reply'; } // comment head with date and user data - ptln('
', 4); - ptln('
', 6); - ptln('', 8); + lptln('
', 4); + lptln('
', 6); + lptln('', 8); $head = ''; // prepare variables @@ -895,17 +897,17 @@ protected function showComment($cid, $data, $reply, $isVisible) strftime('%Y-%m-%dT%H:%M:%SZ', $modified) . '">' . dformat($modified, $conf['dformat']) . ''; } - ptln($head, 8); - ptln('
', 6); // class="comment_head" + lptln($head, 8); + lptln('
', 6); // class="comment_head" // main comment content - ptln('
useAvatar() ? $this->getWidthStyle() : '') . '>', 6); echo ($HIGH ? html_hilight($comment['xhtml'], $HIGH) : $comment['xhtml']) . DOKU_LF; - ptln('
', 6); // class="comment_body" + lptln('
', 6); // class="comment_body" if ($isVisible) { - ptln('
', 6); + lptln('
', 6); // show reply button? if ($data['status'] == 1 && !$reply && $comment['show'] @@ -922,9 +924,9 @@ protected function showComment($cid, $data, $reply, $isVisible) $this->showButton($cid, $label, 'toogle'); $this->showButton($cid, $lang['btn_delete'], 'delete'); } - ptln('
', 6); // class="comment_buttons" + lptln('
', 6); // class="comment_buttons" } - ptln('
', 4); // class="hentry" + lptln('', 4); // class="hentry" } /** @@ -936,9 +938,9 @@ protected function showComment($cid, $data, $reply, $isVisible) protected function showReplyForm($cid, $reply) { if ($this->getConf('usethreading') && $reply == $cid) { - ptln('
', 4); + lptln('
', 4); $this->showCommentForm('', 'add', $cid); - ptln('
', 4); // class="comment_replies" + lptln('
', 4); // class="comment_replies" } } @@ -956,12 +958,12 @@ protected function showReplies($cid, &$data, $reply, &$isVisible) if (!empty($comment['replies'])) { return; } - ptln('
getWidthStyle() . '>', 4); + lptln('
getWidthStyle() . '>', 4); $isVisible = ($comment['show'] && $isVisible); foreach ($comment['replies'] as $rid) { $this->showCommentWithReplies($rid, $data, $cid, $reply, $isVisible); } - ptln('
', 4); + lptln('
', 4); } /** @@ -1004,10 +1006,10 @@ protected function getWidthStyle() */ protected function showDiscussionToggleButton() { - ptln('
'); - ptln(''); + lptln(''); - ptln('
'); + lptln(''); } /** diff --git a/admin.php b/admin.php index 55e6527..4e16484 100644 --- a/admin.php +++ b/admin.php @@ -6,6 +6,8 @@ use dokuwiki\Utf8\PhpString; +include_once 'lptln.php'; + /** * Class admin_plugin_discussion */ @@ -71,7 +73,7 @@ public function html() $num = $conf['recent'] ?: 20; - ptln('

' . $this->getLang('menu') . '

'); + lptln('

' . $this->getLang('menu') . '

'); $threads = $this->getThreads(); @@ -83,20 +85,20 @@ public function html() $comments = $this->getComments($thread); $this->threadHead($thread); if ($comments === false) { - ptln('', 6); // class="level2" + lptln('', 6); // class="level2" continue; } - ptln('
', 8); - ptln('
', 10); - ptln('', 10); - ptln('', 10); - ptln('', 10); + lptln('', 8); + lptln('
', 10); + lptln('', 10); + lptln('', 10); + lptln('', 10); echo html_buildlist($comments, 'admin_discussion', [$this, 'commentItem'], [$this, 'liComment']); $this->actionButtons(); - ptln('
', 10); // class="no" - ptln('', 8); - ptln('
', 6); // class="level2" + lptln('', 10); // class="no" + lptln('', 8); + lptln('', 6); // class="level2" } $this->browseDiscussionLinks($isMore, $first, $num); @@ -330,11 +332,11 @@ protected function actionButtons() { global $lang; - ptln('
', 12); - ptln('', 14); - ptln('', 14); - ptln('', 14); - ptln('
', 12); // class="comment_buttons" + lptln('
', 12); + lptln('', 14); + lptln('', 14); + lptln('', 14); + lptln('
', 12); // class="comment_buttons" } /** @@ -352,7 +354,7 @@ protected function browseDiscussionLinks($isMore, $first, $num) $params = ['do' => 'admin', 'page' => 'discussion']; $last = $first + $num; - ptln('
', 8); + lptln('
', 8); $return = ''; if ($first > 0) { $first -= $num; @@ -360,24 +362,24 @@ protected function browseDiscussionLinks($isMore, $first, $num) $first = 0; } $params['first'] = $first; - ptln('

', 8); + lptln('

', 8); $return = '<< ' . $this->getLang('newer') . ''; if ($isMore) { $return .= ' | '; } else { - ptln($return, 10); - ptln('

', 8); + lptln($return, 10); + lptln('

', 8); } } elseif ($isMore) { - ptln('

', 8); + lptln('

', 8); } if ($isMore) { $params['first'] = $last; $return .= '' . $this->getLang('older') . ' >>'; - ptln($return, 10); - ptln('

', 8); + lptln($return, 10); + lptln('

', 8); } - ptln('
', 6); // class="level1" + lptln('
', 6); // class="level1" } /** diff --git a/lptln.php b/lptln.php new file mode 100644 index 0000000..8f2ced0 --- /dev/null +++ b/lptln.php @@ -0,0 +1,26 @@ + + */ + +/** + * print a newline terminated string + * + * You can give an indention as optional parameter + * + * This function is an exact copy of 'ptln' in DokuWiki + * which is deprecated since 2023-08-31. + * This is introduced here in order to get + * rid of deprecation warnings without changing the + * plugin too much. + * + * @author Andreas Gohr + * + * @param string $string line of text + * @param int $indent number of spaces indention + */ +function lptln($string, $indent = 0) +{ + echo str_repeat(' ', $indent) . "$string\n"; +}