Skip to content

Commit

Permalink
Merge branch 'textreparser' into 3.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Crizz0 committed Oct 4, 2019
2 parents 096cefe + 38b6cba commit f9bce2e
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
11 changes: 10 additions & 1 deletion config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,13 @@ services:
- %tables.notifications%
- %tables.user_notifications%
tags:
- { name: notification.type }
- { name: notification.type }
tas2580.wiki.text_reparser.article_text:
class: tas2580\wiki\textreparser\plugins\article_text
arguments:
- '@dbal.conn'
- '%tables.wiki.article%'
calls:
- [set_name, [tas2580_wiki_article]]
tags:
- { name: text_reparser.plugin}
56 changes: 56 additions & 0 deletions migrations/text_reparse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
*
* @package phpBB Extension - Wiki
* @copyright (c) 2016 tas2580 (https://tas2580.net)
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

namespace tas2580\wiki\migrations;

class text_reparse extends \phpbb\db\migration\container_aware_migration
{
public static function depends_on()
{
return array(
'\tas2580\wiki\migrations\update_0_3_3',
);
}

public function update_data()
{
return array(
array('custom', array(array($this, 'reparse'))),
);
}

/**
* Run the wiki article text reparser
*
* @param int $current A rule identifier
* @return bool|int A rule identifier or true if finished
*/
public function reparse($current = 0)
{
$reparser = new \tas2580\wiki\textreparser\plugins\article_text(
$this->db,
$this->container->getParameter('core.table_prefix') . 'wiki_article'
);

if (empty($current))
{
$current = $reparser->get_max_id();
}

$limit = 50;
$start = max(1, $current + 1 - $limit);
$end = max(1, $current);

$reparser->reparse_range($start, $end);

$current = $start - 1;

return ($current === 0) ? true : $current;
}
}
24 changes: 24 additions & 0 deletions textreparser/plugins/article_text.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
*
* Wiki extension for the phpBB Forum Software package.
*
* @copyright (c) 2019
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace tas2580\wiki\textreparser\plugins;
class article_text extends \phpbb\textreparser\row_based_plugin
{
/**
* {@inheritdoc}
*/
public function get_columns()
{
return array(
'id' => 'article_id',
'text' => 'article_text',
'bbcode_uid' => 'bbcode_uid',
);
}
}

0 comments on commit f9bce2e

Please sign in to comment.