Merge pull request #1018 from annando/master

Solved install issues, support for predefined preview picture in page info function
This commit is contained in:
tobiasd 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

@ -6,73 +6,84 @@ function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
function ($match) use ($plaintext){
$attributes = $match[1];
$attributes = $match[1];
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$type = $matches[1];
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$type = $matches[1];
preg_match('/type="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$type = $matches[1];
preg_match('/type="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$type = $matches[1];
if ($type == "")
return($match[0]);
if ($type == "")
return($match[0]);
if (!in_array($type, array("link", "audio", "video")))
return($match[0]);
if (!in_array($type, array("link", "audio", "video")))
return($match[0]);
$url = "";
preg_match("/url='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$url = $matches[1];
$url = "";
preg_match("/url='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$url = $matches[1];
preg_match('/url="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$url = $matches[1];
preg_match('/url="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$url = $matches[1];
$title = "";
preg_match("/title='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$title = $matches[1];
$title = "";
preg_match("/title='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$title = $matches[1];
preg_match('/title="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$title = $matches[1];
preg_match('/title="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$title = $matches[1];
$image = "";
preg_match("/image='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$image = $matches[1];
$image = "";
preg_match("/image='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$image = $matches[1];
preg_match('/image="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$image = $matches[1];
preg_match('/image="(.*?)"/ism', $attributes, $matches);
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 {
$text = sprintf('<span class="type-%s">', $type);
$text = sprintf('<span class="type-%s">', $type);
$bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $title, $url);
$bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $title, $url);
if ($tryoembed)
$oembed = tryoembed($bookmark);
$oembed = tryoembed($bookmark);
else
$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"
if (($image != "") AND !strstr(strtolower($oembed), "<img "))
$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;
$text .= $oembed;
$text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[2]));
$text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[2]));
}
return($text);
return($text);
},$Text);
return($Text);
return($Text);
}
function bb_rearrange_link($shared) {
@ -104,37 +115,43 @@ 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);
return($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]);
return($shared[0]);
if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
return($shared[0]);
if ($plaintext)
$shared[3] = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism","[bookmark=$1]$1[/bookmark]", $shared[3]);
$title = "";
$link = "";
if (!preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$shared[3], $bookmark))
return($shared[0]);
if (isset($bookmark[2][0]))
$title = $bookmark[2][0];
if ($nolink)
return(trim($shared[1]));
if (isset($bookmark[1][0]))
$link = $bookmark[1][0];
$title = "";
$link = "";
if (strpos($shared[1],$title) !== false)
$title = "";
if (isset($bookmark[2][0]))
$title = $bookmark[2][0];
if (isset($bookmark[1][0]))
$link = $bookmark[1][0];
if (strpos($shared[1],$title) !== false)
$title = "";
// if (strpos($shared[1],$link) !== false)
// $link = "";
$text = trim($shared[1]);
$text = trim($shared[1]);
if (($text == "") AND ($title != "") AND ($link == ""))
$text .= "\n\n".trim($title);
@ -144,7 +161,7 @@ function bb_cleanup_share($shared) {
elseif (($link != ""))
$text .= "\n".trim($link);
return(trim($text));
return(trim($text));
}
@ -274,7 +291,7 @@ function get_bb_tag_pos($s, $name, $occurance = 1) {
return false;
$res = array( 'start' => array('open' => $start_open, 'close' => $start_close),
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
'end' => array('open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']')) );
if( $start_equal !== false)
$res['start']['equal'] = $start_equal + 1;
@ -364,45 +381,46 @@ function bb_replace_images($body, $images) {
return $newbody;
}}
/*
function bb_ShareAttributes($match) {
$attributes = $match[1];
$attributes = $match[1];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
$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];
preg_match('/author="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$author = $matches[1];
$link = "";
preg_match("/link='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$link = $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];
preg_match('/link="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$link = $matches[1];
$avatar = "";
preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$avatar = $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];
preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$avatar = $matches[1];
$profile = "";
preg_match("/profile='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$profile = $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];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$posted = "";
@ -422,57 +440,57 @@ function bb_ShareAttributes($match) {
}
$headline = '<div class="shared_header">';
//$headline = '<br /><div class="shared_header">';
//$headline = '<br /><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>";
$headline .= "</div>";
$text = $headline.'<blockquote class="shared_content">'.trim($match[2])."</blockquote>";
$text = $headline.'<blockquote class="shared_content">'.trim($match[2])."</blockquote>";
return($text);
return($text);
}
// Escpecially for Diaspora (there mustn't be links in the share information)
function bb_ShareAttributesDiaspora($match) {
$attributes = $match[2];
$attributes = $match[2];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
$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];
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];
$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];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$link = "";
preg_match("/link='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$link = $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];
preg_match('/link="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$link = $matches[1];
$userid = GetProfileUsername($profile,$author);
$headline = '<div class="shared_header">';
$headline .= '<span><b>'.html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').$userid.':</b></span>';
$headline .= "</div>";
$headline .= "</div>";
$text = trim($match[1]);
@ -486,40 +504,40 @@ function bb_ShareAttributesDiaspora($match) {
// $text .= '<br /><a href="'.$link.'">'.t("Link").' [l]</a>';
return($text);
return($text);
}
// Optimized for Libertree, Wordpress, Tumblr, ...
function bb_ShareAttributesForExport($match) {
$attributes = $match[2];
$attributes = $match[2];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
$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];
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];
$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];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$link = "";
preg_match("/link='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$link = $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];
preg_match('/link="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$link = $matches[1];
if ($link == "")
$link = $profile;
@ -529,7 +547,7 @@ function bb_ShareAttributesForExport($match) {
$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>";
$headline .= ":</b></span></div>";
$text = trim($match[1]);
@ -538,68 +556,186 @@ function bb_ShareAttributesForExport($match) {
$text .= $headline.'<blockquote class="shared_content">'.trim($match[3])."</blockquote><br />";
return($text);
return($text);
}
// Still in use?
function bb_ShareAttributesSimple($match) {
$attributes = $match[1];
$attributes = $match[1];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
$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];
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];
$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];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$userid = GetProfileUsername($profile,$author);
$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$userid."</a>: <br />»".$match[2]."«";
$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$userid."</a>: <br />»".$match[2]."«";
return($text);
return($text);
}
// Used for text exports (Twitter, Facebook, Google+)
function bb_ShareAttributesSimple2($match) {
$attributes = $match[1];
$attributes = $match[1];
$author = "";
preg_match("/author='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
$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];
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];
$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];
preg_match('/profile="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$profile = $matches[1];
$userid = GetProfileUsername($profile,$author);
//$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$userid."</a>: <br />".$match[2];
$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' '.$userid.": <br />".$match[2];
//$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$userid."</a>: <br />".$match[2];
$text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' '.$userid.": <br />".$match[2];
return($text);
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);
}
@ -901,7 +1045,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism","<span style=\"color: $1;\">$2</span>",$Text);
// Check for sized text
// [size=50] --> font-size: 50px (with the unit).
// [size=50] --> font-size: 50px (with the unit).
$Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px; line-height: initial;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1; line-height: initial;\">$2</span>",$Text);
@ -917,7 +1061,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// Check for CSS classes
$Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanclass",$Text);
// handle nested lists
// handle nested lists
$endlessloop = 0;
while ((((strpos($Text, "[/list]") !== false) && (strpos($Text, "[list") !== false)) ||
@ -978,8 +1122,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$endlessloop = 0;
while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20))
$Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
"<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
$Text);
"<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
$Text);
// Declare the format for [quote] layout
$QuoteLayout = '<blockquote>$1</blockquote>';
@ -998,8 +1142,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$endlessloop = 0;
while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20))
$Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
"<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>",
$Text);
"<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote>$2</blockquote>",
$Text);
// [img=widthxheight]image source[/img]
//$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $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

@ -49,8 +49,8 @@ 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 ($sql3 == "")
$sql3 = "ALTER TABLE `".$name."` ".$sql2;
else
$sql3 .= ", ".$sql2;
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);

106
include/items.php Executable file → Normal file
View File

@ -874,21 +874,15 @@ 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) {
require_once("mod/parse_url.php");
$data = parseurl_getsiteinfo($url, true);
function add_page_info($url, $no_photos = false, $photo = "") {
require_once("mod/parse_url.php");
logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
$data = parseurl_getsiteinfo($url, true);
logger('add_page_info: fetch page info for '.$url.' '.print_r($data, true), LOGGER_DEBUG);
// It maybe is a rich content, but if it does have everything that a link has,
// then treat it that way
@ -896,51 +890,53 @@ function add_page_info($url, $no_photos = false) {
is_string($data["text"]) AND (sizeof($data["images"]) > 0))
$data["type"] = "link";
if ((($data["type"] != "link") AND ($data["type"] != "video") AND ($data["type"] != "photo")) OR ($data["title"] == $url))
return("");
if ((($data["type"] != "link") AND ($data["type"] != "video") AND ($data["type"] != "photo")) OR ($data["title"] == $url))
return("");
if ($no_photos AND ($data["type"] == "photo"))
return("");
if (($data["type"] != "photo") AND is_string($data["title"]))
$text .= "[bookmark=".$url."]".trim($data["title"])."[/bookmark]";
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)) {
$imagedata = $data["images"][0];
$text .= '[img]'.$imagedata["src"].'[/img]';
}
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]';
}
if (($data["type"] != "photo") AND is_string($data["text"]))
$text .= "[quote]".$data["text"]."[/quote]";
if (($data["type"] != "photo") AND is_string($data["text"]))
$text .= "[quote]".$data["text"]."[/quote]";
return("\n[class=type-".$data["type"]."]".$text."[/class]");
return("\n[class=type-".$data["type"]."]".$text."[/class]");
}
function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
logger('add_page_info_to_body: fetch page info for body '.$body, LOGGER_DEBUG);
logger('add_page_info_to_body: fetch page info for body '.$body, LOGGER_DEBUG);
$URLSearchString = "^\[\]";
$URLSearchString = "^\[\]";
// Adding these spaces is a quick hack due to my problems with regular expressions :)
preg_match("/[^!#@]\[url\]([$URLSearchString]*)\[\/url\]/ism", " ".$body, $matches);
// Adding these spaces is a quick hack due to my problems with regular expressions :)
preg_match("/[^!#@]\[url\]([$URLSearchString]*)\[\/url\]/ism", " ".$body, $matches);
if (!$matches)
preg_match("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", " ".$body, $matches);
if (!$matches)
preg_match("/[^!#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", " ".$body, $matches);
// Convert urls without bbcode elements
if (!$matches AND $texturl) {
preg_match("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", " ".$body, $matches);
// Yeah, a hack. I really hate regular expressions :)
if ($matches)
$matches[1] = $matches[2];
if ($matches)
$matches[1] = $matches[2];
}
if ($matches)
$body .= add_page_info($matches[1], $no_photos);
if ($matches)
$body .= add_page_info($matches[1], $no_photos);
return $body;
return $body;
}
function encode_rel_links($links) {
@ -983,7 +979,7 @@ function item_store($arr,$force_parent = false) {
if (isset($arr["ostatus_conversation"])) {
$ostatus_conversation = $arr["ostatus_conversation"];
unset($arr["ostatus_conversation"]);
unset($arr["ostatus_conversation"]);
}
if(x($arr, 'gravity'))
@ -1245,7 +1241,7 @@ function item_store($arr,$force_parent = false) {
if(count($r)) {
logger('item_store: Send notification for contact '.$arr['contact-id'].' and post '.$current_post, LOGGER_DEBUG);
$u = q("SELECT * FROM user WHERE uid = %d LIMIT 1",
intval($arr['uid']));
intval($arr['uid']));
$item = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d",
intval($current_post),
@ -1290,7 +1286,7 @@ function item_store($arr,$force_parent = false) {
if((! $parent_id) || ($arr['parent-uri'] === $arr['uri']))
$parent_id = $current_post;
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
$private = 1;
else
$private = $arr['private'];
@ -1313,14 +1309,14 @@ function item_store($arr,$force_parent = false) {
if ($ostatus_conversation)
complete_conversation($current_post, $ostatus_conversation);
$arr['id'] = $current_post;
$arr['parent'] = $parent_id;
$arr['allow_cid'] = $allow_cid;
$arr['allow_gid'] = $allow_gid;
$arr['deny_cid'] = $deny_cid;
$arr['deny_gid'] = $deny_gid;
$arr['private'] = $private;
$arr['deleted'] = $parent_deleted;
$arr['id'] = $current_post;
$arr['parent'] = $parent_id;
$arr['allow_cid'] = $allow_cid;
$arr['allow_gid'] = $allow_gid;
$arr['deny_cid'] = $deny_cid;
$arr['deny_gid'] = $deny_gid;
$arr['private'] = $private;
$arr['deleted'] = $parent_deleted;
// update the commented timestamp on the parent
@ -1798,10 +1794,10 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
*/
function edited_timestamp_is_newer($existing, $update) {
if (!x($existing,'edited') || !$existing['edited']) {
return true;
return true;
}
if (!x($update,'edited') || !$update['edited']) {
return false;
return false;
}
$existing_edited = datetime_convert('UTC', 'UTC', $existing['edited']);
$update_edited = datetime_convert('UTC', 'UTC', $update['edited']);
@ -1994,7 +1990,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$r = q("INSERT INTO `event` (`uid`,`cid`,`created`,`edited`,`start`,`finish`,`summary`,`desc`,`type`)
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($contact['uid']),
intval($contact['id']),
intval($contact['id']),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert('UTC','UTC', $birthday)),
@ -2156,7 +2152,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
logger('consume_feed: feed item count = ' . $feed->get_item_quantity());
// in inverse date order
// in inverse date order
if ($datedir)
$items = array_reverse($feed->get_items());
else
@ -3592,16 +3588,16 @@ function local_delivery($importer,$data) {
$links = parse_xml_string("<links>".unxmlify($xo->link)."</links>",false);
foreach($links->link as $l) {
$atts = $l->attributes();
switch($atts['rel']) {
case "alternate":
foreach($links->link as $l) {
$atts = $l->attributes();
switch($atts['rel']) {
case "alternate":
$Blink = $atts['href'];
break;
default:
break;
}
}
}
}
if($Blink && link_compare($Blink,$a->get_baseurl() . '/profile/' . $importer['nickname'])) {
// send a notification
@ -4455,7 +4451,7 @@ function posted_dates($uid,$wall) {
$start_month = datetime_convert('','',$dstart,'Y-m-d');
$end_month = datetime_convert('','',$dend,'Y-m-d');
$str = day_translate(datetime_convert('','',$dnow,'F Y'));
$ret[] = array($str,$end_month,$start_month);
$ret[] = array($str,$end_month,$start_month);
$dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d');
}
return $ret;

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")