|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xooghost\Plugin; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Xooghost module |
|
7
|
|
|
* |
|
8
|
|
|
* You may not change or alter any portion of this comment or credits |
|
9
|
|
|
* of supporting developers from this source code or any supporting source code |
|
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* @package Xooghost |
|
18
|
|
|
* @since 2.6.0 |
|
19
|
|
|
* @author Laurent JEN (Aka DuGris) |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class XooghostCommentsPlugin |
|
24
|
|
|
*/ |
|
25
|
|
|
class CommentsPlugin extends \Xoops\Module\Plugin\PluginAbstract implements \CommentsPluginInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
|
|
public function itemName() |
|
31
|
|
|
{ |
|
32
|
|
|
return 'ghost_id'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
|
|
public function pageName() |
|
39
|
|
|
{ |
|
40
|
|
|
return 'page_comment.php'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
|
|
public function extraParams() |
|
47
|
|
|
{ |
|
48
|
|
|
return []; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* This method will be executed upon successful post of an approved comment. |
|
53
|
|
|
* This includes comment posts by administrators, and change of comment status from 'pending' to 'active' state. |
|
54
|
|
|
* An CommentsComment object that has been approved will be passed as the first and only parameter. |
|
55
|
|
|
* This should be useful for example notifying the item submitter of a comment post. |
|
56
|
|
|
* |
|
57
|
|
|
* @param \CommentsComment $comment |
|
58
|
|
|
*/ |
|
59
|
|
|
public function approve(\CommentsComment $comment) |
|
60
|
|
|
{ |
|
61
|
|
|
//Where are you looking at? |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* This method will be executed whenever the total number of 'active' comments for an item is changed. |
|
66
|
|
|
* |
|
67
|
|
|
* @param int $item_id The unique ID of an item |
|
68
|
|
|
* @param int $total_num The total number of active comments |
|
69
|
|
|
*/ |
|
70
|
|
|
public function update($item_id, $total_num) |
|
71
|
|
|
{ |
|
72
|
|
|
$db = \Xoops::getInstance()->db(); |
|
73
|
|
|
$sql = 'UPDATE ' . $db->prefix('xooghost') . ' SET xooghost_comments = ' . (int)($total_num) . ' WHERE xooghost_id = ' . (int)($item_id); |
|
74
|
|
|
$db->query($sql); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* This method will be executed whenever a new comment form is displayed. |
|
79
|
|
|
* You can set a default title for the comment and a header to be displayed on top of the form |
|
80
|
|
|
* ex: return array( |
|
81
|
|
|
* 'title' => 'My Article Title', |
|
82
|
|
|
* 'text' => 'Content of the article'); |
|
83
|
|
|
* 'timestamp' => time(); //Date of the article in unix format |
|
84
|
|
|
* 'uid' => Id of the article author |
|
85
|
|
|
* |
|
86
|
|
|
* @param int $item_id The unique ID of an item |
|
87
|
|
|
* |
|
88
|
|
|
* @return array |
|
89
|
|
|
*/ |
|
90
|
|
|
public function itemInfo($item_id) |
|
91
|
|
|
{ |
|
92
|
|
|
$ret = []; |
|
93
|
|
|
|
|
94
|
|
|
$helper = \XoopsModules\Xooghost\Helper::getInstance(); |
|
95
|
|
|
$pageHandler = $helper->getHandler('Page'); |
|
96
|
|
|
$page = $page = $pageHandler->get($item_id); |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
$ret['text'] = $page->getVar('xooghost_content'); |
|
|
|
|
|
|
99
|
|
|
$ret['title'] = $page->getVar('xooghost_title'); |
|
100
|
|
|
$ret['uid'] = $page->getVar('xooghost_uid'); |
|
101
|
|
|
$ret['timestamp'] = $page->getVar('xooghost_published'); |
|
102
|
|
|
|
|
103
|
|
|
return $ret; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|