language detection and sparkle links added to plinks where appropriate
This commit is contained in:
parent
bb6d8e9597
commit
3f7b93ce65
9
boot.php
9
boot.php
@ -34,6 +34,14 @@ define ( 'JPEG_QUALITY', 100 );
|
||||
*/
|
||||
define ( 'PNG_QUALITY', 8 );
|
||||
|
||||
/**
|
||||
* Language detection parameters
|
||||
*/
|
||||
|
||||
define ( 'LANGUAGE_DETECT_MIN_LENGTH', 128 );
|
||||
define ( 'LANGUAGE_DETECT_MIN_CONFIDENCE', 0.01 );
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* An alternate way of limiting picture upload sizes. Specify the maximum pixel
|
||||
@ -415,6 +423,7 @@ if(! class_exists('App')) {
|
||||
. 'include' . PATH_SEPARATOR
|
||||
. 'library' . PATH_SEPARATOR
|
||||
. 'library/phpsec' . PATH_SEPARATOR
|
||||
. 'library/langdet' . PATH_SEPARATOR
|
||||
. '.' );
|
||||
|
||||
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=") {
|
||||
|
@ -242,6 +242,16 @@ function localize_item(&$item){
|
||||
}
|
||||
}
|
||||
|
||||
// add sparkle links to appropriate permalinks
|
||||
|
||||
$x = stristr($item['plink'],'/display/');
|
||||
if($x) {
|
||||
$sparkle = false;
|
||||
$y = best_link_url($item,$sparkle,true);
|
||||
if(strstr($y,'/redir/'))
|
||||
$item['plink'] = $y . '?f=&url=' . $item['plink'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -826,6 +826,9 @@ function item_store($arr,$force_parent = false) {
|
||||
if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
|
||||
$arr['body'] = strip_tags($arr['body']);
|
||||
|
||||
require_once('include/language.php');
|
||||
$arr['lang'] = detect_language($arr['body']);
|
||||
|
||||
|
||||
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
|
||||
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string());
|
||||
|
18
mod/item.php
18
mod/item.php
@ -217,6 +217,12 @@ function item_post(&$a) {
|
||||
$emailcc = notags(trim($_REQUEST['emailcc']));
|
||||
$body = escape_tags(trim($_REQUEST['body']));
|
||||
|
||||
|
||||
require_once('include/language.php');
|
||||
$language = detect_language($body);
|
||||
|
||||
logger('detected language: ' . $language);
|
||||
|
||||
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
|
||||
|
||||
// If this is a comment, set the permissions from the parent.
|
||||
@ -553,6 +559,7 @@ function item_post(&$a) {
|
||||
$datarray['title'] = $title;
|
||||
$datarray['body'] = $body;
|
||||
$datarray['app'] = $app;
|
||||
$datarray['lang'] = $language;
|
||||
$datarray['location'] = $location;
|
||||
$datarray['coord'] = $coord;
|
||||
$datarray['tag'] = $str_tags;
|
||||
@ -641,9 +648,9 @@ function item_post(&$a) {
|
||||
|
||||
|
||||
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
|
||||
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
|
||||
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `lang`, `location`, `coord`,
|
||||
`tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`,`origin`, `moderated`, `file` )
|
||||
VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s' )",
|
||||
VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s' )",
|
||||
dbesc($datarray['guid']),
|
||||
intval($datarray['uid']),
|
||||
dbesc($datarray['type']),
|
||||
@ -666,6 +673,7 @@ function item_post(&$a) {
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['app']),
|
||||
dbesc($datarray['lang']),
|
||||
dbesc($datarray['location']),
|
||||
dbesc($datarray['coord']),
|
||||
dbesc($datarray['tag']),
|
||||
@ -680,9 +688,9 @@ function item_post(&$a) {
|
||||
intval($datarray['pubmail']),
|
||||
dbesc($datarray['attach']),
|
||||
intval($datarray['origin']),
|
||||
intval($datarray['moderated']),
|
||||
dbesc($datarray['file'])
|
||||
);
|
||||
intval($datarray['moderated']),
|
||||
dbesc($datarray['file'])
|
||||
);
|
||||
|
||||
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
|
||||
dbesc($datarray['uri']));
|
||||
|
@ -22,7 +22,7 @@
|
||||
<div class="wall-item-actions-author">
|
||||
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle">$item.name</span></a>
|
||||
<span class="wall-item-ago">-
|
||||
{{ if $item.plink }}<a class="link" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
||||
{{ if $item.plink }}<a class="link$item.sparkle" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
||||
{{ if $item.lock }} - <span class="fakelink" style="color: #999" onclick="lockview(event,$item.id);">$item.lock</span> {{ endif }}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -28,7 +28,7 @@
|
||||
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle">$item.name</span></a>
|
||||
$item.to <a href="$item.owner_url" target="redir" title="$item.olinktitle" class="wall-item-name-link"><span class="wall-item-name$item.osparkle" id="wall-item-ownername-$item.id">$item.owner_name</span></a>
|
||||
$item.vwall <span class="wall-item-ago">-
|
||||
{{ if $item.plink }}<a class="link" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
||||
{{ if $item.plink }}<a class="link$item.sparkle" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
||||
{{ if $item.lock }} - <span class="fakelink" style="color: #999" onclick="lockview(event,$item.id);">$item.lock</span> {{ endif }}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -52,7 +52,7 @@
|
||||
<li><a href="#" id="filer-$item.id" onclick="itemFiler($item.id); return false;" class="filer-item icon file-as" title="$item.filer"></a></li>
|
||||
{{ endif }}
|
||||
{{ if $item.plink }}
|
||||
<li class="wall-item-links-wrapper"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link"></a></li>
|
||||
<li class="wall-item-links-wrapper$item.sparkle"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link"></a></li>
|
||||
{{ endif }}
|
||||
{{ if $item.edpost }}
|
||||
<li><a class="editpost icon pencil" href="$item.edpost.0" title="$item.edpost.1"></a></li>
|
||||
|
@ -59,7 +59,7 @@ class="icon recycle wall-item-share-buttons" title="$item.vote.share.0" onclick
|
||||
<li class="wall-item-filer-wrapper"><a href="#" id="filer-$item.id" onclick="itemFiler($item.id); return false;" class="filer-item icon file-as" title="$item.star.filer"></a></li>
|
||||
{{ endif }}
|
||||
{{ if $item.plink }}
|
||||
<li class="wall-item-links-wrapper"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link"></a></li>
|
||||
<li class="wall-item-links-wrapper$item.sparkle"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link"></a></li>
|
||||
{{ endif }}
|
||||
{{ if $item.edpost }}
|
||||
<li><a class="editpost icon pencil" href="$item.edpost.0" title="$item.edpost.1"></a></li>
|
||||
|
@ -23,7 +23,7 @@
|
||||
<div class="wall-item-location">$item.location</div>
|
||||
</div>
|
||||
<div class="wall-item-content">
|
||||
{{ if $item.title }}<h2><a href="$item.plink.href">$item.title</a></h2>{{ endif }}
|
||||
{{ if $item.title }}<h2><a href="$item.plink.href" class="$item.sparkle">$item.title</a></h2>{{ endif }}
|
||||
$item.body
|
||||
</div>
|
||||
</div>
|
||||
@ -38,7 +38,7 @@
|
||||
</div>
|
||||
<div class="wall-item-bottom">
|
||||
<div class="">
|
||||
{{ if $item.plink }}<a class="icon s16 link" title="$item.plink.title" href="$item.plink.href">$item.plink.title</a>{{ endif }}
|
||||
{{ if $item.plink }}<a class="icon s16 link$item.sparkle" title="$item.plink.title" href="$item.plink.href">$item.plink.title</a>{{ endif }}
|
||||
</div>
|
||||
<div class="wall-item-actions">
|
||||
<div class="wall-item-actions-author">
|
||||
|
@ -27,7 +27,7 @@
|
||||
<div class="wall-item-location">$item.location</div>
|
||||
</div>
|
||||
<div class="wall-item-content">
|
||||
{{ if $item.title }}<h2><a href="$item.plink.href">$item.title</a></h2>{{ endif }}
|
||||
{{ if $item.title }}<h2><a href="$item.plink.href" class="$item.sparkle">$item.title</a></h2>{{ endif }}
|
||||
$item.body
|
||||
</div>
|
||||
</div>
|
||||
@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<div class="wall-item-bottom">
|
||||
<div class="wall-item-links">
|
||||
{{ if $item.plink }}<a class="icon s16 link" title="$item.plink.title" href="$item.plink.href">$item.plink.title</a>{{ endif }}
|
||||
{{ if $item.plink }}<a class="icon s16 link$item.sparkle" title="$item.plink.title" href="$item.plink.href">$item.plink.title</a>{{ endif }}
|
||||
</div>
|
||||
<div class="wall-item-actions">
|
||||
<div class="wall-item-actions-author">
|
||||
|
@ -48,7 +48,7 @@
|
||||
</div>
|
||||
{{ endif }}
|
||||
{{ if $item.plink }}
|
||||
<div class="wall-item-links-wrapper"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link"></a></div>
|
||||
<div class="wall-item-links-wrapper"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link$item.sparkle"></a></div>
|
||||
{{ endif }}
|
||||
{{ if $item.edpost }}
|
||||
<a class="editpost icon pencil" href="$item.edpost.0" title="$item.edpost.1"></a>
|
||||
|
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
{{ endif }}
|
||||
{{ if $item.plink }}
|
||||
<div class="wall-item-links-wrapper"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link"></a></div>
|
||||
<div class="wall-item-links-wrapper"><a href="$item.plink.href" title="$item.plink.title" target="external-link" class="icon remote-link$item.sparkle"></a></div>
|
||||
{{ endif }}
|
||||
{{ if $item.edpost }}
|
||||
<a class="editpost icon pencil" href="$item.edpost.0" title="$item.edpost.1"></a>
|
||||
|
Reference in New Issue
Block a user