Development

#2616: _commentForm.php

You must first sign up to be able to contribute.

Ticket #2616: _commentForm.php

File _commentForm.php, 3.8 kB (added by Roman.Piekarski, 1 year ago)
Line 
1 <?php use_helper('Form') ?>
2 <?php use_helper('Validation') ?>
3 <?php use_helper('Javascript') ?>
4 <?php use_helper('I18N'); ?>
5 <?php use_helper('Date'); ?>
6
7 <?php if ( ($sf_user->isAuthenticated() && $config_user['enabled'])
8           || $config_anonymous['enabled']): ?>
9   <?php
10  
11   echo form_tag('sfComment/'.$action,
12                 array('class' => 'sf_comment_form',
13                       'id'    => 'sf_comment_form',
14                       'name'  => 'sf_comment_form'));
15   ?>
16     <fieldset>
17       <?php if ($sf_request->hasError('unauthorized')): ?>
18         <div class="sf_comment_form_error">
19           <?php echo $sf_request->getError('unauthorized') ?>
20         </div>
21       <?php endif; ?>
22
23       <?php if (isset($config_used['layout']['name'])): ?>
24         <div class="<?php echo $config_used['layout']['name']; ?>">
25           <?php echo form_error('sf_comment_name') ?>
26           <label for="sf_comment_name"><?php echo __('Name') ?></label>
27           <?php echo input_tag('sf_comment_name') ?>
28         </div>
29       <?php endif; ?>
30
31       <?php if (isset($config_used['layout']['email'])): ?>
32         <div class="<?php echo $config_used['layout']['email']; ?>">
33           <?php echo form_error('sf_comment_email') ?>
34           <label for="sf_comment_email"><?php echo __('Email') ?></label>
35           <?php echo input_tag('sf_comment_email') ?>
36         </div>
37       <?php endif; ?>
38
39       <?php if (isset($config_used['layout']['title'])): ?>
40         <div class="<?php echo $config_used['layout']['title']; ?>">
41           <?php echo form_error('sf_comment_title') ?>
42           <label for="sf_comment_title"><?php echo __('Title') ?></label>
43           <?php echo input_tag('sf_comment_title') ?>
44         </div>
45       <?php endif; ?>
46
47       <div class="required">
48         <?php echo form_error('sf_comment') ?>
49         <label for="sf_comment"><?php echo __('Write a comment') ?></label>
50         <?php echo textarea_tag('sf_comment') ?>
51       </div>
52     </fieldset>
53
54     <?php
55     switch (sfConfig::get('sf_path_info_array'))
56     {
57       case 'SERVER':
58         $pathInfoArray =& $_SERVER;
59         break;
60       case 'ENV':
61       default:
62         $pathInfoArray =& $_ENV;
63     }
64
65     $referer = sfRouting::getInstance()->getCurrentInternalUri();
66     
67     if ($pathInfoArray['QUERY_STRING'] != '')
68     {
69       $referer .= '?'.$pathInfoArray['QUERY_STRING'];
70     }
71     ?>
72     <?php echo input_hidden_tag('sf_comment_referer', sfContext::getInstance()->getRequest()->getParameter('sf_comment_referer', $referer)) ?>
73     <?php echo input_hidden_tag('sf_comment_object_id', $object_id) ?>
74     <?php echo input_hidden_tag('sf_comment_object_model', $object_model) ?>
75
76     <?php if (isset($namespace) && ($namespace != null)): ?>
77       <?php echo input_hidden_tag('sf_comment_namespace', $namespace) ?>
78     <?php endif; ?>
79
80     <?php if ($config['use_ajax']): ?>
81       <div id="sf_comment_ajax_indicator" style="display: none">&nbsp;</div>
82       <?php
83       echo submit_to_remote('sf_comment_ajax_submit',
84                            __('Post this comment'),
85                            array('update'   => array('success' => 'sf_comment_list', 'failure' => 'sf_comment_form'),
86                                  'url'      => 'sfComment/'.$action,
87                                  'loading'  => "Element.show('sf_comment_ajax_indicator')",
88                                  'complete' => "Element.hide('sf_comment_ajax_indicator');Element.scrollTo('sf_comment_list')",
89                                  'script'   => true),
90                            array('class' => 'submit'));
91       ?>
92       <noscript>
93         <?php echo submit_tag(__('Post this comment'), array('class' => 'submit')) ?>
94       </noscript>
95     <?php else: ?>
96       <?php echo submit_tag(__('Post this comment'), array('class' => 'submit')) ?>
97     <?php endif; ?>
98   </form>
99 <?php endif; ?>