本文整理汇总了PHP中Uri::current方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::current方法的具体用法?PHP Uri::current怎么用?PHP Uri::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public static function render($app, $ref_id, $title = 'Comments')
{
if (!isset($app)) {
throw new \FuelException('Petro_Comment : Invalid $app = ' . $app);
}
$query = \DB::query('SELECT ' . static::$_table . '.*, users.username FROM ' . static::$_table . ', users' . ' WHERE ' . static::$_table . '.user_id = users.id' . ' AND ' . static::$_table . '.app = "' . $app . '"' . ' AND ' . static::$_table . '.ref_id = ' . $ref_id . ' ORDER BY ' . static::$_table . '.created_at asc')->execute();
$data['title'] = $title;
$data['app'] = $app;
$data['ref_id'] = $ref_id;
$data['total_comments'] = count($query);
if ($data['total_comments'] <= 0) {
$data['comments'] = str_replace('{text}', 'No comments yet.', \Config::get('petro.template.comment.empty'));
} else {
$t = \Config::get('petro.template.comment.item');
$out = '';
foreach ($query as $item) {
$author = isset($item['username']) ? $item['username'] : 'Anonymous';
$date = empty($item['created_at']) ? '' : \Date::forge($item['created_at'])->format(\Config::get('petro.date_format', '%Y-%m-%d %H:%M'));
$cost = empty($item['cost']) ? '' : number_format($item['cost']);
$out .= str_replace(array('{comment_id}', '{comment_author}', '{comment_date}', '{comment_text}', '{comment_cost}'), array($item['id'], $author, $date, nl2br($item['text']), $cost), $t);
}
$data['comments'] = $out;
}
$data['last_url'] = \Uri::current();
return \View::forge('petro/comments/_form', $data, false)->render();
}
示例2: action_usercp
public function action_usercp()
{
if (!$this->current_user->logged_in()) {
Session::set_flash('error', 'You need to be logged in to access is page');
Session::set_flash('login_redirect', Uri::current());
Response::redirect('login');
}
$this->title('UserCP');
$this->view = $this->theme->view('users/usercp');
if (Input::param() != array()) {
// Set name and email
$this->current_user->name = Input::param('name');
$this->current_user->email = Input::param('email');
// Set new password
if (Input::param('new_password')) {
$this->current_user->password = Input::param('new_password');
}
// Check if the current password is valid...
$auth = Model_User::authenticate_login($this->current_user->username, Input::param('current_password'));
if ($this->current_user->is_valid() and $auth) {
$this->current_user->save();
Session::set_flash('success', 'Details saved');
Response::redirect('usercp');
} else {
$errors = $this->current_user->errors();
if (!$auth) {
$errors = array('Current password is invalid.') + $errors;
}
}
$this->view->set('errors', isset($errors) ? $errors : array());
}
}
示例3: require_auth
public static function require_auth()
{
if (!empty(static::$user)) {
return true;
}
\Config::load('facebook::facebook', 'facebook');
$login_url = static::$instance->getLoginUrl(array('redirect_uri' => \Uri::current(), 'client_id' => \Config::get('facebook.app_id')));
\Uri::redirect($login_url);
}
示例4: action_recover
public function action_recover($hash = null)
{
if (Input::Method() === "POST") {
if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) {
// generate a recovery hash
$hash = \Auth::instance()->hash_password(\Str::random()) . $user->id;
// and store it in the user profile
\Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username);
// send an email out with a reset link
\Package::load('email');
$email = \Email::forge();
$html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>';
// use a view file to generate the email message
$email->html_body($html);
// give it a subject
$email->subject(\Settings::Get('site_name') . ' Password Recovery');
// GET ADMIN EMAIL FROM SETTINGS?
$admin_email = Settings::get('admin_email');
if (empty($admin_email) === false) {
$from = $admin_email;
} else {
$from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false)));
}
$email->from($from);
$email->to($user->email, $user->fullname);
// and off it goes (if all goes well)!
try {
// send the email
$email->send();
Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!');
} catch (\Exception $e) {
Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email);
\Response::redirect_back();
}
} else {
Session::Set('error', 'Sorry there is not a matching email!');
}
} elseif (empty($hash) === false) {
$hash = str_replace(Uri::Create('login/recover/'), '', Uri::current());
$user = substr($hash, 44);
if ($user = \Model\Auth_User::find_by_id($user)) {
// do we have this hash for this user, and hasn't it expired yet , must be within 24 hours
if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) {
// invalidate the hash
\Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username);
// log the user in and go to the profile to change the password
if (\Auth::instance()->force_login($user->id)) {
Session::Set('current_password', Auth::reset_password($user->username));
Response::Redirect(Uri::Create('user/settings'));
}
}
}
Session::Set('error', 'Invalid Hash!');
}
$this->template->content = View::forge('login/recover');
}
示例5: action_index
public function action_index()
{
$this->dataGlobal['pageTitle'] = __('backend.category.manage');
// Pagination
$config = array('pagination_url' => \Uri::current(), 'total_items' => \Model_User::count(), 'per_page' => floor(\Model_User::count() / 2), 'uri_segment' => 'page');
$this->data['pagination'] = $pagination = \Pagination::forge('authors_pagination', $config);
// Get categories
$this->data['authors'] = \Model_User::query()->offset($pagination->offset)->limit($pagination->per_page)->order_by('created_at', 'DESC')->get();
return \Response::forge(\View::forge('backend/author/index')->set($this->data, null, false));
}
示例6: action_index
public function action_index()
{
$this->dataGlobal['pageTitle'] = __('backend.post.manage');
// Pagination
$config = array('pagination_url' => \Uri::current(), 'total_items' => Model_Post::count(), 'per_page' => \Config::get('application.pagination.per_page'), 'uri_segment' => 'page');
$this->data['pagination'] = $pagination = \Pagination::forge('post_pagination', $config);
// Get posts
$this->data['posts'] = \Model_Post::query()->offset($pagination->offset)->limit($pagination->per_page)->order_by('created_at', 'DESC')->get();
$this->theme->set_partial('content', 'backend/post/index')->set($this->data, null, false);
}
示例7: action_index
public function action_index()
{
$export = \Input::get('export', false);
//set cookie order
\Fuel\Core\Cookie::set('person_url', Uri::base() . 'job/orders');
$this->template->title = 'UOS求人システム';
//get search value
$search_arr = \Input::get();
//set return url after edit
$pagination_url = \Uri::base() . 'job/orders/index';
$return_url = \Uri::current();
if (\Input::get('flag') != null) {
$pagination_url = \Uri::base() . 'job/orders/index' . '?' . http_build_query($_GET);
$return_url = \Uri::current() . '?' . http_build_query($_GET);
}
//config pagination
$config = array('pagination_url' => $pagination_url, 'total_items' => count(\Model_Orders::get_all_order_list(null, null, $search_arr)), 'per_page' => \Constants::$default_limit_pagination, 'uri_segment' => 'page', 'num_links' => \Constants::$default_num_links, 'show_last' => true);
if ($export) {
$config['per_page'] = 100000;
} else {
//setcookie
\Cookie::set('return_url_search', $return_url, 60 * 60 * 24);
}
//setup pagination
$pagination = \Uospagination::forge('orders-pagination', $config);
$model_group = new \Model_Mgroups();
$data['listgroup'] = $model_group->get_type(1);
$model_partner = new \Model_Mpartner();
$data['listpartner'] = $model_partner->get_filter_partner(array('type' => 1));
//get list media
$model_media = new \Model_Mmedia();
$data['listmedias'] = $model_media->get_list_all_media();
if (is_array($data['listmedias']) == false) {
$data['listmedias'] = array();
}
//get list post
$model_post = new \Model_Mpost();
$data['listpost'] = $model_post->get_list_all();
//get list ss
$model_ss = new \Model_Mss();
$data['list_all_ss'] = $model_ss->get_list_all_ss();
//get all orders
$model_order = new \Model_Orders();
$data['listorders'] = \Model_Orders::get_all_order_list($pagination->per_page, $pagination->offset, $search_arr);
if ($export) {
$csv_data = $model_order->csv_process($data['listorders']);
\Model_Orders::export($csv_data);
}
foreach ($data['listorders'] as $key => $value) {
$data['listorders'][$key]['image_content'] = base64_encode($data['listorders'][$key]['image_content']);
$data['listorders'][$key]['price'] = \Model_Orders::cost_of_order($value);
}
$this->template->content = \View::forge('orders/index', $data);
}
示例8: segments
/**
* return just the segments of the uri as an array
*
* @param num mixed[string|int] The segment number to be returned
*
* @return array
*/
static function segments($num = null)
{
//get the current url
$url = parse_url(trim(Uri::current(), '/'));
//explode it into segments seperated by the /
$segments = array_filter(explode('/', $url['path']));
//if num is given, use non-zero indexed
if (!is_null($num)) {
return $segments[$num - 1];
}
//return either the segments of an array containing / for the root - this means we can always loop
return $segments ?: array('/');
}
示例9: redirect_back
/**
* Redirects back to the previous page, if that page is within the current
* application. If not, it will redirect to the given url, and if none is
* given, back to the application root
*
* @param string $url The url
* @param string $method The redirect method
* @param int $code The redirect status code
*
* @return void
*/
public static function redirect_back($url = '', $method = 'location', $code = 302)
{
// do we have a referrer?
if ($referrer = \Input::referrer()) {
// is it within our website? And not equal to the current url?
if (strpos($referrer, \Uri::base()) === 0 and $referrer != \Uri::current()) {
// redirect back to where we came from
static::redirect($referrer, $method, $code);
}
}
// no referrer or an external link, do a normal redirect
static::redirect($url, $method, $code);
}
示例10: __construct
/**
* Overloads default class properties from the options.
*
* Any of the provider options can be set here, such as app_id or secret.
*
* @param array provider options
* @return void
*/
public function __construct(array $options = array())
{
if (!$this->name) {
// Attempt to guess the name from the class name
$this->name = strtolower(substr(get_class($this), strlen('OAuth2\\Provider_')));
}
if (!($this->client_id = \Arr::get($options, 'id'))) {
throw new Exception(array('message' => 'Required option not provided: id'));
}
$this->callback = \Arr::get($options, 'callback');
$this->client_secret = \Arr::get($options, 'secret');
$this->scope = \Arr::get($options, 'scope');
$this->redirect_uri = \Uri::current();
}
示例11: action_show_by_author
/**
* Get all categorys from author
* @param string $author username
*/
public function action_show_by_author($author = false)
{
$author = $this->data['author'] = \Model_User::query()->where('username', $author)->get_one();
if (!$author) {
\Messages::error(__('frontend.author.not-found'));
\Response::redirect_back(\Router::get('homepage'));
} else {
// Pagination
$config = array('pagination_url' => \Uri::current(), 'total_items' => count($author->posts), 'per_page' => \Config::get('application.pagination.per_page'), 'uri_segment' => 'page');
$this->data['pagination'] = $pagination = \Pagination::forge('category_pagination', $config);
// Get categorys
$this->data['categories'] = Model_Category::query()->where('user_id', $author->id)->order_by('created_at', 'DESC')->offset($pagination->offset)->limit($pagination->per_page)->get();
return \Response::forge(\View::forge('frontend/category/author')->set($this->data, null, false));
}
}
示例12: set
/**
* Set an item on breadcrumb static property
*
* @param string $title Display Link
* @param string $link Relative Link
* @param intenger $index Index to replace itens
* @return void
*/
public static function set($title, $link = "", $index = null, $overwrite = true)
{
// trim the bastard
$title = trim($title);
// if link is empty user the current
$link = $link === '' ? \Uri::current() : $link;
if (is_null($index)) {
static::$breadcrumb[] = array('title' => $title, 'link' => $link);
} else {
if ($overwrite === true) {
static::$breadcrumb[$index] = array('title' => $title, 'link' => $link);
} else {
static::append($title, $link, $index);
}
}
}
示例13: body_class
function body_class()
{
$classes = array();
// Get the URL slug
$parts = explode('/', Uri::current());
$classes[] = count($parts) ? trim(current($parts)) : 'index';
// Is it a posts page?
if (is_postspage()) {
$classes[] = 'posts';
}
// Is it the homepage?
if (is_homepage()) {
$classes[] = 'home';
}
return implode(' ', array_unique($classes));
}
示例14: action_index
public function action_index()
{
if (!$this->current_user->group->is_admin) {
return $this->no_permission();
}
$this->title('Settings');
$this->view = $this->theme->view('admin/settings/index');
if (Input::param() != array()) {
foreach (Input::param('settings') as $setting => $value) {
$s = Model_Setting::find('first', array('where' => array('setting' => $setting)));
$s->value = $value;
$s->save();
}
Session::set_flash('success', 'Settings saved');
Response::redirect(Uri::current());
}
}
示例15: action_index
/**
* Load every call to the API with this method.
*
* @return void
* @access public
*/
public function action_index()
{
// Profile the loader
\Profiler::mark('Start of loader\'s action_index() function');
\Profiler::mark_memory($this, 'Start of loader\'s action_index() function');
// Make sure we aren't processing crap.
if (in_array($this->format, array('csv', 'php', 'serialize'))) {
$this->format = 'json';
}
// For some reason this value is quoted when set to html.
if (\Input::post('format') === '"html"') {
$this->format = 'html';
}
// Cleanse the session to keep things stable.
\Session::destroy();
// For error handling
\Session::set('response_format', $this->format);
// External error processing through Apache
if (\Uri::segment(1) === 'error' && is_numeric(\Uri::segment(2)) && strlen(\Uri::segment(2)) === 3) {
return $this->response(\Utility::format_error(\Uri::segment(2)));
}
// /loader/index/error/404 style (Due to routing)
if (substr_count(\Uri::current(), 'loader/index/error') === 1 && is_numeric(\Uri::segment(4)) && strlen(\Uri::segment(4)) === 3) {
return $this->response(\Utility::format_error(\Uri::segment(4)));
}
// We need a version number
if (empty(\Uri::segment(1)) || \Module::exists(\Uri::segment(1)) === false) {
$error_data = \Utility::format_error(400, \Err::BAD_OR_NO_VERSION, \Lang::get('errors.bad_version'));
return $this->response($error_data, 400);
}
// We need a request.
if (empty(\Input::post()) || \Input::method() !== 'POST') {
$error_data = \Utility::format_error(405, null, \Lang::get('errors.no_request'));
return $this->response($error_data, 405);
}
// Pass the request to the proper API version request handler. (Module)
if (!empty(\Input::post())) {
\Module::load(\Uri::segment(1));
$response = \Request::forge(\Uri::segment(1) . '/index', false)->execute()->response->body;
// HTML only Data Calls
if (is_string($response)) {
return $this->response($response, 200);
}
return $this->response($response[0], $response[1]);
}
}