Completed
Pull Request — master (#462)
by Richard
15:21
created

CommentsCommentRenderer::renderNestReplies()   C

Complexity

Conditions 12
Paths 30

Size

Total Lines 43
Code Lines 32

Duplication

Lines 15
Ratio 34.88 %
Metric Value
dl 15
loc 43
rs 5.1612
cc 12
eloc 32
nc 30
nop 6

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
use Xoops\Core\XoopsTpl;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsTpl.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
13
14
/**
15
 * @copyright       XOOPS Project (http://xoops.org)
16
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17
 * @package         Comments
18
 * @author          trabis <[email protected]>
19
 * @author          Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
20
 * @version         $Id$
21
 */
22
23
/**
24
 * Display comments
25
 *
26
 * @author  Kazumi Ono <[email protected]>
27
 * @package class
28
 */
29
class CommentsCommentRenderer
30
{
31
    /**
32
     * @var XoopsTpl
33
     */
34
    private $tpl;
35
36
    /**
37
     * @var array
38
     */
39
    private $comments = array();
40
41
    /**
42
     * @var bool
43
     */
44
    private $useIcons = true;
45
46
    /**
47
     * @var bool
48
     */
49
    private $doIconCheck = false;
50
51
    /**
52
     * @var array
53
     */
54
    private $statusText;
55
56
    /**
57
     * Constructor
58
     *
59
     * @param XoopsTpl $tpl
60
     * @param boolean  $use_icons
61
     * @param boolean  $do_iconcheck
62
     */
63
    public function __construct(XoopsTpl $tpl, $use_icons = true, $do_iconcheck = false)
64
    {
65
        $this->tpl = $tpl;
66
        $this->useIcons = $use_icons;
67
        $this->doIconCheck = $do_iconcheck;
68
        $this->statusText = array(
69
            COMMENTS_PENDING => '<span style="text-decoration: none; font-weight: bold; color: #00ff00;">'
70
                . _MD_COMMENTS_PENDING . '</span>',
71
            COMMENTS_ACTIVE  => '<span style="text-decoration: none; font-weight: bold; color: #ff0000;">'
72
                . _MD_COMMENTS_ACTIVE . '</span>',
73
            COMMENTS_HIDDEN  => '<span style="text-decoration: none; font-weight: bold; color: #0000ff;">'
74
                . _MD_COMMENTS_HIDDEN . '</span>'
75
        );
76
    }
77
78
    /**
79
     * Access the only instance of this class
80
     *
81
     * @param XoopsTpl $tpl          reference to a {@link XoopsTpl} object
82
     * @param boolean  $use_icons    use image icons
83
     * @param boolean  $do_iconcheck do icon check
84
     *
85
     * @return CommentsCommentRenderer
86
     */
87
    public static function getInstance(XoopsTpl $tpl, $use_icons = true, $do_iconcheck = false)
88
    {
89
        static $instance;
90
        if (!isset($instance)) {
91
            $class = __CLASS__;
92
            $instance = new $class($tpl, $use_icons, $do_iconcheck);
93
        }
94
        return $instance;
95
    }
96
97
    /**
98
     * Accessor
99
     *
100
     * @param array $comments_arr array of CommentsComment objects
101
     *
102
     * @return void
103
     */
104
    public function setComments(&$comments_arr)
105
    {
106
        if (isset($this->comments)) {
107
            unset($this->comments);
108
        }
109
        $this->comments =& $comments_arr;
110
    }
111
112
    /**
113
     * Render the comments in flat view
114
     *
115
     * @param boolean $admin_view
116
     *
117
     * @return void
118
     */
119
    public function renderFlatView($admin_view = false)
120
    {
121
        foreach ($this->comments as $i => $comment) {
122
            /* @var $comment CommentsComment */
123
            $image = (false != $this->useIcons) ? $this->getTitleIcon($comment->getVar('icon')) : '';
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
124
            $title = $comment->getVar('title');
125
126
            $poster = $this->getPosterArray($comment->getVar('uid'));
127
            if (false != $admin_view) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
128
                $text = $comment->getVar('text')
129
                    . '<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'
130
                    . _MD_COMMENTS_STATUS . ': ' . $this->statusText[$comment->getVar('status')]
131
                    . '<br />IP: <span style="font-weight: bold;">' . $comment->getVar('ip') . '</span></div>';
132
            } else {
133
                // hide comments that are not active
134
                if (COMMENTS_ACTIVE != $comment->getVar('status')) {
135
                    continue;
136
                } else {
137
                    $text = $comment->getVar('text');
138
                }
139
            }
140
            $this->comments[$i] = $comment;
141
            $this->tpl->append('comments', array(
142
                'id'            => $comment->getVar('id'),
143
                'image'         => $image,
144
                'title'         => $title,
145
                'text'          => $text,
146
                'date_posted'   => XoopsLocale::formatTimestamp($comment->getVar('created'), 'm'),
147
                'date_modified' => XoopsLocale::formatTimestamp($comment->getVar('modified'), 'm'),
148
                'poster'        => $poster
149
            ));
150
        }
151
    }
152
153
    /**
154
     * Render the comments in thread view
155
     * This method calls itself recursively
156
     *
157
     * @param integer $comment_id Should be "0" when called by client
158
     * @param boolean $admin_view
159
     * @param boolean $show_nav
160
     *
161
     * @return void
162
     */
163
    public function renderThreadView($comment_id = 0, $admin_view = false, $show_nav = true)
164
    {
165
        // construct comment tree
166
        $xot = new XoopsObjectTree($this->comments, 'id', 'pid', 'rootid');
167
        $tree = $xot->getTree();
168
169
        $image = (false != $this->useIcons) ? $this->getTitleIcon($tree[$comment_id]['obj']->getVar('icon')) : '';
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
170
        $title = $tree[$comment_id]['obj']->getVar('title');
171
        if (false != $show_nav && $tree[$comment_id]['obj']->getVar('pid') != 0) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
172
            $this->tpl->assign('lang_top', _MD_COMMENTS_TOP);
173
            $this->tpl->assign('lang_parent', _MD_COMMENTS_PARENT);
174
            $this->tpl->assign('show_threadnav', true);
175
        } else {
176
            $this->tpl->assign('show_threadnav', false);
177
        }
178 View Code Duplication
        if (false != $admin_view) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
179
            // admins can see all
180
            $text = $tree[$comment_id]['obj']->getVar('text')
181
                . '<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'
182
                . _MD_COMMENTS_STATUS . ': ' . $this->statusText[$tree[$comment_id]['obj']->getVar('status')]
183
                . '<br />IP: <span style="font-weight: bold;">' . $tree[$comment_id]['obj']->getVar('ip')
184
                . '</span></div>';
185
        } else {
186
            // hide comments that are not active
187
            if (COMMENTS_ACTIVE != $tree[$comment_id]['obj']->getVar('status')) {
188
                // if there are any child comments, display them as root comments
189
                if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
190
                    foreach ($tree[$comment_id]['child'] as $child_id) {
191
                        $this->renderThreadView($child_id, $admin_view, false);
192
                    }
193
                }
194
                return;
195
            } else {
196
                $text = $tree[$comment_id]['obj']->getVar('text');
197
            }
