Esempio n. 1
4
 /**
  * Show bbcodes and smilies in the quickreply
  * Template data for Ajax submit
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_modify_data($event)
 {
     $forum_id = $event['forum_id'];
     $topic_data = $event['topic_data'];
     $post_list = $event['post_list'];
     $topic_id = $topic_data['topic_id'];
     $s_quick_reply = false;
     if (($this->user->data['is_registered'] || $this->config['qr_allow_for_guests']) && $this->config['allow_quick_reply'] && $topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY && $this->auth->acl_get('f_reply', $forum_id)) {
         // Quick reply enabled forum
         $s_quick_reply = $topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED || $this->auth->acl_get('m_edit', $forum_id) ? true : false;
     }
     if (!$this->user->data['is_registered'] && $s_quick_reply) {
         add_form_key('posting');
         $s_attach_sig = $this->config['allow_sig'] && $this->user->optionget('attachsig') && $this->auth->acl_get('f_sigs', $forum_id) && $this->auth->acl_get('u_sig');
         $s_smilies = $this->config['allow_smilies'] && $this->user->optionget('smilies') && $this->auth->acl_get('f_smilies', $forum_id);
         $s_bbcode = $this->config['allow_bbcode'] && $this->user->optionget('bbcode') && $this->auth->acl_get('f_bbcode', $forum_id);
         $s_notify = false;
         $qr_hidden_fields = array('topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], 'lastclick' => (int) time(), 'topic_id' => (int) $topic_data['topic_id'], 'forum_id' => (int) $forum_id);
         // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked
         !$s_bbcode ? $qr_hidden_fields['disable_bbcode'] = 1 : true;
         !$s_smilies ? $qr_hidden_fields['disable_smilies'] = 1 : true;
         !$this->config['allow_post_links'] ? $qr_hidden_fields['disable_magic_url'] = 1 : true;
         $s_attach_sig ? $qr_hidden_fields['attach_sig'] = 1 : true;
         $s_notify ? $qr_hidden_fields['notify'] = 1 : true;
         $topic_data['topic_status'] == ITEM_LOCKED ? $qr_hidden_fields['lock_topic'] = 1 : true;
         $this->template->assign_vars(array('S_QUICK_REPLY' => true, 'U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}"), 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), 'USERNAME' => $this->request->variable('username', '', true)));
         if ($this->config['enable_post_confirm']) {
             $captcha = $this->captcha->get_instance($this->config['captcha_plugin']);
             $captcha->init(CONFIRM_POST);
         }
         if ($this->config['enable_post_confirm'] && (isset($captcha) && $captcha->is_solved() === false)) {
             $this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template()));
         }
         // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
         if (isset($captcha) && $captcha->is_solved() !== false) {
             $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
         }
     }
     // Ajaxify viewtopic data
     if ($this->request->is_ajax() && $this->request->is_set('qr_request')) {
         if (!$this->user->data['is_registered'] && $this->config['enable_post_confirm']) {
             $captcha = $this->captcha->get_instance($this->config['captcha_plugin']);
             $captcha->init(CONFIRM_POST);
             // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview
             if (isset($captcha) && $captcha->is_solved() !== false) {
                 $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields()));
             }
         }
         // Fix issues if the inserted post is not the first.
         if ($this->qr_insert && !$this->qr_first) {
             $this->template->alter_block_array('postrow', array('S_FIRST_ROW' => false), false, 'change');
         }
         $page_title = $event['page_title'];
         $this->template->assign_vars(array('S_QUICKREPLY_REQUEST' => true, 'S_QR_NO_FIRST_POST' => $this->qr_insert, 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote']));
         $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list))));
         // Output the page
         page_header($page_title, false, $forum_id);
         page_footer(false, false, false);
         $json_response = new \phpbb\json_response();
         $json_response->send(array('success' => true, 'result' => $this->template->assign_display('@tatiana5_quickreply/quickreply_template.html', '', true), 'insert' => $this->qr_insert));
     }
     if ($s_quick_reply) {
         include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext;
         // HTML, BBCode, Smilies, Images and Flash status
         $bbcode_status = $this->config['allow_bbcode'] && $this->config['qr_bbcode'] && $this->auth->acl_get('f_bbcode', $forum_id) ? true : false;
         $smilies_status = $this->config['allow_smilies'] && $this->config['qr_smilies'] && $this->auth->acl_get('f_smilies', $forum_id) ? true : false;
         $img_status = $bbcode_status && $this->auth->acl_get('f_img', $forum_id) ? true : false;
         $url_status = $this->config['allow_post_links'] ? true : false;
         $flash_status = $bbcode_status && $this->auth->acl_get('f_flash', $forum_id) && $this->config['allow_post_flash'] ? true : false;
         $quote_status = true;
         // Build custom bbcodes array
         if ($bbcode_status) {
             display_custom_bbcodes();
         }
         // Generate smiley listing
         if ($smilies_status) {
             generate_smilies('inline', $forum_id);
         }
         // Show attachment box for adding attachments if true
         $form_enctype = @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$this->config['allow_attachments'] || !$this->auth->acl_get('u_attach') || !$this->auth->acl_get('f_attach', $forum_id) ? '' : '" enctype="multipart/form-data';
         $allowed = $this->auth->acl_get('f_attach', $forum_id) && $this->auth->acl_get('u_attach') && $this->config['allow_attachments'] && $form_enctype;
         $attachment_data = false;
         if ($bbcode_status || $smilies_status || $this->config['qr_attach'] && $allowed) {
             $this->user->add_lang('posting');
         }
         if ($this->config['qr_attach'] && $allowed) {
             $this->template->assign_vars(array('U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}") . $form_enctype));
             include_once $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext;
             $message_parser = new \parse_message();
             $message_parser->set_plupload($this->plupload);
             $message_parser->set_mimetype_guesser($this->mimetype_guesser);
             $message_parser->get_submitted_attachment_data($this->user->data['user_id']);
             $attachment_data = $message_parser->attachment_data;
             $filename_data = $message_parser->filename_data;
             posting_gen_inline_attachments($attachment_data);
             $max_files = $this->auth->acl_get('a_') || $this->auth->acl_get('m_', $forum_id) ? 0 : (int) $this->config['max_attachments'];
             $topic_id = $topic_data['topic_id'];
             $s_action = append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}");
             $this->plupload->configure($this->cache, $this->template, $s_action, $forum_id, $max_files);
             posting_gen_attachment_entry($attachment_data, $filename_data, $allowed);
         }
         $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list))));
         if ($this->phpbb_extension_manager->is_enabled('rxu/PostsMerging') && $this->user->data['is_registered'] && $this->config['merge_interval']) {
             // Always show the checkbox if PostsMerging extension is installed.
             $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging');
             $this->template->assign_var('POSTS_MERGING_OPTION', true);
         }
         $this->template->assign_vars(array('S_QR_COLOUR_NICKNAME' => $this->config['qr_color_nickname'], 'S_QR_NOT_CHANGE_SUBJECT' => $this->auth->acl_get('f_qr_change_subject', $forum_id) ? false : true, 'S_QR_COMMA_ENABLE' => $this->config['qr_comma'], 'S_QR_QUICKNICK_ENABLE' => $this->config['qr_quicknick'], 'S_QR_QUICKNICK_REF' => $this->config['qr_quicknick_ref'], 'S_QR_QUICKNICK_PM' => $this->config['qr_quicknick_pm'], 'S_QR_QUICKQUOTE_ENABLE' => $this->config['qr_quickquote'], 'S_QR_QUICKQUOTE_LINK' => $this->config['qr_quickquote_link'], 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote'], 'S_QR_CE_ENABLE' => $this->config['qr_ctrlenter'], 'QR_SOURCE_POST' => $this->config['qr_source_post'], 'S_DISPLAY_USERNAME' => !$this->user->data['is_registered'], 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'MESSAGE' => $this->request->variable('message', '', true), 'READ_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'S_QR_CAPS_ENABLE' => $this->config['qr_capslock_transfer'], 'S_QR_SHOW_BUTTON_TRANSLIT' => $this->config['qr_show_button_translit'], 'L_FULL_EDITOR' => $this->config['qr_ajax_submit'] ? $this->user->lang['PREVIEW'] : $this->user->lang['FULL_EDITOR'], 'S_QR_AJAX_SUBMIT' => $this->config['qr_ajax_submit'], 'S_QR_AJAX_PAGINATION' => $this->config['qr_ajax_pagination'] && $this->user->data['ajax_pagination'], 'S_QR_ENABLE_SCROLL' => $this->user->data['qr_enable_scroll'], 'S_QR_SCROLL_INTERVAL' => $this->config['qr_scroll_time'], 'S_QR_SOFT_SCROLL' => $this->config['qr_scroll_time'] && $this->user->data['qr_soft_scroll'], 'S_QR_ALLOWED_GUEST' => $this->config['qr_allow_for_guests'] && $this->user->data['user_id'] == ANONYMOUS, 'S_ABBC3_INSTALLED' => $this->phpbb_extension_manager->is_enabled('vse/abbc3'), 'S_QR_SHOW_ATTACH_BOX' => $this->config['qr_attach'] && $allowed, 'S_ATTACH_DATA' => $attachment_data ? json_encode($attachment_data) : '[]'));
         $add_re = $this->config['qr_enable_re'] ? 'Re: ' : '';
         $this->template->assign_var('SUBJECT', $this->request->variable('subject', $add_re . censor_text($topic_data['topic_title']), true));
     }
     $this->template->assign_vars(array('QR_HIDE_POSTS_SUBJECT' => $this->config['qr_show_subjects'] ? false : true));
 }
Esempio n. 2
0
 /**
  * Automate setting up the page and creating the response object.
  *
  * @param string $template_file The template handle to render
  * @param string $page_title The title of the page to output
  * @param int $status_code The status code to be sent to the page header
  * @param bool $display_online_list Do we display online users list
  *
  * @return Response object containing rendered page
  */
 public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false)
 {
     page_header($page_title, $display_online_list);
     $this->template->set_filenames(array('body' => $template_file));
     page_footer(true, false, false);
     return new Response($this->template->assign_display('body'), $status_code);
 }
 /**
  * This listener is run when the KernelEvents::EXCEPTION event is triggered
  *
  * @param GetResponseForExceptionEvent $event
  * @return null
  */
 public function on_kernel_exception(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     $message = $exception->getMessage();
     if ($exception instanceof \phpbb\exception\exception_interface) {
         $message = $this->language->lang_array($message, $exception->get_parameters());
     }
     if (!$event->getRequest()->isXmlHttpRequest()) {
         page_header($this->language->lang('INFORMATION'));
         $this->template->assign_vars(array('MESSAGE_TITLE' => $this->language->lang('INFORMATION'), 'MESSAGE_TEXT' => $message));
         $this->template->set_filenames(array('body' => 'message_body.html'));
         page_footer(true, false, false);
         $response = new Response($this->template->assign_display('body'), 500);
     } else {
         $data = array();
         if (!empty($message)) {
             $data['message'] = $message;
         }
         if (defined('DEBUG')) {
             $data['trace'] = $exception->getTrace();
         }
         $response = new JsonResponse($data, 500);
     }
     if ($exception instanceof HttpExceptionInterface) {
         $response->setStatusCode($exception->getStatusCode());
         $response->headers->add($exception->getHeaders());
     }
     $event->setResponse($response);
 }
