mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-12 01:48:48 +00:00
[Sfeed] Fixed category separator and random white spaces (#3308)
This commit is contained in:
parent
c1f446fd19
commit
224cce08a8
@ -7,8 +7,8 @@ class SfeedFormat extends FormatAbstract
|
|||||||
private function escape(string $str)
|
private function escape(string $str)
|
||||||
{
|
{
|
||||||
$str = str_replace('\\', '\\\\', $str);
|
$str = str_replace('\\', '\\\\', $str);
|
||||||
$str = str_replace("\n", "\\n", $str);
|
$str = str_replace("\n", '\\n', $str);
|
||||||
return str_replace("\t", "\\t", $str);
|
return str_replace("\t", '\\t', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFirstEnclosure(array $enclosures)
|
private function getFirstEnclosure(array $enclosures)
|
||||||
@ -22,13 +22,12 @@ class SfeedFormat extends FormatAbstract
|
|||||||
private function getCategories(array $cats)
|
private function getCategories(array $cats)
|
||||||
{
|
{
|
||||||
$toReturn = '';
|
$toReturn = '';
|
||||||
$i = 0;
|
$i = 1;
|
||||||
foreach ($cats as $cat) {
|
foreach ($cats as $cat) {
|
||||||
$toReturn .= $cat;
|
$toReturn .= trim($cat);
|
||||||
if (count($cats) < $i) {
|
if (count($cats) > $i++) {
|
||||||
$toReturn .= '|';
|
$toReturn .= '|';
|
||||||
}
|
}
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
return $toReturn;
|
return $toReturn;
|
||||||
}
|
}
|
||||||
@ -42,12 +41,18 @@ class SfeedFormat extends FormatAbstract
|
|||||||
$toReturn .= sprintf(
|
$toReturn .= sprintf(
|
||||||
"%s\t%s\t%s\t%s\thtml\t\t%s\t%s\t%s\n",
|
"%s\t%s\t%s\t%s\thtml\t\t%s\t%s\t%s\n",
|
||||||
$item->toArray()['timestamp'],
|
$item->toArray()['timestamp'],
|
||||||
$this->escape($item->toArray()['title']),
|
preg_replace('/\s/', ' ', $item->toArray()['title']),
|
||||||
$item->toArray()['uri'],
|
$item->toArray()['uri'],
|
||||||
$this->escape($item->toArray()['content']),
|
$this->escape($item->toArray()['content']),
|
||||||
$item->toArray()['author'],
|
$item->toArray()['author'],
|
||||||
$this->getFirstEnclosure($item->toArray()['enclosures']),
|
$this->getFirstEnclosure(
|
||||||
$this->getCategories($item->toArray()['categories'])
|
$item->toArray()['enclosures']
|
||||||
|
),
|
||||||
|
$this->escape(
|
||||||
|
$this->getCategories(
|
||||||
|
$item->toArray()['categories']
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user