198
        }
199
        $replies = array();
200
        $this->renderThreadReplies($tree, $comment_id, $replies, '&nbsp;&nbsp;', $admin_view);
201
        $show_replies = (count($replies) > 0) ? true : false;
202
        $this->tpl->append('comments', array(
203
            'pid'           => $tree[$comment_id]['obj']->getVar('pid'),
204
            'id'            => $tree[$comment_id]['obj']->getVar('id'),
205
            'itemid'        => $tree[$comment_id]['obj']->getVar('itemid'),
206
            'rootid'        => $tree[$comment_id]['obj']->getVar('rootid'),
207
            'image'         => $image,
208
            'title'         => $title,
209
            'text'          => $text,
210
            'date_posted'   => XoopsLocale::formatTimestamp($tree[$comment_id]['obj']->getVar('created'), 'm'),
211
            'date_modified' => XoopsLocale::formatTimestamp($tree[$comment_id]['obj']->getVar('modified'), 'm'),
212
            'poster'        => $this->getPosterArray($tree[$comment_id]['obj']->getVar('uid')),
213
            'replies'       => $replies,
214
            'show_replies'  => $show_replies
215
        ));
216
    }
217
218
    /**
219
     * Render replies to a thread
220
     *
221
     * @param array   $thread
222
     * @param int     $key
223
     * @param array   $replies
224
     * @param string  $prefix
225
     * @param bool    $admin_view
226
     * @param integer $depth
227
     * @param string  $current_prefix
228
     *
229
     * @return void
230
     */
