*/\r
class FeedItem\r
{\r
- private $elements = array(); //Collection of feed elements\r
- private $version;\r
- \r
- /**\r
- * Constructor \r
- * \r
- * @param contant (RSS1/RSS2/ATOM) RSS2 is default. \r
- */ \r
- function __construct($version = RSS2)\r
- { \r
- $this->version = $version;\r
- }\r
+ private $elements = array(); //Collection of feed elements\r
+ private $version;\r
+ \r
+ /**\r
+ * Constructor \r
+ * \r
+ * @param contant (RSS1/RSS2/ATOM) RSS2 is default. \r
+ */ \r
+ function __construct($version = RSS2)\r
+ { \r
+ $this->version = $version;\r
+ }\r
\r
- /**\r
- * Set element (overwrites existing elements with $elementName)\r
- * \r
- * @access public\r
- * @param srting The tag name of an element\r
- * @param srting The content of tag\r
- * @param array Attributes(if any) in 'attrName' => 'attrValue' format\r
- * @return void\r
- */\r
- public function setElement($elementName, $content, $attributes = null)\r
- {\r
- if (isset($this->elements[$elementName])) {\r
- unset($this->elements[$elementName]);\r
- }\r
- $this->addElement($elementName, $content, $attributes);\r
- } \r
- \r
- /**\r
- * Add an element to elements array\r
- * \r
- * @access public\r
- * @param srting The tag name of an element\r
- * @param srting The content of tag\r
- * @param array Attributes(if any) in 'attrName' => 'attrValue' format\r
- * @return void\r
- */\r
- public function addElement($elementName, $content, $attributes = null)\r
- {\r
- $i = 0;\r
- if (isset($this->elements[$elementName])) {\r
- $i = count($this->elements[$elementName]);\r
- } else {\r
- $this->elements[$elementName] = array();\r
- }\r
- $this->elements[$elementName][$i]['name'] = $elementName;\r
- $this->elements[$elementName][$i]['content'] = $content;\r
- $this->elements[$elementName][$i]['attributes'] = $attributes;\r
- }\r
- \r
- /**\r
- * Set multiple feed elements from an array. \r
- * Elements which have attributes cannot be added by this method\r
- * \r
- * @access public\r
- * @param array array of elements in 'tagName' => 'tagContent' format.\r
- * @return void\r
- */\r
- public function addElementArray($elementArray)\r
- {\r
- if(! is_array($elementArray)) return;\r
- foreach ($elementArray as $elementName => $content) \r
- {\r
- $this->addElement($elementName, $content);\r
- }\r
- }\r
- \r
- /**\r
- * Return the collection of elements in this feed item\r
- * \r
- * @access public\r
- * @return array\r
- */\r
- public function getElements()\r
- {\r
- return $this->elements;\r
- }\r
- \r
- // Wrapper functions ------------------------------------------------------\r
- \r
- /**\r
- * Set the 'dscription' element of feed item\r
- * \r
- * @access public\r
- * @param string The content of 'description' element\r
- * @return void\r
- */\r
- public function setDescription($description) \r
- {\r
- $tag = 'description'; \r
- $this->setElement($tag, $description);\r
- }\r
- \r
- /**\r
- * @desc Set the 'title' element of feed item\r
- * @access public\r
- * @param string The content of 'title' element\r
- * @return void\r
- */\r
- public function setTitle($title) \r
- {\r
- $this->setElement('title', $title); \r
- }\r
- \r
- /**\r
- * Set the 'date' element of feed item\r
- * \r
- * @access public\r
- * @param string The content of 'date' element\r
- * @return void\r
- */\r
- public function setDate($date) \r
- {\r
- if(! is_numeric($date))\r
- {\r
- $date = strtotime($date);\r
- }\r
+ /**\r
+ * Set element (overwrites existing elements with $elementName)\r
+ * \r
+ * @access public\r
+ * @param srting The tag name of an element\r
+ * @param srting The content of tag\r
+ * @param array Attributes(if any) in 'attrName' => 'attrValue' format\r
+ * @return void\r
+ */\r
+ public function setElement($elementName, $content, $attributes = null)\r
+ {\r
+ if (isset($this->elements[$elementName])) {\r
+ unset($this->elements[$elementName]);\r
+ }\r
+ $this->addElement($elementName, $content, $attributes);\r
+ } \r
+ \r
+ /**\r
+ * Add an element to elements array\r
+ * \r
+ * @access public\r
+ * @param srting The tag name of an element\r
+ * @param srting The content of tag\r
+ * @param array Attributes(if any) in 'attrName' => 'attrValue' format\r
+ * @return void\r
+ */\r
+ public function addElement($elementName, $content, $attributes = null)\r
+ {\r
+ $i = 0;\r
+ if (isset($this->elements[$elementName])) {\r
+ $i = count($this->elements[$elementName]);\r
+ } else {\r
+ $this->elements[$elementName] = array();\r
+ }\r
+ $this->elements[$elementName][$i]['name'] = $elementName;\r
+ $this->elements[$elementName][$i]['content'] = $content;\r
+ $this->elements[$elementName][$i]['attributes'] = $attributes;\r
+ }\r
+ \r
+ /**\r
+ * Set multiple feed elements from an array. \r
+ * Elements which have attributes cannot be added by this method\r
+ * \r
+ * @access public\r
+ * @param array array of elements in 'tagName' => 'tagContent' format.\r
+ * @return void\r
+ */\r
+ public function addElementArray($elementArray)\r
+ {\r
+ if(! is_array($elementArray)) return;\r
+ foreach ($elementArray as $elementName => $content) \r
+ {\r
+ $this->addElement($elementName, $content);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Return the collection of elements in this feed item\r
+ * \r
+ * @access public\r
+ * @return array\r
+ */\r
+ public function getElements()\r
+ {\r
+ return $this->elements;\r
+ }\r
+ \r
+ // Wrapper functions ------------------------------------------------------\r
+ \r
+ /**\r
+ * Set the 'dscription' element of feed item\r
+ * \r
+ * @access public\r
+ * @param string The content of 'description' element\r
+ * @return void\r
+ */\r
+ public function setDescription($description) \r
+ {\r
+ $tag = 'description'; \r
+ $this->setElement($tag, $description);\r
+ }\r
+ \r
+ /**\r
+ * @desc Set the 'title' element of feed item\r
+ * @access public\r
+ * @param string The content of 'title' element\r
+ * @return void\r
+ */\r
+ public function setTitle($title) \r
+ {\r
+ $this->setElement('title', $title); \r
+ }\r
+ \r
+ /**\r
+ * Set the 'date' element of feed item\r
+ * \r
+ * @access public\r
+ * @param string The content of 'date' element\r
+ * @return void\r
+ */\r
+ public function setDate($date) \r
+ {\r
+ if(! is_numeric($date))\r
+ {\r
+ $date = strtotime($date);\r
+ }\r
\r
- if($this->version == RSS2) \r
- {\r
- $tag = 'pubDate';\r
- $value = date(DATE_RSS, $date);\r
- }\r
- else \r
- {\r
- $tag = 'dc:date';\r
- $value = date("Y-m-d", $date);\r
- }\r
- \r
- $this->setElement($tag, $value); \r
- }\r
- \r
- /**\r
- * Set the 'link' element of feed item\r
- * \r
- * @access public\r
- * @param string The content of 'link' element\r
- * @return void\r
- */\r
- public function setLink($link) \r
- {\r
- if($this->version == RSS2 || $this->version == RSS1)\r
- {\r
- $this->setElement('link', $link);\r
- $this->setElement('guid', $link);\r
- }\r
- else\r
- {\r
- $this->setElement('link','',array('href'=>$link));\r
- $this->setElement('id', FeedWriter::uuid($link,'urn:uuid:'));\r
- } \r
- \r
- }\r
- \r
- /**\r
- * Set the 'encloser' element of feed item\r
- * For RSS 2.0 only\r
- * \r
- * @access public\r
- * @param string The url attribute of encloser tag\r
- * @param string The length attribute of encloser tag\r
- * @param string The type attribute of encloser tag\r
- * @return void\r
- */\r
- public function setEncloser($url, $length, $type)\r
- {\r
- $attributes = array('url'=>$url, 'length'=>$length, 'type'=>$type);\r
- $this->setElement('enclosure','',$attributes);\r
- }\r
- \r
+ if($this->version == RSS2) \r
+ {\r
+ $tag = 'pubDate';\r
+ $value = date(DATE_RSS, $date);\r
+ }\r
+ else \r
+ {\r
+ $tag = 'dc:date';\r
+ $value = date("Y-m-d", $date);\r
+ }\r
+ \r
+ $this->setElement($tag, $value); \r
+ }\r
+ \r
+ /**\r
+ * Set the 'link' element of feed item\r
+ * \r
+ * @access public\r
+ * @param string The content of 'link' element\r
+ * @return void\r
+ */\r
+ public function setLink($link) \r
+ {\r
+ if($this->version == RSS2 || $this->version == RSS1)\r
+ {\r
+ $this->setElement('link', $link);\r
+ $this->setElement('guid', $link);\r
+ }\r
+ else\r
+ {\r
+ $this->setElement('link','',array('href'=>$link));\r
+ $this->setElement('id', FeedWriter::uuid($link,'urn:uuid:'));\r
+ } \r
+ \r
+ }\r
+\r
+ /**\r
+ * Set the 'source' element of feed item\r
+ * \r
+ * @access public\r
+ * @param string The content of 'source' element\r
+ * @return void\r
+ */\r
+ public function setSource($link) \r
+ {\r
+ $this->setElement('source', $link);\r
+ }\r
+ \r
+ /**\r
+ * Set the 'encloser' element of feed item\r
+ * For RSS 2.0 only\r
+ * \r
+ * @access public\r
+ * @param string The url attribute of encloser tag\r
+ * @param string The length attribute of encloser tag\r
+ * @param string The type attribute of encloser tag\r
+ * @return void\r
+ */\r
+ public function setEncloser($url, $length, $type)\r
+ {\r
+ $attributes = array('url'=>$url, 'length'=>$length, 'type'=>$type);\r
+ $this->setElement('enclosure','',$attributes);\r
+ }\r
+ \r
} // end of class FeedItem\r
-?>\r
+?>
\ No newline at end of file
define('IMPORT_LIMIT', 5);
}
if (!defined('IMPORT_DELAY')) {
- define('IMPORT_DELAY', 5);
+ define('IMPORT_DELAY', 5);
}
if ( isset($_FILES['file']) ) {
$read = 0;
foreach (array('ol','ul') as $list) {
foreach ($html->find($list) as $ul) {
- foreach ($ul->find('li') as $li) {
- $tmpEntry = array();
- $a = $li->find('a');
- $tmpEntry['url'] = $a[0]->href;
- $tmpEntry['tags'] = $a[0]->tags;
- $tmpEntry['is_read'] = $read;
- if ($tmpEntry['url']) {
- $data[] = $tmpEntry;
- }
- }
- # the second <ol/ul> is for read links
- $read = ((sizeof($data) && $read)?0:1);
+ foreach ($ul->find('li') as $li) {
+ $tmpEntry = array();
+ $a = $li->find('a');
+ $tmpEntry['url'] = $a[0]->href;
+ $tmpEntry['tags'] = $a[0]->tags;
+ $tmpEntry['is_read'] = $read;
+ if ($tmpEntry['url']) {
+ $data[] = $tmpEntry;
+ }
+ }
+ # the second <ol/ul> is for read links
+ $read = ((sizeof($data) && $read)?0:1);
}
}
}
$data[] = $record;
foreach ($record as $record2) {
if (is_array($record2)) {
- $data[] = $record2;
+ $data[] = $record2;
}
}
}
//increment no of records inserted
$i++;
if ( isset($record['tags']) && trim($record['tags']) ) {
- //@TODO: set tags
+ //@TODO: set tags
}
}
$purifier = new HTMLPurifier($config);
foreach ($items as $item) {
- $url = new Url(base64_encode($item['url']));
- $content = Tools::getPageContent($url);
+ $url = new Url(base64_encode($item['url']));
+ $content = Tools::getPageContent($url);
- $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'));
- $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined'));
+ $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'));
+ $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined'));
- //clean content to prevent xss attack
- $title = $purifier->purify($title);
- $body = $purifier->purify($body);
+ //clean content to prevent xss attack
+ $title = $purifier->purify($title);
+ $body = $purifier->purify($body);
- $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId());
+ $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId());
}
}
*/
public function export()
{
- $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json";
- header('Content-Disposition: attachment; filename='.$filename);
+ $filename = "wallabag-export-".$this->user->getId()."-".date("Y-m-d").".json";
+ header('Content-Disposition: attachment; filename='.$filename);
$entries = $this->store->retrieveAll($this->user->getId());
echo $this->tpl->render('export.twig', array(
public function generateToken()
{
if (ini_get('open_basedir') === '') {
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- echo 'This is a server using Windows!';
- // alternative to /dev/urandom for Windows
- $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
- } else {
- $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
- }
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ echo 'This is a server using Windows!';
+ // alternative to /dev/urandom for Windows
+ $token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
+ } else {
+ $token = substr(base64_encode(file_get_contents('/dev/urandom', false, null, 0, 20)), 0, 15);
+ }
}
else {
$token = substr(base64_encode(uniqid(mt_rand(), true)), 0, 20);
foreach ($entries as $entry) {
$newItem = $feed->createNewItem();
$newItem->setTitle($entry['title']);
+ $newItem->setSource(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']);
$newItem->setLink($entry['url']);
$newItem->setDate(time());
$newItem->setDescription($entry['content']);