Skip to content

Commit f9bce2e

Browse files
committed
Merge branch 'textreparser' into 3.2.x
2 parents 096cefe + 38b6cba commit f9bce2e

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed

config/services.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,13 @@ services:
109109
- %tables.notifications%
110110
- %tables.user_notifications%
111111
tags:
112-
- { name: notification.type }
112+
- { name: notification.type }
113+
tas2580.wiki.text_reparser.article_text:
114+
class: tas2580\wiki\textreparser\plugins\article_text
115+
arguments:
116+
- '@dbal.conn'
117+
- '%tables.wiki.article%'
118+
calls:
119+
- [set_name, [tas2580_wiki_article]]
120+
tags:
121+
- { name: text_reparser.plugin}

migrations/text_reparse.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Wiki
5+
* @copyright (c) 2016 tas2580 (https://tas2580.net)
6+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7+
*
8+
*/
9+
10+
namespace tas2580\wiki\migrations;
11+
12+
class text_reparse extends \phpbb\db\migration\container_aware_migration
13+
{
14+
public static function depends_on()
15+
{
16+
return array(
17+
'\tas2580\wiki\migrations\update_0_3_3',
18+
);
19+
}
20+
21+
public function update_data()
22+
{
23+
return array(
24+
array('custom', array(array($this, 'reparse'))),
25+
);
26+
}
27+
28+
/**
29+
* Run the wiki article text reparser
30+
*
31+
* @param int $current A rule identifier
32+
* @return bool|int A rule identifier or true if finished
33+
*/
34+
public function reparse($current = 0)
35+
{
36+
$reparser = new \tas2580\wiki\textreparser\plugins\article_text(
37+
$this->db,
38+
$this->container->getParameter('core.table_prefix') . 'wiki_article'
39+
);
40+
41+
if (empty($current))
42+
{
43+
$current = $reparser->get_max_id();
44+
}
45+
46+
$limit = 50;
47+
$start = max(1, $current + 1 - $limit);
48+
$end = max(1, $current);
49+
50+
$reparser->reparse_range($start, $end);
51+
52+
$current = $start - 1;
53+
54+
return ($current === 0) ? true : $current;
55+
}
56+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
*
4+
* Wiki extension for the phpBB Forum Software package.
5+
*
6+
* @copyright (c) 2019
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
*/
10+
namespace tas2580\wiki\textreparser\plugins;
11+
class article_text extends \phpbb\textreparser\row_based_plugin
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public function get_columns()
17+
{
18+
return array(
19+
'id' => 'article_id',
20+
'text' => 'article_text',
21+
'bbcode_uid' => 'bbcode_uid',
22+
);
23+
}
24+
}

0 commit comments

Comments
 (0)