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


PHP Error::raise方法代码示例

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


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

示例1: parse

 public function parse()
 {
     while ($this->has_more() && $this->state != self::$STATE_FINISHED) {
         switch ($this->state) {
             case self::$STATE_START:
                 $this->state = $this->parse_start();
                 break;
             case self::$STATE_TAG:
                 $this->state = $this->parse_tag();
                 break;
             case self::$STATE_ELEMENT_OPEN:
                 $this->state = $this->parse_element_open();
                 break;
             case self::$STATE_ELEMENT_CLOSE:
                 $this->state = $this->parse_element_close();
                 break;
             case self::$STATE_STATEMENT:
                 $this->state = $this->parse_statement();
                 break;
             case self::$STATE_PI:
                 $this->state = $this->parse_pi();
                 break;
             default:
                 Error::raise(sprintf(_t('Invalid state %d in %s->parse()'), $this->state, __CLASS__));
                 $this->state = self::$STATE_FINISHED;
                 break;
         }
     }
     return $this->nodes;
 }
开发者ID:ringmaster,项目名称:system,代码行数:30,代码来源:htmltokenizer.php

示例2: hex_rgb

 /**
  * Converts a HTML style hex string ('#7f6699') to an RGB array.
  */
 public static function hex_rgb($hex_string)
 {
     $hex_string = ltrim($hex_string, '#');
     if (!preg_match('/^[0-9a-f]+$/i', $hex_string)) {
         return Error::raise(_t('Not a valid hex color.'));
     }
     $normalized = '';
     switch (strlen($hex_string)) {
         case 3:
             // 'fed' = 'ffeedd'
             for ($i = 0; $i < 3; $i++) {
                 $normalized .= $hex_string[$i] . $hex_string[$i];
             }
             break;
         case 6:
             // already normal
             $normalized = $hex_string;
             break;
         case 2:
         case 4:
             // who uses this anyway!
             $normalized = $hex_string . str_repeat('0', 6 - strlen($hex_string));
             break;
         default:
             return Error::raise(_t('Not a valid color format.'));
     }
     return self::rgb_rgbarr(hexdec(substr($normalized, 0, 2)), hexdec(substr($normalized, 2, 2)), hexdec(substr($normalized, 4, 2)));
 }
开发者ID:habari,项目名称:system,代码行数:31,代码来源:colorutils.php

