XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
comment_form.php
Go to the documentation of this file.
1 <?php
20 if (!defined('XOOPS_ROOT_PATH') || !is_object($xoopsModule)) {
21  die('Restricted access');
22 }
23 
24 $com_modid = $xoopsModule->getVar('mid');
25 
26 xoops_load('XoopsLists');
27 xoops_load('XoopsFormLoader');
28 
29 $cform = new XoopsThemeForm(_CM_POSTCOMMENT, "commentform", 'comment_post.php', 'post', true);
30 if (isset($xoopsModuleConfig['com_rule'])) {
31  include_once $GLOBALS['xoops']->path('include/comment_constants.php');
32  switch ($xoopsModuleConfig['com_rule']) {
34  $rule_text = _CM_COMAPPROVEALL;
35  break;
37  $rule_text = _CM_COMAPPROVEUSER;
38  break;
40  default:
41  $rule_text = _CM_COMAPPROVEADMIN;
42  break;
43  }
44  $cform->addElement(new XoopsFormLabel(_CM_COMRULES, $rule_text));
45 }
46 
47 $cform->addElement(new XoopsFormText(_CM_TITLE, 'com_title', 50, 255, $com_title), true);
48 // Start add by voltan
49 if (!($com_user == '' && $com_email == '') || !$xoopsUser) {
50  $cform->addElement(new XoopsFormText(_CM_USER, 'com_user', 50, 60, $com_user), true);
51  $cform->addElement(new XoopsFormText(_CM_EMAIL, 'com_email', 50, 60, $com_email), true);
52  $cform->addElement(new XoopsFormText(_CM_URL, 'com_url', 50, 60, $com_url), false);
53 }
54 // End add by voltan
56 $subject_icons = XoopsLists::getSubjectsList();
57 foreach ($subject_icons as $iconfile) {
58  $icons_radio->addOption($iconfile, '<img src="' . XOOPS_URL . '/images/subject/' . $iconfile . '" alt="" />');
59 }
60 $cform->addElement($icons_radio);
61 // editor
62 $editor = xoops_getModuleOption('comments_editor', 'system' );
63 if ( class_exists( 'XoopsFormEditor' ) ) {
64  $configs=array(
65  'name' => 'com_text',
66  'value' => $com_text,
67  'rows' => 25,
68  'cols' => 90,
69  'width' => '100%',
70  'height' => '400px',
71  'editor' => $editor
72  );
73  $cform->addElement( new XoopsFormEditor(_CM_MESSAGE, 'com_text', $configs, false, $onfailure = 'textarea' ));
74 } else {
75  $cform->addElement(new XoopsFormDhtmlTextArea(_CM_MESSAGE, 'com_text', $com_text, 10, 50), true);
76 }
78 $button_tray = new XoopsFormElementTray('', '&nbsp;');
79 
80 if (is_object($xoopsUser)) {
81  if (isset($xoopsModuleConfig['com_anonpost'])) {
82  if ($xoopsModuleConfig['com_anonpost'] == 1) {
83  $noname = !empty($noname) ? 1 : 0;
84  $noname_checkbox = new XoopsFormCheckBox('', 'noname', $noname);
85  $noname_checkbox->addOption(1, _POSTANON);
86  $option_tray->addElement($noname_checkbox);
87  }
88  }
89  if (false != $xoopsUser->isAdmin($com_modid)) {
90  // show status change box when editing (comment id is not empty)
91  if (!empty($com_id)) {
92  include_once $GLOBALS['xoops']->path('include/comment_constants.php');
93  $status_select = new XoopsFormSelect(_CM_STATUS, 'com_status', $com_status);
94  $status_select->addOptionArray(array(
98  $cform->addElement($status_select);
99  $button_tray->addElement(new XoopsFormButton('', 'com_dodelete', _DELETE, 'submit'));
100  }
101  if ( isset( $editor ) && in_array( $editor, array( 'textarea', 'dhtmltextarea' ) ) ) {
102  $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $dohtml);
103  $html_checkbox->addOption(1, _CM_DOHTML);
104  $option_tray->addElement($html_checkbox);
105  }
106  }
107 }
108 if ( isset( $editor ) && in_array( $editor, array( 'textarea', 'dhtmltextarea' ) ) ) {
109 
110 }
112 $smiley_checkbox->addOption(1, _CM_DOSMILEY);
113 $option_tray->addElement($smiley_checkbox);
115 $xcode_checkbox->addOption(1, _CM_DOXCODE);
116 $option_tray->addElement($xcode_checkbox);
117 if ( isset( $editor ) && in_array( $editor, array( 'textarea', 'dhtmltextarea' ) ) ) {
118  $br_checkbox = new XoopsFormCheckBox('', 'dobr', $dobr);
119  $br_checkbox->addOption(1, _CM_DOAUTOWRAP);
120  $option_tray->addElement($br_checkbox);
121 } else {
122  $cform->addElement( new xoopsFormHidden( 'dohtml', 1 ) );
123  $cform->addElement( new xoopsFormHidden( 'dobr', 0 ) );
124 }
125 $cform->addElement($option_tray);
126 if (!$xoopsUser) {
127  $cform->addElement(new XoopsFormCaptcha());
128 }
129 $cform->addElement(new XoopsFormHidden('com_pid', intval($com_pid)));
130 $cform->addElement(new XoopsFormHidden('com_rootid', intval($com_rootid)));
131 $cform->addElement(new XoopsFormHidden('com_id', $com_id));
132 $cform->addElement(new XoopsFormHidden('com_itemid', $com_itemid));
133 $cform->addElement(new XoopsFormHidden('com_order', $com_order));
134 $cform->addElement(new XoopsFormHidden('com_mode', $com_mode));
135 
136 // add module specific extra params
137 if ('system' != $xoopsModule->getVar('dirname')) {
138  $comment_config = $xoopsModule->getInfo('comments');
139  if (isset($comment_config['extraParams']) && is_array($comment_config['extraParams'])) {
141  foreach ($comment_config['extraParams'] as $extra_param) {
142  // This routine is included from forms accessed via both GET and POST
143  if (isset($_POST[$extra_param])) {
144  $hidden_value = $myts->stripSlashesGPC($_POST[$extra_param]);
145  } else if (isset($_GET[$extra_param])) {
146  $hidden_value = $myts->stripSlashesGPC($_GET[$extra_param]);
147  } else {
148  $hidden_value = '';
149  }
150  $cform->addElement(new XoopsFormHidden($extra_param, $hidden_value));
151  }
152  }
153 }
154 $button_tray->addElement(new XoopsFormButton('', 'com_dopreview', _PREVIEW, 'submit'));
155 $button_tray->addElement(new XoopsFormButton('', 'com_dopost', _CM_POSTCOMMENT, 'submit'));
156 $cform->addElement($button_tray);
157 $cform->display();
158 ?>