private function next($item, $mainUrl) { $url = $this->objectQueryLanguage->query($this->fieldExpr, $item); if (empty($url)) { return null; } $parts = parse_url($url); if (isset($parts['scheme'])) { return $url; } $mainParts = parse_url($mainUrl); $parts['scheme'] = $mainParts['scheme']; if (!isset($parts['host']) && isset($mainParts['host'])) { $parts['host'] = $mainParts['host']; if (!isset($parts['port']) && isset($mainParts['port'])) { $parts['port'] = $mainParts['port']; } } if (!isset($parts['path']) && isset($mainParts['path'])) { $parts['path'] = $mainParts['path']; } return DataFeed::build_url($parts); }
private function configurePaginationPolicy($pagination_policy) { if (empty($pagination_policy)) { $this->feed_item_cache = DataFeed::component(DataFeed::FEED_CACHE); return; } $parameters = array(); parse_str($pagination_policy, $parameters); $page_url = null; if (isset($parameters['page-url'])) { $page_url = $parameters['page-url']; } $pageUrlComponent = $this->page_url_factory->create($page_url); $page_update_check = null; if (isset($parameters['page-update-check'])) { $page_update_check = $parameters['page-update-check']; } $pageUpdateCheckComponent = $this->page_update_check_factory->create($page_update_check); $this->feed_item_cache = DataFeed::component(DataFeed::MERGING_FEED_CACHE); $this->feed_item_cache->setPageUpdateCheck($pageUpdateCheckComponent); $this->feed_item_cache->setPageUrl($pageUrlComponent); if (isset($parameters['limit']) && \is_numeric($parameters['limit'])) { $this->feed_item_cache->setLimit((int) $parameters['limit']); } }
public static function datafeed_service() { DataFeed::component(DataFeed::REST_SERVICE)->handle(); }
private static function store() { return DataFeed::component(DataFeed::FEED_STORE); }
/** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { // outputs the content of the widget $h = DataFeed::handle($this->c(self::NAME, $instance), $this->c(self::URL, $instance), $this->c(self::INTERVAL, $instance), $this->c(self::PAGINATION_POLICY, $instance)); $url = \parse_url($h->getEffectiveURL()); $exception = false; try { $item = $h->getCurrentItem(); } catch (\Exception $e) { $exception = $e; } $columns = $this->c(self::COLUMNS, $instance); if ($columns < 1 || $columns > 4) { $columns = 1; } $amount = 3 * $columns; $date = ''; $thumb_url = null; $link_url = null; $type = $this->c(self::TYPE, $instance); $type_text = $this->c(self::TYPE_TEXT, $instance); if ($exception === false) { $time_field = $this->c(self::TIME_FIELD, $instance); if ($time_field !== null) { $date_format = \get_option('date_format'); $date = \date($date_format, \strtotime($this->query($time_field, $item))); } $text = ''; $text_field = $this->c(self::TEXT_FIELD, $instance); $excerpt_length = $this->c(self::EXCERPT_LENGTH, $instance); if ($text_field !== null) { if (empty($excerpt_length)) { $excerpt_length = \apply_filters('excerpt_length', 55); } $excerpt_more = \apply_filters('excerpt_more', ' ' . '[…]'); $text = \wp_trim_words($this->query($text_field, $item), $excerpt_length, $excerpt_more); } $title = ''; $title_field = $this->c(self::TITLE_FIELD, $instance); if ($title_field !== null) { $title = htmlspecialchars($this->query($title_field, $item)); } $thumb_field = $this->c(self::THUMB_FIELD, $instance); if ($thumb_field !== null) { $thumb = $this->query($thumb_field, $item); $thumb_url = self::extend_url($thumb, $url); } $link_field = $this->c(self::LINK_FIELD, $instance); if ($link_field !== null) { $link = $this->query($link_field, $item); $link_url = self::extend_url($link, $url); } } else { $title = \__("Error", 'data_feed'); $text = \esc_html(sprintf(\__("Caugh exception when fetching data feed: %s", 'data_feed'), $exception)); } $this->increment_index(); ?> <div class="col-md-<?php echo $amount; ?> eq"> <div class="box-wrap dyno <?php if (\is_front_page()) { echo 'home'; } ?> "> <a href="<?php echo $link_url; ?> " class="boxlink"></a> <div class="header-wrap"> <h2><?php echo $title; ?> </h2> </div> <div class="infobar <?php echo $type; ?> "> <time class="<?php echo $type; ?> date" datetime="<?php echo $date; ?> "><?php echo $date; ?> </time> <span class="type"><span><?php _e($type_text, 'sage'); ?> </span></span> </div> <?php if (!empty($thumb_url)) { ?> <div class="thumb-wrapper"> <img src="<?php echo $thumb_url; ?> "> </div> <?php } ?> <div class="excerpt<?php if ($exception !== false) { ?> exception" style="max-height: 20em; overflow: scroll;<?php } ?> "> <?php echo $text; ?> </div> </div> </div> <?php }