当前位置: 首页>>代码示例>>PHP>>正文


PHP Items::get_instance方法代码示例

本文整理汇总了PHP中Items::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Items::get_instance方法的具体用法?PHP Items::get_instance怎么用?PHP Items::get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Items的用法示例。


在下文中一共展示了Items::get_instance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process_single

 /**
  * Process a single feed
  *
  * @param array $feed Feed information (required elements are 'name' for error reporting, 'feed' for the feed URL and 'id' for the feed's unique internal ID)
  * @return int Number of items added
  */
 public static function process_single($feed)
 {
     do_action('iu-feed-start', $feed);
     $sp =& self::load_feed($feed);
     if ($error = $sp->error()) {
         self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
         do_action('iu-feed-finish', $feed);
         return -1;
     }
     $count = 0;
     $items = $sp->get_items();
     foreach ($items as $item) {
         $new_item = self::normalise($item, $feed['id']);
         $new_item = apply_filters('item_data_precache', $new_item, $feed);
         if (Items::get_instance()->check_item($new_item)) {
             $count++;
             do_action('iu-item-add', $new_item, $feed);
         } else {
             do_action('iu-item-noadd', $new_item, $feed);
         }
     }
     $sp->__destruct();
     unset($sp);
     do_action('iu-feed-finish', $feed);
     return $count;
 }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:32,代码来源:class-itemupdater.php

示例2: process

 public static function process()
 {
     header('Content-Type: text/plain; charset=utf-8');
     require_once LILINA_INCPATH . '/contrib/simplepie.class.php';
     $updated = false;
     foreach (self::$feeds as $feed) {
         do_action('iu-feed-start', $feed);
         $sp = self::load_feed($feed);
         if ($error = $sp->error()) {
             self::log(sprintf(_r('An error occurred with "%2$s": %1$s'), $error, $feed['name']), Errors::get_code('api.itemupdater.itemerror'));
             continue;
         }
         $count = 0;
         $items = $sp->get_items();
         foreach ($items as $item) {
             $new_item = self::normalise($item, $feed['id']);
             $new_item = apply_filters('item_data_precache', $new_item);
             if (Items::get_instance()->check_item($new_item)) {
                 $count++;
                 $updated = true;
             }
         }
         do_action('iu-feed-finish', $feed);
     }
     Items::get_instance()->sort_all();
     if ($updated) {
         Items::get_instance()->save_cache();
     }
 }
开发者ID:rmccue,项目名称:Lilina,代码行数:29,代码来源:class-cronupdater.php

示例3: instapaper_submit

function instapaper_submit()
{
    $id = $_GET['id'];
    $item = Items::get_instance()->get_item($id);
    if (false === $item) {
        throw new Exception(_r('Invalid item ID specified', 'instapaper'));
    }
    $user = get_option('instapaper_user');
    if (empty($user)) {
        throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
    }
    if (!check_nonce($_GET['_nonce'])) {
        throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
    }
    $data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
    $request = new HTTPRequest('', 2);
    $response = $request->post("https://www.instapaper.com/api/add", array(), $data);
    switch ($response->status_code) {
        case 400:
            throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
        case 403:
            throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
        case 500:
            throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
    }
    instapaper_page_head();
    ?>
	<div id="message">
		<h1><?php 
    _e('Success!');
    ?>
</h1>
		<p class="sidenote"><?php 
    _e('Closing window in...', 'instapaper');
    ?>
</p>
		<p class="sidenote" id="counter">3</p>
	</div>
	<script>
		$(document).ready(function () {
			setInterval(countdown, 1000);
		});

		function countdown() {
			if(timer > 0) {
				$('#counter').text(timer);
				timer--;
			}
			else {
				self.close();
			}
		}

		var timer = 2;
	</script>
<?php 
    instapaper_page_foot();
    die;
}
开发者ID:rmccue,项目名称:Lilina,代码行数:59,代码来源:instapaper.php

示例4: items_getList

 public static function items_getList($start = 0, $limit = null)
 {
     $items = Items::get_instance()->retrieve();
     if ($limit == null) {
         return $items;
     }
     return array_slice($items, $start, $limit, true);
 }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:8,代码来源:method-api.php

示例5: lilina_return_items