Esempio n. 4
0
 /**
  * Automate setting up the page and creating the response object.
  *
  * @param string $template_file The template handle to render
  * @param string $page_title The title of the page to output
  * @param int $status_code The status code to be sent to the page header
  * @param bool $display_online_list Do we display online users list
  * @param int $item_id Restrict online users to item id
  * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id
  * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers.
  *
  * @return Response object containing rendered page
  */
 public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false)
 {
     page_header($page_title, $display_online_list, $item_id, $item, $send_headers);
     $this->template->set_filenames(array('body' => $template_file));
     page_footer(true, false, false);
     $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array();
     return new Response($this->template->assign_display('body'), $status_code, $headers);
 }
 /**
  * @param array $block_data
  * @param array $default_settings
  * @return template|string
  */
 public function get_edit_form(array $block_data, array $default_settings)
 {
     global $module;
     if (!function_exists('build_cfg_template')) {
         include $this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext;
     }
     // We fake this class as it is needed by the build_cfg_template function
     $module = new \stdClass();
     $module->module = $this;
     $this->_generate_config_fields($block_data['settings'], $default_settings);
     $this->template->assign_vars(array('S_ACTIVE' => $block_data['status'], 'S_TYPE' => $block_data['type'], 'S_NO_WRAP' => $block_data['no_wrap'], 'S_HIDE_TITLE' => $block_data['hide_title'], 'S_BLOCK_CLASS' => trim($block_data['class']), 'S_GROUP_OPS' => $this->_get_group_options($block_data['permission'])));
     $this->template->set_filenames(array('block_settings' => 'block_settings.html'));
     return $this->template->assign_display('block_settings');
 }
 /**
  * Event: core.viewforum_modify_topicrow
  *
  * Get and assign tags to topic-row-template -> RH_TOPICTAGS_TAGS.
  *
  * Note that we assign a string which includes the a-href-links already,
  * because we cannot assign sub-blocks before the outer-block with
  * assign_block_vars(...) and the event is before the actual assignment.
  *
  * @param $event
  */
 public function viewforum_modify_topicrow($event)
 {
     if ($this->config[prefixes::CONFIG . '_display_tags_in_viewforum']) {
         $data = $event->get_data();
         $topic_id = (int) $data['row']['topic_id'];
         $forum_id = (int) $data['row']['forum_id'];
         if ($this->tags_manager->is_tagging_enabled_in_forum($forum_id)) {
             $tags = $this->tags_manager->get_assigned_tags($topic_id);
             if (!empty($tags)) {
                 // we cannot use assign_block_vars('topicrow.tags', ...) here, because the block 'topicrow' is not yet assigned
                 // add links
                 $this->assign_tags_to_template('rh_tags_tmp', $tags);
                 // small_tag.html might want to use our extension's css.
                 $this->template->assign_var('S_RH_TOPICTAGS_INCLUDE_CSS', true);
                 // we cannot just use 'small_tag.html' because in viewforum.php twig only searches in phpbb_root/styles/prosilver/template,
                 // but we need a template from our extension.
                 $rendered_tags = $this->template->assign_display('./../../../ext/robertheim/topictags/styles/all/template/small_tag.html');
                 // remove temporary data
                 $this->template->destroy_block_vars('rh_tags_tmp');
                 // assign the template data
                 $data['topic_row']['RH_TOPICTAGS_TAGS'] = $rendered_tags;
                 $event->set_data($data);
             }
         }
     }
 }