231
    private function renderThreadReplies(
232
        &$thread,
233
        $key,
234
        &$replies,
235
        $prefix,
236
        $admin_view,
237
        $depth = 0,
238
        $current_prefix = ''
239
    ) {
240
        if ($depth > 0) {
241
            $image = (false != $this->useIcons) ? $this->getTitleIcon($thread[$key]['obj']->getVar('icon')) : '';
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
242
            $title = $thread[$key]['obj']->getVar('title');
243
            $title = (false != $admin_view)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
244
                ? $title . ' ' . $this->statusText[$thread[$key]['obj']->getVar('status')] : $title;
245
            $replies[] = array(
246
                'id'          => $key,
247
                'prefix'      => $current_prefix,
248
                'date_posted' => XoopsLocale::formatTimestamp($thread[$key]['obj']->getVar('created'), 'm'),
249
                'title'       => $title,
250
                'image'       => $image,
251
                'root_id'     => $thread[$key]['obj']->getVar('rootid'),
252
                'status'      => $this->statusText[$thread[$key]['obj']->getVar('status')],
253
                'poster'      => $this->getPosterName($thread[$key]['obj']->getVar('uid'))
254
            );
255
            $current_prefix .= $prefix;
256
        }
257 View Code Duplication
        if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
258
            ++$depth;
259
            foreach ($thread[$key]['child'] as $childkey) {
260
                if (!$admin_view && $thread[$childkey]['obj']->getVar('status') != COMMENTS_ACTIVE) {
261
                    // skip this comment if it is not active and continue on processing its child comments instead
262
                    if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
263
                        foreach ($thread[$childkey]['child'] as $childchildkey) {
264
                            $this->renderThreadReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
265
                        }
266
                    }
267
                } else {
268
                    $this->renderThreadReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth, $current_prefix);
269
                }
270
            }
271
        }
272
    }
273
274
    /**
275
     * Render comments in nested view
276
     * Danger: Recursive!
277
     *
278
     * @param integer $comment_id Always "0" when called by client.
279
     * @param boolean $admin_view
280
     *
281
     * @return void
282
     */
283
    public function renderNestView($comment_id = 0, $admin_view = false)
284
    {
285
        $xot = new XoopsObjectTree($this->comments, 'id', 'pid', 'rootid');
286
        $tree = $xot->getTree();
287
        $image = (false != $this->useIcons) ? $this->getTitleIcon($tree[$comment_id]['obj']->getVar('icon')) : '';
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
288
        $title = $tree[$comment_id]['obj']->getVar('title');
289 View Code Duplication
        if (false != $admin_view) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
290
            $text = $tree[$comment_id]['obj']->getVar('text')
291
                . '<div style="text-align:right; margin-top: 2px; margin-bottom: 0px; margin-right: 2px;">'
292
                . _MD_COMMENTS_STATUS . ': ' . $this->statusText[$tree[$comment_id]['obj']->getVar('status')]
293
                . '<br />IP: <span style="font-weight: bold;">' . $tree[$comment_id]['obj']->getVar('ip')
294
                . '</span></div>';
295
        } else {
296
            // skip this comment if it is not active and continue on processing its child comments instead
297
            if (COMMENTS_ACTIVE != $tree[$comment_id]['obj']->getVar('status')) {
298
                // if there are any child comments, display them as root comments
299
                if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
300
                    foreach ($tree[$comment_id]['child'] as $child_id) {
301
                        $this->renderNestView($child_id, $admin_view);
302
                    }
303
                }
304
                return;
305
            } else {
306
                $text = $tree[$comment_id]['obj']->getVar('text');
307
            }