/**
 * Generates a SimplePie object from a list of feeds
 *
 * Takes an input array and parses it using the SimplePie library. Returns a SimplePie object.
 * @param array $input Deprecated
 * @return object SimplePie object with all feed's associated data
 */
function lilina_return_items($input = '', $conditions = array())
{
    foreach (Feeds::get_instance()->getAll() as $the_feed) {
        $feed_list[] = $the_feed['feed'];
    }
    $itemcache = Items::get_instance();
    $itemcache->init();
    $conditions = apply_filters('return_items-conditions', array('time' => time() - 86400));
    $itemcache->set_conditions($conditions);
    $itemcache->filter();
    return apply_filters('return_items', $itemcache);
}
开发者ID:rmccue,项目名称:Lilina,代码行数:19,代码来源:feed-functions.php

示例6: headers

 /**
  * HTTP header handler
  *
  * Handles the output of all default headers, but can be changed via the
  * `template-headers` filter.
  *
  * Also controls working with If-None-Match/If-Modified-Since
  */
 public static function headers()
 {
     // Basic default headers
     $headers = array('Content-Type' => 'text/html; charset=utf-8');
     // Last-Modified and ETag
     $itemcache = Items::get_instance();
     $itemcache->init();
     $items = $itemcache->retrieve();
     if (is_array($items)) {
         $item = reset($items);
     }
     if ($item !== false) {
         $last_modified_timestamp = $item->timestamp;
     } else {
         $last_modified_timestamp = time();
     }
     $last_modified = date('D, d M Y H:i:s', $last_modified_timestamp);
     $headers['Last-Modified'] = $last_modified . ' GMT';
     $headers['ETag'] = '"' . md5($last_modified) . '"';
     // Do the header dance
     $headers = apply_filters('template-headers', $headers);
     foreach ($headers as $name => $value) {
         header($name . ': ' . $value);
     }
     // Conditional GET
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
     } else {
         $client_etag = false;
     }
     $client_modified = !empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime(trim($_SERVER['HTTP_IF_MODIFIED_SINCE'])) : false;
     $protocol = $_SERVER["SERVER_PROTOCOL"];
     if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
         $protocol = 'HTTP/1.0';
     }
     if ($client_modified !== false && $client_etag !== false) {
         if ($client_modified >= $last_modified_timestamp && $client_etag == $headers['ETag']) {
             header($protocol . ' 304 Not Modified');
             die;
         }
     } elseif ($client_modified >= $last_modified_timestamp || $client_etag == $headers['ETag']) {
         header($protocol . ' 304 Not Modified');
         die;
     }
 }
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:53,代码来源:class-templates.php

示例7: has_items

/**
 * @todo Document
 * @return boolean Are items available?
 */
function has_items()
{
    global $lilina_items;
    if (count(Feeds::get_instance()->getAll()) === 0) {
        return false;
    }
    if (empty($lilina_items)) {
        foreach (Feeds::get_instance()->getAll() as $the_feed) {
            $feed_list[] = $the_feed['feed'];
        }
        $lilina_items = Items::get_instance();
        $lilina_items->init();
        $conditions = apply_filters('return_items-conditions', array('time' => time() - get_offset()));
        $lilina_items->set_conditions($conditions);
        $lilina_items->filter();
    }
    return $lilina_items->has_items();
}
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:22,代码来源:skin.php

示例8: _e

?>
</h1>
<?php 
if (count(Feeds::get_instance()->getAll()) === 0) {
    ?>
<p><?php 
    _e("Firstly, thanks for using Lilina! To help you settle in, we've included a few nifty tools in Lilina, just to help you get started.");
    ?>
</p>
<?php 
} else {
    $updated = get_option('last_updated');
    if (!$updated) {
        $message = sprintf(_r('You currently have %d items in %d feeds. Never updated.', count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll())));
    } else {
        $message = sprintf(_r('You currently have %d items in %d feeds. Last updated %s.'), count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll()), relative_time($updated));
    }
    ?>
<p><?php 
    echo $message;
    ?>
</p>
<?php 
}
?>
<h2><?php 
_e('Import');
?>
</h2>
<p><?php 
_e("We can import from any service which supports an open standard called OPML. Here's some services you can import from:");
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:31,代码来源:index.php


注:本文中的Items::get_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。