Add source of link (via imput)

This commit is contained in:
Knah Tsaeb 2013-10-11 15:18:37 +02:00
parent 6f5933d23f
commit 040eb18ec8
3 changed files with 23 additions and 5 deletions

View file

@ -432,6 +432,12 @@ if (isset($_POST['login']))
// ------------------------------------------------------------------------------------------
// Misc utility functions:
// Try to get just domain for @via
function getJustDomain($url){
$parts = parse_url($url);
return trim($parts['host']);
}
// Returns the server URL (including port and http/https), without path.
// eg. "http://myserver.com:8080"
// You can append $_SERVER['SCRIPT_NAME'] to get the current script URL.
@ -794,7 +800,8 @@ class linkdb implements Iterator, Countable, ArrayAccess
$found= (strpos(strtolower($l['title']),$s)!==false)
|| (strpos(strtolower($l['description']),$s)!==false)
|| (strpos(strtolower($l['url']),$s)!==false)
|| (strpos(strtolower($l['tags']),$s)!==false);
|| (strpos(strtolower($l['tags']),$s)!==false)
|| (strpos(strtolower($l['via']),$s)!==false);
if ($found) $filtered[$l['linkdate']] = $l;
}
krsort($filtered);
@ -939,7 +946,12 @@ function showRSS()
// If user wants permalinks first, put the final link in description
if ($usepermalinks===true) $descriptionlink = '(<a href="'.$absurl.'">Link</a>)';
if (strlen($link['description'])>0) $descriptionlink = '<br>'.$descriptionlink;
echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$descriptionlink.']]></description>'."\n</item>\n";
if(!empty($link['via'])){
$via = '<br>via '.text2clickable(htmlspecialchars($link['via']));
} else {
$via = '';
}
echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$via.$descriptionlink.']]></description>'."\n</item>\n";
$i++;
}
echo '</channel></rss><!-- Cached version of '.pageUrl().' -->';
@ -1001,11 +1013,12 @@ function showATOM()
// Add permalink in description
$descriptionlink = htmlspecialchars('(<a href="'.$guid.'">Permalink</a>)');
$via = htmlspecialchars('</br> via '.(text2clickable(htmlspecialchars($link['via']))));
// If user wants permalinks first, put the final link in description
if ($usepermalinks===true) $descriptionlink = htmlspecialchars('(<a href="'.$absurl.'">Link</a>)');
if (strlen($link['description'])>0) $descriptionlink = '&lt;br&gt;'.$descriptionlink;
$entries.='<content type="html">'.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink."</content>\n";
$entries.='<content type="html">'.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink.$via."</content>\n";
if ($link['tags']!='') // Adding tags to each ATOM entry (as mentioned in ATOM specification)
{
foreach(explode(' ',$link['tags']) as $tag)
@ -1472,7 +1485,7 @@ function renderPage()
if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?'))
$url = 'http://'.$url;
$link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags));
'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags), 'via'=>trim($_POST['lf_via']));
if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
$LINKSDB[$linkdate] = $link;
$LINKSDB->savedb(); // save to disk
@ -1582,7 +1595,7 @@ function renderPage()
}
}
if ($url=='') $url='?'.smallHash($linkdate); // In case of empty URL, this is just a text (with a link that point to itself)
$link = array('linkdate'=>$linkdate,'title'=>$title,'url'=>$url,'description'=>$description,'tags'=>$tags,'private'=>$private);
$link = array('linkdate'=>$linkdate,'title'=>$title,'url'=>$url,'description'=>$description,'tags'=>$tags,'via' => $via,'private'=>$private);
}
$PAGE = new pageBuilder;
@ -1832,6 +1845,9 @@ function buildLinkList($PAGE,$LINKSDB)
$taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp');
$link['taglist']=$taglist;
if(!empty($link['via'])){
$link['via']=htmlspecialchars($link['via']);
}
$linkDisp[$keys[$i]] = $link;
$i++;
}

View file

@ -16,6 +16,7 @@
<i>Title</i><br><input type="text" name="lf_title" value="{$link.title|htmlspecialchars}" style="width:100%"><br>
<i>Description</i><br><textarea name="lf_description" rows="4" cols="25" style="width:100%">{$link.description|htmlspecialchars}</textarea><br>
<i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br>
<i>Via</i><br><input type="text" name="lf_via" value="{$link.via|htmlspecialchars}" style="width:100%"><br>
{if condition="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}
<input type="checkbox" checked="checked" name="lf_private" id="lf_private">
&nbsp;<label for="lf_private"><i>Private</i></label><br>

View file

@ -43,6 +43,7 @@
<span class="linktitle"><a href="{$redirector}{$value.url|htmlspecialchars}">{$value.title|htmlspecialchars}</a></span>
<br>
{if="$value.description"}<div class="linkdescription"{if condition="$search_type=='permalink'"} style="max-height:none !important;"{/if}>{$value.description}</div>{/if}
{if condition="isset($value.via) && !empty($value.via)"}<div><a href="{$value.via}">@ via {$value.via|getJustDomain}</a></div>{/if}
{if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"}
<span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{$value.localdate|htmlspecialchars} - permalink</a> - </span>
{else}