public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $this->setMethod("POST"); $this->setAttrib('name', 'forum_post_create'); $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); $viewer = Engine_Api::_()->user()->getViewer(); $filter = new Engine_Filter_Html(); $allowed_tags = explode(',', Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'forum', 'commentHtml')); if ($settings->getSetting('forum_html', 0) == '0') { $filter->setForbiddenTags(); $filter->setAllowedTags($allowed_tags); } if ($settings->getSetting('forum_html', 0) == '1' || $settings->getSetting('forum_bbcode', 0) == '1') { $this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'required' => true, 'editorOptions' => array('bbcode' => $settings->getSetting('forum_bbcode', 0), 'html' => $settings->getSetting('forum_html', 0)), 'allowEmpty' => false, 'decorators' => array('ViewHelper'), 'filters' => array($filter, new Engine_Filter_Censor()))); } else { $this->addElement('textarea', 'body', array('required' => true, 'allowEmpty' => false, 'attribs' => array('rows' => 24, 'cols' => 80, 'style' => 'width:553px; max-width:553px;height:158px;'), 'filters' => array($filter, new Engine_Filter_Censor()))); } // Photo $this->addElement('File', 'photo', array('label' => '<a id="photo-label" href="javascript:showUploader();">Attach a Photo</a>', 'size' => '40', 'attribs' => array('style' => 'display:none;'))); $this->getElement('photo')->getDecorator('label')->setOptions(array('escape' => false, 'class' => 'buttonlink')); $this->addElement('Checkbox', 'watch', array('label' => 'Send me notifications when other members reply to this topic.', 'value' => '1')); // Buttons $this->addElement('Button', 'submit', array('label' => 'Post Reply', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper'))); $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('submit', 'cancel'), 'buttons'); $button_group = $this->getDisplayGroup('buttons'); $button_group->addDecorator('DivDivDivWrapper'); }
public function init() { $this->setTitle('Reply')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('action' => 'post', 'controller' => 'topic'), 'event_extended', true)); $viewer = Engine_Api::_()->user()->getViewer(); $settings = Engine_Api::_()->getApi('settings', 'core'); $allowHtml = (bool) $settings->getSetting('event_html', 0); $allowBbcode = (bool) $settings->getSetting('event_bbcode', 0); if (!$allowHtml) { $filter = new Engine_Filter_HtmlSpecialChars(); } else { $filter = new Engine_Filter_Html(); $filter->setForbiddenTags(); $allowed_tags = array_map('trim', explode(',', Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'event', 'commentHtml'))); $filter->setAllowedTags($allowed_tags); } if ($allowHtml || $allowBbcode) { $upload_url = ""; if (Engine_Api::_()->authorization()->isAllowed('album', $viewer, 'create')) { $upload_url = Zend_Controller_Front::getInstance()->getRouter()->assemble(array('action' => 'upload-photo'), 'event_photo', true); } $editorOptions = array('upload_url' => $upload_url, 'bbcode' => $settings->getSetting('forum_bbcode', 0), 'html' => $settings->getSetting('forum_html', 0)); if (!empty($upload_url)) { $editorOptions['plugins'] = array('table', 'fullscreen', 'media', 'preview', 'paste', 'code', 'image', 'textcolor', 'jbimages', 'link'); $editorOptions['toolbar1'] = array('undo', 'redo', 'removeformat', 'pastetext', '|', 'code', 'media', 'image', 'jbimages', 'link', 'fullscreen', 'preview'); } $this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'editorOptions' => $editorOptions, 'required' => true, 'allowEmpty' => false, 'decorators' => array('ViewHelper'), 'filters' => array($filter, new Engine_Filter_Censor()))); } else { $this->addElement('Textarea', 'body', array('label' => 'Body', 'allowEmpty' => false, 'required' => true, 'filters' => array(new Engine_Filter_HtmlSpecialChars(), new Engine_Filter_Censor()))); } $this->addElement('Checkbox', 'watch', array('label' => 'Send me notifications when other members reply to this topic.', 'value' => '1')); $this->addElement('Button', 'submit', array('label' => 'Post Reply', 'ignore' => true, 'type' => 'submit')); $this->addElement('Hidden', 'topic_id', array('order' => '920', 'filters' => array('Int'))); $this->addElement('Hidden', 'ref'); }
public function init() { $view = $this->getView(); $baseUrl = $view->layout()->staticBaseUrl; $view->headScript()->appendFile($baseUrl . 'externals/autocompleter/Observer.js')->appendFile($baseUrl . 'externals/autocompleter/Autocompleter.js')->appendFile($baseUrl . 'externals/autocompleter/Autocompleter.Local.js')->appendFile($baseUrl . 'externals/autocompleter/Autocompleter.Request.js'); $view->headScript()->appendScript("\r\n \twindow.addEvent('domready', function() {\r\n \t\tvar viewBookFunc = function() { \t\t\t\r\n\t \t\tvar isAboutBookChk = \$('hasParent').get('checked');\r\n\t \t\tif (!isAboutBookChk) {\r\n\t \t\t\t\$('book-wrapper').set('style','display:none');\r\n\t \t\t} else {\r\n\t \t\t\t\$('book-wrapper').set('style','display:block');\r\n\t \t\t\t\$('book').focus();\r\n\t \t\t}\t\r\n \t\t}\r\n \t\t\r\n \t\t\$('hasParent').addEvent('click', viewBookFunc);\r\n \t\t\r\n \t\tviewBookFunc();\r\n \t});\r\n "); $view->headStyle()->appendStyle('#parentBookValue-wrapper{height:0}'); $this->setMethod('POST')->setTitle($this->_postName)->setAttrib('class', 'global_form book_form'); $filter = new Engine_Filter_Html(); $allowed_tags = array_map('trim', explode(',', Book_Plugin_Constants::ALLOWED_HTML_TAGS)); $filter->setAllowedTags($allowed_tags); $this->addElement('Checkbox', 'hasParent', array('label' => 'This post is about a specific book.', 'value' => 0, 'order' => 1)); $this->addElement('Text', 'book', array('label' => 'Book', 'autocomplete' => 'off', 'order' => 2)); $this->addElement('Hidden', 'parentBookValue', array('allowEmpty' => true, 'order' => 3)); Engine_Form::addDefaultDecorators($this->parentBookValue); $this->addElement('Text', 'post_name', array('label' => 'Title', 'required' => true, 'allowEmpty' => false, 'filters' => array(new Engine_Filter_Censor(), new Engine_Filter_StringLength(array('max' => '127'))), 'order' => 4)); // init photo $this->addElement('File', 'photo', array('label' => 'Post Image', 'description' => 'The image should have the size with the portion 200px * 150px')); $this->photo->addValidator('Extension', false, 'jpg,png,gif,jpeg'); // init description $this->addElement('TinyMce', 'content', array('order' => 5, 'label' => 'Content', 'editorOptions' => array('theme_advanced_buttons1' => array('undo', 'redo', 'cleanup', 'removeformat', 'pasteword', '|', 'media', 'image', 'fullscreen', 'preview', 'emotions'), 'theme_advanced_buttons2' => array('fontselect', 'fontsizeselect', 'bold', 'italic', 'underline', 'strikethrough', 'forecolor', 'backcolor', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|', 'outdent', 'indent', 'blockquote'), 'width' => '800px', 'height' => '450px', 'content_css' => '/application/modules/Book/externals/styles/editor.css', 'upload_url' => Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'book', 'controller' => 'index', 'action' => 'upload'), 'default', true)), 'required' => true, 'allowEmpty' => false, 'filters' => array(new Engine_Filter_Censor(), $filter, new Book_Filter_HTMLPurifier()))); Engine_Form::addDefaultDecorators($this->getElement('content')); // init tag $this->addElement('Text', 'tags', array('label' => 'Tags (Keywords)', 'description' => 'Separate tags with commas.', 'filters' => array('StripTags', new Engine_Filter_Censor()), 'order' => 6)); $this->tags->getDecorator("Description")->setOption("placement", "append"); // init author autocomplete $this->addElement('Text', 'tags_user', array('label' => 'Tag Users', 'autocomplete' => 'off', 'filters' => array('StripTags', new Engine_Filter_Censor()), 'order' => 7, 'description' => 'You can tag your friends here')); $this->tags_user->getDecorator("Description")->setOption("placement", "append"); // Init to Values $this->addElement('Hidden', 'toValues', array('allowEmpty' => true, 'order' => 8, 'filters' => array('HtmlEntities'), 'required' => false)); Engine_Form::addDefaultDecorators($this->toValues); // init author autocomplete $this->addElement('Text', 'tags_book', array('label' => 'Tag Books', 'autocomplete' => 'off', 'filters' => array('StripTags', new Engine_Filter_Censor()), 'order' => 9, 'description' => 'You can tag the books that having the similar content with this one')); $this->tags_book->getDecorator("Description")->setOption("placement", "append"); // Init to Values $this->addElement('Hidden', 'toBookValues', array('allowEmpty' => true, 'filters' => array('HtmlEntities'), 'order' => 10)); Engine_Form::addDefaultDecorators($this->toBookValues); $this->addDisplayGroup(array('tags', 'tags_user', 'toValues', 'tags_book', 'toBookValues'), 'tag_group', array('order' => 11)); // Element: submit $this->addElement('Button', 'submit', array('label' => 'Post', 'type' => 'submit', 'decorators' => array('ViewHelper'))); $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('submit', 'cancel'), 'buttons', array('decorators' => array('FormElements', 'DivDivDivWrapper'), 'order' => 12)); }
public function init() { $this->setTitle('Quick Reply')->setAttrib('name', 'forum_post_quick'); $settings = Engine_Api::_()->getApi('settings', 'core'); $viewer = Engine_Api::_()->user()->getViewer(); $filter = new Engine_Filter_Html(); $allowed_tags = explode(',', Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'forum', 'commentHtml')); if ($settings->getSetting('forum_html', 0) == '0') { $filter->setForbiddenTags(); $filter->setAllowedTags($allowed_tags); } // Element: body $this->addElement('textarea', 'body', array('label' => 'Quick Reply', 'required' => true, 'allowEmpty' => false, 'filters' => array($filter, new Engine_Filter_Censor()))); // Element: photo // Need this hack for some reason $this->addElement('File', 'photo', array('attribs' => array('style' => 'display:none;'))); // Element: watch $this->addElement('Checkbox', 'watch', array('label' => 'Send me notifications when other members reply to this topic.', 'value' => '1')); // Element: submit $this->addElement('Button', 'submit', array('label' => 'Post Reply', 'type' => 'submit')); }
public function init() { $settings = Engine_Api::_()->getApi('settings', 'core'); $this->setMethod("POST"); $this->setAttrib('name', 'forum_post_edit'); $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); $filter = new Engine_Filter_Html(); $viewer = Engine_Api::_()->user()->getViewer(); $allowed_tags = explode(',', Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'forum', 'commentHtml')); if ($settings->getSetting('forum_html', 0) == '0') { $filter->setForbiddenTags(); $filter->setAllowedTags($allowed_tags); } if ($settings->getSetting('forum_html', 0) == '1' || $settings->getSetting('forum_bbcode', 0) == '1') { $this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'required' => true, 'editorOptions' => array('bbcode' => $settings->getSetting('forum_bbcode', 0), 'html' => $settings->getSetting('forum_html', 0)), 'allowEmpty' => false, 'decorators' => array('ViewHelper'), 'filters' => array($filter, new Engine_Filter_Censor()))); } else { $this->addElement('textarea', 'body', array('required' => true, 'attribs' => array('rows' => 24, 'cols' => 80, 'style' => 'width:553px; max-width:553px;height:158px;'), 'allowEmpty' => false, 'filters' => array($filter, new Engine_Filter_Censor()))); } if (!empty($this->_post->file_id)) { $photo_delete_element = new Engine_Form_Element_Checkbox('photo_delete', array('label' => 'This post has a photo attached. Do you want to delete it?')); $photo_delete_element->setAttrib('onchange', 'updateUploader()'); $this->addElement($photo_delete_element); $this->addDisplayGroup(array('photo_delete'), 'photo_delete_group'); } // Photo $file_element = new Engine_Form_Element_File('photo', array('label' => 'Attach a New Photo (optional)', 'size' => '40')); $this->addElement($file_element); $this->addDisplayGroup(array('photo'), 'photo_group'); if (!empty($this->_post->file_id)) { $this->getDisplayGroup('photo_group')->getDecorator('HtmlTag')->setOption('style', 'display:none;'); } // Buttons $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true, 'decorators' => array('ViewHelper'))); $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'link' => true, 'prependText' => ' or ', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('submit', 'cancel'), 'buttons'); $button_group = $this->getDisplayGroup('buttons'); $button_group->addDecorator('DivDivDivWrapper'); }
public function init() { $this->setTitle('Edit Post'); $viewer = Engine_Api::_()->user()->getViewer(); $settings = Engine_Api::_()->getApi('settings', 'core'); $allowHtml = (bool) $settings->getSetting('group_html', 0); $allowBbcode = (bool) $settings->getSetting('group_bbcode', 0); if (!$allowHtml) { $filter = new Engine_Filter_HtmlSpecialChars(); } else { $filter = new Engine_Filter_Html(); $filter->setForbiddenTags(); $allowed_tags = array_map('trim', explode(',', Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'group', 'commentHtml'))); $filter->setAllowedTags($allowed_tags); } if ($allowHtml || $allowBbcode) { $this->addElement('TinyMce', 'body', array('disableLoadDefaultDecorators' => true, 'required' => true, 'allowEmpty' => false, 'decorators' => array('ViewHelper'), 'editorOptions' => array('bbcode' => (bool) $allowBbcode, 'html' => (bool) $allowHtml), 'filters' => array(new Engine_Filter_Censor()))); } else { $this->addElement('textarea', 'body', array('filters' => array(new Engine_Filter_Censor()))); } $this->addElement('Button', 'submit', array('label' => 'Edit Post', 'ignore' => true, 'type' => 'submit', 'decorators' => array('ViewHelper'))); $this->addElement('Cancel', 'cancel', array('label' => 'cancel', 'prependText' => ' or ', 'type' => 'link', 'link' => true, 'onclick' => 'parent.Smoothbox.close();', 'decorators' => array('ViewHelper'))); $this->addDisplayGroup(array('submit', 'cancel'), 'buttons'); }
public function createAction() { $this->view->options = array(); $this->view->form = $form = new Ynfeedback_Form_Admin_Polls_Create(); $viewer = Engine_Api::_()->user()->getViewer(); if (!$this->getRequest()->isPost()) { return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Check options $options = (array) $this->_getParam('optionsArray'); $options = array_filter(array_map('trim', $options)); $options = array_slice($options, 0, $max_options); $this->view->options = $options; if (empty($options) || !is_array($options) || count($options) < 2) { return $form->addError('You must provide at least two possible answers.'); } foreach ($options as $index => $option) { if (strlen($option) > 80) { $options[$index] = Engine_String::substr($option, 0, 80); } } // Process $pollTable = Engine_Api::_()->getItemTable('ynfeedback_poll'); $pollOptionsTable = Engine_Api::_()->getDbtable('options', 'ynfeedback'); $db = $pollTable->getAdapter(); $db->beginTransaction(); try { $values = $form->getValues(); $values['user_id'] = $viewer->getIdentity(); // Create poll $poll = $pollTable->createRow(); $poll->setFromArray($values); $poll->save(); // Create options $censor = new Engine_Filter_Censor(); $html = new Engine_Filter_Html(array('AllowedTags' => array('a'))); foreach ($options as $option) { $option = $censor->filter($html->filter($option)); $pollOptionsTable->insert(array('poll_id' => $poll->getIdentity(), 'poll_option' => $option)); } $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } $this->_forward('success', 'utility', 'core', array('smoothboxClose' => 10, 'parentRefresh' => 10, 'messages' => array(''))); }