Merge pull request #914 from annando/master

Vier, API and Twitter cards
This commit is contained in:
tobiasd 2014-02-24 07:21:15 +01:00
commit 0eec22f656
11 changed files with 277 additions and 70 deletions

View file

@ -1625,6 +1625,8 @@
if ($include_entities != "true") if ($include_entities != "true")
return array(); return array();
$bbcode = bb_CleanPictureLinks($bbcode);
// Change pure links in text to bbcode uris // Change pure links in text to bbcode uris
$bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); $bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
@ -2392,6 +2394,8 @@ function api_get_nick($profile) {
function api_clean_plain_items($Text) { function api_clean_plain_items($Text) {
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false"); $include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
$Text = bb_CleanPictureLinks($Text);
if ($include_entities == "true") { if ($include_entities == "true") {
$URLSearchString = "^\[\]"; $URLSearchString = "^\[\]";

View file

@ -533,22 +533,93 @@ function GetProfileUsername($profile, $username) {
return($username); return($username);
} }
function RemovePictureLinks($match) { function bb_RemovePictureLinks($match) {
$ch = @curl_init($match[2]); $text = Cache::get($match[1]);
@curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)");
@curl_exec($ch);
$curl_info = @curl_getinfo($ch);
if (substr($curl_info["content_type"], 0, 6) == "image/") if(is_null($text)){
$text = "[url=".$match[2]."]".$match[2]."[/url]"; $ch = @curl_init($match[1]);
else @curl_setopt($ch, CURLOPT_NOBODY, true);
$text = "[url=".$match[1]."]".$match[1]."[/url]"; @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)");
@curl_exec($ch);
$curl_info = @curl_getinfo($ch);
if (substr($curl_info["content_type"], 0, 6) == "image/")
$text = "[url=".$match[1]."]".$match[1]."[/url]";
else {
$text = "[url=".$match[2]."]".$match[2]."[/url]";
// if its not a picture then look if its a page that contains a picture link
require_once("include/network.php");
$body = fetch_url($match[1]);
$doc = new DOMDocument();
@$doc->loadHTML($body);
$xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]");
foreach ($list as $node) {
$attr = array();
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
$attr[$attribute->name] = $attribute->value;
if (strtolower($attr["name"]) == "twitter:image")
$text = "[url=".$attr["content"]."]".$attr["content"]."[/url]";
}
}
Cache::set($match[1],$text);
}
return($text); return($text);
} }
function bb_CleanPictureLinksSub($match) {
$text = Cache::get($match[1]);
if(is_null($text)){
$ch = @curl_init($match[1]);
@curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Friendica)");
@curl_exec($ch);
$curl_info = @curl_getinfo($ch);
// if its a link to a picture then embed this picture
if (substr($curl_info["content_type"], 0, 6) == "image/")
$text = "[img]".$match[1]."[/img]";
else {
$text = "[img]".$match[2]."[/img]";
// if its not a picture then look if its a page that contains a picture link
require_once("include/network.php");
$body = fetch_url($match[1]);
$doc = new DOMDocument();
@$doc->loadHTML($body);
$xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]");
foreach ($list as $node) {
$attr = array();
if ($node->attributes->length)
foreach ($node->attributes as $attribute)
$attr[$attribute->name] = $attribute->value;
if (strtolower($attr["name"]) == "twitter:image")
$text = "[img]".$attr["content"]."[/img]";
}
}
Cache::set($match[1],$text);
}
return($text);
}
function bb_CleanPictureLinks($text) {
$text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_CleanPictureLinksSub', $text);
return ($text);
}
// BBcode 2 HTML was written by WAY2WEB.net // BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica - Mike Macgirvin // extended to work with Mistpark/Friendica - Mike Macgirvin
@ -635,6 +706,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// Set up the parameters for a MAIL search string // Set up the parameters for a MAIL search string
$MAILSearchString = $URLSearchString; $MAILSearchString = $URLSearchString;
// Bookmarks in red - will be converted to bookmarks in friendica
$Text = preg_replace("/#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $Text);
$Text = preg_replace("/#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $Text);
if ($simplehtml == 5) if ($simplehtml == 5)
$Text = preg_replace("/[^#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text); $Text = preg_replace("/[^#@]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url]$1[/url]', $Text);
@ -652,7 +727,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text); $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
else { else {
$Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text); $Text = preg_replace("(\[url\]([$URLSearchString]*)\[\/url\])ism"," $1 ",$Text);
$Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'RemovePictureLinks', $Text); $Text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'bb_RemovePictureLinks', $Text);
} }
if ($tryoembed) if ($tryoembed)

