Merge pull request #1018 from annando/master

Solved install issues, support for predefined preview picture in page info function
This commit is contained in:
Tobias Diekershoff 2014-06-16 09:00:07 +02:00
commit 83ac685deb
14 changed files with 456 additions and 282 deletions

View file

@ -755,3 +755,23 @@ function import_profile_photo($photo,$uid,$cid) {
return(array($photo,$thumb,$micro));
}
function get_photo_info($url) {
$data = array();
$data = Cache::get($url);
if (is_null($data)) {
$img_str = fetch_url($url, true, $redirects, 4);
$tempfile = tempnam(get_config("system","temppath"), "cache");
file_put_contents($tempfile, $img_str);
$data = getimagesize($tempfile);
unlink($tempfile);
Cache::set($url, serialize($data));
} else
$data = unserialize($data);
return $data;
}

View file

@ -1653,7 +1653,7 @@
'[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode);
$bbcode = preg_replace("/\[youtube\](.*?)\[\/youtube\]/ism",'[url=$1]$1[/url]',$bbcode);
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
$bbcode = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
'[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode);
$bbcode = preg_replace("/\[vimeo\](.*?)\[\/vimeo\]/ism",'[url=$1]$1[/url]',$bbcode);

View file

@ -50,6 +50,15 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
if ($matches[1] != "")
$image = $matches[1];
$preview = "";
preg_match("/preview='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$preview = $matches[1];
preg_match('/preview="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$preview = $matches[1];
if ($plaintext)
$text = sprintf('<a href="%s" target="_blank">%s</a>', $url, $title);
else {
@ -62,7 +71,9 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$oembed = $bookmark[0];
if (($image != "") AND !strstr(strtolower($oembed), "<img "))
$text .= sprintf('<img src="%s" alt="%s" />', $image, $title); // To-Do: Anführungszeichen in "alt"
$text .= sprintf('<img src="%s" alt="%s" class="attachment-image" />', $image, $title); // To-Do: Anführungszeichen in "alt"
elseif (($preview != "") AND !strstr(strtolower($oembed), "<img "))
$text .= sprintf('<img src="%s" alt="%s" class="attachment-preview" />', $preview, $title); // To-Do: Anführungszeichen in "alt"
$text .= $oembed;
@ -104,21 +115,27 @@ function bb_rearrange_link($shared) {
return($newshare);
}
function bb_remove_share_information($Text, $plaintext = false) {
if ($plaintext)
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism","[bookmark=$1]$1[/bookmark]", $Text);
$Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanup_share",$Text);
function bb_remove_share_information($Text, $plaintext = false, $nolink = false) {
$Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism",
function ($match) use ($plaintext, $nolink){
return(bb_cleanup_share($match, $plaintext, $nolink));
},$Text);
return($Text);
}
function bb_cleanup_share($shared) {
function bb_cleanup_share($shared, $plaintext, $nolink) {
if (!in_array($shared[2], array("type-link", "type-video")))
return($shared[0]);
if ($plaintext)
$shared[3] = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism","[bookmark=$1]$1[/bookmark]", $shared[3]);
if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
return($shared[0]);
if ($nolink)
return(trim($shared[1]));
$title = "";
$link = "";
@ -364,6 +381,7 @@ function bb_replace_images($body, $images) {
return $newbody;
}}
/*
function bb_ShareAttributes($match) {
$attributes = $match[1];
@ -601,6 +619,124 @@ function bb_ShareAttributesSimple2($match) {
return($text);
}
*/
function bb_ShareAttributes($share, $simplehtml) {
$attributes = $share[2];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$author = $matches[1];
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$avatar = $matches[1];
preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$avatar = $matches[1];
$link = "";
preg_match("/link='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$link = $matches[1];
preg_match('/link="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$link = $matches[1];
$posted = "";
$itemcache = get_config("system","itemcache");
// relative dates only make sense when they aren't cached
if ($itemcache == "") {
preg_match("/posted='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$posted = $matches[1];
preg_match('/posted="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$posted = $matches[1];
$reldate = (($posted) ? " " . relative_date($posted) : '');
}
$userid = GetProfileUsername($profile,$author);
$preshare = trim($share[1]);
if ($preshare != "")
$preshare .= "<br /><br />";
switch ($simplehtml) {
case 1:
$text = $preshare.html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$userid."</a>: <br />»".$share[3]."«";
break;
case 2:
$text = $preshare.html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' '.$userid.": <br />".$share[3];
break;
case 3:
$headline = '<div class="shared_header">';
$headline .= '<span><b>'.html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').$userid.':</b></span>';
$headline .= "</div>";
$text = trim($share[1]);
if ($text != "")
$text .= "<hr />";
$text .= $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote><br />";
if ($link != "")
$text .= '<br /><a href="'.$link.'">[l]</a>';
break;
case 4:
$headline = '<div class="shared_header">';
$headline .= '<span><b>'.html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
$headline .= sprintf(t('<a href="%1$s" target="_blank">%2$s</a> %3$s'), $link, $userid, $posted);
$headline .= ":</b></span></div>";
$text = trim($share[1]);
if ($text != "")
$text .= "<hr />";
$text .= $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote><br />";
break;
case 5:
$text = $preshare.html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' '.$userid.": <br />".$share[3];
break;
case 6:
$text = $preshare."&gt;&gt; ".$userid.": <br />".$share[3];
break;
default:
$headline = trim($share[1]).'<div class="shared_header">';
if ($avatar != "")
$headline .= '<img src="'.$avatar.'" height="32" width="32" >';
$headline .= sprintf(t('<span><a href="%s" target="_blank">%s</a> wrote the following <a href="%s" target="_blank">post</a>'.$reldate.':</span>'), $profile, $author, $link);
$headline .= "</div>";
$text = $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote>";
break;
}
return($text);
}
function GetProfileUsername($profile, $username) {
@ -687,6 +823,13 @@ function bb_RemovePictureLinks($match) {
return($text);
}
function bb_expand_links($match) {
if (stristr($match[2], $match[3]) OR ($match[2] == $match[3]))
return ($match[1]."[url]".$match[2]."[/url]");
else
return ($match[1].$match[3]." [url]".$match[2]."[/url]");
}
function bb_CleanPictureLinksSub($match) {
$text = Cache::get($match[1]);
@ -836,8 +979,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
"[bookmark=$1]$2[/bookmark]", $Text);
if ($simplehtml == 2) {
$Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism",' $2 [url]$1[/url]',$Text);
if (in_array($simplehtml, array(2, 6))) {
$Text = preg_replace_callback("/([^#@])\[url\=([^\]]*)\](.*?)\[\/url\]/ism","bb_expand_links",$Text);
//$Text = preg_replace("/[^#@]\[url\=([^\]]*)\](.*?)\[\/url\]/ism",' $2 [url]$1[/url]',$Text);
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",' $2 [url]$1[/url]',$Text);
}
@ -1012,6 +1156,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
// Shared content
$Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism",
function ($match) use ($simplehtml){
return(bb_ShareAttributes($match, $simplehtml));
},$Text);
/*
if (!$simplehtml)
$Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
elseif ($simplehtml == 1)
@ -1022,6 +1171,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesDiaspora",$Text);
elseif ($simplehtml == 4)
$Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesForExport",$Text);
*/
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
$Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);

View file

@ -50,7 +50,7 @@ function networks_widget($baseurl,$selected = '') {
if(! feature_enabled(local_user(),'networks'))
return '';
$r = q("select distinct(network) from contact where uid = %d and self = 0",
$r = q("SELECT DISTINCT(`network`) FROM `contact` WHERE `uid` = %d AND `self` = 0 ORDER BY `network`",
intval(local_user())
);

View file

@ -15,9 +15,6 @@ function dbstructure_run(&$argv, &$argc) {
unset($db_host, $db_user, $db_pass, $db_data);
}
load_config('config');
load_config('system');
update_structure(true, true);
}
@ -115,11 +112,11 @@ function update_structure($verbose, $action) {
// Compare it
foreach ($definition AS $name => $structure) {
$sql3="";
if (!isset($database[$name]))
if (!isset($database[$name])) {
$r = db_create_table($name, $structure["fields"], $verbose, $action);
if(false === $r)
$errors .= t('Errors encountered creating database tables.').$name.EOL;
else {
} else {
// Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldname])) {
@ -155,14 +152,17 @@ function update_structure($verbose, $action) {
}
// Create the index
foreach ($structure["indexes"] AS $indexname => $fieldnames)
foreach ($structure["indexes"] AS $indexname => $fieldnames) {
if (!isset($database[$name]["indexes"][$indexname])) {
$sql2=db_create_index($indexname, $fieldnames);
if ($sql2 != "") {
if ($sql3 == "")
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
else
$sql3 .= ", ".$sql2;
}
}
}
if ($sql3 != "") {
$sql3 .= ";";
@ -212,7 +212,7 @@ function db_create_table($name, $fields, $verbose, $action) {
$sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
}
$sql = sprintf("ADD TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
$sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
if ($verbose)
echo $sql.";\n";

View file

@ -469,10 +469,6 @@ function delivery_run(&$argv, &$argc){
//if($reply_to)
// $headers .= 'Reply-to: ' . $reply_to . "\n";
// for testing purposes: Collect exported mails
// $file = tempnam("/tmp/friendica/", "mail-out-");
// file_put_contents($file, json_encode($it));
$headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n";
//logger("Mail: uri: ".$it['uri']." parent-uri ".$it['parent-uri'], LOGGER_DEBUG);

View file

@ -82,10 +82,6 @@ function email_get_msg($mbox,$uid, $reply) {
if(! $struc)
return $ret;
// for testing purposes: Collect imported mails
// $file = tempnam("/tmp/friendica2/", "mail-in-");
// file_put_contents($file, json_encode($struc));
if(! $struc->parts) {
$ret['body'] = email_get_part($mbox,$uid,$struc,0, 'html');
$html = $ret['body'];
@ -138,10 +134,6 @@ function email_get_part($mbox,$uid,$p,$partno, $subtype) {
? @imap_fetchbody($mbox,$uid,$partno, FT_UID|FT_PEEK)
: @imap_body($mbox,$uid,FT_UID|FT_PEEK);
// for testing purposes: Collect imported mails
// $file = tempnam("/tmp/friendica2/", "mail-body-");
// file_put_contents($file, $data);
// Any part may be encoded, even plain text messages, so check everything.
if ($p->encoding==4)
$data = quoted_printable_decode($data);

14
include/items.php Executable file → Normal file
View file

@ -874,18 +874,12 @@ function get_atom_elements($feed, $item, $contact = array()) {
call_hooks('parse_atom', $arr);
//if (($res["title"] != "") or (strpos($res["body"], "RT @") > 0)) {
//if (strpos($res["body"], "RT @") !== false) {
/*if (strpos($res["body"], "@") !== false) {
$debugfile = tempnam("/var/www/virtual/pirati.ca/phptmp/", "item-res2-");
file_put_contents($debugfile, serialize($arr));
}*/
return $res;
}
function add_page_info($url, $no_photos = false) {
function add_page_info($url, $no_photos = false, $photo = "") {
require_once("mod/parse_url.php");
$data = parseurl_getsiteinfo($url, true);
logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
@ -905,7 +899,9 @@ function add_page_info($url, $no_photos = false) {
if (($data["type"] != "photo") AND is_string($data["title"]))
$text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]";
if (($data["type"] != "video") AND (sizeof($data["images"]) > 0)) {
if (($data["type"] != "video") AND ($photo != ""))
$text .= '[img]'.$photo.'[/img]';
elseif (($data["type"] != "video") AND (sizeof($data["images"]) > 0)) {
$imagedata = $data["images"][0];
$text .= '[img]'.$imagedata["src"].'[/img]';
}

View file

@ -786,10 +786,6 @@ function notifier_run(&$argv, &$argc){
//if($reply_to)
// $headers .= 'Reply-to: ' . $reply_to . "\n";
// for testing purposes: Collect exported mails
//$file = tempnam("/tmp/friendica/", "mail-out2-");
//file_put_contents($file, json_encode($it));
$headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n";
if($it['uri'] !== $it['parent-uri']) {

View file

@ -46,6 +46,7 @@ function get_attached_data($body) {
// if nothing is found, it maybe having an image.
if (!isset($post["type"])) {
require_once("mod/parse_url.php");
require_once("include/Photo.php");
$URLSearchString = "^\[\]";
if (preg_match_all("(\[url=([$URLSearchString]*)\]\s*\[img\]([$URLSearchString]*)\[\/img\]\s*\[\/url\])ism", $body, $pictures, PREG_SET_ORDER)) {
@ -64,12 +65,8 @@ function get_attached_data($body) {
$post["text"] = str_replace($pictures[0][0], "", $body);
} else {
$img_str = fetch_url($pictures[0][1]);
$tempfile = tempnam(get_config("system","temppath"), "cache");
file_put_contents($tempfile, $img_str);
$mime = image_type_to_mime_type(exif_imagetype($tempfile));
unlink($tempfile);
if (substr($mime, 0, 6) == "image/") {
$imgdata = get_photo_info($img_str);
if (substr($imgdata["mime"], 0, 6) == "image/") {
$post["type"] = "photo";
$post["image"] = $pictures[0][1];
$post["preview"] = $pictures[0][2];
@ -111,7 +108,7 @@ function shortenmsg($msg, $limit, $twitter = false) {
$msg = "";
$recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
foreach ($lines AS $row=>$line) {
if (strlen(trim($msg."\n".$line)) <= $limit)
if (iconv_strlen(trim($msg."\n".$line), "UTF-8") <= $limit)
$msg = trim($msg."\n".$line);
// Is the new message empty by now or is it a reshared message?
elseif (($msg == "") OR (($row == 1) AND (substr($msg, 0, 4) == $recycle)))
@ -122,7 +119,7 @@ function shortenmsg($msg, $limit, $twitter = false) {
return($msg);
}
function plaintext($a, $b, $limit = 0, $includedlinks = false) {
function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) {
require_once("include/bbcode.php");
require_once("include/html2plain.php");
require_once("include/network.php");
@ -136,7 +133,7 @@ function plaintext($a, $b, $limit = 0, $includedlinks = false) {
elseif ($b["title"] != "")
$post["text"] = trim($b["title"]);
$html = bbcode($post["text"], false, false, 2);
$html = bbcode($post["text"], false, false, $htmlmode);
$msg = html2plain($html, 0, true);
$msg = trim(html_entity_decode($msg,ENT_QUOTES,'UTF-8'));

View file

@ -33,13 +33,23 @@ span.connector {
clear: both;
visibility: hidden;
}
.wall-item-container .wall-item-content .type-link img,
.type-link img, .type-video img {
.type-link img, .type-video img, img.attachment-preview {
max-width: 160px;
max-height: 160px;
float: left;
margin-right: 10px;
}
.wall-item-container .wall-item-content .type-link img.attachment-image,
.type-link img.attachment-image, .type-video img.attachment-image {
max-width: 640px;
max-height: initial;
float: initial;
margin-right: 0px;
}
.type-link blockquote, .type-video blockquote {
margin-left: 0px;
max-height: 160px;

View file

@ -11,6 +11,9 @@ function theme_content(&$a){
$style = get_pconfig(local_user(), 'vier', 'style');
if ($style == "")
$style = get_config('vier', 'style');
return vier_form($a,$style);
}

View file

@ -2,3 +2,13 @@
body, section { background-color: #ffffff !important;}
#profile-jot-form { background-color: #ffffff !important;}
.dspr, .twit, .pump, .dfrn { background-color: #ffffff !important;}
div.pager, ul.tabs {
box-shadow: unset;
background-color: unset;
border-bottom: unset;
}
aside {
border-right: 1px solid #D2D2D2;
}

View file

@ -16,6 +16,10 @@ $baseurl = $a->get_baseurl();
$a->theme_info = array();
$style = get_pconfig(local_user(), 'vier', 'style');
if ($style == "")
$style = get_config('vier', 'style');
if ($style == "flat")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/flat.css" type="text/css" media="screen"/>'."\n";
else if ($style == "netcolour")