-
Notifications
You must be signed in to change notification settings - Fork 5
/
CommentForm.php
73 lines (67 loc) · 2.9 KB
/
CommentForm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
class Commenting_CommentForm extends Omeka_Form
{
public function init()
{
parent::init();
$this->setAction(WEB_ROOT . '/commenting/comment/add');
$this->setAttrib('id', 'comment-form');
$user = current_user();
$urlOptions = array(
'label' => __('Website'),
);
$emailOptions = array(
'label' => __('Email (required)'),
'required' => true,
'attribs' => array(
'required' => 'required',
),
'validators' => array(
array('validator' => 'EmailAddress')
)
);
$nameOptions = array('label' => __('Your name'));
if ($user) {
$emailOptions['value'] = $user->email;
$nameOptions['value'] = $user->name;
}
$this->addElement('text', 'author_name', $nameOptions);
$this->addElement('text', 'author_url', $urlOptions);
$this->addElement('text', 'author_email', $emailOptions);
$this->addElement('textarea', 'body', array(
'label' => __('Comment'),
'description' => __("Allowed tags:") . " <p>, <a>, <em>, <strong>, <ul>, <ol>, <li>",
'id' => 'comment-form-body',
'rows' => 6,
'required' => true,
));
//assume registered users are trusted and don't make them play recaptcha
if (!$user && get_option('recaptcha_public_key') && get_option('recaptcha_private_key')) {
$this->addElement('captcha', 'captcha', array(
'label' => __("Please verify you're a human"),
'captcha' => Omeka_Captcha::getCaptcha()
));
$this->getElement('captcha')->removeDecorator('ViewHelper');
}
$this->addElement('hidden', 'record_id', array('decorators' => array('ViewHelper') ));
$this->addElement('hidden', 'path', array('decorators' => array('ViewHelper')));
$this->addElement('hidden', 'record_type', array('decorators' => array('ViewHelper')));
$this->addElement('hidden', 'parent_comment_id', array('id' => 'parent-id', 'value' => null, 'decorators' => array('ViewHelper')));
fire_plugin_hook('commenting_form', array('comment_form' => $this));
$this->addElement('submit', 'submit', array('label' => __('Submit')));
}
/**
* Override wrapper classes for simplicity and to guarantee unique
* selectors for applying cross-theme styles.
*/
public function getDefaultElementDecorators()
{
return array(
array('Description', array('tag' => 'p', 'class' => 'commenting-explanation', 'escape' => false)),
'ViewHelper',
array('Errors', array('class' => 'error')),
'Label',
array(array('FieldTag' => 'HtmlTag'), array('tag' => 'div', 'class' => 'commenting-field'))
);
}
}