move language detection to a plugin, remove config.php constant
parent
724e08f1c0
commit
3318d32410
@ -1,3 +1,3 @@
|
|||||||
<?php # This file has been generated at: Tue Feb 3 14:45:46 MSK 2015
|
<?php # This file has been generated at: Fri, Jun 19, 2015 10:11:43 AM
|
||||||
define('GENERATED_CONFIG_CHECK', 26);
|
define('GENERATED_CONFIG_CHECK', 26);
|
||||||
$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'FEED_CRYPT_KEY', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_SERVER', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'SMTP_SECURE', 'CHECK_FOR_UPDATES', 'DETECT_ARTICLE_LANGUAGE', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?>
|
$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MYSQL_CHARSET', 'SELF_URL_PATH', 'FEED_CRYPT_KEY', 'SINGLE_USER_MODE', 'SIMPLE_UPDATE_MODE', 'PHP_EXECUTABLE', 'LOCK_DIRECTORY', 'CACHE_DIR', 'ICONS_DIR', 'ICONS_URL', 'AUTH_AUTO_CREATE', 'AUTH_AUTO_LOGIN', 'FORCE_ARTICLE_PURGE', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'SPHINX_SERVER', 'SPHINX_INDEX', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'SESSION_COOKIE_LIFETIME', 'SESSION_CHECK_ADDRESS', 'SMTP_FROM_NAME', 'SMTP_FROM_ADDRESS', 'DIGEST_SUBJECT', 'SMTP_SERVER', 'SMTP_LOGIN', 'SMTP_PASSWORD', 'SMTP_SECURE', 'CHECK_FOR_UPDATES', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?>
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
class Af_Lang_Detect extends Plugin {
|
||||||
|
private $host;
|
||||||
|
private $lang;
|
||||||
|
|
||||||
|
function about() {
|
||||||
|
return array(1.0,
|
||||||
|
"Detect article language",
|
||||||
|
"fox");
|
||||||
|
}
|
||||||
|
|
||||||
|
function init($host) {
|
||||||
|
$this->host = $host;
|
||||||
|
|
||||||
|
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
|
||||||
|
|
||||||
|
require_once __DIR__ . "/languagedetect/LanguageDetect.php";
|
||||||
|
|
||||||
|
$this->lang = new Text_LanguageDetect();
|
||||||
|
$this->lang->setNameMode(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hook_article_filter($article) {
|
||||||
|
|
||||||
|
if ($this->lang) {
|
||||||
|
$entry_language = $this->lang->detect($article['title'] . " " . $article['content'], 1);
|
||||||
|
|
||||||
|
if (count($entry_language) > 0) {
|
||||||
|
$possible = array_keys($entry_language);
|
||||||
|
$entry_language = $possible[0];
|
||||||
|
|
||||||
|
_debug("detected language: $entry_language");
|
||||||
|
|
||||||
|
$article["language"] = $entry_language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $article;
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_version() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue