From 5ddd2705ca0c2729d4a5a6e37b6df8ad8b67379d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 27 Sep 2013 13:45:21 +0400 Subject: [PATCH] make language detection optional (closes #779) --- config.php-dist | 6 ++++++ include/rssfuncs.php | 24 ++++++++++++++---------- include/sanity_config.php | 4 ++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/config.php-dist b/config.php-dist index ec4fb8411..789ac95ba 100644 --- a/config.php-dist +++ b/config.php-dist @@ -184,6 +184,12 @@ define('CHECK_FOR_NEW_VERSION', true); // Check for new versions of tt-rss automatically. + define('DETECT_ARTICLE_LANGUAGE', true); + // Detect article language when updating feeds, presently this is only + // used for hyphenation. This may increase amount of CPU time used by + // update processes, disable if necessary (i.e. you are being billed + // for CPU time). + define('ENABLE_GZIP_OUTPUT', false); // Selectively gzip output to improve wire performance. This requires // PHP Zlib extension on the server. diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 6d067065e..13d6baeab 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -356,10 +356,12 @@ $rss->init(); } - require_once "lib/languagedetect/LanguageDetect.php"; + if (DETECT_ARTICLE_LANGUAGE) { + require_once "lib/languagedetect/LanguageDetect.php"; - $lang = new Text_LanguageDetect(); - $lang->setNameMode(2); + $lang = new Text_LanguageDetect(); + $lang->setNameMode(2); + } // print_r($rss); @@ -572,15 +574,17 @@ print "\n"; } - $entry_language = $lang->detect($entry_title . " " . $entry_content, 1); + $entry_language = ""; - if (count($entry_language) > 0) { - $entry_language = array_keys($entry_language); - $entry_language = db_escape_string(substr($entry_language[0], 0, 2)); + if (DETECT_ARTICLE_LANGUAGE) { + $entry_language = $lang->detect($entry_title . " " . $entry_content, 1); - _debug("detected language: $entry_language", $debug_enabled); - } else{ - $entry_language = ""; + if (count($entry_language) > 0) { + $entry_language = array_keys($entry_language); + $entry_language = db_escape_string(substr($entry_language[0], 0, 2)); + + _debug("detected language: $entry_language", $debug_enabled); + } } $entry_comments = $item->get_comments_url(); diff --git a/include/sanity_config.php b/include/sanity_config.php index 527fa6dc4..99e83e0d9 100644 --- a/include/sanity_config.php +++ b/include/sanity_config.php @@ -1,3 +1,3 @@ - +$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_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_NEW_VERSION', 'DETECT_ARTICLE_LANGUAGE', 'ENABLE_GZIP_OUTPUT', 'PLUGINS', 'LOG_DESTINATION', 'CONFIG_VERSION'); ?>