示例3: __construct

 /**
  * @param string URL
  * @param string method to call
  * @param string method's arguments
  */
 function __construct($url, $method, $params)
 {
     if (!function_exists('xmlrpc_encode_request')) {
         return Error::raise(_t('xmlrpc extension not found'));
     }
     $this->url = $url;
     $this->method = $method;
     $this->params = $params;
     $this->request_body = xmlrpc_encode_request($method, $params);
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:15,代码来源:rpcclient.php

示例4: get_external_content

 private static function get_external_content($url)
 {
     // Get PHP serialized object from Flickr
     $call = new RemoteRequest($url);
     $call->set_timeout(5);
     $result = $call->execute();
     if (Error::is_error($result)) {
         throw Error::raise(_t('Unable to contact Flickr.', 'flickrfeed'));
     }
     return $call->get_response_body();
 }
开发者ID:habari-extras,项目名称:flickrfeed,代码行数:11,代码来源:flickrfeed.plugin.php

示例5: absolute_path

 /**
  * Return a normalized and absolute path if path exist
  * or the normalized provided path if `$strict = false`
  * otherwise an error is raised.
  *
  * @static
  * @method absolute_path
  * @param  {String}  $path
  * @param  {Boolean} [$strict=true] Throw an exception if does not exist.
  * @throws {Error} If `$path` does not exist and `$strict = true`.
  * @return {String}
  */
 public static function absolute_path($path, $strict = true)
 {
     // If the path exist
     if (file_exists($path)) {
         // Get the absolute path
         $path = realpath($path);
     } else {
         if ($strict) {
             Error::raise('Path "%s" does not exist.', [$path]);
         }
     }
     // Return a normalized path
     return self::normalize_path($path);
 }
开发者ID:lautr3k,项目名称:Straw,代码行数:26,代码来源:helper.php

示例6: script_name

	/**
	 * script_name is a helper function to determine the name of the script
	 * not all PHP installations return the same values for $_SERVER['SCRIPT_URL']
	 * and $_SERVER['SCRIPT_NAME']
	 */
	public static function script_name()
	{
		switch ( true ) {
			case isset( self::$scriptname ):
				break;
			case isset( $_SERVER['SCRIPT_NAME'] ):
				self::$scriptname = $_SERVER['SCRIPT_NAME'];
				break;
			case isset( $_SERVER['PHP_SELF'] ):
				self::$scriptname = $_SERVER['PHP_SELF'];
				break;
			default:
				Error::raise( _t( 'Could not determine script name.' ) );
				die();
		}
		return self::$scriptname;
	}
开发者ID:nerdfiles,项目名称:habari_boilerplate,代码行数:22,代码来源:site.php

示例7: call

 /**
  * Execute a call to the Picasa Service
  *
  * @param $url string The destination url
  * @param $args array Optional Extra arguments
  * @param $post_data Optional Post data
  * @return mixed false on error or xml string
  */
 public function call($url, $args = array(), $post_data = '')
 {
     $token = Options::get('picasa_token_' . User::identify()->id);
     $default_args = array('method' => 'GET');
     $args = array_merge($default_args, $args);
     $request = new RemoteRequest($url, $args['method']);
     // set authorisation header
     $request->add_header(array("Authorization" => "AuthSub token=" . $token));
     // add extra headers
     if (isset($args['http_headers'])) {
         foreach ($args['http_headers'] as $key => $value) {
             $request->add_header(array($key => $value));
         }
     }
     if ($post_data != '') {
         $request->set_body($post_data);
     }
     $request->set_timeout(30);
     // execute request
     $result = $request->execute();
     if (Error::is_error($result)) {
         return $result;
     }
     // get the response if executed
     if ($request->executed()) {
         $response = $request->get_response_body();
     }
     if (!$response) {
         return Error::raise('API call failure', E_USER_WARNING);
     }
     // parse the result
     try {
         $xml = new SimpleXMLElement($response);
         return $xml;
     } catch (Exception $e) {
         Session::error('Currently unable to connect to the Picasa API.', 'Picasa API');
         return false;
     }
 }
开发者ID:habari-extras,项目名称:picasasilo,代码行数:47,代码来源:picasasilo.plugin.php

示例8: parse_json

 private static function parse_json($block, $json)
 {
     // Decode JSON
     $obj = json_decode($json);
     if (isset($obj->query)) {
         $obj = $obj->results;
         // Strip user designate tags
         foreach ($obj as &$o) {
             $o->text = str_replace($block->search, '', $o->text);
         }
     }
     if (!is_array($obj)) {
         // Response is not JSON
         throw Error::raise(_t('Response is not correct, Twitter server may be down or API is changed.', 'twitterlitte'));
     }
     $serial = serialize($obj);
     // Convert stdClass to TwitterLitteTweet and TwitterLitteUser
     $serial = str_replace('s:4:"user";O:8:"stdClass":', 's:4:"user";O:16:"TwitterLitteUser":', $serial);
     $serial = str_replace('O:8:"stdClass":', 'O:17:"TwitterLitteTweet":', $serial);
     $tweets = unserialize($serial);
     return $tweets;
 }
开发者ID:habari-extras,项目名称:twitterlitte,代码行数:22,代码来源:twitterlitte.plugin.php

示例9: update_tweetbacks

 private function update_tweetbacks(Post $post)
 {
     // Get the lastest tweetback in database
     $tweetbacks = $post->comments->tweetbacks;
     if ($tweetbacks->count > 0) {
         $tweet_url = explode('/', $tweetbacks[0]->url);
         $since_id = end($tweet_url);
     } else {
         $since_id = 0;
     }
     // Get short urls
     $aliases = array_filter((array) ShortURL::get($post));
     //$aliases[] = $post->permalink; // Do not include original permalink, because Twitter Search has character limit, too.
     // Construct request URL
     $url = 'http://search.twitter.com/search.json?';
     $url .= http_build_query(array('ors' => implode(' ', $aliases), 'rpp' => 50, 'since_id' => $since_id), '', '&');
     // Get JSON content
     $call = new RemoteRequest($url);
     $call->set_timeout(5);
     $result = $call->execute();
     if (Error::is_error($result)) {
         throw Error::raise(_t('Unable to contact Twitter.', $this->class_name));
     }
     $response = $call->get_response_body();
     // Decode JSON
     $obj = json_decode($response);
     if (isset($obj->results) && is_array($obj->results)) {
         $obj = $obj->results;
     } else {
         throw Error::raise(_t('Response is not correct, Twitter server may be down or API is changed.', $this->class_name));
     }
     // Store new tweetbacks into database
     foreach ($obj as $tweet) {
         Comment::create(array('post_id' => $post->id, 'name' => $tweet->from_user, 'url' => sprintf('http://twitter.com/%1$s/status/%2$d', $tweet->from_user, $tweet->id), 'content' => $tweet->text, 'status' => Comment::STATUS_APPROVED, 'date' => HabariDateTime::date_create($tweet->created_at), 'type' => Comment::TWEETBACK));
     }
 }
开发者ID:habari-extras,项目名称:tweetsuite,代码行数:36,代码来源:tweetsuite.plugin.php

示例10: SMTP

 /**
  * Connect to the SMTP server by instantiating a SMTP object.
  *
  * @return mixed Returns a reference to the SMTP object on success, or
  *			   a Error containing a descriptive error message on
  *			   failure.
  *
  * @since  1.2.0
  * @access public
  */
 public function &getSMTPObject()
 {
     if (is_object($this->_smtp) !== false) {
         return $this->_smtp;
     }
     $this->_smtp = new SMTP($this->host, $this->port, $this->localhost);
     /* If we still don't have an SMTP object at this point, fail. */
     if (is_object($this->_smtp) === false) {
         throw Error::raise('Failed to create a SMTP object', self::ERROR_CREATE);
     }
     /* Configure the SMTP connection. */
     if ($this->debug) {
         $this->_smtp->setDebug(true);
     }
     /* Attempt to connect to the configured SMTP server. */
     if (Error::is_error($res = $this->_smtp->connect($this->timeout))) {
         $error = $this->_error('Failed to connect to ' . $this->host . ':' . $this->port, $res);
         throw Error::raise($error, self::ERROR_CONNECT);
     }
     /* Attempt to authenticate if authentication has been enabled. */
     if ($this->auth) {
         $method = is_string($this->auth) ? $this->auth : '';
         if (Error::is_error($res = $this->_smtp->auth($this->username, $this->password, $method))) {
             $error = $this->_error("{$method} authentication failure", $res);
             $this->_smtp->rset();
             throw Error::raise($error, self::ERROR_AUTH);
         }
     }
     return $this->_smtp;
 }
开发者ID:habari-extras,项目名称:mail_smtp,代码行数:40,代码来源:mail.php

示例11: get_response_headers

 public function get_response_headers()
 {
     if (!$this->executed) {
         return Error::raise(_t('Request did not yet execute.'));
     }
     return $this->response_headers;
 }
开发者ID:anupom,项目名称:my-blog,代码行数:7,代码来源:socketrequestprocessor.php

示例12: setPath

 /**
  * Set new path.
  *
  * @method setPath
  * @param  string $key
  * @param  string  $path
  * @param  boolean [$strict=true]
  * @return string
  */
 public function setPath($key, $path, $strict = true)
 {
     // If strict mode and path not found.
     if ($strict and !file_exists($path)) {
         // Throw an error.
         Error::raise('Path not found: [%s: "%s"].', [$key, $path]);
     }
     // Else set and return normalized absolute path.
     return $this->config[$key] = self::normalizePath(realpath($path));
 }
开发者ID:lautr3k,项目名称:LADoc,代码行数:19,代码来源:config.php

示例13: theme_audioscrobbler

 /**
  * Add last Audioscrobbler status, time, and image to the available template vars
  * @param Theme $theme The theme that will display the template
  **/
 public function theme_audioscrobbler($theme, $params = array())
 {
     $params = array_merge($this->config, $params);
     $cache_name = $this->class_name . '__' . md5(serialize($params));
     if ($params['username'] != '') {
         $track_url = 'http://ws.audioscrobbler.com/1.0/user/' . urlencode($params['username']) . '/recenttracks.xml';
         if (Cache::has($cache_name)) {
             $xml = new SimpleXMLElement(Cache::get($cache_name));
             $theme->track = $xml->track;
         } else {
             try {
                 // Get XML content via Audioscrobbler API
                 $call = new RemoteRequest($track_url);
                 $call->set_timeout(5);
                 $result = $call->execute();
                 if (Error::is_error($result)) {
                     throw Error::raise(_t('Unable to contact Last.fm.', $this->class_name));
                 }
                 $response = $call->get_response_body();
                 // Parse XML content
                 $xml = new SimpleXMLElement($response);
                 $theme->track = $xml->track;
                 Cache::set($cache_name, $response, $params['cache']);
             } catch (Exception $e) {
                 $theme->track = $e->getMessage();
             }
         }
     } else {
         $theme->track = _t('Please set your username in the Audioscrobbler plugin config.', $this->class_name);
     }
     return $theme->fetch('audioscrobbler');
 }
开发者ID:habari-extras,项目名称:audioscrobbler,代码行数:36,代码来源:audioscrobbler.plugin.php

示例14: action_hconsole_debug

 public function action_hconsole_debug()
 {
     if (isset($this->code['debug'])) {
         ob_start();
         $res = eval($this->code['debug']);
         $dat = ob_get_contents();
         ob_end_clean();
         if ($res === false) {
             throw Error::raise($dat, E_COMPILE_ERROR);
         } else {
             echo $this->htmlspecial ? htmlspecialchars($dat) : $dat;
         }
     }
     if ($this->sql) {
         $itemlist = array();
         if (preg_match('#^\\s*(select|show).*#i', $this->sql)) {
             $data = DB::get_results($this->sql);
             if (DB::has_errors()) {
                 throw Error::raise(DB::get_last_error());
             }
             if (is_array($data) && count($data)) {
                 self::sql_dump($data);
             } else {
                 echo 'empty set, nothing returned.';
             }
         } else {
             $data = DB::query($this->sql);
             if (DB::has_errors()) {
                 throw Error::raise(DB::get_last_error());
             }
             echo 'Result: ' . (string) $data;
         }
     }
 }
开发者ID:habari,项目名称:habari,代码行数:34,代码来源:hconsole.plugin.php

示例15: load_bk_info

 /**
  * Get the brightkite feed for our user_id
  **/
 private function load_bk_info($params = array())
 {
     $cache_name = $this->class_name . '__' . md5(serialize($params));
     if (Cache::has($cache_name)) {
         // Read from the cache
         return Cache::get($cache_name);
     } else {
         // Time to fetch it.
         $url = 'http://brightkite.com/people/' . $params['user_id'] . '.json';
         try {
             $call = new RemoteRequest($url);
             $call->set_timeout(5);
             $result = $call->execute();
             if (Error::is_error($result)) {
                 throw Error::raise(_t('Unable to contact Brightkite.', $this->class_name));
             }
             $response = $call->get_response_body();
             // Decode the JSON
             $bkdata = json_decode($response, true);
             if (!is_array($bkdata)) {
                 // Response is not JSON
                 throw Error::raise(_t('Response is not correct, maybe Brightkite server is down or API changed.', $this->class_name));
             }
             // Do cache
             Cache::set($cache_name, $bkdata, $params['cache_expiry']);
             return $bkdata;
         } catch (Exception $e) {
             return $e->getMessage();
         }
     }
 }
开发者ID:habari-extras,项目名称:brightkite,代码行数:34,代码来源:brightkite.plugin.php


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