XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
comment_new.php
1<?php
13
14//
15// Guard directly access.
16//
17if (!defined('XOOPS_ROOT_PATH') || !is_object($xoopsModule)) {
18 exit();
19}
20
21require_once XOOPS_MODULE_PATH . '/legacy/forms/CommentEditForm.class.php';
22
23//
24// Load message resource
25//
26$t_root =& XCube_Root::getSingleton();
27
28$t_root->mLanguageManager->loadModuleMessageCatalog('legacy');
29
30require_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
31
32if ('system' != $xoopsModule->getVar('dirname') && XOOPS_COMMENT_APPROVENONE == $xoopsModuleConfig['com_rule'])
33{
34 exit();
35}
36
37$t_root->mLanguageManager->loadPageTypeMessageCatalog('comment');
38
39$com_itemid = isset($_GET['com_itemid']) ? (int)$_GET['com_itemid'] : 0;
40
41if ($com_itemid > 0)
42{
43 include XOOPS_ROOT_PATH.'/header.php';
44
45 if (isset($com_replytitle))
46 {
47 if (isset($com_replytext)) {
48 themecenterposts($com_replytitle, $com_replytext);
49 }
51 $com_title = $myts->htmlSpecialChars($com_replytitle);
52 if (!preg_match('/^re:/i', $com_title)) {
53 $com_title = 'Re: ' . xoops_substr($com_title, 0, 56);
54 }
55 } else {
56 $com_title = '';
57 }
58
59 $com_mode = isset($_GET['com_mode']) ? htmlspecialchars(trim($_GET['com_mode']), ENT_QUOTES) : '';
60
61 if ('' == $com_mode)
62 {
63 if (is_object($xoopsUser)) {
64 $com_mode = $xoopsUser->getVar('umode');
65 } else {
66 $com_mode = $xoopsConfig['com_mode'];
67 }
68 }
69
70 if (!isset($_GET['com_order']))
71 {
72 if (is_object($xoopsUser)) {
73 $com_order = $xoopsUser->getVar('uorder');
74 } else {
75 $com_order = $xoopsConfig['com_order'];
76 }
77 } else {
78 $com_order = (int)$_GET['com_order'];
79 }
80
81 $noname = 0;
82
83 $handler =& xoops_gethandler('comment');
84 $comment =& $handler->create();
85
86 //
87 // Initialize manually.
88 //
89 $comment->set('com_itemid', $com_itemid);
90 $comment->set('com_modid', $xoopsModule->get('mid'));
91 $comment->set('com_title', $com_title);
92
93 if (is_object($xoopsUser)) {
94 $comment->set('uid', $xoopsUser->get('uid'));
95 } else {
96 $comment->set('uid', 0);
97 }
98
99 //
100 // Create action form instance and load from a comment object.
101 //
102 if (is_object($xoopsUser) && $xoopsUser->isAdmin())
103 {
104 $actionForm =new Legacy_CommentEditForm_Admin();
105 } else {
106 $actionForm =new Legacy_CommentEditForm();
107 }
108
109 $actionForm->prepare();
110 $actionForm->load($comment);
111
112 //
113 // Get the icons of subject.
114 //
115 $handler =& xoops_gethandler('subjecticon');
116 $subjectIcons =& $handler->getObjects();
117
118 //
119 // Render comment-form to render buffer using Legacy_RenderSystem.
120 //
121 $renderSystem =& $t_root->getRenderSystem($t_root->mContext->mBaseRenderSystemName);
122 $renderTarget =& $renderSystem->createRenderTarget('main');
123
124 $renderTarget->setTemplateName('legacy_comment_edit.html');
125
126 $renderTarget->setAttribute('actionForm', $actionForm);
127 $renderTarget->setAttribute('subjectIcons', $subjectIcons);
128 $renderTarget->setAttribute('xoopsModuleConfig', $xoopsModuleConfig);
129 $renderTarget->setAttribute('com_order', $com_order);
130
131 $extraParams = [];
132 if ('system' !== $xoopsModule->get('dirname'))
133 {
134 $comment_config = $xoopsModule->getInfo('comments');
135 if (isset($comment_config['extraParams']) && is_array($comment_config['extraParams'])) {
136 foreach ($comment_config['extraParams'] as $extra_param) {
137 $extraParams[$extra_param] = xoops_getrequest($extra_param);
138 }
139 }
140 }
141
142 $renderTarget->setAttribute('extraParams', $extraParams);
143
144 //
145 // Rendering
146 //
147 $renderSystem->render($renderTarget);
148
149 //
150 // Display now.
151 //
152 print $renderTarget->getResult();
153
154 require_once XOOPS_ROOT_PATH . '/footer.php';
155}