/** * loads content for given source * * @return void * @param string $url */ public function load($params) { $this->apiKey = $params['api']; if (strlen(trim($this->apiKey)) == 0) { $this->apiKey = \F3::get('readability'); } parent::load(array('url' => $params['url'])); }
/** * loads content for given source * * @return void * @param string $url */ public function load($params) { parent::load(array('url' => $this->getXmlUrl())); }
function nvweb_metatags($vars = array()) { global $website; global $current; global $DB; global $structure; global $events; // process page title and (to do: get specific metatags) $section = ''; $separator = ' | '; if (!empty($vars['title_separator'])) { $separator = $vars['title_separator']; } switch ($current['type']) { case 'item': $section = $DB->query_single('text', 'nv_webdictionary', ' node_type = ' . protect($current['type']) . ' AND node_id = ' . protect($current['object']->id) . ' AND subtype = ' . protect('title') . ' AND website = ' . $website->id . ' AND lang = ' . protect($current['lang'])); $section = $separator . $section; break; case 'structure': $breadcrumbs = nvweb_breadcrumbs(array('separator' => $separator, 'links' => 'false')); $section = $separator . $breadcrumbs; break; default: } // global website metatags $metatags = $website->metatags; if (is_array($metatags)) { $metatags = $metatags[$current['lang']]; } if (!empty($website->metatag_description[$current['lang']])) { $metatags .= "\n" . '<meta name="language" content="' . $current['lang'] . '" />' . "\n"; } if (!empty($website->metatag_description[$current['lang']])) { $metatags .= "\n" . '<meta name="description" content="' . $website->metatag_description[$current['lang']] . '" />' . "\n"; } // retrieve content tags and add it to the global metatags of the website $tags_website = str_replace(', ', ',', $website->metatag_keywords[$current['lang']]); $tags_website = explode(',', $tags_website); $tags_website = array_filter($tags_website); $tags_content = webdictionary::load_element_strings($current['type'], $current['object']->id); $tags_content = str_replace(', ', ',', @$tags_content[$current['lang']]['tags']); $tags_content = explode(',', $tags_content); $tags_content = array_filter($tags_content); $tags = array_merge($tags_website, $tags_content); $tags = implode(',', $tags); if (strpos($metatags, '<meta name="keywords" content="') !== FALSE) { $metatags = str_replace('<meta name="keywords" content="', '<meta name="keywords" content="' . $tags, $metatags); } else { $metatags .= '<meta name="keywords" content="' . $tags . '" />'; } if (@$vars['generator'] != 'false') { $current_version = update::latest_installed(); $metatags .= "\n" . '<meta name="generator" content="Navigate CMS ' . $current_version->version . '" />'; } if ($website->favicon > 0) { $favicon = NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $website->favicon . '&disposition=inline'; $metatags .= "\n" . '<link rel="shortcut icon" href="' . $favicon . '" />'; } // website public feeds $DB->query('SELECT id FROM nv_feeds WHERE website = ' . $website->id . ' AND permission = 0 AND enabled = 1'); $feeds = $DB->result('id'); for ($f = 0; $f < count($feeds); $f++) { $feed = new feed(); $feed->load($feeds[$f]); if (strpos(strtolower($feed->format), 'rss') !== false) { $mime = 'application/rss+xml'; } else { if (strpos(strtolower($feed->format), 'atom') !== false) { $mime = 'application/atom+xml'; } else { $mime = 'text/xml'; } } $metatags .= "\n" . '<link rel="alternate" type="' . $mime . '" title="' . $feed->dictionary[$current['lang']]['title'] . '" href="' . $website->absolute_path() . $feed->paths[$current['lang']] . '" />'; } $out = '<title>' . $website->name . $section . '</title>' . "\n"; $out .= $metatags; if (!empty($website->additional_scripts) && empty($_SESSION['APP_USER#' . APP_UNIQUE])) { nvweb_after_body('html', $website->additional_scripts); } $events->trigger('metatags', 'render', array('out' => &$out, 'default_title' => $website->name . $section, 'section' => $section)); return $out; }
public static function generate_feed($id = NULL) { global $current; global $website; global $DB; if (empty($id)) { $id = $current['id']; } $item = new feed(); $item->load($id); $permission = nvweb_object_enabled($item); if (!$permission) { return; } $feed = new UniversalFeedCreator(); $feed->encoding = 'UTF-8'; $feed->title = $item->dictionary[$current['lang']]['title']; $feed->description = $item->dictionary[$current['lang']]['description']; $feed->link = $website->absolute_path(); $feed->syndicationURL = $website->absolute_path() . $item->paths[$current['lang']]; if (!empty($item->image)) { $image = new FeedImage(); $image->url = $website->absolute_path() . '/object?type=image&id=' . $item->image; $image->link = $website->absolute_path(); //$image->description = $vars['dictionary_description']; $feed->image = $image; } if (!empty($item->categories[0])) { $limit = intval($item->entries); if ($limit <= 0) { $limit = 10; } $DB->query(' SELECT SQL_CALC_FOUND_ROWS i.id, i.permission, i.date_published, i.date_unpublish, i.date_to_display, COALESCE(NULLIF(i.date_to_display, 0), i.date_created) as pdate, d.text as title, i.position as position, i.galleries as galleries, i.template as template FROM nv_items i, nv_structure s, nv_webdictionary d WHERE i.category IN(' . implode(",", $item->categories) . ') AND i.website = ' . $website->id . ' AND i.permission = 0 AND (i.date_published = 0 OR i.date_published < ' . core_time() . ') AND (i.date_unpublish = 0 OR i.date_unpublish > ' . core_time() . ') AND s.id = i.category AND (s.date_published = 0 OR s.date_published < ' . core_time() . ') AND (s.date_unpublish = 0 OR s.date_unpublish > ' . core_time() . ') AND s.permission = 0 AND (s.access = 0) AND (i.access = 0) AND d.website = i.website AND d.node_type = "item" AND d.subtype = "title" AND d.node_id = i.id AND d.lang = ' . protect($current['lang']) . ' ORDER BY pdate DESC LIMIT ' . $limit . ' OFFSET 0'); $rs = $DB->result(); for ($x = 0; $x < count($rs); $x++) { if (nvweb_object_enabled($rs[$x])) { $texts = webdictionary::load_element_strings('item', $rs[$x]->id); $paths = path::loadElementPaths('item', $rs[$x]->id); $fitem = new FeedItem(); $fitem->title = $texts[$current['lang']]['title']; $fitem->link = $website->absolute_path() . $paths[$current['lang']]; switch ($item->content) { case 'title': // no description break; case 'content': $fitem->description = $texts[$current['lang']]['section-main']; break; case 'summary': default: $fitem->description = $texts[$current['lang']]['section-main']; $fitem->description = str_replace(array('</p>', '<br />', '<br/>', '<br>'), array('</p>' . "\n", '<br />' . "\n", '<br/>' . "\n", '<br>' . "\n"), $fitem->description); $fitem->description = core_string_cut($fitem->description, 500, '…'); break; } $fitem->date = $rs[$x]->date_to_display; // find an image to attach to the item // A) first enabled image in item gallery // B) first image on properties $image = ''; if (!empty($rs[$x]->galleries)) { $galleries = mb_unserialize($rs[$x]->galleries); $photo = @array_shift(array_keys($galleries[0])); if (!empty($photo)) { $image = $website->absolute_path(false) . '/object?type=image&id=' . $photo; } } if (empty($image)) { // no image found on galleries, look for image properties $properties = property::load_properties("item", $rs[$x]->template, "item", $rs[$x]->id); for ($p = 0; $p < count($properties); $p++) { if ($properties[$p]->type == 'image') { if (!empty($properties[$p]->value)) { $image = $properties[$p]->value; } else { if (!empty($properties[$p]->dvalue)) { $image = $properties[$p]->dvalue; } } if (is_array($image)) { $image = array_values($image); $image = $image[0]; } if (!empty($image)) { $image = $website->absolute_path(false) . '/object?type=image&id=' . $image; } } // we only need the first image if (!empty($image)) { break; } } } if (!empty($image)) { $fitem->image = $image; // feedly will only display images of >450px --> http://blog.feedly.com/2015/07/31/10-ways-to-optimize-your-feed-for-feedly/ if (strpos($item->format, 'RSS') !== false) { $fitem->description = '<img src="' . $image . '&width=640"><br />' . $fitem->description; } } //$item->author = $contents->rows[$x]->author_name; $feed->addItem($fitem); } } // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), // MBOX, OPML, ATOM, ATOM10, ATOM0.3, HTML, JS //echo $rss->saveFeed("RSS1.0", "news/feed.xml"); } $xml = $feed->createFeed($item->format); if ($item->format == "RSS2.0") { // add extra tweaks to improve the feed $xml = str_replace('<rss ', '<rss xmlns:webfeeds="http://webfeeds.org/rss/1.0" ', $xml); // also available: // <webfeeds:cover image="http://yoursite.com/a-large-cover-image.png" />\n // <webfeeds:accentColor>00FF00</webfeeds:accentColor> $xml = str_replace('<channel>', '<channel>' . "\n\t\t" . '<webfeeds:related layout="card" target="browser" />', $xml); $xml = str_replace('<channel>', '<channel>' . "\n\t\t" . '<webfeeds:logo>' . file::file_url($item->image) . '</webfeeds:logo>', $xml); $xml = str_replace('<channel>', '<channel>' . "\n\t\t" . '<webfeeds:icon>' . file::file_url($website->favicon) . '</webfeeds:icon>', $xml); } return $xml; }
function run() { global $user; global $layout; global $DB; global $website; $out = ''; $item = new feed(); switch ($_REQUEST['act']) { case 1: // json data retrieval & operations switch ($_REQUEST['oper']) { case 'del': // remove rows $ids = $_REQUEST['ids']; foreach ($ids as $id) { $item->load($id); $item->delete(); } echo json_encode(true); break; default: // list or search $page = intval($_REQUEST['page']); $max = intval($_REQUEST['rows']); $offset = ($page - 1) * $max; $orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord']; $where = " f.website = " . $website->id; if ($_REQUEST['_search'] == 'true' || isset($_REQUEST['quicksearch'])) { if (isset($_REQUEST['quicksearch'])) { $where .= $item->quicksearch($_REQUEST['quicksearch']); } else { if (isset($_REQUEST['filters'])) { $where .= navitable::jqgridsearch($_REQUEST['filters']); } else { // single search $where .= ' AND ' . navitable::jqgridcompare($_REQUEST['searchField'], $_REQUEST['searchOper'], $_REQUEST['searchString']); } } } $sql = ' SELECT SQL_CALC_FOUND_ROWS f.*, d.text as title FROM nv_feeds f LEFT JOIN nv_webdictionary d ON f.id = d.node_id AND d.node_type = "feed" AND d.subtype = "title" AND d.lang = "' . $website->languages_list[0] . '" AND d.website = ' . $website->id . ' WHERE ' . $where . ' ORDER BY ' . $orderby . ' LIMIT ' . $max . ' OFFSET ' . $offset; if (!$DB->query($sql, 'array')) { throw new Exception($DB->get_last_error()); } $dataset = $DB->result(); $total = $DB->foundRows(); $out = array(); $permissions = array(0 => '<img src="img/icons/silk/world.png" align="absmiddle" /> ' . t(69, 'Published'), 1 => '<img src="img/icons/silk/world_dawn.png" align="absmiddle" /> ' . t(70, 'Private'), 2 => '<img src="img/icons/silk/world_night.png" align="absmiddle" /> ' . t(81, 'Hidden')); if (empty($dataset)) { $rows = 0; } else { $rows = count($dataset); } for ($i = 0; $i < $rows; $i++) { $out[$i] = array(0 => $dataset[$i]['id'], 1 => $dataset[$i]['title'], 2 => count(explode(',', $dataset[$i]['categories'])), 3 => $dataset[$i]['format'], 4 => $dataset[$i]['views'], 5 => $permissions[$dataset[$i]['permission']], 6 => $dataset[$i]['enabled'] == 1 ? '<img src="img/icons/silk/accept.png" />' : '<img src="img/icons/silk/cancel.png" />'); } navitable::jqgridJson($out, $page, $offset, $max, $total); break; } core_terminate(); break; case 2: // edit/new form if (!empty($_REQUEST['id'])) { $item->load(intval($_REQUEST['id'])); } if (isset($_REQUEST['form-sent'])) { $item->load_from_post(); try { $item->save(); $id = $item->id; unset($item); $item = new feed(); $item->load($id); $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check'); } catch (Exception $e) { $layout->navigate_notification($e->getMessage(), true, true); } } $out = feeds_form($item); break; case 4: // remove if (!empty($_REQUEST['id'])) { $item->load(intval($_REQUEST['id'])); if ($item->delete() > 0) { $layout->navigate_notification(t(55, 'Item removed successfully.'), false); $out = feeds_list(); } else { $layout->navigate_notification(t(56, 'Unexpected error.'), false); $out = feeds_list(); } } break; case "path_check": // check if a requested path is not used $path = $_REQUEST['path']; $id = $_REQUEST['id']; $DB->query('SELECT type, object_id, lang FROM nv_paths WHERE path = ' . protect($path) . ' AND website = ' . $website->id); $rs = $DB->result(); echo json_encode($rs); core_terminate(); break; case 0: // list / search result // list / search result default: $out = feeds_list(); break; } return $out; }
/** * loads content for given source * * @return void * @param string $url */ public function load($params) { parent::load(array('url' => $params['url'])); }