1: <?php
2: /*
3: * Banners Class Manager
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14: * @author Gregory Mage (AKA Mage)
15: * @package system
16: */
17:
18: // defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
19:
20: /**
21: * System Banner
22: *
23: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
24: * @package system
25: */
26:
27: class SystemBanner extends XoopsObject
28: {
29: //PHP 8.2 Dynamic properties deprecated
30: public $bid;
31: public $cid;
32: public $imptotal;
33: public $impmade;
34: public $clicks;
35: public $imageurl;
36: public $clickurl;
37: public $date;
38: public $htmlbanner;
39: public $htmlcode;
40:
41: /**
42: *
43: */
44: public function __construct()
45: {
46: parent::__construct();
47: $this->initVar('bid', XOBJ_DTYPE_INT, null, false, 5);
48: $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 3);
49: $this->initVar('imptotal', XOBJ_DTYPE_INT, null, false, 8);
50: $this->initVar('impmade', XOBJ_DTYPE_INT, null, false, 8);
51: $this->initVar('clicks', XOBJ_DTYPE_INT, null, false, 8);
52: $this->initVar('imageurl', XOBJ_DTYPE_TXTBOX, null, false);
53: $this->initVar('clickurl', XOBJ_DTYPE_TXTBOX, null, false);
54: $this->initVar('date', XOBJ_DTYPE_INT, null, false, 10);
55: $this->initVar('htmlbanner', XOBJ_DTYPE_INT, null, false, 1);
56: $this->initVar('htmlcode', XOBJ_DTYPE_TXTBOX, null, false);
57: // For allow HTML
58: //$this->initVar( 'dohtml', XOBJ_DTYPE_INT, 1, false);
59: }
60:
61: /**
62: * @param bool $action
63: *
64: * @return XoopsThemeForm
65: */
66: public function getForm($action = false)
67: {
68: if ($action === false) {
69: $action = $_SERVER['REQUEST_URI'];
70: }
71:
72: $title = $this->isNew() ? sprintf(_AM_SYSTEM_BANNERS_ADDNWBNR) : sprintf(_AM_SYSTEM_BANNERS_EDITBNR);
73:
74: xoops_load('XoopsFormLoader');
75:
76: $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
77: /** @var SystemBannerclientHandler $banner_client_Handler */
78: $banner_client_Handler = xoops_getModuleHandler('bannerclient', 'system');
79: $client_select = new XoopsFormSelect(_AM_SYSTEM_BANNERS_CLINAMET, 'cid', $this->getVar('cid'));
80: $client_select->addOptionArray($banner_client_Handler->getList());
81: $form->addElement($client_select, true);
82:
83: $form->addElement(new XoopsFormText(_AM_SYSTEM_BANNERS_IMPPURCHT, 'imptotal', 20, 255, $this->getVar('imptotal')), true);
84: $form->addElement(new XoopsFormText(_AM_SYSTEM_BANNERS_IMGURLT, 'imageurl', 80, 255, $this->getVar('imageurl')), false);
85: $form->addElement(new XoopsFormText(_AM_SYSTEM_BANNERS_CLICKURLT, 'clickurl', 80, 255, $this->getVar('clickurl')), false);
86:
87: $htmlbanner = $this->isNew() ? 0 : $this->getVar('htmlbanner');
88: $form->addElement(new XoopsFormRadioYN(_AM_SYSTEM_BANNERS_USEHTML, 'htmlbanner', $htmlbanner, _YES, _NO));
89:
90: $form->addElement(new xoopsFormTextArea(_AM_SYSTEM_BANNERS_CODEHTML, 'htmlcode', $this->getVar('htmlcode'), 5, 50), false);
91: if (!$this->isNew()) {
92: $form->addElement(new XoopsFormHidden('bid', $this->getVar('bid')));
93: }
94: $form->addElement(new XoopsFormHidden('op', 'banner_save'));
95: $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
96:
97: //$form->display();
98: return $form;
99: }
100: }
101:
102: /**
103: * System banner handler class. (Singelton)
104: *
105: * This class is responsible for providing data access mechanisms to the data source
106: * of XOOPS block class objects.
107: *
108: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
109: * @package system
110: * @subpackage banner
111: */
112: class SystemBannerHandler extends XoopsPersistableObjectHandler
113: {
114: /**
115: * @param null|object $db
116: */
117: public function __construct($db)
118: {
119: parent::__construct($db, 'banner', 'SystemBanner', 'bid', 'imageurl');
120: }
121: }
122: