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: /**
13: * @copyright XOOPS Project (http://xoops.org)
14: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15: * @author Laurent JEN (aka DuGris)
16: * @version $Id$
17: */
18:
19: class PageSystemPlugin extends Xoops\Module\Plugin\PluginAbstract implements SystemPluginInterface
20: {
21: /**
22: * @param int $uid
23: *
24: * @return int
25: */
26: public function userPosts($uid)
27: {
28: $criteria = new CriteriaCompo();
29: $criteria->add(new Criteria('content_status', 0, '!='));
30: $criteria->add(new Criteria('content_author', (int)$uid));
31: return \Xoops::getModuleHelper('page')->getContentHandler()->getCount($criteria);
32: }
33:
34: /**
35: * @return array
36: */
37: public function waiting()
38: {
39: $criteria = new CriteriaCompo(new Criteria('content_status', 0));
40: $page = \Xoops::getModuleHelper('page');
41: if ($count = $page->getContentHandler()->getCount($criteria)) {
42: $ret['count'] = $count;
43: $ret['name'] = $page->getModule()->getVar('name');
44: $ret['link'] = $page->url('admin/content.php');
45: return $ret;
46: }
47: return array();
48: }
49:
50: /**
51: * Used to populate backend
52: *
53: * @param int $limit : Number of item for backend
54: * Expects an array containing:
55: * title : Title for the backend items
56: * link : Link for the backend items
57: * content : content for the backend items
58: * date : Date of the backend items
59: *
60: * @return array
61: */
62: public function backend($limit)
63: {
64: $ret = array();
65: $page = \Xoops::getModuleHelper('page');
66: $contents = $page->getContentHandler()->getPagePublished(0, $limit);
67: foreach ($contents as $k => $content) {
68: $ret[$k]['title'] = $content->getVar('content_title');
69: $ret[$k]['link'] = $page->url('viewpage.php') . '?id=' . $content->getVar('content_id');
70: $ret[$k]['content'] = $content->getVar('content_shorttext') . '<br />' . $content->getVar('content_text');
71: $ret[$k]['date'] = $content->getVar('content_create');
72: }
73: return $ret;
74: }
75:
76: /**
77: * Used to populate the User Block
78: * Expects an array containing:
79: * name : Name for the Link
80: * link : Link relative to module
81: * image : Url of image to display, please use 16px*16px image
82: *
83: * @return array
84: */
85: public function userMenus()
86: {
87: // TODO: Implement userMenus() method.
88: }
89: }
90: