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
|
|
|
* presenter module for xoops |
13
|
|
|
* |
14
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
15
|
|
|
* @license GPL 2.0 or later |
16
|
|
|
* @package presenter |
17
|
|
|
* @since 2.5.5 |
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
19
|
|
|
*/ |
20
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
21
|
|
|
|
22
|
|
|
class PresenterCategories extends XoopsObject |
23
|
|
|
{ |
24
|
|
|
//Constructor |
25
|
|
|
/** |
26
|
|
|
* PresenterCategories constructor. |
27
|
|
|
*/ |
28
|
|
|
public function __construct() |
29
|
|
|
{ |
30
|
|
|
parent::__construct(); |
31
|
|
|
$this->initVar('cat_id', XOBJ_DTYPE_INT); |
32
|
|
|
$this->initVar('cat_pid', XOBJ_DTYPE_INT); |
33
|
|
|
$this->initVar('cat_title', XOBJ_DTYPE_TXTBOX); |
34
|
|
|
$this->initVar('cat_desc', XOBJ_DTYPE_TXTAREA); |
35
|
|
|
$this->initVar('cat_image', XOBJ_DTYPE_TXTBOX); |
36
|
|
|
$this->initVar('cat_weight', XOBJ_DTYPE_INT); |
37
|
|
|
// $this->initVar('cat_color', XOBJ_DTYPE_TXTBOX); |
38
|
|
|
|
39
|
|
|
$this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
40
|
|
|
$this->initVar('dosmiley', XOBJ_DTYPE_INT, 1, false); |
41
|
|
|
$this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false); |
42
|
|
|
$this->initVar('doimage', XOBJ_DTYPE_INT, 1, false); |
43
|
|
|
$this->initVar('dobr', XOBJ_DTYPE_INT, 1, false); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param bool $action |
48
|
|
|
* @return XoopsThemeForm |
49
|
|
|
*/ |
50
|
|
|
public function getForm($action = false) |
51
|
|
|
{ |
52
|
|
|
global $xoopsDB, $xoopsModuleConfig; |
53
|
|
|
|
54
|
|
|
if (false === $action) { |
55
|
|
|
$action = $_SERVER['REQUEST_URI']; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$title = $this->isNew() ? sprintf(_AM_PRESENTER_CAT_ADD) : sprintf(_AM_PRESENTER_CAT_EDIT); |
59
|
|
|
|
60
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
61
|
|
|
|
62
|
|
|
$form = new XoopsThemeForm($title, 'form', $action, 'post', true); |
63
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
64
|
|
|
|
65
|
|
|
// Cat_pid |
66
|
|
|
require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
67
|
|
|
$categoriesHandler = xoops_getModuleHandler('categories', 'presenter'); |
68
|
|
|
$criteria = new CriteriaCompo(); |
69
|
|
|
$categories = $categoriesHandler->getObjects($criteria); |
70
|
|
|
if ($categories) { |
71
|
|
|
$categories_tree = new XoopsObjectTree($categories, 'cat_id', 'cat_pid'); |
72
|
|
|
$cat_pid = $categories_tree->makeSelBox('cat_pid', 'cat_title', '--', $this->getVar('cat_pid', 'e'), false); |
73
|
|
|
$form->addElement(new XoopsFormLabel(_AM_PRESENTER_CAT_PID, $cat_pid)); |
74
|
|
|
} |
75
|
|
|
// Cat_title |
76
|
|
|
$form->addElement(new XoopsFormText(_AM_PRESENTER_CAT_TITLE, 'cat_title', 50, 255, $this->getVar('cat_title')), true); |
77
|
|
|
// Cat_desc |
78
|
|
|
$form->addElement(new XoopsFormTextArea(_AM_PRESENTER_CAT_DESC, 'cat_desc', $this->getVar('cat_desc'), 4, 47), true); |
79
|
|
|
// Cat_image |
80
|
|
|
$cat_image = $this->getVar('cat_image') ? $this->getVar('cat_image') : 'blank.gif'; |
81
|
|
|
|
82
|
|
|
$uploadir = '/uploads/presenter/images/categories'; |
83
|
|
|
$imgtray = new XoopsFormElementTray(_AM_PRESENTER_CAT_IMAGE, '<br>'); |
84
|
|
|
$imgpath = sprintf(_AM_PRESENTER_FORMIMAGE_PATH, $uploadir); |
85
|
|
|
$imageselect = new XoopsFormSelect($imgpath, 'cat_image', $cat_image); |
86
|
|
|
$image_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . $uploadir); |
87
|
|
|
foreach ($image_array as $image) { |
88
|
|
|
$imageselect->addOption("{$image}", $image); |
89
|
|
|
} |
90
|
|
|
$imageselect->setExtra("onchange='showImgSelected(\"image_cat_image\", \"cat_image\", \"" . $uploadir . "\", \"\", \"" . XOOPS_URL . "\")'"); |
91
|
|
|
$imgtray->addElement($imageselect); |
92
|
|
|
$imgtray->addElement(new XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $uploadir . '/' . $cat_image . "' name='image_cat_image' id='image_cat_image' alt=''>")); |
93
|
|
|
$fileseltray = new XoopsFormElementTray('', '<br>'); |
94
|
|
|
$fileseltray->addElement(new XoopsFormFile(_AM_PRESENTER_FORMUPLOAD, 'cat_image', $xoopsModuleConfig['maxsize'])); |
95
|
|
|
$fileseltray->addElement(new XoopsFormLabel('')); |
96
|
|
|
$imgtray->addElement($fileseltray); |
97
|
|
|
$form->addElement($imgtray); |
98
|
|
|
// Cat_weight |
99
|
|
|
$form->addElement(new XoopsFormText(_AM_PRESENTER_CAT_WEIGHT, 'cat_weight', 50, 255, $this->getVar('cat_weight')), false); |
100
|
|
|
// Cat_color |
101
|
|
|
// $form->addElement(new XoopsFormColorPicker(_AM_PRESENTER_CAT_COLOR, 'cat_color', $this->getVar('cat_color')), false); |
102
|
|
|
|
103
|
|
|
$form->addElement(new XoopsFormHidden('op', 'save')); |
104
|
|
|
$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
105
|
|
|
|
106
|
|
|
return $form; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Class PresenterCategoriesHandler |
112
|
|
|
*/ |
113
|
|
|
class PresenterCategoriesHandler extends XoopsPersistableObjectHandler |
114
|
|
|
{ |
115
|
|
|
/** |
116
|
|
|
* PresenterCategoriesHandler constructor. |
117
|
|
|
* @param XoopsDatabase $db |
118
|
|
|
*/ |
119
|
|
|
public function __construct(XoopsDatabase $db) |
120
|
|
|
{ |
121
|
|
|
parent::__construct($db, 'presenter_categories', 'PresenterCategories', 'cat_id', 'cat_title'); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|