Esempio n. 7
0
 /**
  * {@inheritdoc}
  */
 public function add_user_form_group($title, $form)
 {
     $this->template->assign_var('S_FORM_ELEM_COUNT', sizeof($form));
     $this->template->assign_block_vars('options', array('LEGEND' => $this->language->lang($title), 'S_LEGEND' => true));
     foreach ($form as $input_name => $input_options) {
         if (!isset($input_options['type'])) {
             continue;
         }
         $tpl_ary = array();
         $tpl_ary['TYPE'] = $input_options['type'];
         $tpl_ary['TITLE'] = $this->language->lang($input_options['label']);
         $tpl_ary['KEY'] = $input_name;
         $tpl_ary['S_EXPLAIN'] = false;
         if (isset($input_options['default'])) {
             $default = $input_options['default'];
             $default = preg_replace_callback('#\\{L_([A-Z0-9\\-_]*)\\}#s', array($this, 'lang_replace_callback'), $default);
             $tpl_ary['DEFAULT'] = $default;
         }
         if (isset($input_options['description'])) {
             $tpl_ary['TITLE_EXPLAIN'] = $this->language->lang($input_options['description']);
             $tpl_ary['S_EXPLAIN'] = true;
         }
         if (in_array($input_options['type'], array('select', 'radio'))) {
             for ($i = 0, $total = sizeof($input_options['options']); $i < $total; $i++) {
                 if (isset($input_options['options'][$i]['label'])) {
                     $input_options['options'][$i]['label'] = $this->language->lang($input_options['options'][$i]['label']);
                 }
             }
             $tpl_ary['OPTIONS'] = $input_options['options'];
         }
         $this->template->assign_block_vars('options', $tpl_ary);
     }
     $this->template->set_filenames(array('form_install' => 'installer_form.html'));
     $this->form = $this->template->assign_display('form_install');
 }
