Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • Comment
  • ConfigBlock
  • ConfigOperation
  • DeleteBlock
  • DeleteOperation
  • EditBlock
  • Hooks
  • ManageBlock
  • Model
  • Module
  • PatchOperation
  • PreviewOperation
  • SaveOperation
  • SubmitForm
  • Update20131208
  • ViewProvider
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Icybee\Modules\Comments;
 13 
 14 use ICanBoogie\Operation;
 15 
 16 use Brickrouge\Element;
 17 use Brickrouge\Form;
 18 use Brickrouge\Text;
 19 
 20 /**
 21  * The form used to submit comments.
 22  */
 23 class SubmitForm extends Form
 24 {
 25     static protected function add_assets(\Brickrouge\Document $document)
 26     {
 27         parent::add_assets($document);
 28 
 29         $document->js->add('submit.js');
 30     }
 31 
 32     public function __construct(array $attributes=array())
 33     {
 34         global $core;
 35 
 36         $user = $core->user;
 37         $is_member = !$user->is_guest;
 38         $values = array();
 39 
 40         if ($is_member)
 41         {
 42             $values[Comment::AUTHOR] = $user->name;
 43             $values[Comment::AUTHOR_EMAIL] = $user->email;
 44         }
 45 
 46         parent::__construct
 47         (
 48             \ICanBoogie\array_merge_recursive
 49             (
 50                 $attributes, array
 51                 (
 52                     Form::RENDERER => 'Simple',
 53                     Form::VALUES => $values,
 54                     Form::HIDDENS => array
 55                     (
 56                         Operation::DESTINATION => 'comments',
 57                         Operation::NAME => 'save'
 58                     ),
 59 
 60                     Element::CHILDREN => array
 61                     (
 62                         Comment::AUTHOR => new Text
 63                         (
 64                             array
 65                             (
 66                                 Element::LABEL => 'Name',
 67                                 Element::REQUIRED => true
 68                             )
 69                         ),
 70 
 71                         Comment::AUTHOR_EMAIL => new Text
 72                         (
 73                             array
 74                             (
 75                                 Element::LABEL => 'E-mail',
 76                                 Element::REQUIRED => true,
 77                                 Element::VALIDATOR => array('Brickrouge\Form::validate_email')
 78                             )
 79                         ),
 80 
 81                         Comment::AUTHOR_URL => new Text
 82                         (
 83                             array
 84                             (
 85                                 Element::LABEL => 'Website'
 86                             )
 87                         ),
 88 
 89                         Comment::CONTENTS => new Element
 90                         (
 91                             'textarea', array
 92                             (
 93                                 Element::REQUIRED => true,
 94                                 Element::LABEL_MISSING => 'Message',
 95 
 96                                 'class' => 'span6',
 97                                 'rows' => 8
 98                             )
 99                         ),
100 
101                         Comment::NOTIFY => new Element
102                         (
103                             Element::TYPE_RADIO_GROUP, array
104                             (
105                                 Form::LABEL => "Shouhaitez-vous être informé d'une réponse à votre message ?",
106 
107                                 Element::OPTIONS => array
108                                 (
109                                     'yes' => "Bien sûr !",
110                                     'author' => "Seulement si c'est l'auteur du billet qui répond.",
111                                     'no' => "Pas la peine, je viens tous les jours."
112                                 ),
113 
114                                 Element::DEFAULT_VALUE => 'no',
115 
116                                 'class' => 'inputs-list'
117                             )
118                         )
119                     ),
120 
121                     Element::WIDGET_CONSTRUCTOR => 'SubmitComment',
122 
123                     'action' => '#view-comments-submit',
124                     'class' => 'widget-submit-comment'
125                 )
126             ),
127 
128             'div'
129         );
130     }
131 
132     public function alter_notify(\Icybee\Modules\Forms\NotifyParams $properties)
133     {
134         global $core;
135 
136         $properties->bind = $core->models['comments'][$properties->rc['key']];
137     }
138 
139     static public function get_defaults()
140     {
141         global $core;
142 
143         if (isset($_GET['type']) && $_GET['type'] == 'notify')
144         {
145             return array
146             (
147                 'from' => 'no-reply@' . $_SERVER['SERVER_NAME'],
148                 'subject' => 'Notification de réponse au billet : #{@node.title}',
149                 'bcc' => $core->user->email,
150                 'template' => <<<EOT
151 Bonjour,
152 
153 Vous recevez cet e-mail parce que vous surveillez le billet "#{@node.title}" sur #{\$core.site.title}.
154 Ce billet a reçu une réponse depuis votre dernière visite. Vous pouvez utiliser le lien suivant
155 pour voir les réponses qui ont été faites :
156 
157 #{@absolute_url}
158 
159 Aucune autre notification ne vous sera envoyée.
160 
161 À bientôt sur #{\$core.site.title}.
162 EOT
163             );
164         }
165 
166         return array
167         (
168             'notify_subject' => 'Un nouveau commentaire a été posté sur #{$core.site.title}',
169             'notify_from' => 'Comments <comments@#{$server.http.host}>',
170             'notify_template' => <<<EOT
171 Bonjour,
172 
173 Vous recevez ce message parce qu'un nouveau commentaire a été posté sur le site #{\$core.site.title} :
174 
175 URL : #{@absolute_url}
176 Auteur : #{@author} <#{@author_email}>
177 
178 #{@strip_tags()=}
179 
180 EOT
181         );
182     }
183 }
Autodoc API documentation generated by ApiGen 2.8.0