Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove calls to ptln() in order to remove deprecation warnings #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 26 additions & 24 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use dokuwiki\Subscriptions\SubscriberManager;
use dokuwiki\Utf8\PhpString;

include_once 'lptln.php';

/**
* Class action_plugin_discussion
*
Expand Down Expand Up @@ -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('<div class="comment_wrapper" id="comment_wrapper">'); // the id value is used for visibility toggling the section
ptln('<h2><a name="discussion__section" id="discussion__section">', 2);
ptln($title, 4);
ptln('</a></h2>', 2);
ptln('<div class="level2 hfeed">', 2);
lptln('<div class="comment_wrapper" id="comment_wrapper">'); // the id value is used for visibility toggling the section
lptln('<h2><a name="discussion__section" id="discussion__section">', 2);
lptln($title, 4);
lptln('</a></h2>', 2);
lptln('<div class="level2 hfeed">', 2);
}

// now display the comments
Expand All @@ -466,8 +468,8 @@ protected function showDiscussionSection($reply = null, $edit = null)
}

if ($show) {
ptln('</div>', 2); // level2 hfeed
ptln('</div>'); // comment_wrapper
lptln('</div>', 2); // level2 hfeed
lptln('</div>'); // comment_wrapper
}

// check for toggle print configuration
Expand Down Expand Up @@ -824,9 +826,9 @@ protected function showComment($cid, $data, $reply, $isVisible)
$class .= ' reply';
}
// comment head with date and user data
ptln('<div class="hentry' . $class . '">', 4);
ptln('<div class="comment_head">', 6);
ptln('<a name="comment_' . $cid . '" id="comment_' . $cid . '"></a>', 8);
lptln('<div class="hentry' . $class . '">', 4);
lptln('<div class="comment_head">', 6);
lptln('<a name="comment_' . $cid . '" id="comment_' . $cid . '"></a>', 8);
$head = '<span class="vcard author">';

// prepare variables
Expand Down Expand Up @@ -895,17 +897,17 @@ protected function showComment($cid, $data, $reply, $isVisible)
strftime('%Y-%m-%dT%H:%M:%SZ', $modified) . '">' . dformat($modified, $conf['dformat']) .
'</abbr>';
}
ptln($head, 8);
ptln('</div>', 6); // class="comment_head"
lptln($head, 8);
lptln('</div>', 6); // class="comment_head"

// main comment content
ptln('<div class="comment_body entry-content"' .
lptln('<div class="comment_body entry-content"' .
($this->useAvatar() ? $this->getWidthStyle() : '') . '>', 6);
echo ($HIGH ? html_hilight($comment['xhtml'], $HIGH) : $comment['xhtml']) . DOKU_LF;
ptln('</div>', 6); // class="comment_body"
lptln('</div>', 6); // class="comment_body"

if ($isVisible) {
ptln('<div class="comment_buttons">', 6);
lptln('<div class="comment_buttons">', 6);

// show reply button?
if ($data['status'] == 1 && !$reply && $comment['show']
Expand All @@ -922,9 +924,9 @@ protected function showComment($cid, $data, $reply, $isVisible)
$this->showButton($cid, $label, 'toogle');
$this->showButton($cid, $lang['btn_delete'], 'delete');
}
ptln('</div>', 6); // class="comment_buttons"
lptln('</div>', 6); // class="comment_buttons"
}
ptln('</div>', 4); // class="hentry"
lptln('</div>', 4); // class="hentry"
}

/**
Expand All @@ -936,9 +938,9 @@ protected function showComment($cid, $data, $reply, $isVisible)
protected function showReplyForm($cid, $reply)
{
if ($this->getConf('usethreading') && $reply == $cid) {
ptln('<div class="comment_replies reply">', 4);
lptln('<div class="comment_replies reply">', 4);
$this->showCommentForm('', 'add', $cid);
ptln('</div>', 4); // class="comment_replies"
lptln('</div>', 4); // class="comment_replies"
}
}

Expand All @@ -956,12 +958,12 @@ protected function showReplies($cid, &$data, $reply, &$isVisible)
if (!empty($comment['replies'])) {
return;
}
ptln('<div class="comment_replies"' . $this->getWidthStyle() . '>', 4);
lptln('<div class="comment_replies"' . $this->getWidthStyle() . '>', 4);
$isVisible = ($comment['show'] && $isVisible);
foreach ($comment['replies'] as $rid) {
$this->showCommentWithReplies($rid, $data, $cid, $reply, $isVisible);
}
ptln('</div>', 4);
lptln('</div>', 4);
}

/**
Expand Down Expand Up @@ -1004,10 +1006,10 @@ protected function getWidthStyle()
*/
protected function showDiscussionToggleButton()
{
ptln('<div id="toggle_button" class="toggle_button">');
ptln('<input type="submit" id="discussion__btn_toggle_visibility" title="Toggle Visibiliy" class="button"'
lptln('<div id="toggle_button" class="toggle_button">');
lptln('<input type="submit" id="discussion__btn_toggle_visibility" title="Toggle Visibiliy" class="button"'
. 'value="' . $this->getLang('toggle_display') . '">');
ptln('</div>');
lptln('</div>');
}

/**
Expand Down
48 changes: 25 additions & 23 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use dokuwiki\Utf8\PhpString;

include_once 'lptln.php';

/**
* Class admin_plugin_discussion
*/
Expand Down Expand Up @@ -71,7 +73,7 @@ public function html()

$num = $conf['recent'] ?: 20;

ptln('<h1>' . $this->getLang('menu') . '</h1>');
lptln('<h1>' . $this->getLang('menu') . '</h1>');

$threads = $this->getThreads();

Expand All @@ -83,20 +85,20 @@ public function html()
$comments = $this->getComments($thread);
$this->threadHead($thread);
if ($comments === false) {
ptln('</div>', 6); // class="level2"
lptln('</div>', 6); // class="level2"
continue;
}

ptln('<form method="post" action="' . wl($thread['id']) . '">', 8);
ptln('<div class="no">', 10);
ptln('<input type="hidden" name="do" value="admin" />', 10);
ptln('<input type="hidden" name="page" value="discussion" />', 10);
ptln('<input type="hidden" name="sectok" value="'.getSecurityToken().'" />', 10);
lptln('<form method="post" action="' . wl($thread['id']) . '">', 8);
lptln('<div class="no">', 10);
lptln('<input type="hidden" name="do" value="admin" />', 10);
lptln('<input type="hidden" name="page" value="discussion" />', 10);
lptln('<input type="hidden" name="sectok" value="'.getSecurityToken().'" />', 10);
echo html_buildlist($comments, 'admin_discussion', [$this, 'commentItem'], [$this, 'liComment']);
$this->actionButtons();
ptln('</div>', 10); // class="no"
ptln('</form>', 8);
ptln('</div>', 6); // class="level2"
lptln('</div>', 10); // class="no"
lptln('</form>', 8);
lptln('</div>', 6); // class="level2"
}
$this->browseDiscussionLinks($isMore, $first, $num);