Esempio n. 8
0
 /**
  * Display the panels (tabs)
  */
 public function display_panels()
 {
     foreach ($this->posting_panels as $name => $lang) {
         $this->template->set_filenames(array($name => 'posting/panels/' . $name . '.html'));
         $this->template->assign_block_vars('panels', array('NAME' => $name, 'TITLE' => $this->user->lang($lang), 'OUTPUT' => $this->template->assign_display($name)));
     }
 }
Esempio n. 9
0
 /**
  * Reduce the set of elements to the one that we need to retrieve.
  *
  * @param object $event The event object
  * @return null
  * @access public
  */
 public function viewtopic_modify_sql($event)
 {
     if ($this->request->is_ajax() && $this->request->is_set('qr_captcha_refresh')) {
         if ($this->config['enable_post_confirm']) {
             $this->helper->set_captcha(false);
         }
         $json_response = new \phpbb\json_response();
         $json_response->send(array('captcha_refreshed' => true, 'captcha_result' => $this->template->assign_display('@boardtools_quickreply/quickreply_captcha_template.html', '', true)));
     }
     $post_list = $event['post_list'];
     $current_post = $this->request->variable('qr_cur_post_id', 0);
     if ($this->request->is_ajax() && $this->request->variable('qr_no_refresh', 0) && in_array($current_post, $post_list)) {
         $sql_ary = $event['sql_ary'];
         $qr_get_current = $this->request->is_set('qr_get_current');
         $compare = $qr_get_current ? ' >= ' : ' > ';
         $sql_ary['WHERE'] .= ' AND p.post_id' . $compare . $current_post;
         $event['sql_ary'] = $sql_ary;
         $this->helper->qr_insert = true;
         $this->helper->qr_first = $current_post == min($post_list) && $qr_get_current;
         // Check whether no posts are found.
         if ($compare == ' > ' && max($post_list) <= $current_post) {
             $json_response = new \phpbb\json_response();
             $json_response->send(array('error' => true, 'MESSAGE_TITLE' => $this->user->lang['INFORMATION'], 'MESSAGE_TEXT' => $this->user->lang['NO_POSTS_TIME_FRAME']));
         }
     }
     $this->user->add_lang_ext('boardtools/quickreply', 'quickreply');
 }
