Apply the new ID system accros the whole codebase

This commit is contained in:
ArthurHoaro 2016-11-28 16:16:44 +01:00
parent 1dc37f9cf8
commit 01878a75b9
9 changed files with 100 additions and 85 deletions

View file

@ -143,7 +143,7 @@ class FeedBuilder
*/ */
protected function buildItem($link, $pageaddr) protected function buildItem($link, $pageaddr)
{ {
$link['guid'] = $pageaddr .'?'. smallHash($link['linkdate']); $link['guid'] = $pageaddr .'?'. smallHash($link['created']->format('Ymd_His'));
// Check for both signs of a note: starting with ? and 7 chars long. // Check for both signs of a note: starting with ? and 7 chars long.
if ($link['url'][0] === '?' && strlen($link['url']) === 7) { if ($link['url'][0] === '?' && strlen($link['url']) === 7) {
$link['url'] = $pageaddr . $link['url']; $link['url'] = $pageaddr . $link['url'];
@ -156,12 +156,12 @@ class FeedBuilder
$link['description'] = format_description($link['description'], '', $pageaddr); $link['description'] = format_description($link['description'], '', $pageaddr);
$link['description'] .= PHP_EOL .'<br>&#8212; '. $permalink; $link['description'] .= PHP_EOL .'<br>&#8212; '. $permalink;
$pubDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $pubDate = $link['created'];
$link['pub_iso_date'] = $this->getIsoDate($pubDate); $link['pub_iso_date'] = $this->getIsoDate($pubDate);
// atom:entry elements MUST contain exactly one atom:updated element. // atom:entry elements MUST contain exactly one atom:updated element.
if (!empty($link['updated'])) { if (!empty($link['updated'])) {
$upDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']); $upDate = $link['updated'];
$link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM); $link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM);
} else { } else {
$link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);; $link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);;

View file

@ -33,12 +33,12 @@ class LinkFilter
public static $HASHTAG_CHARS = '\p{Pc}\p{N}\p{L}\p{Mn}'; public static $HASHTAG_CHARS = '\p{Pc}\p{N}\p{L}\p{Mn}';
/** /**
* @var array all available links. * @var LinkDB all available links.
*/ */
private $links; private $links;
/** /**
* @param array $links initialization. * @param LinkDB $links initialization.
*/ */
public function __construct($links) public function __construct($links)
{ {
@ -94,18 +94,16 @@ class LinkFilter
private function noFilter($privateonly = false) private function noFilter($privateonly = false)
{ {
if (! $privateonly) { if (! $privateonly) {
krsort($this->links);
return $this->links; return $this->links;
} }
$out = array(); $out = array();
foreach ($this->links as $value) { foreach ($this->links as $key => $value) {
if ($value['private']) { if ($value['private']) {
$out[$value['linkdate']] = $value; $out[$key] = $value;
} }
} }
krsort($out);
return $out; return $out;
} }
@ -121,10 +119,10 @@ class LinkFilter
private function filterSmallHash($smallHash) private function filterSmallHash($smallHash)
{ {
$filtered = array(); $filtered = array();
foreach ($this->links as $l) { foreach ($this->links as $key => $l) {
if ($smallHash == smallHash($l['linkdate'])) { if ($smallHash == smallHash($l['created']->format('Ymd_His'))) {
// Yes, this is ugly and slow // Yes, this is ugly and slow
$filtered[$l['linkdate']] = $l; $filtered[$key] = $l;
return $filtered; return $filtered;
} }
} }
@ -188,7 +186,7 @@ class LinkFilter
$keys = array('title', 'description', 'url', 'tags'); $keys = array('title', 'description', 'url', 'tags');
// Iterate over every stored link. // Iterate over every stored link.
foreach ($this->links as $link) { foreach ($this->links as $id => $link) {
// ignore non private links when 'privatonly' is on. // ignore non private links when 'privatonly' is on.
if (! $link['private'] && $privateonly === true) { if (! $link['private'] && $privateonly === true) {
@ -222,11 +220,10 @@ class LinkFilter
} }
if ($found) { if ($found) {
$filtered[$link['linkdate']] = $link; $filtered[$id] = $link;
} }
} }
krsort($filtered);
return $filtered; return $filtered;
} }
@ -256,7 +253,7 @@ class LinkFilter
return $filtered; return $filtered;
} }
foreach ($this->links as $link) { foreach ($this->links as $key => $link) {
// ignore non private links when 'privatonly' is on. // ignore non private links when 'privatonly' is on.
if (! $link['private'] && $privateonly === true) { if (! $link['private'] && $privateonly === true) {
continue; continue;
@ -278,10 +275,9 @@ class LinkFilter
} }
if ($found) { if ($found) {
$filtered[$link['linkdate']] = $link; $filtered[$key] = $link;
} }
} }
krsort($filtered);
return $filtered; return $filtered;
} }
@ -304,13 +300,14 @@ class LinkFilter
} }
$filtered = array(); $filtered = array();
foreach ($this->links as $l) { foreach ($this->links as $key => $l) {
if (startsWith($l['linkdate'], $day)) { if ($l['created']->format('Ymd') == $day) {
$filtered[$l['linkdate']] = $l; $filtered[$key] = $l;
} }
} }
ksort($filtered);
return $filtered; // sort by date ASC
return array_reverse($filtered, true);
} }
/** /**

View file

@ -38,7 +38,7 @@ class NetscapeBookmarkUtils
if ($link['private'] == 0 && $selection == 'private') { if ($link['private'] == 0 && $selection == 'private') {
continue; continue;
} }
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $date = $link['created'];
$link['timestamp'] = $date->getTimestamp(); $link['timestamp'] = $date->getTimestamp();
$link['taglist'] = str_replace(' ', ',', $link['tags']); $link['taglist'] = str_replace(' ', ',', $link['tags']);
@ -147,7 +147,6 @@ class NetscapeBookmarkUtils
'url' => $bkm['uri'], 'url' => $bkm['uri'],
'description' => $bkm['note'], 'description' => $bkm['note'],
'private' => $private, 'private' => $private,
'linkdate'=> '',
'tags' => $bkm['tags'] 'tags' => $bkm['tags']
); );
@ -161,25 +160,21 @@ class NetscapeBookmarkUtils
} }
// Overwrite an existing link, keep its date // Overwrite an existing link, keep its date
$newLink['linkdate'] = $existingLink['linkdate']; $newLink['id'] = $existingLink['id'];
$linkDb[$existingLink['linkdate']] = $newLink; $newLink['created'] = $existingLink['created'];
$newLink['updated'] = new DateTime();
$linkDb[$existingLink['id']] = $newLink;
$importCount++; $importCount++;
$overwriteCount++; $overwriteCount++;
continue; continue;
} }
// Add a new link // Add a new link - @ used for UNIX timestamps
$newLinkDate = new DateTime('@'.strval($bkm['time'])); $newLinkDate = new DateTime('@'.strval($bkm['time']));
while (!empty($linkDb[$newLinkDate->format(LinkDB::LINK_DATE_FORMAT)])) { $newLinkDate->setTimezone(new DateTimeZone(date_default_timezone_get()));
// Ensure the date/time is not already used $newLink['created'] = $newLinkDate;
// - this hack is necessary as the date/time acts as a primary key $newLink['id'] = $linkDb->getNextId();
// - apply 1 second increments until an unused index is found $linkDb[$newLink['id']] = $newLink;
// See https://github.com/shaarli/Shaarli/issues/351
$newLinkDate->add(new DateInterval('PT1S'));
}
$linkDbDate = $newLinkDate->format(LinkDB::LINK_DATE_FORMAT);
$newLink['linkdate'] = $linkDbDate;
$linkDb[$linkDbDate] = $newLink;
$importCount++; $importCount++;
} }

View file

@ -218,7 +218,7 @@ class Updater
/** /**
* Update the database to use the new ID system, which replaces linkdate primary keys. * Update the database to use the new ID system, which replaces linkdate primary keys.
* Also, creation and update dates are now DateTime objects. * Also, creation and update dates are now DateTime objects (done by LinkDB).
* *
* Since this update is very sensitve (changing the whole database), the datastore will be * Since this update is very sensitve (changing the whole database), the datastore will be
* automatically backed up into the file datastore.<datetime>.php. * automatically backed up into the file datastore.<datetime>.php.
@ -243,10 +243,6 @@ class Updater
$links = array_reverse($links); $links = array_reverse($links);
$cpt = 0; $cpt = 0;
foreach ($links as $l) { foreach ($links as $l) {
$l['created'] = DateTime::createFromFormat('Ymd_His', $l['linkdate']);
if (! empty($l['updated'])) {
$l['updated'] = DateTime::createFromFormat('Ymd_His', $l['updated']);
}
unset($l['linkdate']); unset($l['linkdate']);
$l['id'] = $cpt; $l['id'] = $cpt;
$this->linkDB[$cpt++] = $l; $this->linkDB[$cpt++] = $l;

View file

@ -564,24 +564,23 @@ function showDailyRSS($conf) {
); );
/* Some Shaarlies may have very few links, so we need to look /* Some Shaarlies may have very few links, so we need to look
back in time (rsort()) until we have enough days ($nb_of_days). back in time until we have enough days ($nb_of_days).
*/ */
$linkdates = array(); $ids = array();
foreach ($LINKSDB as $linkdate => $value) { foreach ($LINKSDB as $id => $value) {
$linkdates[] = $linkdate; $ids[] = $id;
} }
rsort($linkdates);
$nb_of_days = 7; // We take 7 days. $nb_of_days = 7; // We take 7 days.
$today = date('Ymd'); $today = date('Ymd');
$days = array(); $days = array();
foreach ($linkdates as $linkdate) { foreach ($ids as $id) {
$day = substr($linkdate, 0, 8); // Extract day (without time) $day = $LINKSDB[$id]['created']->format('Ymd'); // Extract day (without time)
if (strcmp($day,$today) < 0) { if (strcmp($day, $today) < 0) {
if (empty($days[$day])) { if (empty($days[$day])) {
$days[$day] = array(); $days[$day] = array();
} }
$days[$day][] = $linkdate; $days[$day][] = $id;
} }
if (count($days) > $nb_of_days) { if (count($days) > $nb_of_days) {
@ -601,7 +600,7 @@ function showDailyRSS($conf) {
echo '<copyright>'. $pageaddr .'</copyright>'. PHP_EOL; echo '<copyright>'. $pageaddr .'</copyright>'. PHP_EOL;
// For each day. // For each day.
foreach ($days as $day => $linkdates) { foreach ($days as $day => $ids) {
$dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000'); $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000');
$absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page. $absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page.
@ -609,16 +608,15 @@ function showDailyRSS($conf) {
$links = array(); $links = array();
// We pre-format some fields for proper output. // We pre-format some fields for proper output.
foreach ($linkdates as $linkdate) { foreach ($ids as $id) {
$l = $LINKSDB[$linkdate]; $l = $LINKSDB[$id];
$l['formatedDescription'] = format_description($l['description'], $conf->get('redirector.url')); $l['formatedDescription'] = format_description($l['description'], $conf->get('redirector.url'));
$l['thumbnail'] = thumbnail($conf, $l['url']); $l['thumbnail'] = thumbnail($conf, $l['url']);
$l_date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $l['linkdate']); $l['timestamp'] = $l['created']->getTimestamp();
$l['timestamp'] = $l_date->getTimestamp();
if (startsWith($l['url'], '?')) { if (startsWith($l['url'], '?')) {
$l['url'] = index_url($_SERVER) . $l['url']; // make permalink URL absolute $l['url'] = index_url($_SERVER) . $l['url']; // make permalink URL absolute
} }
$links[$linkdate] = $l; $links[$id] = $l;
} }
// Then build the HTML for this day: // Then build the HTML for this day:
@ -677,11 +675,11 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
$taglist = explode(' ',$link['tags']); $taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp'); uasort($taglist, 'strcasecmp');
$linksToDisplay[$key]['shorturl'] = smallHash($link['created']->format('Ymd_His'));
$linksToDisplay[$key]['taglist']=$taglist; $linksToDisplay[$key]['taglist']=$taglist;
$linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('redirector.url')); $linksToDisplay[$key]['formatedDescription'] = format_description($link['description'], $conf->get('redirector.url'));
$linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']); $linksToDisplay[$key]['thumbnail'] = thumbnail($conf, $link['url']);
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $linksToDisplay[$key]['timestamp'] = $link['created']->getTimestamp();
$linksToDisplay[$key]['timestamp'] = $date->getTimestamp();
} }
/* We need to spread the articles on 3 columns. /* We need to spread the articles on 3 columns.
@ -831,7 +829,7 @@ function renderPage($conf, $pluginManager)
// Get only links which have a thumbnail. // Get only links which have a thumbnail.
foreach($links as $link) foreach($links as $link)
{ {
$permalink='?'.escape(smallHash($link['linkdate'])); $permalink='?'.escape(smallHash($link['created']->format('Ymd_His')));
$thumb=lazyThumbnail($conf, $link['url'],$permalink); $thumb=lazyThumbnail($conf, $link['url'],$permalink);
if ($thumb!='') // Only output links which have a thumbnail. if ($thumb!='') // Only output links which have a thumbnail.
{ {
@ -1245,13 +1243,28 @@ function renderPage($conf, $pluginManager)
// -------- User clicked the "Save" button when editing a link: Save link to database. // -------- User clicked the "Save" button when editing a link: Save link to database.
if (isset($_POST['save_edit'])) if (isset($_POST['save_edit']))
{ {
$linkdate = $_POST['lf_linkdate'];
$updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false;
// Go away! // Go away!
if (! tokenOk($_POST['token'])) { if (! tokenOk($_POST['token'])) {
die('Wrong token.'); die('Wrong token.');
} }
// lf_id should only be present if the link exists.
$id = !empty($_POST['lf_id']) ? (int) escape($_POST['lf_id']) : $LINKSDB->getNextId();
// Linkdate is kept here to:
// - use the same permalink for notes as they're displayed when creating them
// - let users hack creation date of their posts
// See: https://github.com/shaarli/Shaarli/wiki/Datastore-hacks#changing-the-timestamp-for-a-link
$linkdate = escape($_POST['lf_linkdate']);
if (isset($LINKSDB[$id])) {
// Edit
$created = DateTime::createFromFormat('Ymd_His', $linkdate);
$updated = new DateTime();
} else {
// New link
$created = DateTime::createFromFormat('Ymd_His', $linkdate);
$updated = null;
}
// Remove multiple spaces. // Remove multiple spaces.
$tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags'])); $tags = trim(preg_replace('/\s\s+/', ' ', $_POST['lf_tags']));
// Remove first '-' char in tags. // Remove first '-' char in tags.
@ -1268,14 +1281,16 @@ function renderPage($conf, $pluginManager)
} }
$link = array( $link = array(
'id' => $id,
'title' => trim($_POST['lf_title']), 'title' => trim($_POST['lf_title']),
'url' => $url, 'url' => $url,
'description' => $_POST['lf_description'], 'description' => $_POST['lf_description'],
'private' => (isset($_POST['lf_private']) ? 1 : 0), 'private' => (isset($_POST['lf_private']) ? 1 : 0),
'linkdate' => $linkdate, 'created' => $created,
'updated' => $updated, 'updated' => $updated,
'tags' => str_replace(',', ' ', $tags) 'tags' => str_replace(',', ' ', $tags)
); );
// If title is empty, use the URL as title. // If title is empty, use the URL as title.
if ($link['title'] == '') { if ($link['title'] == '') {
$link['title'] = $link['url']; $link['title'] = $link['url'];
@ -1283,7 +1298,7 @@ function renderPage($conf, $pluginManager)
$pluginManager->executeHooks('save_link', $link); $pluginManager->executeHooks('save_link', $link);
$LINKSDB[$linkdate] = $link; $LINKSDB[$id] = $link;
$LINKSDB->save($conf->get('resource.page_cache')); $LINKSDB->save($conf->get('resource.page_cache'));
pubsubhub($conf); pubsubhub($conf);
@ -1296,7 +1311,7 @@ function renderPage($conf, $pluginManager)
$returnurl = !empty($_POST['returnurl']) ? $_POST['returnurl'] : '?'; $returnurl = !empty($_POST['returnurl']) ? $_POST['returnurl'] : '?';
$location = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link')); $location = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link'));
// Scroll to the link which has been edited. // Scroll to the link which has been edited.
$location .= '#' . smallHash($_POST['lf_linkdate']); $location .= '#' . smallHash($created->format('Ymd_His'));
// After saving the link, redirect to the page the user was on. // After saving the link, redirect to the page the user was on.
header('Location: '. $location); header('Location: '. $location);
exit; exit;
@ -1307,8 +1322,10 @@ function renderPage($conf, $pluginManager)
{ {
// If we are called from the bookmarklet, we must close the popup: // If we are called from the bookmarklet, we must close the popup:
if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; } if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
$link = $LINKSDB[(int) escape($_POST['lf_id'])];
$returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' ); $returnurl = ( isset($_POST['returnurl']) ? $_POST['returnurl'] : '?' );
$returnurl .= '#'.smallHash($_POST['lf_linkdate']); // Scroll to the link which has been edited. // Scroll to the link which has been edited.
$returnurl .= '#'.smallHash($link['created']->format('Ymd_His'));
$returnurl = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link')); $returnurl = generateLocation($returnurl, $_SERVER['HTTP_HOST'], array('addlink', 'post', 'edit_link'));
header('Location: '.$returnurl); // After canceling, redirect to the page the user was on. header('Location: '.$returnurl); // After canceling, redirect to the page the user was on.
exit; exit;
@ -1318,14 +1335,17 @@ function renderPage($conf, $pluginManager)
if (isset($_POST['delete_link'])) if (isset($_POST['delete_link']))
{ {
if (!tokenOk($_POST['token'])) die('Wrong token.'); if (!tokenOk($_POST['token'])) die('Wrong token.');
// We do not need to ask for confirmation: // We do not need to ask for confirmation:
// - confirmation is handled by JavaScript // - confirmation is handled by JavaScript
// - we are protected from XSRF by the token. // - we are protected from XSRF by the token.
$linkdate=$_POST['lf_linkdate'];
$pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); // FIXME! We keep `lf_linkdate` for consistency before a proper API. To be removed.
$id = isset($_POST['lf_id']) ? (int) escape($_POST['lf_id']) : (int) escape($_POST['lf_linkdate']);
unset($LINKSDB[$linkdate]); $pluginManager->executeHooks('delete_link', $LINKSDB[$id]);
unset($LINKSDB[$id]);
$LINKSDB->save('resource.page_cache'); // save to disk $LINKSDB->save('resource.page_cache'); // save to disk
// If we are called from the bookmarklet, we must close the popup: // If we are called from the bookmarklet, we must close the popup:
@ -1364,8 +1384,10 @@ function renderPage($conf, $pluginManager)
// -------- User clicked the "EDIT" button on a link: Display link edit form. // -------- User clicked the "EDIT" button on a link: Display link edit form.
if (isset($_GET['edit_link'])) if (isset($_GET['edit_link']))
{ {
$link = $LINKSDB[$_GET['edit_link']]; // Read database $id = (int) escape($_GET['edit_link']);
$link = $LINKSDB[$id]; // Read database
if (!$link) { header('Location: ?'); exit; } // Link not found in database. if (!$link) { header('Location: ?'); exit; } // Link not found in database.
$link['linkdate'] = $link['created']->format('Ymd_His');
$data = array( $data = array(
'link' => $link, 'link' => $link,
'link_is_new' => false, 'link_is_new' => false,
@ -1389,7 +1411,7 @@ function renderPage($conf, $pluginManager)
$link_is_new = false; $link_is_new = false;
// Check if URL is not already in database (in this case, we will edit the existing link) // Check if URL is not already in database (in this case, we will edit the existing link)
$link = $LINKSDB->getLinkFromUrl($url); $link = $LINKSDB->getLinkFromUrl($url);
if (!$link) if (! $link)
{ {
$link_is_new = true; $link_is_new = true;
$linkdate = strval(date('Ymd_His')); $linkdate = strval(date('Ymd_His'));
@ -1430,6 +1452,8 @@ function renderPage($conf, $pluginManager)
'tags' => $tags, 'tags' => $tags,
'private' => $private 'private' => $private
); );
} else {
$link['linkdate'] = $link['created']->format('Ymd_His');
} }
$data = array( $data = array(
@ -1635,18 +1659,16 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
$link['description'] = format_description($link['description'], $conf->get('redirector.url')); $link['description'] = format_description($link['description'], $conf->get('redirector.url'));
$classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight'; $classLi = ($i % 2) != 0 ? '' : 'publicLinkHightLight';
$link['class'] = $link['private'] == 0 ? $classLi : 'private'; $link['class'] = $link['private'] == 0 ? $classLi : 'private';
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); $link['timestamp'] = $link['created']->getTimestamp();
$link['timestamp'] = $date->getTimestamp();
if (! empty($link['updated'])) { if (! empty($link['updated'])) {
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']); $link['updated_timestamp'] = $link['updated']->getTimestamp();
$link['updated_timestamp'] = $date->getTimestamp();
} else { } else {
$link['updated_timestamp'] = ''; $link['updated_timestamp'] = '';
} }
$taglist = explode(' ', $link['tags']); $taglist = explode(' ', $link['tags']);
uasort($taglist, 'strcasecmp'); uasort($taglist, 'strcasecmp');
$link['taglist'] = $taglist; $link['taglist'] = $taglist;
$link['shorturl'] = smallHash($link['linkdate']); $link['shorturl'] = smallHash($link['created']->format('Ymd_His'));
// Check for both signs of a note: starting with ? and 7 chars long. // Check for both signs of a note: starting with ? and 7 chars long.
if ($link['url'][0] === '?' && if ($link['url'][0] === '?' &&
strlen($link['url']) === 7) { strlen($link['url']) === 7) {

View file

@ -41,9 +41,11 @@ function hook_isso_render_linklist($data, $conf)
// Only display comments for permalinks. // Only display comments for permalinks.
if (count($data['links']) == 1 && empty($data['search_tags']) && empty($data['search_term'])) { if (count($data['links']) == 1 && empty($data['search_tags']) && empty($data['search_term'])) {
$link = reset($data['links']); $link = reset($data['links']);
$isso_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/isso/isso.html'); $issoHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/isso/isso.html');
$isso = sprintf($isso_html, $issoUrl, $issoUrl, $link['linkdate'], $link['linkdate']); // FIXME! KO thread unique si même date
$linkDate = $link['created']->format('Ymd_His');
$isso = sprintf($issoHtml, $issoUrl, $issoUrl, $linkDate, $linkDate);
$data['plugin_end_zone'][] = $isso; $data['plugin_end_zone'][] = $isso;
// Hackish way to include this CSS file only when necessary. // Hackish way to include this CSS file only when necessary.

View file

@ -49,13 +49,13 @@
{$link=$value} {$link=$value}
<div class="dailyEntry"> <div class="dailyEntry">
<div class="dailyEntryPermalink"> <div class="dailyEntryPermalink">
<a href="?{$link.linkdate|smallHash}"> <a href="?{$value.shorturl}">
<img src="../images/squiggle2.png" width="25" height="26" title="permalink" alt="permalink"> <img src="../images/squiggle2.png" width="25" height="26" title="permalink" alt="permalink">
</a> </a>
</div> </div>
{if="!$hide_timestamps || isLoggedIn()"} {if="!$hide_timestamps || isLoggedIn()"}
<div class="dailyEntryLinkdate"> <div class="dailyEntryLinkdate">
<a href="?{$link.linkdate|smallHash}">{function="strftime('%c', $link.timestamp)"}</a> <a href="?{$value.shorturl}">{function="strftime('%c', $link.timestamp)"}</a>
</div> </div>
{/if} {/if}
{if="$link.tags"} {if="$link.tags"}

View file

@ -16,6 +16,9 @@
<div id="editlinkform"> <div id="editlinkform">
<form method="post" name="linkform"> <form method="post" name="linkform">
<input type="hidden" name="lf_linkdate" value="{$link.linkdate}"> <input type="hidden" name="lf_linkdate" value="{$link.linkdate}">
{if="isset($link.id)"}
<input type="hidden" name="lf_id" value="{$link.id}">
{/if}
<label for="lf_url"><i>URL</i></label><br><input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input"><br> <label for="lf_url"><i>URL</i></label><br><input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input"><br>
<label for="lf_title"><i>Title</i></label><br><input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="lf_input"><br> <label for="lf_title"><i>Title</i></label><br><input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="lf_input"><br>
<label for="lf_description"><i>Description</i></label><br><textarea name="lf_description" id="lf_description" rows="4" cols="25">{$link.description}</textarea><br> <label for="lf_description"><i>Description</i></label><br><textarea name="lf_description" id="lf_description" rows="4" cols="25">{$link.description}</textarea><br>

View file

@ -71,11 +71,11 @@
{if="isLoggedIn()"} {if="isLoggedIn()"}
<div class="linkeditbuttons"> <div class="linkeditbuttons">
<form method="GET" class="buttoneditform"> <form method="GET" class="buttoneditform">
<input type="hidden" name="edit_link" value="{$value.linkdate}"> <input type="hidden" name="edit_link" value="{$value.id}">
<input type="image" alt="Edit" src="images/edit_icon.png#" title="Edit" class="button_edit"> <input type="image" alt="Edit" src="images/edit_icon.png#" title="Edit" class="button_edit">
</form><br> </form><br>
<form method="POST" class="buttoneditform"> <form method="POST" class="buttoneditform">
<input type="hidden" name="lf_linkdate" value="{$value.linkdate}"> <input type="hidden" name="lf_linkdate" value="{$value.id}">
<input type="hidden" name="token" value="{$token}"> <input type="hidden" name="token" value="{$token}">
<input type="hidden" name="delete_link"> <input type="hidden" name="delete_link">
<input type="image" alt="Delete" src="images/delete_icon.png#" title="Delete" <input type="image" alt="Delete" src="images/delete_icon.png#" title="Delete"
@ -91,7 +91,7 @@
{if="!$hide_timestamps || isLoggedIn()"} {if="!$hide_timestamps || isLoggedIn()"}
{$updated=$value.updated_timestamp ? 'Edited: '. strftime('%c', $value.updated_timestamp) : 'Permalink'} {$updated=$value.updated_timestamp ? 'Edited: '. strftime('%c', $value.updated_timestamp) : 'Permalink'}
<span class="linkdate" title="Permalink"> <span class="linkdate" title="Permalink">
<a href="?{$value.linkdate|smallHash}"> <a href="?{$value.shorturl}">
<span title="{$updated}"> <span title="{$updated}">
{function="strftime('%c', $value.timestamp)"} {function="strftime('%c', $value.timestamp)"}
{if="$value.updated_timestamp"}*{/if} {if="$value.updated_timestamp"}*{/if}