本文整理汇总了PHP中Errors::get_code方法的典型用法代码示例。如果您正苦于以下问题:PHP Errors::get_code方法的具体用法?PHP Errors::get_code怎么用?PHP Errors::get_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Errors
的用法示例。
在下文中一共展示了Errors::get_code方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: _sortArgs
/**
* Sort parameters by order specified in method declaration
*
* Takes a callback and a list of available params, then filters and sorts
* by the parameters the method actually needs, using the reflection APIs
*
* @author Morten Fangel <fangel@sevengoslings.net>
* @param callback $callback
* @param array $params
* @return array
*/
protected function _sortArgs($callback, $params)
{
// Takes a callback and a list or params and filter and
// sort the list by the parameters the method actually needs
if (is_array($callback)) {
$ref_func = new ReflectionMethod($callback[0], $callback[1]);
} else {
$ref_func = new ReflectionFunction($callback);
}
// Create a reflection on the method
$ref_parameters = $ref_func->getParameters();
// finds the parameters needed for the function via Reflections
$ordered_parameters = array();
foreach ($ref_parameters as $ref_parameter) {
// Run through all the parameters we need
if (isset($params[$ref_parameter->getName()])) {
// We have this parameters in the list to choose from
$ordered_parameters[] = $params[$ref_parameter->getName()];
} elseif ($ref_parameter->isDefaultValueAvailable()) {
// We don't have this parameter, but it's optional
$ordered_parameters[] = $ref_parameter->getDefaultValue();
} else {
// We don't have this parameter and it wasn't optional, abort!
throw new Exception('Missing parameter ' . $ref_parameter->getName() . '', Errors::get_code('admin.ajax.missing_param'));
$ordered_parameters[] = null;
}
}
return $ordered_parameters;
}
示例3: 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();
}
}
示例4: authenticate
protected function authenticate()
{
$data = array('service' => 'reader', 'continue' => 'http://www.google.com/', 'Email' => $this->id, 'Passwd' => $this->pass, 'source' => 'Lilina/' . LILINA_CORE_VERSION);
$response = $this->request->post($this->urls['auth'], array(), $data);
if ($response->success !== true) {
if ($response->status_code == 403) {
// Error text from Google
throw new Exception(_r('The username or password you entered is incorrect.'), Errors::get_code('admin.importer.greader.invalid_auth'));
}
}
preg_match('#SID=(.*)#i', $response->body, $results);
// so we've found the SID
// now we can build the cookie that gets us in the door
$this->cookie = 'SID=' . $results[1];
}
示例5: validate_plugin
/**
* Validate a plugin filename
*
* Checks that the file exists and {@link validate_file() is valid file}. If
* it either condition is not met, returns false and adds an error to the
* {@see MessageHandler} stack.
*
* @since 1.0
*
* @param $filename Path to plugin
* @return bool True if file exists and is valid, otherwise an exception will be thrown
*/
function validate_plugin($filename)
{
switch (validate_file($filename)) {
case 1:
case 2:
throw new Exception(_r('Invalid plugin path.'), Errors::get_code('admin.plugins.invalid_path'));
break;
default:
if (file_exists(get_plugin_dir() . $filename)) {
return true;
} else {
throw new Exception(_r('Plugin file was not found.'), Errors::get_code('admin.plugins.not_found'));
}
}
return false;
}
示例6: error_reporting
error_reporting(E_ALL);
// Fool the authentication so we can handle it ourselves
define('LILINA_LOGIN', true);
require_once 'admin.php';
require_once LILINA_PATH . '/admin/includes/feeds.php';
require_once LILINA_PATH . '/admin/includes/class-ajaxhandler.php';
//header('Content-Type: application/javascript');
header('Content-Type: application/json');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (defined('LILINA_AUTH_ERROR')) {
header('HTTP/1.1 401 Unauthorized');
echo json_encode(array('error' => 1, 'msg' => _r('You are not currently logged in'), 'code' => Errors::get_code('auth.none')));
die;
}
class AdminAjax
{
/**
* Initialise the Ajax interface
*/
public static function init()
{
$handler = new AjaxHandler();
$handler->registerMethod('feeds.add', array('AdminAjax', 'feeds_add'));
$handler->registerMethod('feeds.change', array('AdminAjax', 'feeds_change'));
$handler->registerMethod('feeds.remove', array('AdminAjax', 'feeds_remove'));
$handler->registerMethod('feeds.list', array('AdminAjax', 'feeds_list'));
$handler->registerMethod('feeds.get', array('AdminAjax', 'feeds_get'));
示例7: remove_feed
/**
* Remove a feed
*
* @param int $id ID of the feed to remove
* @return bool
*/
function remove_feed($id)
{
global $data;
if (!isset($data['feeds'][$id])) {
throw new Exception(_r('Feed does not exist'), Errors::get_code('admin.feeds.invalid_id'));
}
//Make a copy for later.
$removed = $data['feeds'][$id];
unset($data['feeds'][$id]);
//Reorder array
$data['feeds'] = array_values($data['feeds']);
save_feeds();
return sprintf(_r('Removed feed — <a href="%s">Undo</a>?'), 'feeds.php?action=add&add_name=' . urlencode($removed['name']) . '&add_url=' . urlencode($removed['feed']));
}
示例8: delete
/**
* Remove a feed
*
* @param string $id ID of the feed to remove
* @return bool
*/
public function delete($id)
{
if (empty($this->feeds[$id])) {
throw new Exception(_r('Feed does not exist'), Errors::get_code('admin.feeds.invalid_id'));
}
//Make a copy for later.
$removed = $this->feeds[$id];
$removed = apply_filters('feed-delete', $removed);
$cache = new DataHandler(get_option('cachedir'));
if ($cache->load($id . '.ico') !== null) {
$cache->delete($id . '.ico');
}
unset($this->feeds[$id]);
$this->save();
return sprintf(_r('Removed "%1$s" — <a href="%2$s">Undo</a>?'), $removed['name'], 'feeds.php?action=add&add_name=' . urlencode($removed['name']) . '&add_url=' . urlencode($removed['feed']) . '&id=' . urlencode($removed['id']));
}
示例9: init
/**
* Run the updater
*/
public function init()
{
if (empty($this->format)) {
$this->page();
die;
}
try {
header('Content-Type: text/json; charset=utf-8');
if (empty($this->action)) {
throw new Exception(_r('No action specified'), Errors::get_code('api.itemupdater.ajax.action_unknown'));
}
switch ($this->action) {
case 'test':
$return = $this->test();
break;
case 'cron':
$return = $this->cron();
break;
case 'all':
$return = $this->process('all');
break;
case 'single':
if (empty($_REQUEST['id'])) {
throw new Exception('No ID specified', Errors::get_code('api.itemupdater.ajax.no_id'));
}
$return = $this->process($_REQUEST['id']);
break;
default:
throw new Exception('Unknown action: ' . preg_replace('/[^-_.0-9a-zA-Z]/', '', $_REQUEST['action']), Errors::get_code('api.itemupdater.ajax.action_unknown'));
break;
}
} catch (Exception $e) {
header('HTTP/1.1 500 Internal Server Error');
echo json_encode(array('error' => 1, 'msg' => $e->getMessage(), 'code' => $e->getCode()));
die;
}
echo json_encode($return);
die;
}
示例10: isset
* @version 1.0
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
require_once 'admin.php';
require_once LILINA_PATH . '/admin/includes/feeds.php';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
/** Make sure we're actually adding */
switch ($action) {
case 'add':
/** We need some sort of value here */
if (!isset($_REQUEST['add_name'])) {
$_REQUEST['add_name'] = '';
}
try {
if (empty($_REQUEST['add_url'])) {
throw new Exception(_r('No URL specified'), Errors::get_code('admin.feeds.no_url'));
}
$message = add_feed($_REQUEST['add_url'], $_REQUEST['add_name']);
clear_html_cache();
} catch (Exception $e) {
$error = $e->getMessage();
}
break;
case 'change':
$change_name = !empty($_REQUEST['change_name']) ? htmlspecialchars($_REQUEST['change_name']) : '';
$change_url = !empty($_REQUEST['change_url']) ? $_REQUEST['change_url'] : '';
$change_id = !empty($_REQUEST['change_id']) ? (int) $_REQUEST['change_id'] : null;
try {
$message = change_feed($change_id, $change_url, $change_name);
clear_html_cache();
} catch (Exception $e) {