Expand Down Expand Up @@ -330,11 +332,11 @@ protected function actionButtons()
{
global $lang;

ptln('<div class="comment_buttons">', 12);
ptln('<input type="submit" name="comment" value="' . $this->getLang('btn_show') . '" class="button" title="' . $this->getLang('btn_show') . '" />', 14);
ptln('<input type="submit" name="comment" value="' . $this->getLang('btn_hide') . '" class="button" title="' . $this->getLang('btn_hide') . '" />', 14);
ptln('<input type="submit" name="comment" value="' . $lang['btn_delete'] . '" class="button" title="' . $lang['btn_delete'] . '" />', 14);
ptln('</div>', 12); // class="comment_buttons"
lptln('<div class="comment_buttons">', 12);
lptln('<input type="submit" name="comment" value="' . $this->getLang('btn_show') . '" class="button" title="' . $this->getLang('btn_show') . '" />', 14);
lptln('<input type="submit" name="comment" value="' . $this->getLang('btn_hide') . '" class="button" title="' . $this->getLang('btn_hide') . '" />', 14);
lptln('<input type="submit" name="comment" value="' . $lang['btn_delete'] . '" class="button" title="' . $lang['btn_delete'] . '" />', 14);
lptln('</div>', 12); // class="comment_buttons"
}

/**
Expand All @@ -352,32 +354,32 @@ protected function browseDiscussionLinks($isMore, $first, $num)

$params = ['do' => 'admin', 'page' => 'discussion'];
$last = $first + $num;
ptln('<div class="level1">', 8);
lptln('<div class="level1">', 8);
$return = '';
if ($first > 0) {
$first -= $num;
if ($first < 0) {
$first = 0;
}
$params['first'] = $first;
ptln('<p class="centeralign">', 8);
lptln('<p class="centeralign">', 8);
$return = '<a href="' . wl($ID, $params) . '" class="wikilink1">&lt;&lt; ' . $this->getLang('newer') . '</a>';
if ($isMore) {
$return .= ' | ';
} else {
ptln($return, 10);
ptln('</p>', 8);
lptln($return, 10);
lptln('</p>', 8);
}
} elseif ($isMore) {
ptln('<p class="centeralign">', 8);
lptln('<p class="centeralign">', 8);
}
if ($isMore) {
$params['first'] = $last;
$return .= '<a href="' . wl($ID, $params) . '" class="wikilink1">' . $this->getLang('older') . ' &gt;&gt;</a>';
ptln($return, 10);
ptln('</p>', 8);
lptln($return, 10);
lptln('</p>', 8);
}
ptln('</div>', 6); // class="level1"
lptln('</div>', 6); // class="level1"
}

/**
Expand Down
26 changes: 26 additions & 0 deletions lptln.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christoph Scholz <christoph.scholz@gmail.com>
*/

/**
* 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 <andi@splitbrain.org>
*
* @param string $string line of text
* @param int $indent number of spaces indention
*/
function lptln($string, $indent = 0)
{
echo str_repeat(' ', $indent) . "$string\n";
}