View file

@ -2,29 +2,42 @@
/** /**
* cache api * cache api
*/ */
class Cache { class Cache {
public static function get($key){ public static function get($key) {
if (function_exists("apc_fetch") AND function_exists("apc_exists"))
if (apc_exists($key))
return(apc_fetch($key));
$r = q("SELECT `v` FROM `cache` WHERE `k`='%s' limit 1", $r = q("SELECT `v` FROM `cache` WHERE `k`='%s' limit 1",
dbesc($key) dbesc($key)
); );
if (count($r)) return $r[0]['v']; if (count($r)) {
if (function_exists("apc_store"))
apc_store($key, $r[0]['v'], 600);
return $r[0]['v'];
}
return null; return null;
} }
public static function set($key,$value) { public static function set($key,$value) {
q("REPLACE INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')", q("REPLACE INTO `cache` (`k`,`v`,`updated`) VALUES ('%s','%s','%s')",
dbesc($key), dbesc($key),
dbesc($value), dbesc($value),
dbesc(datetime_convert())); dbesc(datetime_convert()));
if (function_exists("apc_store"))
apc_store($key, $value, 600);
} }
/* /*
* *
* Leaving this legacy code temporaily to see how REPLACE fares * Leaving this legacy code temporaily to see how REPLACE fares
* as opposed to non-atomic checks when faced with fast moving key duplication. * as opposed to non-atomic checks when faced with fast moving key duplication.
* As a MySQL extension it isn't portable, but we're not yet very portable. * As a MySQL extension it isn't portable, but we're not yet very portable.
*/ */
@ -48,11 +61,11 @@
* } * }
*/ */
public static function clear(){ public static function clear(){
q("DELETE FROM `cache` WHERE `updated` < '%s'", q("DELETE FROM `cache` WHERE `updated` < '%s'",
dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); dbesc(datetime_convert('UTC','UTC',"now - 30 days")));
} }
} }

View file