308
        }
309
        $replies = array();
310
        $this->renderNestReplies($tree, $comment_id, $replies, 25, $admin_view);
311
        $this->tpl->append('comments', array(
312
            'pid'           => $tree[$comment_id]['obj']->getVar('pid'),
313
            'id'            => $tree[$comment_id]['obj']->getVar('id'),
314
            'itemid'        => $tree[$comment_id]['obj']->getVar('itemid'),
315
            'rootid'        => $tree[$comment_id]['obj']->getVar('rootid'),
316
            'image'       => $image,
317
            'title'         => $title,
318
            'text'          => $text,
319
            'date_posted'   => XoopsLocale::formatTimestamp($tree[$comment_id]['obj']->getVar('created'), 'm'),
320
            'date_modified' => XoopsLocale::formatTimestamp($tree[$comment_id]['obj']->getVar('modified'), 'm'),
321
            'poster'        => $this->getPosterArray($tree[$comment_id]['obj']->getVar('uid')),
322
            'replies'       => $replies
323
        ));
324
    }
325
326
    /**
327
     * Render replies in nested view
328
     *
329
     * @param array   $thread
330
     * @param integer $key
331
     * @param array   $replies
332
     * @param integer $prefix     width of td element prefixed to comment display (indent)
333
     * @param bool    $admin_view
334
     * @param integer $depth
335
     *
336
     * @return void
337
     */
338
    private function renderNestReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0)
339
    {
340
        if ($depth > 0) {
341
            $image = (false != $this->useIcons) ? $this->getTitleIcon($thread[$key]['obj']->getVar('icon')) : '';
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
342
            $title = $thread[$key]['obj']->getVar('title');
343
            $text = (false != $admin_view) ? $thread[$key]['obj']->getVar('text')
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
344
                . '<div style="text-align:right; margin-top: 2px; margin-right: 2px;">'
345
                . _MD_COMMENTS_STATUS . ': ' . $this->statusText[$thread[$key]['obj']->getVar('status')]
346
                . '<br />IP: <span style="font-weight: bold;">' . $thread[$key]['obj']->getVar('ip')
347
                . '</span></div>'
348
                : $thread[$key]['obj']->getVar('text');
349
            $replies[] = array(
350
                'id'            => $key,
351
                'prefix'        => $prefix,
352
                'pid'           => $thread[$key]['obj']->getVar('pid'),
353
                'itemid'        => $thread[$key]['obj']->getVar('itemid'),
354
                'rootid'        => $thread[$key]['obj']->getVar('rootid'),
355
                'title'         => $title,
356
                'image'         => $image,
357
                'text'          => $text,
358
                'date_posted'   => XoopsLocale::formatTimestamp($thread[$key]['obj']->getVar('created'), 'm'),
359
                'date_modified' => XoopsLocale::formatTimestamp($thread[$key]['obj']->getVar('modified'), 'm'),
360
                'poster'        => $this->getPosterArray($thread[$key]['obj']->getVar('uid'))
361
            );
362
363
            $prefix = $prefix + 25;
364
        }
365 View Code Duplication
        if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
366
            ++$depth;
367
            foreach ($thread[$key]['child'] as $childkey) {
368
                if (!$admin_view && $thread[$childkey]['obj']->getVar('status') != COMMENTS_ACTIVE) {
369
                    // skip this comment if it is not active and continue on processing its child comments instead
370
                    if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
371
                        foreach ($thread[$childkey]['child'] as $childchildkey) {
372
                            $this->renderNestReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
373
                        }
374
                    }
375
                } else {
376
                    $this->renderNestReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth);
377
                }
