public static function kses($t, $h, $p = array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'gopher', 'mailto')) { // kses compat foreach ($h as $k => $v) { $h[$k]['n']['*'] = 1; } $C['cdata'] = $C['comment'] = $C['make_tag_strict'] = $C['no_deprecated_attr'] = $C['unique_ids'] = 0; $C['keep_bad'] = 1; $C['elements'] = count($h) ? strtolower(implode(',', array_keys($h))) : '-*'; $C['hook'] = 'htmLawed::kses_hook'; $C['schemes'] = '*:' . implode(',', $p); return htmLawed::tidy($t, $C, $h); // eof }
private function processItems($items) { $result = array(); foreach ($items as $item) { $data = array(); // Fetch the title $data['title'] = $this->getFirstFeedNode($item->title()); // Fetch the link $link = $item->link; if (is_array($link)) { $link = $link[0]; } if (isset($link['href'])) { $link = $link['href']; } $data['link'] = $link; // Date $pubDate = strtotime((string) $item->pubDate); // For RSS entries $published = strtotime((string) $item->published); // For Atom entries $updated = strtotime((string) $item->updated); // For Atom entries $data['published'] = max($pubDate, $published, $updated); //Content $content = (string) $item->content; $desc = (string) $item->description; if (strlen($desc) > strlen($content)) { $content = $desc; } $data['content'] = htmLawed::tidy($content, array('safe' => 1, 'tidy' => '2s0n')); // Get the categories as tags, if we can $tags = array(); try { $categories = $item->category(); if ($categories && count($categories) > 0) { foreach ($categories as $category) { $tags[] = $category->nodeValue; } } } catch (Exception $e) { } // Save the item in the database $id = $this->addItem($data, $data['published'], SourceItem::BLOG_TYPE, $tags, false, false, $data['title']); if ($id) { $result[] = $id; } if (count($result) > 100) { break; } } return $result; }
private function processItems($items) { $result = array(); foreach ($items as $item) { $data = array(); $data['title'] = $item->title(); if ($item->link() && count($item->link()) > 0) { $links = $item->link(); $link = $links[0]; if (is_object($link)) { $data['link'] = (string) $link->getAttribute('href'); } else { $data['link'] = ""; } } else { $link = $item->link; $data['link'] = (string) $link['href']; } $content = $item->content(); $data['published'] = $item->published(); $data['note'] = $item->{'gr:annotation'}->content; $crawl = (string) $item->getDom()->getAttribute("gr:crawl-timestamp-msec"); $timestamp = $crawl != "" ? substr($crawl, 0, 10) : strtotime((string) $data['published']); $data['content'] = htmLawed::tidy($content, array('safe' => 1, 'tidy' => '2s0n')); $id = $this->addItem($data, $timestamp, SourceItem::LINK_TYPE, false, false, false, $data['title']); if ($id) { $result[] = $id; } unset($data); } return $result; }