Esempio n. 10
0
 /**
  * Get the html form
  *
  * @param array $block_data
  * @return string
  */
 private function _get_form(array $block_data)
 {
     $selected_groups = $this->_ensure_array($block_data['permission']);
     $this->template->assign_vars(array('S_ACTIVE' => $block_data['status'], 'S_TYPE' => $block_data['type'], 'S_NO_WRAP' => $block_data['no_wrap'], 'S_HIDE_TITLE' => $block_data['hide_title'], 'S_BLOCK_CLASS' => trim($block_data['class']), 'S_GROUP_OPS' => $this->groups->get_options('special', $selected_groups)));
     $this->template->set_filenames(array('block_settings' => 'block_settings.html'));
     return $this->template->assign_display('block_settings');
 }
Esempio n. 11
0
 /**
  * Return templated value/field. Possible values for $mode are:
  * change == user is able to set/enter profile values; preview == just show the value
  */
 public function process_field_row($mode, $profile_row)
 {
     $preview_options = $mode == 'preview' ? $profile_row['lang_options'] : false;
     // set template filename
     $this->template->set_filenames(array('cp_body' => $this->get_template_filename()));
     // empty previously filled blockvars
     $this->template->destroy_block_vars($this->get_name_short());
     // Assign template variables
     $this->generate_field($profile_row, $preview_options);
     return $this->template->assign_display('cp_body');
 }
Esempio n. 12
0
 /**
  * Run AutoMOD test.
  *
  * @param \phpbb\titania\entity\package $package
  * @param string $phpbb_path Path to phpBB files we run the test on
  * @param string $details Will hold the details of the mod
  * @param string $results Will hold the results for output
  * @param string $bbcode_results Will hold the results for storage
  * @return bool true on success, false on failure
  */
 public function run_automod_test($package, $phpbb_path, &$details, &$results, &$bbcode_results)
 {
     require $this->phpbb_root_path . 'includes/functions_transfer.' . $this->php_ext;
     require $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/acp_mods.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/editor.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/mod_parser.' . $this->php_ext;
     require $this->ext_root_path . 'includes/library/automod/functions_mods.' . $this->php_ext;
     $this->user->add_lang_ext('phpbb/titania', 'automod');
     // Find the main modx file
     $modx_root = $package->find_directory(array('files' => array('required' => 'install*.xml')));
     if ($modx_root === null) {
         $this->user->add_lang_ext('phpbb/titania', 'contributions');
         $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     $modx_root = $package->get_temp_path() . '/' . $modx_root . '/';
     $modx_file = false;
     if (file_exists($modx_root . 'install.xml')) {
         $modx_file = $modx_root . 'install.xml';
     } else {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->name('install*.xml')->depth(0)->in($modx_root);
         if ($finder->count()) {
             foreach ($finder as $file) {
                 $modx_file = $file->getPathname();
                 break;
             }
         }
     }
     if (!$modx_file) {
         $this->user->add_lang_ext('phpbb/titania', 'contributions');
         $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT'];
         return false;
     }
     // HAX
     global $phpbb_root_path;
     $phpbb_root_path = $phpbb_path;
     // The real stuff
     $acp_mods = new \acp_mods();
     $acp_mods->mods_dir = $this->ext_config->__get('contrib_temp_path');
     $acp_mods->mod_root = $modx_root;
     $editor = new \editor_direct();
     $details = $acp_mods->mod_details($modx_file, false);
     $actions = $acp_mods->mod_actions($modx_file);
     $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false);
     // Reverse HAX
     $phpbb_root_path = $this->phpbb_root_path;
     $this->template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html'));
     $this->template->assign_var('S_AUTOMOD_SUCCESS', $installed);
     $results = $this->template->assign_display('automod');
     $bbcode_results = $this->template->assign_display('automod_bbcode');
     return $installed;
 }
	/**
	* This listener is run when the KernelEvents::EXCEPTION event is triggered
	*
	* @param GetResponseForExceptionEvent $event
	* @return null
	*/
	public function on_kernel_exception(GetResponseForExceptionEvent $event)
	{
		page_header($this->user->lang('INFORMATION'));

		$exception = $event->getException();

		$this->template->assign_vars(array(
			'MESSAGE_TITLE'		=> $this->user->lang('INFORMATION'),
			'MESSAGE_TEXT'		=> $exception->getMessage(),
		));

		$this->template->set_filenames(array(
			'body'	=> 'message_body.html',
		));

		page_footer(true, false, false);

		$status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500;
		$response = new Response($this->template->assign_display('body'), $status_code);
		$event->setResponse($response);
	}
Esempio n. 14
0
 /**
  * {@inheritdoc}
  */
 public function render_update_file_status($status_array)
 {
     $this->template->assign_vars(array('T_IMAGE_PATH' => $this->path_helper->get_web_root_path() . 'adm/images/'));
     foreach ($status_array as $block => $list) {
         foreach ($list as $filename) {
             $dirname = dirname($filename);
             $this->template->assign_block_vars($block, array('STATUS' => $block, 'FILENAME' => $filename, 'DIR_PART' => !empty($dirname) && $dirname !== '.' ? dirname($filename) . '/' : false, 'FILE_PART' => basename($filename)));
         }
     }
     $this->template->set_filenames(array('file_status' => 'installer_update_file_status.html'));
     $this->file_status = $this->template->assign_display('file_status');
 }
