- * Build a feed item (one per shaare).
- *
- * @param array $link Single link array extracted from LinkDB.
- * @param string $pageaddr Index URL.
- *
- * @return array Link array with feed attributes.
- */
- protected function buildItem($link, $pageaddr)
- {
- $link['guid'] = $pageaddr . '?' . $link['shorturl'];
- // Check for both signs of a note: starting with ? and 7 chars long.
- if ($link['url'][0] === '?' && strlen($link['url']) === 7) {
- $link['url'] = $pageaddr . $link['url'];
- }
- if ($this->usePermalinks === true) {
- $permalink = '<a href="' . $link['url'] . '" title="' . t('Direct link') . '">' . t('Direct link') . '</a>';
- } else {
- $permalink = '<a href="' . $link['guid'] . '" title="' . t('Permalink') . '">' . t('Permalink') . '</a>';
- }
- $link['description'] = format_description($link['description'], $pageaddr);
- $link['description'] .= PHP_EOL . '<br>— ' . $permalink;
-
- $pubDate = $link['created'];
- $link['pub_iso_date'] = $this->getIsoDate($pubDate);
-
- // atom:entry elements MUST contain exactly one atom:updated element.
- if (!empty($link['updated'])) {
- $upDate = $link['updated'];
- $link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM);
- } else {
- $link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);
- }
-
- // Save the more recent item.
- if (empty($this->latestDate) || $this->latestDate < $pubDate) {
- $this->latestDate = $pubDate;
- }
- if (!empty($upDate) && $this->latestDate < $upDate) {
- $this->latestDate = $upDate;
- }
-
- $taglist = array_filter(explode(' ', $link['tags']), 'strlen');
- uasort($taglist, 'strcasecmp');
- $link['taglist'] = $taglist;
-
- return $link;
- }
-
- /**
- * Set this to true to use permalinks instead of direct links.