[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/db/migration/data/v31x/ -> update_custom_bbcodes_with_idn.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\db\migration\data\v31x;
  15  
  16  class update_custom_bbcodes_with_idn extends \phpbb\db\migration\migration
  17  {
  18  	static public function depends_on()
  19      {
  20          return array(
  21              '\phpbb\db\migration\data\v31x\v312',
  22          );
  23      }
  24  
  25  	public function update_data()
  26      {
  27          return array(
  28              array('custom', array(array($this, 'update_bbcodes_table'))),
  29          );
  30      }
  31  
  32  	public function update_bbcodes_table()
  33      {
  34          if (!class_exists('acp_bbcodes'))
  35          {
  36              include($this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext);
  37          }
  38  
  39          $bbcodes = new \acp_bbcodes();
  40  
  41          $sql = 'SELECT bbcode_id, bbcode_match, bbcode_tpl
  42              FROM ' . BBCODES_TABLE;
  43          $result = $this->sql_query($sql);
  44  
  45          $sql_ary = array();
  46          while ($row = $this->db->sql_fetchrow($result))
  47          {
  48              $data = array();
  49              if (preg_match('/(URL|LOCAL_URL|RELATIVE_URL)/', $row['bbcode_match']))
  50              {
  51                  $data = $bbcodes->build_regexp($row['bbcode_match'], $row['bbcode_tpl']);
  52                  $sql_ary[$row['bbcode_id']] = array(
  53                      'first_pass_match'            => $data['first_pass_match'],
  54                      'first_pass_replace'        => $data['first_pass_replace'],
  55                      'second_pass_match'            => $data['second_pass_match'],
  56                      'second_pass_replace'        => $data['second_pass_replace']
  57                  );
  58              }
  59          }
  60          $this->db->sql_freeresult($result);
  61  
  62          foreach ($sql_ary as $bbcode_id => $bbcode_data)
  63          {
  64              $sql = 'UPDATE ' . BBCODES_TABLE . '
  65                  SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . '
  66                  WHERE bbcode_id = ' . (int) $bbcode_id;
  67              $this->sql_query($sql);
  68          }
  69      }
  70  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1