Pastebin

bbcodepage_main.php

von Kirk (30.12.2025 17:33)
Beschreibung:
Seiten Pagination
Snippet erstellt:
30.12.2025 17:33
Snippet wird automatisch gelöscht:
28.02.2026 17:33

Dein Code:
  1. <?php
  2. /**
  3. *
  4. * @package BBcode Page Extension for the phpBB Forum Software package.
  5. * @copyright (c) 2017 - 2025 Kirk https://kirk-phpbb.com
  6. * @copyright (c) 2008 - 2012 Stoker http://www.phpbb3bbcodes.com
  7. * @copyright (c) 2007 nedka (Nguyen Dang Khoa)
  8. * @license GNU General Public License, version 2 (GPL-2.0-only)
  9. *
  10. */
  11.  
  12. namespace kirk\bbcodepage\controller;
  13.  
  14. /**
  15. * @ignore
  16. */
  17.  
  18. class bbcodepage_main
  19. {
  20.         protected $auth;
  21.         protected $config;
  22.         protected $language;
  23.         protected $helper;
  24.         protected $request;
  25.         protected $template;
  26.         protected $db;
  27.         protected $phpbb_root_path;
  28.         protected $php_ext;
  29.  
  30.         public function __construct(
  31.                 \phpbb\auth\auth $auth,
  32.                 \phpbb\config\config $config,
  33.                 \phpbb\language\language $language,
  34.                 \phpbb\request\request_interface $request,
  35.                 \phpbb\template\template $template,
  36.                 \phpbb\controller\helper $helper,
  37.                 \phpbb\db\driver\driver_interface $db,
  38.                 $pagination,
  39.                 $phpbb_root_path,
  40.                 $php_ext
  41.         )
  42.         {
  43.                 $this->auth                             = $auth;
  44.                 $this->config                   = $config;
  45.                 $this->language                 = $language;
  46.                 $this->request                  = $request;
  47.                 $this->template                 = $template;
  48.                 $this->helper                   = $helper;
  49.                 $this->db                               = $db;
  50.                 $this->pagination               = $pagination;
  51.                 $this->phpbb_root_path  = $phpbb_root_path;
  52.                 $this->php_ext                  = $php_ext;
  53.  
  54.                 // Variables for BBCode Page
  55.                 $this->bbcodes_per_page = !empty($this->config['bbcodes_per_page']) ? $this->config['bbcodes_per_page'] : $this->config['posts_per_page'];
  56.                 $this->pagination_url   = $helper->route('kirk_bbcodepage');
  57.         }
  58.  
  59.         /**
  60.         * Controller for route app.php/bbcodepage and /bbcodepage
  61.         *
  62.         * @return Symfony\Component\HttpFoundation\Response A Symfony Response object
  63.         */
  64.         public function base()
  65.         {
  66.                 $this->language->add_lang('bbcodepage', 'kirk/bbcodepage');
  67.                 // Can this user or Group view the BBCode page?
  68.                 $bbcp_redirect_index_page = !$this->auth->acl_gets('u_view_bbcodepage')
  69.                                                                         || !$this->config['allow_bbcode']
  70.                                                                         || !$this->config['bbcodepage_activated']
  71.                                                                         || $this->config['bbcodepage_adminmode']
  72.                                                                         && !$this->auth->acl_get('a_');
  73.                 if ($bbcp_redirect_index_page)
  74.                 {
  75.                         redirect(append_sid($this->phpbb_root_path . 'index.' . $this->php_ext));
  76.                 }
  77.  
  78.                 // How many bbcodes do we have?
  79.                 // Change "WHERE display_on_posting" to "WHERE bbcode_helpline" if you want to display the BBCodes only with help line.
  80.                 // Delete "WHERE display_on_posting != '' " or "WHERE bbcode_helpline != '' " if you want to display all BBCodes.
  81.                 $sql = 'SELECT COUNT(bbcode_helpline) AS total_bbcodes
  82.                                 FROM ' . BBCODES_TABLE . "
  83.                                 WHERE display_on_posting != ''
  84.                                 ORDER BY bbcode_tag ASC";
  85.                 $result = $this->db->sql_query($sql);
  86.                 $total_bbcodes = (int) $this->db->sql_fetchfield('total_bbcodes');
  87.                 $this->db->sql_freeresult($result);
  88.  
  89.                 $start = $this->request->variable('start', 0);
  90.                 // Grab BBCode tags details for display
  91.                 // Change "WHERE display_on_posting" to "WHERE bbcode_helpline" if you want to display the BBCodes only with help line.
  92.                 // Delete "WHERE display_on_posting != '' " or "WHERE bbcode_helpline != '' " if you want to display all BBCodes.
  93.                 $sql = 'SELECT bbcode_tag, bbcode_helpline, display_on_posting, bbcode_match, bbcode_tpl
  94.                                 FROM ' . BBCODES_TABLE . "
  95.                                 WHERE display_on_posting != ''
  96.                                 ORDER BY bbcode_tag ASC";
  97.                 $result = $this->db->sql_query_limit($sql, $this->bbcodes_per_page, $start);
  98.  
  99.                 while ($bbcodes_rowset = $this->db->sql_fetchrow($result))
  100.                 {
  101.                 // If the helpline is defined within the language file, we will use the localised version, else just use the database entry.
  102.                         $bbcodes_rowset['bbcode_helpline'] = $this->language->lang($bbcodes_rowset['bbcode_helpline']);
  103.                         $this->template->assign_block_vars('bbcodes', [
  104.                                 'BBCP_BBCODE_NAME'              => $bbcodes_rowset['bbcode_tag'],
  105.                                 'BBCP_BBCODE_HELPLINE'  => $bbcodes_rowset['bbcode_helpline'],
  106.                                 'BBCP_BBCODE_DISPLAY'   => $bbcodes_rowset['display_on_posting'],
  107.                                 'BBCP_BBCODE_USAGE'             => $bbcodes_rowset['bbcode_match'],
  108.                                 'BBCP_BBCODE_TPL'               => $bbcodes_rowset['bbcode_tpl']
  109.                         ]);
  110.                 }
  111.                 $this->db->sql_freeresult($result);
  112.  
  113.                 $bbcodes = $this->language->lang('BBCP_BBCODES_COUNT', $total_bbcodes);
  114.                 $this->pagination->generate_template_pagination = $this->helper->route('kirk_bbcodepage');
  115.  
  116.                 $this->template->assign_vars([
  117.                         'PAGINATION'            => $this->pagination->generate_template_pagination($this->pagination_url, 'pagination', 'start', $total_bbcodes, $this->bbcodes_per_page, $start),
  118.                         'PAGE_NUMBER'           => $this->pagination->on_page($total_bbcodes, $this->bbcodes_per_page, $start),
  119.                         'TOTAL_BBCODES'         => $bbcodes
  120.                 ]);
  121.  
  122.                 // Adding links to the breadcrumbs
  123.                 $this->template->assign_block_vars('navlinks', [
  124.                         'FORUM_NAME'                    => $this->language->lang('BBCP'),
  125.                         'U_VIEW_FORUM'                  => append_sid('bbcodepage')
  126.                 ]);
  127.  
  128.                 return $this->helper->render('bbcodepage.html', $this->language->lang('BBCP'));
  129.         }
  130.  
  131.         public function redirect()
  132.         {
  133.                 redirect($this->helper->route('kirk_bbcodepage'));
  134.         }
  135. }

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. Alternativ kannst du den gesamten Eintrag auch als Datei herunterladen.