378
            }
379
        }
380
    }
381
382
    /**
383
     * Get the name of the poster
384
     *
385
     * @param int $poster_id uid of poster
386
     *
387
     * @return array
388
     * @access private
389
     */
390
    private function getPosterName($poster_id)
391
    {
392
        $poster['id'] = (int)($poster_id);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$poster was never initialized. Although not strictly required by PHP, it is generally a good practice to add $poster = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
393
        if ($poster['id'] > 0) {
394
            $user = Xoops::getInstance()->getHandlerMember()->getUser($poster['id']);
395
            if (!is_object($user)) {
396
                $poster['id'] = 0;
397
            }
398
        }
399
        $poster['uname'] = XoopsUserUtility::getUnameFromId($poster['id'], false, true);
400
        return $poster;
401
    }
402
403
    /**
404
     * Get an array with info about the poster
405
     *
406
     * @param int $poster_id
407
     *
408
     * @return array
409
     * @access private
410
     */
411
    private function getPosterArray($poster_id)
412
    {
413
        $xoops = Xoops::getInstance();
414
        $poster['id'] = (int)($poster_id);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$poster was never initialized. Although not strictly required by PHP, it is generally a good practice to add $poster = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
415
        if ($poster['id'] > 0) {
416
            $member_handler = $xoops->getHandlerMember();
417
            $user = $member_handler->getUser($poster['id']);
418
            if (is_object($user)) {
419
                $poster['uname'] = XoopsUserUtility::getUnameFromId($poster['id'], false, true);
420
                $poster_rank = $user->rank();
421
                $poster['rank_image'] = $poster_rank['image'];
422
                $poster['rank_title'] = $poster_rank['title'];
423
                $response = $xoops->service("Avatar")->getAvatarUrl($user);
424
                $avatar = $response->getValue();
425
                $avatar = empty($avatar) ? $xoops->url('uploads/blank.gif') : $avatar;
426
                $poster['avatar'] = $avatar;
427
                $poster['regdate'] = XoopsLocale::formatTimestamp($user->getVar('user_regdate'), 's');
428
                $poster['from'] = $user->getVar('user_from');
429
                $poster['postnum'] = $user->getVar('posts');
430
                $poster['status'] = $user->isOnline() ? _MD_COMMENTS_ONLINE : '';
431
                return $poster;
432
            } else {
433
                $poster['id'] = 0;
434
            }
435
        }
436
437
        $poster['uname'] = XoopsUserUtility::getUnameFromId($poster['id'], false, true);
438
        $poster['rank_title'] = '';
439
        $poster['avatar'] = $xoops->url('uploads/blank.gif');
440
        $poster['regdate'] = '';
441
        $poster['from'] = '';
442
        $poster['postnum'] = 0;
443
        $poster['status'] = '';
444
        return $poster;
445
    }
446
447
    /**
448
     * Get the IMG tag for the title icon
449
     *
450
     * @param string $icon_image
451
     *
452
     * @return string HTML IMG tag
453
     * @access private
454
     */
455
    private function getTitleIcon($icon_image)
456
    {
457
        $icon_image = htmlspecialchars(trim($icon_image));
458
        if ($icon_image != '') {
459
            if (false != $this->doIconCheck) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
460
                if (!XoopsLoad::fileExists(Xoops::getInstance()->path('images/subject/' . $icon_image))) {
461
                    return '<img src="' . \XoopsBaseConfig::get('url')
462
                        . '/images/icons/no_posticon.gif" alt="" />&nbsp;';
463
                } else {
464
                    return '<img src="' . \XoopsBaseConfig::get('url') . '/images/subject/' . $icon_image
465
                        . '" alt="" />&nbsp;';
466
                }
467
            } else {
468
                return '<img src="' . \XoopsBaseConfig::get('url') . '/images/subject/' . $icon_image
469
                    . '" alt="" />&nbsp;';
470
            }
471
        }
472
        return '<img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" />&nbsp;';
473
    }
474
}
475