Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IMC-GER committed Dec 26, 2022
1 parent 41c3815 commit 9f22c6f
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 50 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -25,6 +25,12 @@ Go to "ACP" > "Extension" > "Curly Quotes Settings" and set the quote style for

## Changelog

### v1.1.0 (26-12-2022)
- Added suport for coordinates and length specifications ft./in.
- Added replace quotes in preview
- Changed PHP max to v8.2
- Update check system requirement

### v1.0.3 (02-10-2022)
- Fixed don't show attachment in post

Expand Down
4 changes: 2 additions & 2 deletions curlyquotes_version.json
@@ -1,7 +1,7 @@
{
"stable": {
"1.0": {
"current": "1.0.3",
"1.1": {
"current": "1.1.0",
"announcement": "https://www.phpbb.de/community/viewtopic.php?t=246397",
"download": "https://github.com/IMC-GER/phpBB-Curly-Quotes/tags",
"eol": null,
Expand Down
6 changes: 6 additions & 0 deletions imcger/curlyquotes/README.md
Expand Up @@ -25,6 +25,12 @@ Go to "ACP" > "Extension" > "Curly Quotes Settings" and set the quote style for

## Changelog

### v1.1.0 (26-12-2022)
- Added suport for coordinates and length specifications ft./in.
- Added replace quotes in preview
- Changed PHP max to v8.2
- Update check system requirement

### v1.0.3 (02-10-2022)
- Fixed don't show attachment in post

Expand Down
4 changes: 2 additions & 2 deletions imcger/curlyquotes/composer.json
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Replaces quotation marks with curly quotes.",
"homepage": "https://github.com/IMC-GER/phpBB-Curly-Quotes",
"version": "1.0.3",
"time": "2022-10-02",
"version": "1.1.0",
"time": "2022-12-26",
"license": "GPL-2.0-only",
"authors": [{
"name": "Thorsten Ahlers",
Expand Down
56 changes: 32 additions & 24 deletions imcger/curlyquotes/core/fixer.php
Expand Up @@ -6,6 +6,8 @@
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*
* Copyright (c) 2022, Customizations for phpBB by Thorsten Ahlers
*
* https://en.wikipedia.org/wiki/Quotation_mark
* https://www.virtualsystem.de/browsersprachen/
*/
Expand All @@ -21,26 +23,26 @@ class fixer
public const ALL_SPACES = "\xE2\x80\xAF|\xC2\xAD|\xC2\xA0|\\s"; // All supported spaces, used in regexps. Better than \s
public const NO_BREAK_THIN_SPACE = "\xE2\x80\xAF"; //  
public const NO_BREAK_SPACE = "\xC2\xA0"; //  
public const SHY = "\xC2\xAD"; // ­
public const ELLIPSIS = '…'; // …
public const LDQUO = '“'; // “ or “
public const RDQUO = '”'; // ” or ”
public const BDQUO = '„'; // „ or „
public const LSQUO = '‘'; // ‘
public const RSQUO = '’'; // ’
public const SBQUO = '‚'; // ‚
public const LAQUO = '«'; // «
public const RAQUO = '»'; // »
public const LSAQUO = '‹'; // ‹
public const RSAQUO = '›'; // ›
public const PRIME = '″'; // ″
public const SPRIME = '′'; // ′
public const TIMES = '×'; // ×
public const NDASH = '–'; // – or –
public const MDASH = '—'; // — or —
public const TRADE = '™'; // ™
public const REG = '®'; // ®
public const COPY = '©'; // ©
public const SHY = "\xC2\xAD"; // ­
public const ELLIPSIS = '…'; // …
public const LDQUO = '“'; // “ or “
public const RDQUO = '”'; // ” or ”
public const BDQUO = '„'; // „ or „
public const LSQUO = '‘'; // ‘
public const RSQUO = '’'; // ’
public const SBQUO = '‚'; // ‚
public const LAQUO = '«'; // «
public const RAQUO = '»'; // »
public const LSAQUO = '‹'; // ‹
public const RSAQUO = '›'; // ›
public const PRIME = '″'; // ″
public const SPRIME = '′'; // ′
public const TIMES = '×'; // ×
public const NDASH = '–'; // – or –
public const MDASH = '—'; // — or —
public const TRADE = '™'; // ™
public const REG = '®'; // ®
public const COPY = '©'; // ©

protected $dopening;
protected $dclosing;
Expand All @@ -60,13 +62,19 @@ public function fix($content, $set_prime)
}

$pattern = [
'@([a-z0-9])\'([a-z])@im', // Apostrophe
'@(^|\s|\>|\()"([^"^\<]+)"@im', // Double Quotes
'@(^|\s|\>|\()\'([^\'^\<]+)\'@im', // Single Quotes
'@([^\d\s]+)[' . self::ALL_SPACES . ']*(,)[' . self::ALL_SPACES . ']*@mu', // No space before comma (,)
'@(\d+\°)[' . self::ALL_SPACES . ']{0,1}(\d+)\'[' . self::ALL_SPACES . ']{0,1}((\d{1,2})|(\d{1,2}[.,]\d+))"@im', // GPS Koordinaten ddd mm ss.ss
'@(\d+\°)[' . self::ALL_SPACES . ']{0,1}((\d{1,2})|(\d{1,2}[.,]\d+))\'@im', // GPS Koordinaten ddd mm.mmm
'@(\d+)\'[' . self::ALL_SPACES . ']{0,1}((\d{1,2})|(\d{1,2}[.,]\d+))"@im', // Dimension in inches
'@([a-z0-9])\'([a-z])@im', // Apostrophe
'@(^|\s|\>|\()"([^"^\<]+)"@im', // Double Quotes
'@(^|\s|\>|\()\'([^\'^\<]+)\'@im', // Single Quotes
'@([^\d\s]+)[' . self::ALL_SPACES . ']*(,)[' . self::ALL_SPACES . ']*@mu', // No space before comma (,)
];

$replacement = [
'$1' . self::NO_BREAK_THIN_SPACE . '$2' . self::SPRIME . self::NO_BREAK_THIN_SPACE . '$3' . self::PRIME,
'$1' . self::NO_BREAK_THIN_SPACE . '$2' . self::SPRIME,
'$1' . self::SPRIME . self::NO_BREAK_THIN_SPACE . '$2' . self::PRIME,
'$1' . self::RSQUO . '$2',
'$1' . $this->dopening . $this->dopeningSuffix . '$2' . $this->dclosingPrefix . $this->dclosing,
'$1' . $this->sopening . $this->sopeningSuffix . '$2' . $this->sclosingPrefix . $this->sclosing,
Expand Down
6 changes: 4 additions & 2 deletions imcger/curlyquotes/event/main_listener.php
Expand Up @@ -92,18 +92,20 @@ public function __construct
public static function getSubscribedEvents()
{
return [
'core.modify_text_for_display_before' => 'modify_text_for_display_before',
'core.modify_text_for_display_before' => 'modify_text_for_display', // Fix in post
'core.modify_format_display_text_before' => 'modify_text_for_display', // Fix in preview
];
}

/**
* Fix the quotes before display in post
* Fix the quotes before display in preview
*
* @param object $event The event object
* @return null
* @access public
*/
public function modify_text_for_display_before($event)
public function modify_text_for_display($event)
{
$post_text = $event['text'];

Expand Down
46 changes: 32 additions & 14 deletions imcger/curlyquotes/ext.php
Expand Up @@ -16,37 +16,55 @@
*/
class ext extends \phpbb\extension\base
{
/** @var Extension name */
protected $ext_name = 'curlyquotes';

/** @var min phpBB version */
protected $phpbb_min_version = '3.2.0';

/** @var max phpBB version (>= query) */
protected $phpbb_max_version = '4.0.0';

/** @var min PHP version */
protected $php_min_version = '5.4.7';

/** @var max PHP version (>= query) */
protected $php_max_version = '8.3.0';

/**
* Check the minimum and maximum requirements.
*
* @return bool|string|array A error message
*/
public function is_enableable()
{
$config = $this->container->get('config');

/* If phpBB version 3.1 or less cancel */
if (phpbb_version_compare($config['version'], '3.2.0', '<'))
if (phpbb_version_compare(PHPBB_VERSION, '3.2.0', '<'))
{
return false;
}

$language = $this->container->get('language');
$language->add_lang('info_acp_curlyquotes', 'imcger/curlyquotes');
$language->add_lang('info_acp_'. $this->ext_name, 'imcger/'. $this->ext_name);
$error_message = [];

/* phpBB version greater equal 3.2.0 and less then 4.0 */
if (phpbb_version_compare($config['version'], '3.2.0', '<') || phpbb_version_compare($config['version'], '4.0.0', '>='))
/* phpBB version greater equal $phpbb_min_version and less then $phpbb_max_version */
if (phpbb_version_compare(PHPBB_VERSION, $this->phpbb_min_version, '<') || phpbb_version_compare(PHPBB_VERSION, $this->phpbb_max_version, '>='))
{
$error_message += ['error1' => $language->lang('IMCGER_REQUIRE_PHPBB'),];
$error_message += ['error1' => $language->lang('IMCGER_REQUIRE_PHPBB', $this->phpbb_min_version, $this->phpbb_max_version, PHPBB_VERSION),];
}

/* php version equal or greater 5.4.7 and less 8.2 */
if (version_compare(PHP_VERSION, '8.0', '<') || version_compare(PHP_VERSION, '8.2', '>='))
/* php version equal or greater $php_min_version and less $php_max_version */
if (version_compare(PHP_VERSION, $this->php_min_version, '<') || version_compare(PHP_VERSION, $this->php_max_version, '>='))
{
$error_message += ['error2' => $language->lang('IMCGER_REQUIRE_PHP'),];
$error_message += ['error2' => $language->lang('IMCGER_REQUIRE_PHP', $this->php_min_version, $this->php_max_version, PHP_VERSION),];
}

/* When phpBB older then 3.3.0 use trigger_error() for message output */
if (phpbb_version_compare($config['version'], '3.3.0', '<') && !empty($error_message))
/* When phpBB v3.2 use trigger_error() for message output. For v3.1 return false. */
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0', '<') && !empty($error_message))
{
$error_message = implode('<br>', $error_message);
trigger_error($error_message, E_USER_WARNING);
$message = implode('<br>', $error_message);
trigger_error($message, E_USER_WARNING);
}

return empty($error_message) ? true : $error_message;
Expand Down
4 changes: 2 additions & 2 deletions imcger/curlyquotes/language/de/info_acp_curlyquotes.php
Expand Up @@ -43,6 +43,6 @@
'ACP_CURLYQUOTES_SETTINGS' => 'Einstellungen',
'ACP_CURLYQUOTES_SETTING_SAVED' => 'Curly Quotes Einstellungen erfolgreich gespeichert.',

'IMCGER_REQUIRE_PHPBB' => 'Diese Erweiterung benötigt eine phpBB Version gleich oder grösser 3.2.0 und kleiner 4.0.0',
'IMCGER_REQUIRE_PHP' => 'Diese Erweiterung benötigt eine php Version gleich oder grösser 8.0 und kleiner 8.2.',
'IMCGER_REQUIRE_PHPBB' => 'Diese Erweiterung benötigt eine phpBB Version gleich oder grösser %1$s und kleiner %2$s. Deine Version ist %3$s.',
'IMCGER_REQUIRE_PHP' => 'Diese Erweiterung benötigt eine php Version gleich oder grösser %1$s und kleiner %2$s. Deine Version ist %3$s.',
]);
4 changes: 2 additions & 2 deletions imcger/curlyquotes/language/de_x_sie/info_acp_curlyquotes.php
Expand Up @@ -43,6 +43,6 @@
'ACP_CURLYQUOTES_SETTINGS' => 'Einstellungen',
'ACP_CURLYQUOTES_SETTING_SAVED' => 'Curly Quotes Einstellungen erfolgreich gespeichert.',

'IMCGER_REQUIRE_PHPBB' => 'Diese Erweiterung benötigt eine phpBB Version gleich oder grösser 3.2.0 und kleiner 4.0.0',
'IMCGER_REQUIRE_PHP' => 'Diese Erweiterung benötigt eine php Version gleich oder grösser 8.0 und kleiner 8.2.',
'IMCGER_REQUIRE_PHPBB' => 'Diese Erweiterung benötigt eine phpBB Version gleich oder grösser %1$s und kleiner %2$s. Deine Version ist %3$s.',
'IMCGER_REQUIRE_PHP' => 'Diese Erweiterung benötigt eine php Version gleich oder grösser %1$s und kleiner %2$s. Deine Version ist %3$s.',
]);
4 changes: 2 additions & 2 deletions imcger/curlyquotes/language/en/info_acp_curlyquotes.php
Expand Up @@ -43,6 +43,6 @@
'ACP_CURLYQUOTES_SETTINGS' => 'Settings',
'ACP_CURLYQUOTES_SETTING_SAVED' => 'Curly Quotes settings saved successfully.',

'IMCGER_REQUIRE_PHPBB' => 'This extension requires a phpBB version greater or equal than 3.2.0 and less than 4.0.0',
'IMCGER_REQUIRE_PHP' => 'This extension requires a php version greater or equal than 8.0 and less than 8.2.',
'IMCGER_REQUIRE_PHPBB' => 'This extension requires a phpBB version greater or equal than %1$s and less than %2$s. Your version is %3$s.',
'IMCGER_REQUIRE_PHP' => 'This extension requires a php version greater or equal than %1$s and less than %2$s. Your version is %3$s.',
]);

0 comments on commit 9f22c6f

Please sign in to comment.