Esempio n. 15
0
 /**
  * Automate setting up the page and creating the response object.
  *
  * @param string	$template_file		The template handle to render
  * @param string	$page_title			The title of the page to output
  * @param bool		$selected_language	True to enable language selector it, false otherwise
  * @param int		$status_code		The status code to be sent to the page header
  *
  * @return Response object containing rendered page
  */
 public function render($template_file, $page_title = '', $selected_language = false, $status_code = 200)
 {
     $this->page_header($page_title, $selected_language);
     $this->template->set_filenames(array('body' => $template_file));
     $response = new Response($this->template->assign_display('body'), $status_code);
     // Set language cookie
     if ($this->language_cookie !== false) {
         $cookie = new Cookie('lang', $this->language_cookie, time() + 3600);
         $response->headers->setCookie($cookie);
         $this->language_cookie = false;
     }
     return $response;
 }
Esempio n. 16
0
 /**
  * Quick Edit a post
  *
  * @param int $post_id
  * @return JsonResponse
  * @throws http_exception	Throws http_exception when form token is invalid.
  */
 public function quick_edit($post_id)
 {
     if ($this->request->header('X-PHPBB-USING-PLUPLOAD', false)) {
         return $this->edit($post_id);
     }
     $submit = $this->request->is_set_post('submit');
     $full_editor = $this->request->is_set_post('full_editor');
     // AJAX output
     if (!$submit && !$full_editor) {
         $this->user->add_lang('viewtopic');
         // Load the stuff we need
         $post = $this->load_post($post_id);
         // Check permissions
         $this->quick_edit_auth_check($post);
         $post_message = $post->post_text;
         message::decode($post_message, $post->post_text_uid);
         add_form_key('postform');
         $this->template->assign_vars(array('SUBJECT' => $post->post_subject, 'MESSAGE' => $post_message, 'U_QR_ACTION' => $post->get_url('quick_edit')))->set_filenames(array('quick_edit' => 'posting/quickedit_editor.html'));
         return new JsonResponse(array('form' => $this->template->assign_display('quick_edit')));
     }
     if ($full_editor) {
         return $this->edit($post_id);
     }
     // Load the stuff we need
     $post = $this->load_post($post_id);
     // Check permissions
     $this->quick_edit_auth_check($post);
     if (!check_form_key('postform')) {
         throw new http_exception(200, 'FORM_INVALID');
     }
     // Grab some data
     $for_edit = $post->generate_text_for_edit();
     // Set the post text
     $post->post_subject = $this->request->variable('subject', '', true);
     $post->post_text = $this->request->variable('message', '', true);
     // Generate for storage based on previous options
     $post->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_urls'], $for_edit['allow_smilies']);
     // If u_titania_mod_post_mod permission then no edit info
     // Update edit info if user is editing his post, which is not the last within the topic.
     if (!$this->auth->acl_get('u_titania_mod_post_mod') && $post->topic->topic_last_post_id != $post->post_id) {
         $post->post_edit_time = time();
         $post->post_edit_user = $this->user->data['user_id'];
     }
     // Submit
     $post->submit();
     // Parse the message
     $message = $post->generate_text_for_display();
     // Parse attachments
     $this->attachments->configure($post->post_type, $post->post_id)->load()->parse_attachments($message);
     return new JsonResponse(array('subject' => censor_text($post->post_subject), 'message' => $message));
 }
