|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Module: Lexikon |
|
4
|
|
|
* Author: hsalazar |
|
5
|
|
|
* Chanegs: Yerres |
|
6
|
|
|
* Licence: GNU |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
use XoopsModules\Lexikon\{ |
|
10
|
|
|
Helper, |
|
11
|
|
|
Utility, |
|
12
|
|
|
LexikonTree |
|
13
|
|
|
}; |
|
14
|
|
|
/** @var Helper $helper */ |
|
15
|
|
|
|
|
16
|
|
|
global $term, $definition, $ref, $url, $xoopsUser, $xoopsModule; |
|
17
|
|
|
|
|
18
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/lexikon/class/LexikonTree.php'; // -- LionHell |
|
19
|
|
|
require XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
20
|
|
|
require XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
$helper = Helper::getInstance(); |
|
24
|
|
|
|
|
25
|
|
|
$guesteditoruse = $helper->getConfig('wysiwyg_guests'); |
|
26
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
27
|
|
|
$mytree = new LexikonTree($xoopsDB->prefix('lxcategories'), 'categoryID', '0'); |
|
28
|
|
|
$sform = new \XoopsThemeForm(_MD_LEXIKON_SUB_SMNAME, 'storyform', xoops_getenv('SCRIPT_NAME'), 'post', true); |
|
29
|
|
|
|
|
30
|
|
|
if ('1' == $helper->getConfig('multicats')) { |
|
31
|
|
|
// perms adapted category select |
|
32
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
|
33
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
34
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
35
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_submit', $groups, $xoopsModule->getVar('mid')); |
|
36
|
|
|
if (is_array($allowed_cats)) { |
|
|
|
|
|
|
37
|
|
|
$mytree = new LexikonTree($xoopsDB->prefix('lxcategories'), 'categoryID', '0'); |
|
38
|
|
|
$categoryselect = new \XoopsFormSelect(_MD_LEXIKON_ENTRYCATEGORY, 'categoryID', $allowed_cats); |
|
39
|
|
|
$tbl = []; |
|
40
|
|
|
$tbl = $mytree->getChildTreeArray(0, 'name'); |
|
41
|
|
|
foreach ($tbl as $oneline) { |
|
42
|
|
|
if (in_array($oneline['categoryID'], $allowed_cats)) { |
|
43
|
|
|
if ('.' === $oneline['prefix']) { |
|
44
|
|
|
$oneline['prefix'] = ''; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
$oneline['prefix'] = str_replace('.', '-', $oneline['prefix']); |
|
48
|
|
|
$categoryselect->addOption($oneline['categoryID'], $oneline['prefix'] . ' ' . $oneline['name']); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
$sform->addElement($categoryselect, true); |
|
53
|
|
|
} |
|
54
|
|
|
// This part is common to edit/add |
|
55
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
56
|
|
|
$term = htmlspecialchars($term, ENT_QUOTES | ENT_HTML5); |
|
57
|
|
|
$sform->addElement(new \XoopsFormText(_MD_LEXIKON_ENTRY, 'term', 50, 80, $term), true); |
|
58
|
|
|
|
|
59
|
|
|
//editor for guests/users |
|
60
|
|
|
if (isset($guesteditoruse)) { |
|
61
|
|
|
//if (isset($xoopsUser) && is_object($xoopsUser) ) { |
|
62
|
|
|
if ($xoopsUser) { |
|
63
|
|
|
$editor = $utility::getWysiwygForm(_MD_LEXIKON_DEFINITION, 'definition', _MD_LEXIKON_WRITEHERE, 15, 60); |
|
64
|
|
|
if (_MD_LEXIKON_WRITEHERE == $definition) { |
|
65
|
|
|
$editor->setExtra('onfocus="this.select()"'); |
|
66
|
|
|
} |
|
67
|
|
|
$sform->addElement($editor, true); |
|
68
|
|
|
unset($editor); |
|
69
|
|
|
} else { |
|
70
|
|
|
$def_block = new \XoopsFormDhtmlTextArea(_MD_LEXIKON_DEFINITION, 'definition', _MD_LEXIKON_WRITEHERE, 15, 60); |
|
71
|
|
|
$def_block->setExtra('onfocus="this.select()"'); |
|
72
|
|
|
$sform->addElement($def_block, true); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
$sform->addElement(new \XoopsFormTextArea(_MD_LEXIKON_REFERENCE, 'ref', $ref, 5, 50), false); |
|
77
|
|
|
$sform->addElement(new \XoopsFormText(_MD_LEXIKON_URL, 'url', 50, 80, $url), false); |
|
78
|
|
|
|
|
79
|
|
|
if (is_object($xoopsUser)) { |
|
80
|
|
|
$uid = $xoopsUser->getVar('uid'); |
|
81
|
|
|
$sform->addElement(new \XoopsFormHidden('uid', $uid)); |
|
82
|
|
|
|
|
83
|
|
|
$notify_checkbox = new \XoopsFormCheckBox('', 'notifypub', $notifypub); |
|
84
|
|
|
$notify_checkbox->addOption(1, _MD_LEXIKON_NOTIFY); |
|
85
|
|
|
$sform->addElement($notify_checkbox); |
|
86
|
|
|
} |
|
87
|
|
|
//--- Captcha - Ohne Gewähr |
|
88
|
|
|
if (1 == $utility::getModuleOption('captcha')) { |
|
89
|
|
|
$skipMember = 1; |
|
90
|
|
|
} elseif (2 == $utility::getModuleOption('captcha')) { |
|
91
|
|
|
$skipMember = 0; |
|
92
|
|
|
} |
|
93
|
|
|
if (0 !== $helper->getConfig('captcha')) { |
|
94
|
|
|
xoops_load('XoopsFormCaptcha'); |
|
95
|
|
|
if (class_exists('XoopsFormCaptcha')) { |
|
96
|
|
|
$sform->addElement(new \XoopsFormCaptcha('', 'xoopscaptcha', $skipMember), true); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
|
100
|
|
|
$hidden = new \XoopsFormHidden('op', 'post'); |
|
101
|
|
|
$buttonTray->addElement($hidden); |
|
102
|
|
|
$buttonTray->addElement(new \XoopsFormButton('', 'post', _MD_LEXIKON_CREATE, 'submit')); |
|
103
|
|
|
|
|
104
|
|
|
$sform->addElement($buttonTray); |
|
105
|
|
|
|
|
106
|
|
|
unset($hidden); |
|
107
|
|
|
|