@ -203,6 +203,10 @@ function display_content(&$a, $update = 0) {
$title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true)); $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
$author_name = $r[0]["author-name"]; $author_name = $r[0]["author-name"];
$image = "";
if ($image == "")
$image = $r[0]["thumb"];
if ($title == "") if ($title == "")
$title = $author_name; $title = $author_name;
@ -219,9 +223,16 @@ function display_content(&$a, $update = 0) {
// Schema.org microdata // Schema.org microdata
$a->page['htmlhead'] .= '<meta itemprop="name" content="'.$title.'" />'."\n"; $a->page['htmlhead'] .= '<meta itemprop="name" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta itemprop="description" content="'.$description.'" />'."\n"; $a->page['htmlhead'] .= '<meta itemprop="description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta itemprop="image" content="'.$r[0]["thumb"].'" />'."\n"; $a->page['htmlhead'] .= '<meta itemprop="image" content="'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta itemprop="author" content="'.$author_name.'" />'."\n"; $a->page['htmlhead'] .= '<meta itemprop="author" content="'.$author_name.'" />'."\n";
// Twitter cards
$a->page['htmlhead'] .= '<meta name="twitter:card" content="summary" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$r[0]["plink"].'" />'."\n";
// Dublin Core // Dublin Core
$a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="DC.description" content="'.$description.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="DC.description" content="'.$description.'" />'."\n";
@ -229,7 +240,7 @@ function display_content(&$a, $update = 0) {
// Open Graph // Open Graph
$a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:image" content="'.$r[0]["thumb"].'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:image" content="'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:url" content="'.$r[0]["plink"].'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:url" content="'.$r[0]["plink"].'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";

View file

@ -52,6 +52,9 @@ function completeurl($url, $scheme) {
function parseurl_getsiteinfo($url, $no_guessing = false) { function parseurl_getsiteinfo($url, $no_guessing = false) {
$siteinfo = array(); $siteinfo = array();
$siteinfo["type"] = "link";
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HEADER, 1);
@ -165,6 +168,18 @@ function parseurl_getsiteinfo($url, $no_guessing = false) {
case "description": case "description":
$siteinfo["text"] = $attr["content"]; $siteinfo["text"] = $attr["content"];
break; break;
case "twitter:image":
$siteinfo["image"] = $attr["content"];
break;
case "twitter:card":
$siteinfo["type"] = $attr["content"];
break;
case "twitter:description":
$siteinfo["text"] = $attr["content"];
break;
case "twitter:title":
$siteinfo["title"] = $attr["content"];
break;
case "dc.title": case "dc.title":
$siteinfo["title"] = $attr["content"]; $siteinfo["title"] = $attr["content"];
break; break;
@ -311,9 +326,9 @@ function parse_url_content(&$a) {
logger('parse_url: ' . $url); logger('parse_url: ' . $url);
if($textmode) if($textmode)
$template = '[bookmark=%s]%s[/bookmark]%s' . $br; $template = '[bookmark=%s]%s[/bookmark]%s';
else else
$template = "<a class=\"bookmark\" href=\"%s\" >%s</a>%s<br />"; $template = "<a class=\"bookmark\" href=\"%s\" >%s</a>%s";
$arr = array('url' => $url, 'text' => ''); $arr = array('url' => $url, 'text' => '');
@ -386,9 +401,10 @@ function parse_url_content(&$a) {
$text = '<blockquote>'.htmlspecialchars(trim($text)).'</blockquote>'; $text = '<blockquote>'.htmlspecialchars(trim($text)).'</blockquote>';
} }
if($image) { if($image)
$text = $br.$br.$image.$text; $text = $br.$br.$image.$text;
} else
$text = $br.$text;
$title = str_replace(array("\r","\n"),array('',''),$title); $title = str_replace(array("\r","\n"),array('',''),$title);
@ -398,7 +414,10 @@ function parse_url_content(&$a) {
$sitedata .= trim($result); $sitedata .= trim($result);
echo "[class=type-link]".$sitedata."[/class]"; if (($siteinfo["type"] != "photo"))
echo "[class=type-link]".$sitedata."[/class]";
else
echo "[class=type-photo]".$title.$br.$image."[/class]";
killme(); killme();
} }

View file

@ -49,7 +49,7 @@ function photos_init(&$a) {
if($albums_visible) { if($albums_visible) {
$o .= '<div id="side-bar-photos-albums" class="widget">'; $o .= '<div id="side-bar-photos-albums" class="widget">';
$o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>'; $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
$o .= '<ul>'; $o .= '<ul>';
foreach($albums as $album) { foreach($albums as $album) {
@ -464,11 +464,11 @@ function photos_post(&$a) {
$arr['last-child'] = 1; $arr['last-child'] = 1;
$arr['visible'] = $visibility; $arr['visible'] = $visibility;
$arr['origin'] = 1; $arr['origin'] = 1;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
. '[/url]'; . '[/url]';
$item_id = item_store($arr); $item_id = item_store($arr);
} }
@ -623,7 +623,7 @@ function photos_post(&$a) {
if(count($taginfo)) { if(count($taginfo)) {
foreach($taginfo as $tagged) { foreach($taginfo as $tagged) {
$uri = item_new_uri($a->get_hostname(),$page_owner_uid); $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
$arr = array(); $arr = array();
@ -914,8 +914,8 @@ function photos_content(&$a) {
notice( t('Public access denied.') . EOL); notice( t('Public access denied.') . EOL);
return; return;
} }
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/security.php'); require_once('include/security.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
@ -1032,7 +1032,7 @@ function photos_content(&$a) {
// tabs // tabs
$_is_owner = (local_user() && (local_user() == $owner_uid)); $_is_owner = (local_user() && (local_user() == $owner_uid));
$o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']); $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
// //
// dispatch request // dispatch request
@ -1051,7 +1051,7 @@ function photos_content(&$a) {
$albumselect = ''; $albumselect = '';
$albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>'; $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
if(count($a->data['albums'])) { if(count($a->data['albums'])) {
foreach($a->data['albums'] as $album) { foreach($a->data['albums'] as $album) {
@ -1178,8 +1178,8 @@ function photos_content(&$a) {
); );
$o .= '<h3>' . $album . '</h3>'; $o .= '<h3>' . $album . '</h3>';
if($cmd === 'edit') { if($cmd === 'edit') {
if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) { if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) { if($can_post) {
$edit_tpl = get_markup_template('album_edit.tpl'); $edit_tpl = get_markup_template('album_edit.tpl');
@ -1231,7 +1231,7 @@ function photos_content(&$a) {
$twist = 'rotleft'; $twist = 'rotleft';
else else
$twist = 'rotright'; $twist = 'rotright';
$ext = $phototypes[$rr['type']]; $ext = $phototypes[$rr['type']];
if($a->theme['template_engine'] === 'internal') { if($a->theme['template_engine'] === 'internal') {
@ -1260,7 +1260,7 @@ function photos_content(&$a) {
return $o; return $o;
} }
if($datatype === 'image') { if($datatype === 'image') {
@ -1277,12 +1277,12 @@ function photos_content(&$a) {
); );
if(! count($ph)) { if(! count($ph)) {
$ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
LIMIT 1", LIMIT 1",
intval($owner_uid), intval($owner_uid),
dbesc($datum) dbesc($datum)
); );
if(count($ph)) if(count($ph))
notice( t('Permission denied. Access to this item may be restricted.')); notice( t('Permission denied. Access to this item may be restricted.'));
else else
notice( t('Photo not available') . EOL ); notice( t('Photo not available') . EOL );
@ -1298,11 +1298,11 @@ function photos_content(&$a) {
$order = 'DESC'; $order = 'DESC';
$prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
$sql_extra ORDER BY `created` $order ", $sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']), dbesc($ph[0]['album']),
intval($owner_uid) intval($owner_uid)
); );
if(count($prvnxt)) { if(count($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) { for($z = 0; $z < count($prvnxt); $z++) {
@ -1338,7 +1338,7 @@ function photos_content(&$a) {
$album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']); $album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null; $tools = Null;
$lock = Null; $lock = Null;
if($can_post && ($ph[0]['uid'] == $owner_uid)) { if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array( $tools = array(
'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
@ -1350,8 +1350,8 @@ function photos_content(&$a) {
|| strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) ) || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
? t('Private Message') ? t('Private Message')
: Null); : Null);
} }
if( $cmd === 'edit') { if( $cmd === 'edit') {
@ -1368,7 +1368,11 @@ function photos_content(&$a) {
$photo = array( $photo = array(
'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
'title'=> t('View Full Size'), 'title'=> t('View Full Size'),
'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis') 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis'),
'height' => $hires['height'],
'width' => $hires['width'],
'album' => $hires['album'],
'filename' => $hires['filename'],
); );
if($nextlink) if($nextlink)
@ -1377,7 +1381,7 @@ function photos_content(&$a) {
// Do we have an item for this photo? // Do we have an item for this photo?
// FIXME! - replace following code to display the conversation with our normal // FIXME! - replace following code to display the conversation with our normal
// conversation functions so that it works correctly and tracks changes // conversation functions so that it works correctly and tracks changes
// in the evolving conversation code. // in the evolving conversation code.
// The difference is that we won't be displaying the conversation head item // The difference is that we won't be displaying the conversation head item
@ -1392,7 +1396,7 @@ function photos_content(&$a) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra ", $sql_extra ",
dbesc($link_item['uri']), dbesc($link_item['uri']),
dbesc($link_item['uri']), dbesc($link_item['uri']),
@ -1404,9 +1408,9 @@ function photos_content(&$a) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
`contact`.`rel`, `contact`.`thumb`, `contact`.`self`, `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
@ -1440,7 +1444,7 @@ function photos_content(&$a) {
if(strlen($tag_str)) if(strlen($tag_str))
$tag_str .= ', '; $tag_str .= ', ';
$tag_str .= bbcode($t); $tag_str .= bbcode($t);
} }
$tags = array(t('Tags: '), $tag_str); $tags = array(t('Tags: '), $tag_str);
if($cmd === 'edit') { if($cmd === 'edit') {
$tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id']; $tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id'];
@ -1487,7 +1491,7 @@ function photos_content(&$a) {
'$rotatecw' => t('Rotate CW (right)'), '$rotatecw' => t('Rotate CW (right)'),
'$rotateccw' => t('Rotate CCW (left)'), '$rotateccw' => t('Rotate CCW (left)'),
'$album' => $album_e, '$album' => $album_e,
'$newalbum' => t('New album name'), '$newalbum' => t('New album name'),
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['user']['nickname'],
'$resource_id' => $ph[0]['resource-id'], '$resource_id' => $ph[0]['resource-id'],
'$capt_label' => t('Caption'), '$capt_label' => t('Caption'),
@ -1539,7 +1543,7 @@ function photos_content(&$a) {
if($can_post || can_write_wall($a,$owner_uid)) { if($can_post || can_write_wall($a,$owner_uid)) {
if($link_item['last-child']) { if($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array( $comments .= replace_macros($cmnt_tpl,array(
'$return_path' => '', '$return_path' => '',
'$jsreload' => $return_url, '$jsreload' => $return_url,
'$type' => 'wall-comment', '$type' => 'wall-comment',
'$id' => $link_item['id'], '$id' => $link_item['id'],
@ -1561,7 +1565,7 @@ function photos_content(&$a) {
$alike = array(); $alike = array();
$dlike = array(); $dlike = array();
$like = ''; $like = '';
$dislike = ''; $dislike = '';
@ -1612,9 +1616,9 @@ function photos_content(&$a) {
continue; continue;
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
if(local_user() && ($item['contact-uid'] == local_user())
if(local_user() && ($item['contact-uid'] == local_user())
&& ($item['network'] == 'dfrn') && (! $item['self'] )) { && ($item['network'] == 'dfrn') && (! $item['self'] )) {
$profile_url = $redirect_url; $profile_url = $redirect_url;
$sparkle = ' sparkle'; $sparkle = ' sparkle';
@ -1623,7 +1627,7 @@ function photos_content(&$a) {
$profile_url = $item['url']; $profile_url = $item['url'];
$sparkle = ''; $sparkle = '';
} }
$diff_author = (($item['url'] !== $item['author-link']) ? true : false); $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
$profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']); $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
@ -1689,7 +1693,7 @@ function photos_content(&$a) {
$paginate = paginate($a); $paginate = paginate($a);
} }
$photo_tpl = get_markup_template('photo_view.tpl'); $photo_tpl = get_markup_template('photo_view.tpl');
if($a->theme['template_engine'] === 'internal') { if($a->theme['template_engine'] === 'internal') {
@ -1715,14 +1719,20 @@ function photos_content(&$a) {
'$nextlink' => $nextlink, '$nextlink' => $nextlink,
'$desc' => $ph[0]['desc'], '$desc' => $ph[0]['desc'],
'$tags' => $tags_e, '$tags' => $tags_e,
'$edit' => $edit, '$edit' => $edit,
'$likebuttons' => $likebuttons, '$likebuttons' => $likebuttons,
'$like' => $like_e, '$like' => $like_e,
'$dislike' => $dikslike_e, '$dislike' => $dikslike_e,
'$comments' => $comments, '$comments' => $comments,
'$paginate' => $paginate, '$paginate' => $paginate,
)); ));
$a->page['htmlhead'] .= "\n".'<meta name="twitter:card" content="photo" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$photo["album"].'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="'.$photo["href"].'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image:width" content="'.$photo["width"].'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image:height" content="'.$photo["height"].'" />'."\n";
return $o; return $o;
} }
@ -1783,12 +1793,12 @@ function photos_content(&$a) {
'name' => $name_e, 'name' => $name_e,
'alt' => t('View Album'), 'alt' => t('View Album'),
), ),
); );
} }
} }
$tpl = get_markup_template('photos_recent.tpl'); $tpl = get_markup_template('photos_recent.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
'$title' => t('Recent Photos'), '$title' => t('Recent Photos'),
'$can_post' => $can_post, '$can_post' => $can_post,
@ -1796,7 +1806,7 @@ function photos_content(&$a) {
'$photos' => $photos, '$photos' => $photos,
)); ));
$o .= paginate($a); $o .= paginate($a);
return $o; return $o;
} }

View file

@ -0,0 +1,52 @@
<?php
/**
* Theme settings
*/
function theme_content(&$a){
if(!local_user())
return;
$style = get_pconfig(local_user(), 'vier', 'style');
return vier_form($a,$style);
}
function theme_post(&$a){
if(! local_user())
return;
if (isset($_POST['vier-settings-submit'])){
set_pconfig(local_user(), 'vier', 'style', $_POST['vier_style']);
}
}
function theme_admin(&$a){
$style = get_config('vier', 'style');
return vier_form($a,$style);
}
function theme_admin_post(&$a){
if (isset($_POST['vier-settings-submit'])){
set_config('vier', 'style', $_POST['vier_style']);
}
}
function vier_form(&$a, $style){
$styles = array(
"shadow"=>"Shadow",
"flat"=>"Flat"
);
$t = get_markup_template("theme_settings.tpl" );
$o .= replace_macros($t, array(
'$submit' => t('Submit'),
'$baseurl' => $a->get_baseurl(),
'$title' => t("Theme settings"),
'$style' => array('vier_style',t ('Set style'),$style,'',$styles),
));
return $o;
}

4
view/theme/vier/flat.css Normal file
View file

@ -0,0 +1,4 @@
*{ box-shadow: 0 0 0 0 !important;}
body, section { background-color: #ffffff !important;}
#profile-jot-form { background-color: #ffffff !important;}
.dspr, .twit, .pump, .dfrn { background-color: #ffffff !important;}

View file

@ -1219,6 +1219,10 @@ border-bottom: 1px solid #D2D2D2;
.type-link .oembed { .type-link .oembed {
} }
.type-link img + br{
display: none;
}
.wall-item-container .wall-item-content { .wall-item-container .wall-item-content {
/* font-size: 14px; */ /* font-size: 14px; */
max-width: 660px; max-width: 660px;

View file

@ -0,0 +1,11 @@
{{*
* AUTOMATICALLY GENERATED TEMPLATE
* DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
*
*}}
{{include file="field_select.tpl" field=$style}}
<div class="settings-submit-wrapper">
<input type="submit" value="{{$submit}}" class="settings-submit" name="vier-settings-submit" />
</div>

View file

@ -15,6 +15,10 @@ $baseurl = $a->get_baseurl();
$a->theme_info = array(); $a->theme_info = array();
$style = get_pconfig(local_user(), 'vier', 'style');
if ($style == "flat")
$a->page['htmlhead'] .= '<link rel="stylesheet" href="view/theme/vier/flat.css" type="text/css" media="screen"/>'."\n";
$a->page['htmlhead'] .= <<< EOT $a->page['htmlhead'] .= <<< EOT
<script type="text/javascript" src="$baseurl/view/theme/vier/js/jquery.divgrow-1.3.1.f1.min.js"></script> <script type="text/javascript" src="$baseurl/view/theme/vier/js/jquery.divgrow-1.3.1.f1.min.js"></script>
<script> <script>