Esempio n. 17
0
 /**
  * Output the page for QuickReply
  *
  * @param string $page_title      The title of the page
  * @param int    $current_post_id ID of the current last post
  * @param int    $forum_id        Forum ID
  */
 public function ajax_response($page_title, $current_post_id, $forum_id)
 {
     // Fix issues if the inserted post is not the first.
     if ($this->qr_insert && !$this->qr_first) {
         $this->template->alter_block_array('postrow', array('S_FIRST_ROW' => false), false, 'change');
     }
     $this->template->assign_vars(array('S_QUICKREPLY_REQUEST' => true, 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote']));
     $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) $current_post_id)));
     // Output the page
     page_header($page_title, false, $forum_id);
     page_footer(false, false, false);
     $json_response = new \phpbb\json_response();
     $json_response->send(array('success' => true, 'result' => $this->template->assign_display('@boardtools_quickreply/quickreply_template.html', '', true), 'insert' => $this->qr_insert));
 }
 /**
  * Send the mail out to the recipients set previously in var $this->addresses
  */
 function send($method = NOTIFY_EMAIL, $break = false)
 {
     global $config, $user;
     // We add some standard variables we always use, no need to specify them always
     $this->assign_vars(array('U_BOARD' => generate_board_url(), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), 'SITENAME' => htmlspecialchars_decode($config['sitename'])));
     // Parse message through template
     $this->msg = trim($this->template->assign_display('body'));
     // Because we use \n for newlines in the body message we need to fix line encoding errors for those admins who uploaded email template files in the wrong encoding
     $this->msg = str_replace("\r\n", "\n", $this->msg);
     // We now try and pull a subject from the email body ... if it exists,
     // do this here because the subject may contain a variable
     $drop_header = '';
     $match = array();
     if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) {
         $this->subject = trim($match[2]) != '' ? trim($match[2]) : ($this->subject != '' ? $this->subject : $user->lang['NO_EMAIL_SUBJECT']);
         $drop_header .= '[\\r\\n]*?' . preg_quote($match[1], '#');
     } else {
         $this->subject = $this->subject != '' ? $this->subject : $user->lang['NO_EMAIL_SUBJECT'];
     }
     if ($drop_header) {
         $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
     }
     if ($break) {
         return true;
     }
     switch ($method) {
         case NOTIFY_EMAIL:
             $result = $this->msg_email();
             break;
         case NOTIFY_IM:
             $result = $this->msg_jabber();
             break;
         case NOTIFY_BOTH:
             $result = $this->msg_email();
             $this->msg_jabber();
             break;
     }
     $this->reset();
     return $result;
 }
Esempio n. 19
0
 /**
  * Parse the uploader
  *
  * @param string $tpl_file The name of the template file to use to create the uploader
  * @param bool $custom_sort Function used to sort the attachments
  * @return string The parsed HTML code ready for output
  */
 public function parse_uploader($tpl_file = 'posting/attachments/default.html', $custom_sort = false)
 {
     // If the upload max filesize is less than 0, do not show the uploader (0 = unlimited)
     if (!$this->access->is_team()) {
         if (isset($this->ext_config->upload_max_filesize[$this->object_type]) && $this->ext_config->upload_max_filesize[$this->object_type] < 0) {
             return '';
         }
     }
     $this->template->assign_vars(array('FORM_NAME' => $this->form_name, 'MAX_LENGTH' => $this->access->is_team() ? $this->config['max_filesize'] : false, 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'S_INLINE_ATTACHMENT_OPTIONS' => true, 'S_PLUPLOAD_ENABLED' => $this->use_plupload, 'S_SET_CUSTOM_ORDER' => $this->set_custom_order, 'S_UPLOADER_KEY' => generate_link_hash('uploader_key'), 'SELECT_PREVIEW' => $this->object_type == TITANIA_SCREENSHOT, 'SELECT_REVIEW_VAR' => 'set_preview_file' . $this->object_type));
     $index_dir = '-';
     $index = $this->operator->get_count() - 1;
     if ($custom_sort == false && !$this->config['display_order']) {
         $index_dir = '+';
         $index = 0;
     }
     $this->operator->sort($custom_sort);
     // Delete previous attachments list
     $this->template->destroy_block_vars('attach_row');
     $base_url = $this->controller_helper->get_current_url();
     $hash = generate_link_hash('attach_manage');
     $comments = $this->get_request_comments();
     $hidden_data = $this->get_basic_attachment_data();
     $index_prefix = $this->use_plupload ? '' : $this->form_name . '_';
     foreach ($this->operator->get_all() as $attachment_id => $attach) {
         $params = array('a' => $attachment_id, 'hash' => $hash);
         $_hidden_data = array();
         foreach ($hidden_data[$attachment_id] as $property => $value) {
             $_hidden_data["attachment_data[{$index_prefix}{$index}][{$property}]"] = $value;
         }
         $output = array_merge($attach->get_display_vars(''), array('FILENAME' => $attach->get_filename(), 'FILE_COMMENT' => isset($comments[$attachment_id]) ? $comments[$attachment_id] : $attach->get('attachment_comment'), 'ATTACH_ID' => $attachment_id, 'INDEX' => $index_prefix . $index, 'FILESIZE' => get_formatted_filesize($attach->get('filesize')), 'S_HIDDEN' => build_hidden_fields($_hidden_data), 'S_PREVIEW' => $attach->is_preview(), 'U_VIEW_ATTACHMENT' => $attach->get_url(), 'U_DELETE' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'delete_attach')))));
         if ($attach->is_type(TITANIA_SCREENSHOT)) {
             $output = array_merge($output, array('U_MOVE_UP' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'attach_up'))), 'U_MOVE_DOWN' => $this->path_helper->append_url_params($base_url, array_merge($params, array('action' => 'attach_down')))));
         }
         $index += $index_dir == '+' ? 1 : -1;
         $this->template->assign_block_vars('attach_row', $output);
     }
     $this->template->assign_var('S_ATTACH_DATA', json_encode(array_values($hidden_data)));
     $this->template->set_filenames(array($tpl_file => $tpl_file));
     return $this->template->assign_display($tpl_file);
 }
Esempio n. 20
0
 /**
  * General attachment parsing
  * From phpBB (includes/functions_content.php)
  *
  * @param string &$message The message
  * @param string $tpl The template file to use
  * @param array $preview_comments true if previewing from the posting page
  * @param string|bool $template_block If not false we will output the parsed attachments to this template block
  * @param bool $custom_sort Whether attachments have a custom order.
  *
  * @return array the parsed attachments
  */
 public function parse_attachments(&$message, $tpl = 'common/attachment.html', $preview_comments = array(), $template_block = false, $custom_sort = false)
 {
     if (empty($this->attachments)) {
         return array();
     }
     $this->user->add_lang('viewtopic');
     if ($tpl !== false && !isset($this->template->filename['titania_attachment_tpl'])) {
         $this->template->set_filenames(array('titania_attachment_tpl' => $tpl));
     }
     $this->sort($custom_sort);
     $compiled_attachments = array();
     $total_attachments = 0;
     foreach ($this->attachments as $id => $attach) {
         // We need to reset/empty the _file block var, because this function might be called more than once
         $this->template->destroy_block_vars('_file');
         $comment = $attach->get('attachment_comment');
         if (isset($preview_comments[$id])) {
             $comment = $preview_comments[$id];
         }
         $vars = $attach->get_display_vars($comment);
         // If a template block is specified, output to that also
         if ($template_block) {
             $this->template->assign_block_vars($template_block, $vars);
         }
         if ($attach->is_preview() && $attach->is_type(TITANIA_SCREENSHOT)) {
             $this->template->assign_block_vars('preview', $vars);
         }
         if ($tpl !== false) {
             $this->template->assign_block_vars('_file', $vars);
             $compiled_attachments[] = $this->template->assign_display('titania_attachment_tpl');
         }
         $total_attachments++;
     }
     $tpl_size = sizeof($compiled_attachments);
     $unset_tpl = array();
     // For inline attachments
     if ($message) {
         preg_match_all('#<!\\-\\- ia([0-9]+) \\-\\->(.*?)<!\\-\\- ia\\1 \\-\\->#', $message, $matches, PREG_PATTERN_ORDER);
         $replace = array();
         foreach ($matches[0] as $num => $capture) {
             // Flip index if we are displaying the reverse way
             $index = $this->config['display_order'] ? $tpl_size - ($matches[1][$num] + 1) : $matches[1][$num];
             $replace['from'][] = $matches[0][$num];
             if (isset($compiled_attachments[$index])) {
                 $replace['to'][] = $compiled_attachments[$index];
             } else {
                 $replaced['to'][] = $this->user->lang('MISSING_INLINE_ATTACHMENT', $matches[2][array_search($index, $matches[1])]);
             }
             $unset_tpl[] = $index;
         }
         if (isset($replace['from'])) {
             $message = str_replace($replace['from'], $replace['to'], $message);
         }
         $unset_tpl = array_unique($unset_tpl);
         // Needed to let not display the inlined attachments at the end of the post again
         foreach ($unset_tpl as $index) {
             unset($compiled_attachments[$index]);
         }
     }
     return $compiled_attachments;
 }
Esempio n. 21
0
 /**
  * Renders a template file and returns it
  *
  * @param $template_file string
  * @return string
  */
 protected function render_template($template_file)
 {
     $this->template->set_filenames(array('body' => $template_file));
     $content = $this->template->assign_display('body', '', true);
     return trim(str_replace(array("\r", "\n"), '', $content));
 }
Esempio n. 22
0
 public function portal_block_template($block_file)
 {
     $this->template->set_filenames(array('block' => 'blocks/' . $block_file));
     return $this->template->assign_display('block', true);
 }
Esempio n. 23
0
 /**
  * Get AJAX response.
  *
  * @param string $title
  * @param \phpbb\titania\sort $sort
  * @return JsonResponse
  */
 protected function get_ajax_response($title, $sort)
 {
     $this->template->set_filenames(array('body' => 'common/contribution_list.html', 'breadcrumbs' => 'breadcrumbs.html', 'pagination' => 'common/pagination.html'));
     return new JsonResponse(array('title' => $title, 'content' => $this->template->assign_display('body'), 'breadcrumbs' => $this->template->assign_display('breadcrumbs'), 'categories' => $this->get_category_urls(), 'branches' => $this->get_branches(), 'sort' => $this->get_sorting($sort), 'pagination' => $this->template->assign_display('pagination'), 'u_queue_stats' => $this->get_queue_stats_url(), 'l_queue_stats' => $this->user->lang('QUEUE_STATS')));
 }