Merge pull request #247 from marc1706/ticket/246
[ticket/246] Add spellchecker for common misspellings to develop folder
This commit is contained in:
@@ -18,7 +18,6 @@ before_script:
|
|||||||
# checkout phpBB and move your extension in place
|
# checkout phpBB and move your extension in place
|
||||||
- cd ../../
|
- cd ../../
|
||||||
- git clone "git://github.com/phpbb/phpbb3.git" "phpBB3"
|
- git clone "git://github.com/phpbb/phpbb3.git" "phpBB3"
|
||||||
- mkdir phpBB3/phpBB/ext
|
|
||||||
- mkdir phpBB3/phpBB/ext/board3
|
- mkdir phpBB3/phpBB/ext/board3
|
||||||
- find -type d -name "Board3-Portal" -print | xargs -i mv {} phpBB3/phpBB/ext/board3/portal
|
- find -type d -name "Board3-Portal" -print | xargs -i mv {} phpBB3/phpBB/ext/board3/portal
|
||||||
|
|
||||||
@@ -41,6 +40,7 @@ script:
|
|||||||
- cd ../../../../build
|
- cd ../../../../build
|
||||||
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' ]; then ../phpBB/vendor/bin/phing sniff; fi"
|
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' ]; then ../phpBB/vendor/bin/phing sniff; fi"
|
||||||
- cd ../phpBB/ext/board3/portal
|
- cd ../phpBB/ext/board3/portal
|
||||||
|
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' -a '$DB' = 'mysql' ]; then php develop/spellchecker.php; fi"
|
||||||
- ../../../vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml
|
- ../../../vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class main
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not try to load non-existant modules
|
// Do not try to load non-existent modules
|
||||||
if (!isset($this->modules[$row['module_classname']]))
|
if (!isset($this->modules[$row['module_classname']]))
|
||||||
{
|
{
|
||||||
if (file_exists("{$this->includes_path}modules/portal_{$row['module_classname']}{$this->php_ext}"))
|
if (file_exists("{$this->includes_path}modules/portal_{$row['module_classname']}{$this->php_ext}"))
|
||||||
|
|||||||
4256
develop/misspellings.json
Normal file
4256
develop/misspellings.json
Normal file
File diff suppressed because it is too large
Load Diff
1898
develop/misspellings_de.json
Normal file
1898
develop/misspellings_de.json
Normal file
File diff suppressed because it is too large
Load Diff
118
develop/spellchecker.php
Normal file
118
develop/spellchecker.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package phpBB3
|
||||||
|
* @copyright (c) 2006 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
* This file creates new schema files for every database.
|
||||||
|
* The filenames will be prefixed with an underscore to not overwrite the current schema files.
|
||||||
|
*
|
||||||
|
* If you overwrite the original schema files please make sure you save the file with UNIX linefeeds.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$root_path = dirname(__FILE__) . '/../';
|
||||||
|
|
||||||
|
$spellings = json_decode(file_get_contents($root_path . 'develop/misspellings.json'), true);
|
||||||
|
$spellings_de = json_decode(file_get_contents($root_path . 'develop/misspellings_de.json'), true);
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
// Cycle through all files
|
||||||
|
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root_path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS), \RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
foreach ($iterator as $file_info)
|
||||||
|
{
|
||||||
|
$file_path = $file_info->getPath();
|
||||||
|
$file = $file_info->getFilename();
|
||||||
|
if ($file === 'spellchecker.php')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($file_path . '/' . $file) && preg_match('/.+\.(?:(php))$/', $file))
|
||||||
|
{
|
||||||
|
$content = file_get_contents($file_path . '/' . $file);
|
||||||
|
if (!empty($content))
|
||||||
|
{
|
||||||
|
// English files and php files
|
||||||
|
if (!preg_match('/(?:(\/language\/de))/', $file_path))
|
||||||
|
{
|
||||||
|
$found_misspellings = array();
|
||||||
|
foreach ($spellings as $misspell => $correct)
|
||||||
|
{
|
||||||
|
if (preg_match('/\b(?:(' . $misspell . '))\b/', $content) != false)
|
||||||
|
{
|
||||||
|
//$output .= "Found misspelling \"$misspell\" in $file<br />Should probably be: $correct<br /><br />";
|
||||||
|
$found_misspellings[$misspell] = $correct;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($found_misspellings))
|
||||||
|
{
|
||||||
|
$lines = file($file_path . '/' . $file);
|
||||||
|
|
||||||
|
foreach ($spellings as $misspell => $correct)
|
||||||
|
{
|
||||||
|
if (!isset($found_misspellings[$misspell]))
|
||||||
|
{
|
||||||
|
$continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($lines as $line_no => $line)
|
||||||
|
{
|
||||||
|
if (preg_match('/\b(?:(' . $misspell . '))\b/', $line) != false)
|
||||||
|
{
|
||||||
|
$output .= "Found misspelling \"$misspell\" in " . realpath($file_path) . "/$file at Line $line_no<br />Should probably be: $correct<br /><br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$found_misspellings = array();
|
||||||
|
foreach ($spellings_de as $misspell => $correct)
|
||||||
|
{
|
||||||
|
if (preg_match('/\b(?:(' . $misspell . '))\b/', $content) != false)
|
||||||
|
{
|
||||||
|
//$output .= "Found misspelling \"$misspell\" in $file<br />Should probably be: $correct<br /><br />";
|
||||||
|
$found_misspellings[$misspell] = $correct;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($found_misspellings))
|
||||||
|
{
|
||||||
|
$lines = file($file_path . '/' . $file);
|
||||||
|
|
||||||
|
foreach ($spellings_de as $misspell => $correct)
|
||||||
|
{
|
||||||
|
if (!isset($found_misspellings[$misspell]))
|
||||||
|
{
|
||||||
|
$continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($lines as $line_no => $line)
|
||||||
|
{
|
||||||
|
if (preg_match('/\b(?:(' . $misspell . '))\b/', $line) != false)
|
||||||
|
{
|
||||||
|
$output .= "Found misspelling \"$misspell\" in " . realpath($file_path) . "/$file at Line $line_no<br />Should probably be: $correct<br /><br />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PHP_SAPI == 'cli')
|
||||||
|
{
|
||||||
|
$output = str_replace('<br />', "\n", $output);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $output;
|
||||||
|
|
||||||
|
// Exit with 1 if script encountered issues
|
||||||
|
if (strlen($output) > 0)
|
||||||
|
{
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
6
ext.php
6
ext.php
@@ -2,14 +2,12 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package Board3 Portal v2.1
|
* @package Board3 Portal v2.1
|
||||||
* @copyright (c) 2013 Board3 Group ( www.board3.de )
|
* @copyright (c) 2014 Board3 Group ( www.board3.de )
|
||||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// this file is not really needed, when empty it can be ommitted
|
// This file is needed for phpBB3 to properly register the extension
|
||||||
// however you can override the default methods and add custom
|
|
||||||
// installation logic
|
|
||||||
|
|
||||||
namespace board3\portal;
|
namespace board3\portal;
|
||||||
|
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ function generate_portal_pagination($base_url, $num_items, $per_page, $start_ite
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// this shouldn't happend @todo: use trigger_error()
|
// this shouldn't happen but default to announcements
|
||||||
$pagination_type = 'ap';
|
$pagination_type = 'ap';
|
||||||
$anker = '#a';
|
$anker = '#a';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ class portal_upload
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Michal Nazarewicz (from the php manual)
|
* @author Michal Nazarewicz (from the php manual)
|
||||||
* Creates all non-existant directories in a path
|
* Creates all non-existent directories in a path
|
||||||
* @param $path - path to create
|
* @param $path - path to create
|
||||||
* @param $mode - CHMOD the new dir to these permissions
|
* @param $mode - CHMOD the new dir to these permissions
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ class phpbb_trim_message_bbcodes
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the length of the content (substract code for smilie and url parsing)
|
* Get the length of the content (subtract code for smilie and url parsing)
|
||||||
*
|
*
|
||||||
* @param string $content Message to get the content length from
|
* @param string $content Message to get the content length from
|
||||||
* Exp: <markup>text<markup2>
|
* Exp: <markup>text<markup2>
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ $lang = array_merge($lang, array(
|
|||||||
|
|
||||||
'LINK_ADDED' => 'Der Link wurde erfolgreich eingetragen',
|
'LINK_ADDED' => 'Der Link wurde erfolgreich eingetragen',
|
||||||
'LINK_UPDATED' => 'Der Link wurde erfolgreich geändert',
|
'LINK_UPDATED' => 'Der Link wurde erfolgreich geändert',
|
||||||
'LOG_PORTAL_LINK_ADDED' => '<strong>Portal-Einstellungen geändert</strong><br />» Link hinzu gefügt: %s ',
|
'LOG_PORTAL_LINK_ADDED' => '<strong>Portal-Einstellungen geändert</strong><br />» Link hinzugefügt: %s ',
|
||||||
'LOG_PORTAL_LINK_UPDATED' => '<strong>Portal-Einstellungen geändert</strong><br />» Link geändert: %s ',
|
'LOG_PORTAL_LINK_UPDATED' => '<strong>Portal-Einstellungen geändert</strong><br />» Link geändert: %s ',
|
||||||
'LOG_PORTAL_LINK_REMOVED' => '<strong>Portal-Einstellungen geändert</strong><br />» Link gelöscht: %s ',
|
'LOG_PORTAL_LINK_REMOVED' => '<strong>Portal-Einstellungen geändert</strong><br />» Link gelöscht: %s ',
|
||||||
'LOG_PORTAL_EVENT_ADDED' => '<strong>Portal-Einstellungen geändert</strong><br />» Termin eingetragen: %s ',
|
'LOG_PORTAL_EVENT_ADDED' => '<strong>Portal-Einstellungen geändert</strong><br />» Termin eingetragen: %s ',
|
||||||
|
|||||||
Reference in New Issue
Block a user