Пример #1
0
 /**
  * Build pagination and send to template
  * $this->url_location and $this->url_parameters will over-ride the settings given here for $page, $params.
  * The reason is that the place that calls build_pagination is typically in a completely different area, in an area that can't say for certain the correct URL (other than the current page)
  *
  * @param string $page path/page to be used in pagination url
  * @param array $params to be used in pagination url
  * @return $this
  */
 public function build_pagination($page, $params = array())
 {
     if ($this->url_location) {
         $page = $this->url_location;
     }
     if ($this->url_parameters) {
         $params = $this->url_parameters;
     }
     // Spring cleaning
     unset($params[$this->start_name], $params[$this->limit_name], $params[$this->sort_key_name], $params[$this->sort_dir_name]);
     // Add the limit to the URL if required
     if ($this->limit != $this->default_limit) {
         $params[$this->limit_name] = $this->limit;
     }
     // Don't include the sort key/dir in the sort action url
     $sort_url = $this->path_helper->append_url_params($page, $params);
     // Add the sort key to the URL if required
     if ($this->sort_key != $this->default_sort_key) {
         $params[$this->sort_key_name] = $this->sort_key;
     }
     // Add the sort dir to the URL if required
     if ($this->sort_dir != $this->default_sort_dir) {
         $params[$this->sort_dir_name] = $this->sort_dir;
     }
     $pagination_url = $this->path_helper->append_url_params($page, $params);
     $this->pagination->generate_template_pagination($pagination_url, $this->template_block, 'start', $this->total, $this->limit, $this->start);
     if ($this->template_block == 'pagination') {
         $this->template->assign_vars(array($this->template_vars['S_SORT_ACTION'] => $sort_url, $this->template_vars['S_PAGINATION_ACTION'] => $pagination_url, $this->template_vars['S_NUM_POSTS'] => $this->total, $this->template_vars['S_SELECT_SORT_KEY'] => $this->get_sort_key_list(), $this->template_vars['S_SELECT_SORT_DIR'] => $this->get_sort_dir_list(), $this->template_vars['SORT_KEYS_NAME'] => $this->sort_key_name, $this->template_vars['SORT_DIR_NAME'] => $this->sort_dir_name, $this->template_vars['TOTAL_ITEMS'] => $this->total, $this->template_vars['TOTAL_RESULTS'] => $this->user->lang($this->result_lang, $this->total)));
     }
     return $this;
 }
Пример #2
0
 /**
  * Display the main index page.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function display_index($branch)
 {
     $this->set_branch($branch);
     $title = $this->user->lang('CUSTOMISATION_DATABASE');
     $sort = $this->list_contributions('', self::ALL_CONTRIBS, '');
     $this->params = $this->get_params($sort);
     $this->display->assign_global_vars();
     if ($this->request->is_ajax()) {
         return $this->get_ajax_response($title, $sort);
     }
     $this->display->display_categories(self::ALL_CONTRIBS, 'categories', false, true, $this->params);
     // Mark all contribs read
     if ($this->request->variable('mark', '') == 'contribs') {
         $this->tracking->track(TITANIA_CONTRIB, self::ALL_CONTRIBS);
     }
     $this->template->assign_vars(array('CATEGORY_ID' => self::ALL_CONTRIBS, 'U_CREATE_CONTRIBUTION' => $this->get_create_contrib_url(), 'U_MARK_FORUMS' => $this->path_helper->append_url_params($this->helper->get_current_url(), array('mark' => 'contribs')), 'L_MARK_FORUMS_READ' => $this->user->lang['MARK_CONTRIBS_READ'], 'U_ALL_CONTRIBUTIONS' => $this->get_index_url($this->params), 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => $this->helper->route('phpbb.titania.search.contributions.results')));
     $this->assign_sorting($sort);
     $this->assign_branches();
     return $this->helper->render('index_body.html', $title);
 }
Пример #3
0
 /**
  * Shorten the amount of code required for some places
  *
  * @param mixed $object_type
  * @param mixed $object_id
  * @param mixed $url
  * @param string $lang_key Language key to use in link
  */
 public function handle_subscriptions($object_type, $object_id, $url, $lang_key = 'SUBSCRIBE')
 {
     if (!$this->user->data['is_registered']) {
         // Cannot currently handle non-registered users
         return;
     }
     $action = $this->request->variable('subscribe', '');
     $action = in_array($action, array('subscribe', 'unsubscribe')) ? $action : false;
     $hash = $this->request->variable('hash', '');
     if ($action && check_link_hash($hash, $action)) {
         $this->{$action}($object_type, $object_id);
     }
     $is_subscribed = $this->is_subscribed($object_type, $object_id);
     $action = 'subscribe';
     if ($is_subscribed) {
         $action = 'unsubscribe';
         $lang_key = 'UN' . $lang_key;
     }
     $params = array('subscribe' => $action, 'hash' => generate_link_hash($action));
     $this->template->assign_vars(array('IS_SUBSCRIBED' => $is_subscribed, 'U_SUBSCRIBE' => $this->path_helper->append_url_params($url, $params), 'L_SUBSCRIBE_TYPE' => $this->user->lang($lang_key)));
 }
Пример #4
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);
 }
Пример #5
0
 /**
  * @dataProvider append_url_params_data
  */
 public function test_append_url_params($url, $params, $is_amp, $expected)
 {
     $this->assertEquals($expected, $this->path_helper->append_url_params($url, $params, $is_amp));
 }
Пример #6
0
 /**
  * Get rating string
  *
  * @param $rate_url string	Rating URL
  * @return string The rating string ready for output
  */
 public function get_rating_string($rate_url)
 {
     $can_rate = !$this->cannot_rate && phpbb::$user->data['is_registered'] && phpbb::$auth->acl_get('u_titania_rate') && !$this->rating_id ? true : false;
     // If it has not had any ratings yet, give it 1/2 the max for the rating
     if ($this->rating_count == 0) {
         $this->rating = round(titania::$config->max_rating / 2, 1);
     }
     phpbb::$template->set_filenames(array('rate' => 'common/rate.html'));
     phpbb::$template->assign_vars(array('OBJECT_ID' => $this->rating_object_id, 'OBJECT_RATING' => round($this->rating), 'RATE_URL' => $rate_url, 'S_HAS_RATED' => $this->rating_id ? true : false, 'S_CAN_RATE' => $can_rate, 'UA_MAX_RATING' => titania::$config->max_rating));
     // reset the stars block
     phpbb::$template->destroy_block_vars('stars');
     for ($i = 1; $i <= titania::$config->max_rating; $i++) {
         $rating = !$can_rate ? $this->rating : ($this->rating_value ? $this->rating_value : $i);
         phpbb::$template->assign_block_vars('stars', array('ALT' => $rating . '/' . titania::$config->max_rating, 'ID' => $i, 'RATE_URL' => $this->path_helper->append_url_params($rate_url, array('value' => $i))));
     }
     return phpbb::$template->assign_display('rate', '', true);
 }