1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Database\Connection;
13: use Xoops\Core\Kernel\XoopsObject;
14: use Xoops\Core\Kernel\XoopsPersistableObjectHandler;
15:
16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: class PagePage_related extends XoopsObject
28: {
29: 30: 31:
32: public function __construct()
33: {
34: $this->initVar('related_id', XOBJ_DTYPE_INT, 0, false, 8);
35: $this->initVar('related_name', XOBJ_DTYPE_TXTBOX, '', false);
36: $this->initVar('related_domenu', XOBJ_DTYPE_INT, 1, false, 1);
37: $this->initVar('related_navigation', XOBJ_DTYPE_INT, 1, false, 1);
38: }
39:
40: public function getValues($keys = null, $format = null, $maxDepth = null)
41: {
42: $ret = parent::getValues($keys, $format, $maxDepth);
43: $ret['navigation'] = \Xoops\Locale::translate('L_RELATED_NAVIGATION_OPTION' . $this->getVar('related_navigation'), 'page');
44: $ret['related_links'] = Page::getInstance()->getLinkHandler()->getLinks($this->getVar('related_id'));
45: return $ret;
46: }
47:
48: public function get_new_id()
49: {
50: $xoops = Xoops::getInstance();
51: $new_id = $xoopsDB->getInsertId();
52: return $new_id;
53: }
54: }
55:
56: class PagePage_relatedHandler extends XoopsPersistableObjectHandler
57: {
58: 59: 60:
61: public function __construct(Connection $db = null)
62: {
63: parent::__construct($db, 'page_related', 'pagepage_related', 'related_id', 'related_name');
64: }
65:
66: public function getRelated($start = 0, $limit = 0, $sort = 'related_name', $order = 'ASC')
67: {
68: $criteria = new CriteriaCompo();
69: $criteria->setSort($sort);
70: $criteria->setOrder($order);
71: $criteria->setStart($start);
72: $criteria->setLimit($limit);
73: return parent::getAll($criteria, null, false);
74: }
75:
76: public function countRelated($start = 0, $limit = 0, $sort = 'related_name', $order = 'ASC')
77: {
78: $criteria = new CriteriaCompo();
79: $criteria->setSort($sort);
80: $criteria->setOrder($order);
81: $criteria->setStart($start);
82: $criteria->setLimit($limit);
83: return parent::getCount();
84: }
85: }
86: