]> git.mxchange.org Git - friendica.git/commitdiff
don't use language detection if < php 5.3
authorfriendica <info@friendica.com>
Fri, 13 Jul 2012 22:38:02 +0000 (15:38 -0700)
committerfriendica <info@friendica.com>
Fri, 13 Jul 2012 22:38:02 +0000 (15:38 -0700)
include/items.php
mod/item.php

index 6d58bd182aab30a91939f7bd4fa1faf141773fab..06da4bd612d79c30f3e136532e0759e18b4f085f 100755 (executable)
@@ -816,12 +816,14 @@ function item_store($arr,$force_parent = false) {
        if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) 
                $arr['body'] = strip_tags($arr['body']);
 
-       require_once('Text/LanguageDetect.php');
-       $naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
-       $l = new Text_LanguageDetect;
-       $lng = $l->detectConfidence($naked_body);
-       $arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
 
+       if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+               require_once('Text/LanguageDetect.php');
+               $naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
+               $l = new Text_LanguageDetect;
+               $lng = $l->detectConfidence($naked_body);
+               $arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
+       }
 
        $arr['wall']          = ((x($arr,'wall'))          ? intval($arr['wall'])                : 0);
        $arr['uri']           = ((x($arr,'uri'))           ? notags(trim($arr['uri']))           : random_string());
index b4e894337e3c9073c00507d45491cac7583a1411..fddc3fd124aa3dd49acd989ad82889b9ba9b771c 100644 (file)
@@ -219,12 +219,18 @@ function item_post(&$a) {
 
 
                $naked_body = preg_replace('/\[(.+?)\]/','',$body);
-               $l = new Text_LanguageDetect;
-               $lng = $l->detectConfidence($naked_body);
 
-               $postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
+               if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+                       $l = new Text_LanguageDetect;
+                       $lng = $l->detectConfidence($naked_body);
+
+                       $postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
+
+                       logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA);
+               }
+               else
+                       $postopts = '';
 
-               logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA);
 
                $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);