aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/console/command/reparser/list_all.php69
-rw-r--r--phpBB/phpbb/console/command/reparser/reparse.php188
-rw-r--r--phpBB/phpbb/di/ordered_service_collection.php117
-rw-r--r--phpBB/phpbb/di/pass/collection_pass.php11
-rw-r--r--phpBB/phpbb/di/service_collection_iterator.php2
-rw-r--r--phpBB/phpbb/textformatter/s9e/factory.php2
-rw-r--r--phpBB/phpbb/textreparser/base.php25
-rw-r--r--phpBB/phpbb/textreparser/plugins/forum_description.php1
-rw-r--r--phpBB/phpbb/textreparser/plugins/forum_rules.php1
-rw-r--r--phpBB/phpbb/textreparser/plugins/group_description.php1
-rw-r--r--phpBB/phpbb/textreparser/plugins/poll_option.php2
-rw-r--r--phpBB/phpbb/textreparser/plugins/poll_title.php2
12 files changed, 409 insertions, 12 deletions
diff --git a/phpBB/phpbb/console/command/reparser/list_all.php b/phpBB/phpbb/console/command/reparser/list_all.php
new file mode 100644
index 0000000000..1589836ddd
--- /dev/null
+++ b/phpBB/phpbb/console/command/reparser/list_all.php
@@ -0,0 +1,69 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\console\command\reparser;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class list_all extends \phpbb\console\command\command
+{
+ /**
+ * @var string[] Names of the reparser services
+ */
+ protected $reparser_names;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\user $user
+ * @param \phpbb\di\service_collection $reparsers
+ */
+ public function __construct(\phpbb\user $user, \phpbb\di\service_collection $reparsers)
+ {
+ parent::__construct($user);
+ $this->reparser_names = array();
+ foreach ($reparsers as $name => $reparser)
+ {
+ // Store the names without the "text_reparser." prefix
+ $this->reparser_names[] = str_replace('text_reparser.', '', $name);
+ }
+ }
+
+ /**
+ * Sets the command name and description
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('reparser:list')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_REPARSER_LIST'))
+ ;
+ }
+
+ /**
+ * Executes the command reparser:reparse
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @return integer
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $output->writeln('<info>' . implode(', ', $this->reparser_names) . '</info>');
+
+ return 0;
+ }
+}
diff --git a/phpBB/phpbb/console/command/reparser/reparse.php b/phpBB/phpbb/console/command/reparser/reparse.php
new file mode 100644
index 0000000000..52075dd0ac
--- /dev/null
+++ b/phpBB/phpbb/console/command/reparser/reparse.php
@@ -0,0 +1,188 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\console\command\reparser;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+
+class reparse extends \phpbb\console\command\command
+{
+ /**
+ * @var \phpbb\di\service_collection
+ */
+ protected $reparsers;
+
+ /**
+ * @var SymfonyStyle
+ */
+ protected $io;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\user $user
+ * @param \phpbb\di\service_collection $reparser_collection
+ */
+ public function __construct(\phpbb\user $user, \phpbb\di\service_collection $reparsers)
+ {
+ require_once __DIR__ . '/../../../../includes/functions_content.php';
+
+ $this->reparsers = $reparsers;
+ parent::__construct($user);
+ }
+
+ /**
+ * Sets the command name and description
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('reparser:reparse')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE'))
+ ->addArgument('reparser-name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1'))
+ ->addOption(
+ 'range-min',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN'),
+ 1
+ )
+ ->addOption(
+ 'range-max',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX')
+ )
+ ->addOption(
+ 'range-size',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE'),
+ 100
+ );
+ ;
+ }
+
+ /**
+ * Executes the command reparser:reparse
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @return integer
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->io = new SymfonyStyle($input, $output);
+
+ $name = $input->getArgument('reparser-name');
+ if (isset($name))
+ {
+ // Allow "post_text" to be an alias for "text_reparser.post_text"
+ if (!isset($this->reparsers[$name]))
+ {
+ $name = 'text_reparser.' . $name;
+ }
+ $this->reparse($input, $output, $name);
+ }
+ else
+ {
+ foreach ($this->reparsers as $name => $service)
+ {
+ $this->reparse($input, $output, $name);
+ }
+ }
+
+ $this->io->success($this->user->lang('CLI_REPARSER_REPARSE_SUCCESS'));
+
+ return 0;
+ }
+
+ /**
+ * Reparse all text handled by given reparser within given range
+ *
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ * @param string $name Reparser name
+ * @return null
+ */
+ protected function reparse(InputInterface $input, OutputInterface $output, $name)
+ {
+ $reparser = $this->reparsers[$name];
+
+ // Start at range-max if specified or at the highest ID otherwise
+ $max = (is_null($input->getOption('range-max'))) ? $reparser->get_max_id() : $input->getOption('range-max');
+ $min = $input->getOption('range-min');
+ $size = $input->getOption('range-size');
+
+ if ($max === 0)
+ {
+ return;
+ }
+
+ $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $min, $max));
+
+ $progress = $this->io->createProgressBar($max);
+ if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE)
+ {
+ $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
+ $progress->setOverwrite(false);
+ }
+ else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE)
+ {
+ $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
+ $progress->setOverwrite(false);
+ }
+ else
+ {
+ $this->io->newLine(2);
+ $progress->setFormat(
+ " %current:s%/%max:s% %bar% %percent:3s%%\n" .
+ " %message% %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
+ $progress->setBarWidth(60);
+ }
+
+ $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', str_replace('text_reparser.', '', $name)));
+
+ if (!defined('PHP_WINDOWS_VERSION_BUILD'))
+ {
+ $progress->setEmptyBarCharacter('░'); // light shade character \u2591
+ $progress->setProgressCharacter('');
+ $progress->setBarCharacter('▓'); // dark shade character \u2593
+ }
+
+ $progress->start();
+
+ // Start from $max and decrement $current by $size until we reach $min
+ $current = $max;
+ while ($current >= $min)
+ {
+ $start = max($min, $current + 1 - $size);
+ $end = max($min, $current);
+
+ $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $start, $end));
+ $reparser->reparse_range($start, $end);
+
+ $current = $start - 1;
+ $progress->setProgress($max + 1 - $start);
+ }
+ $progress->finish();
+
+ $this->io->newLine(2);
+ }
+}
diff --git a/phpBB/phpbb/di/ordered_service_collection.php b/phpBB/phpbb/di/ordered_service_collection.php
new file mode 100644
index 0000000000..046012ae5b
--- /dev/null
+++ b/phpBB/phpbb/di/ordered_service_collection.php
@@ -0,0 +1,117 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\di;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Collection of services in a specified order
+ */
+class ordered_service_collection extends service_collection
+{
+ /**
+ * @var bool
+ */
+ protected $is_ordered;
+
+ /**
+ * @var array
+ */
+ protected $service_ids;
+
+ /**
+ * Constructor
+ *
+ * @param ContainerInterface $container Container object
+ */
+ public function __construct(ContainerInterface $container)
+ {
+ $this->is_ordered = false;
+ $this->service_ids = array();
+
+ parent::__construct($container);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIterator()
+ {
+ if (!$this->is_ordered)
+ {
+ $this->sort_services();
+ }
+
+ return new service_collection_iterator($this);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function offsetExists($index)
+ {
+ if (!$this->is_ordered)
+ {
+ $this->sort_services();
+ }
+
+ return parent::offsetExists($index);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function offsetGet($index)
+ {
+ if (!$this->is_ordered)
+ {
+ $this->sort_services();
+ }
+
+ return parent::offsetGet($index);
+ }
+
+ /**
+ * Adds a service ID to the collection
+ *
+ * @param string $service_id
+ * @param int $order
+ */
+ public function add($service_id, $order = 0)
+ {
+ $order = (int) $order;
+ $this->service_ids[$order][] = $service_id;
+ $this->is_ordered = false;
+ }
+
+ protected function sort_services()
+ {
+ if ($this->is_ordered)
+ {
+ return;
+ }
+
+ $this->exchangeArray(array());
+ ksort($this->service_ids);
+ foreach ($this->service_ids as $service_order_group)
+ {
+ foreach ($service_order_group as $service_id)
+ {
+ $this->offsetSet($service_id, null);
+ }
+ }
+
+ $this->is_ordered = true;
+ }
+}
diff --git a/phpBB/phpbb/di/pass/collection_pass.php b/phpBB/phpbb/di/pass/collection_pass.php
index a5c054674e..ccc1250c20 100644
--- a/phpBB/phpbb/di/pass/collection_pass.php
+++ b/phpBB/phpbb/di/pass/collection_pass.php
@@ -37,7 +37,16 @@ class collection_pass implements CompilerPassInterface
foreach ($container->findTaggedServiceIds($data[0]['tag']) as $service_id => $service_data)
{
- $definition->addMethodCall('add', array($service_id));
+ if (substr($definition->getClass(), -strlen('ordered_service_collection')) === 'ordered_service_collection')
+ {
+ $arguments = array($service_id, $service_data[0]['order']);
+ }
+ else
+ {
+ $arguments = array($service_id);
+ }
+
+ $definition->addMethodCall('add', $arguments);
}
}
}
diff --git a/phpBB/phpbb/di/service_collection_iterator.php b/phpBB/phpbb/di/service_collection_iterator.php
index 0d031ab52d..31bc156e99 100644
--- a/phpBB/phpbb/di/service_collection_iterator.php
+++ b/phpBB/phpbb/di/service_collection_iterator.php
@@ -32,7 +32,7 @@ class service_collection_iterator extends \ArrayIterator
*/
public function __construct(service_collection $collection, $flags = 0)
{
- parent::__construct($collection, $flags);
+ parent::__construct($collection->getArrayCopy(), $flags);
$this->collection = $collection;
}
diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php
index cd4e593fb1..2f6498197f 100644
--- a/phpBB/phpbb/textformatter/s9e/factory.php
+++ b/phpBB/phpbb/textformatter/s9e/factory.php
@@ -66,7 +66,7 @@ class factory implements \phpbb\textformatter\cache_interface
protected $default_definitions = array(
'attachment' => '[ATTACHMENT index={NUMBER} filename={TEXT;useContent}]',
'b' => '[B]{TEXT}[/B]',
- 'code' => '[CODE]{TEXT}[/CODE]',
+ 'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]',
'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]',
'email' => '[EMAIL={EMAIL;useContent} subject={TEXT;optional;postFilter=rawurlencode} body={TEXT;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]',
'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]',
diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php
index 87a4268d0d..ed6c2376c7 100644
--- a/phpBB/phpbb/textreparser/base.php
+++ b/phpBB/phpbb/textreparser/base.php
@@ -47,11 +47,22 @@ abstract class base implements reparser_interface
{
if (!isset($record['enable_bbcode'], $record['enable_smilies'], $record['enable_magic_url']))
{
- $record += array(
- 'enable_bbcode' => $this->guess_bbcodes($record),
- 'enable_smilies' => $this->guess_smilies($record),
- 'enable_magic_url' => $this->guess_magic_url($record),
- );
+ if (isset($record['options']))
+ {
+ $record += array(
+ 'enable_bbcode' => (bool) ($record['options'] & OPTION_FLAG_BBCODE),
+ 'enable_smilies' => (bool) ($record['options'] & OPTION_FLAG_SMILIES),
+ 'enable_magic_url' => (bool) ($record['options'] & OPTION_FLAG_LINKS),
+ );
+ }
+ else
+ {
+ $record += array(
+ 'enable_bbcode' => $this->guess_bbcodes($record),
+ 'enable_smilies' => $this->guess_smilies($record),
+ 'enable_magic_url' => $this->guess_magic_url($record),
+ );
+ }
}
// Those BBCodes are disabled based on context and user permissions and that value is never
@@ -92,7 +103,7 @@ abstract class base implements reparser_interface
}
}
- if (substr($record['text'], 0, 2) == '<r')
+ if (substr($record['text'], 0, 2) === '<r')
{
// Look for the closing tag inside of a e element, in an element of the same name, e.g.
// <e>[/url]</e></URL>
@@ -124,7 +135,7 @@ abstract class base implements reparser_interface
}
}
- if (substr($record['text'], 0, 2) == '<r')
+ if (substr($record['text'], 0, 2) === '<r')
{
// Look for a closing tag inside of an e element
return (bool) preg_match('(<e>\\[/\\w+\\]</e>)', $match);
diff --git a/phpBB/phpbb/textreparser/plugins/forum_description.php b/phpBB/phpbb/textreparser/plugins/forum_description.php
index 7798e4b20b..0302dc3082 100644
--- a/phpBB/phpbb/textreparser/plugins/forum_description.php
+++ b/phpBB/phpbb/textreparser/plugins/forum_description.php
@@ -24,6 +24,7 @@ class forum_description extends \phpbb\textreparser\row_based_plugin
'id' => 'forum_id',
'text' => 'forum_desc',
'bbcode_uid' => 'forum_desc_uid',
+ 'options' => 'forum_desc_options',
);
}
diff --git a/phpBB/phpbb/textreparser/plugins/forum_rules.php b/phpBB/phpbb/textreparser/plugins/forum_rules.php
index 57c666a556..ce550225f2 100644
--- a/phpBB/phpbb/textreparser/plugins/forum_rules.php
+++ b/phpBB/phpbb/textreparser/plugins/forum_rules.php
@@ -24,6 +24,7 @@ class forum_rules extends \phpbb\textreparser\row_based_plugin
'id' => 'forum_id',
'text' => 'forum_rules',
'bbcode_uid' => 'forum_rules_uid',
+ 'options' => 'forum_rules_options',
);
}
diff --git a/phpBB/phpbb/textreparser/plugins/group_description.php b/phpBB/phpbb/textreparser/plugins/group_description.php
index ddd0e1d1c5..3346ccf25e 100644
--- a/phpBB/phpbb/textreparser/plugins/group_description.php
+++ b/phpBB/phpbb/textreparser/plugins/group_description.php
@@ -24,6 +24,7 @@ class group_description extends \phpbb\textreparser\row_based_plugin
'id' => 'group_id',
'text' => 'group_desc',
'bbcode_uid' => 'group_desc_uid',
+ 'options' => 'group_desc_options',
);
}
diff --git a/phpBB/phpbb/textreparser/plugins/poll_option.php b/phpBB/phpbb/textreparser/plugins/poll_option.php
index 7b803146c4..44cacfae62 100644
--- a/phpBB/phpbb/textreparser/plugins/poll_option.php
+++ b/phpBB/phpbb/textreparser/plugins/poll_option.php
@@ -48,7 +48,7 @@ class poll_option extends \phpbb\textreparser\base
*/
protected function get_records_by_range($min_id, $max_id)
{
- $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.bbcode_uid
+ $sql = 'SELECT o.topic_id, o.poll_option_id, o.poll_option_text AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid
FROM ' . POLL_OPTIONS_TABLE . ' o, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE o.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .'
AND t.topic_id = o.topic_id
diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php
index b447004527..038ae0c366 100644
--- a/phpBB/phpbb/textreparser/plugins/poll_title.php
+++ b/phpBB/phpbb/textreparser/plugins/poll_title.php
@@ -31,7 +31,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin
*/
protected function get_records_by_range_query($min_id, $max_id)
{
- $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.bbcode_uid
+ $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid
FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
WHERE t.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .'
AND t.poll_max_options > 0