本文整理汇总了PHP中URL::base方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::base方法的具体用法?PHP URL::base怎么用?PHP URL::base使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::base方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_edit
public function action_edit()
{
$id = $this->request->param('id');
if ($id != $this->user) {
$this->request->redirect(URL::base());
}
$view = View::factory('player_edit');
$view->realname = @real_name_from_id($id);
if ($_POST) {
$realname = @$_POST['realname'];
$current_password = @$_POST['current_password'];
$new_password = @$_POST['new_password'];
$confirm_password = @$_POST['confirm_password'];
if ($new_password) {
if (!Auth::check_password($current_password)) {
array_push($this->template->errors, "Password did not match password on file.");
}
if ($new_password != $confirm_password) {
array_push($this->template->errors, "New passwords did not match.");
}
if (empty($this->template->errors)) {
password(name_from_id($id));
}
}
if ($realname) {
DB::update('users')->set(array('realname' => $realname))->where('id', '=', $id)->execute();
}
$this->request->redirect('/player/view/2');
}
$this->template->content = $view;
}
示例2: site
/**
* Fetches an absolute site URL based on a URI segment.
*
* echo URL::site('foo/bar');
*
* @param string site URI to convert
* @param mixed protocol string or boolean, add protocol and domain?
* @return string
* @uses URL::base
*/
public static function site($uri = '', $protocol = FALSE)
{
// Chop off possible scheme, host, port, user and pass parts
$path = preg_replace('~^[-a-z0-9+.]++://[^/]++/?~', '', trim($uri, '/'));
// Concat the URL
return URL::base(TRUE, $protocol) . $path;
}
示例3: __construct
/**
* Create new BBCode object and initialize our own settings
*
* @param string $text
*/
public function __construct($text = null)
{
parent::BBCode();
$this->text = $text;
// Automagically print hrefs
$this->SetDetectURLs(true);
// We have our own smileys
$config = Kohana::$config->load('site.smiley');
if (!empty($config)) {
$this->ClearSmileys();
$this->SetSmileyURL(URL::base() . $config['dir']);
foreach ($config['smileys'] as $name => $smiley) {
$this->AddSmiley($name, $smiley['src']);
}
} else {
$this->SetEnableSmileys(false);
}
// We handle newlines with Kohana
//$this->SetIgnoreNewlines(true);
$this->SetPreTrim('a');
$this->SetPostTrim('a');
// User our own quote
$this->AddRule('quote', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_quote'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns'), 'content' => BBCODE_REQUIRED));
// Media tags
$this->AddRule('audio', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_media'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns', 'inline'), 'allow' => array('align' => '/^left|center|right$/'), 'default' => array('align' => 'left'), 'content' => BBCODE_REQUIRED, 'plain_content' => array('')));
$this->AddRule('video', array('mode' => BBCODE_MODE_CALLBACK, 'method' => array($this, 'bbcode_media'), 'class' => 'block', 'allow_in' => array('listitem', 'block', 'columns', 'inline'), 'allow' => array('align' => '/^left|center|right$/'), 'default' => array('align' => 'left'), 'content' => BBCODE_REQUIRED, 'plain_content' => array('')));
}
示例4: getLanguages
public static function getLanguages($is_public = 1)
{
$languages = Model_Languages::listAll($is_public);
//
foreach ($languages as $lang) {
?>
<li>
<div>
<a href="<?php
echo URL::base();
?>
language/changelangto/<?php
echo $lang['abbr'];
?>
" title="<?php
echo $lang['name'];
?>
"><img src="<?php
echo URL::base();
?>
assets/img/<?php
echo $lang['icon'];
?>
" alt="<?php
echo $lang['name'];
?>
"></a>
</div>
</li>
<?php
}
}
示例5: action_form
/**
* [action_form] generates the form to pay at paypal
*/
public function action_form()
{
$this->auto_render = FALSE;
$order_id = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
if ($order->loaded()) {
// dependant on product we have different names
if ($order->id_product == Paypal::to_featured) {
$item_name = __('Advertisement to featured');
} else {
if ($order->id_product == Paypal::to_top) {
$item_name = __('Advertisement to top');
} else {
$item_name = $order->description . __(' category');
}
}
$paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
$paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => core::config('payment.paypal_currency'), 'item_name' => $item_name);
$this->template = View::factory('paypal', $paypal_data);
$this->response->body($this->template->render());
} else {
Alert::set(Alert::INFO, __('Order could not be loaded'));
$this->request->redirect(Route::url('default'));
}
}
示例6: action_signup
public function action_signup()
{
$this->template->menu_signup = TRUE;
// Если залогинен, то перекидываем на дерево
if (Auth::instance()->logged_in()) {
$this->redirect(Route::url('user/id', array('user_id' => Auth::instance()->get_user()->id)));
}
$post = Arr::extract($this->request->post(), array('name', 'surname', 'email'));
$data['errors'] = NULL;
if ($this->request->method() == 'POST') {
// Генерирую случайный пароль из цифр
$post['password'] = Text::random('numeric', 5);
try {
$user = ORM::factory('User')->values($post)->save();
$user->add('roles', ORM::factory('Role', array('name' => 'login')));
$message = '
Для входа на сайт ' . $_SERVER['HTTP_HOST'] . ' используйте следующие данные:<br><br>
Адрес электронной почты: ' . HTML::chars($user->email) . '<br>
Пароль: ' . HTML::chars($post['password']) . '<br><br>
<a href="' . URL::base(TRUE) . '">Перейти на сайт</a>';
Useful::mail($user->email, 'Регистрация LiveTex', $message, 'LiveTex');
// Авторизовываю
Auth::instance()->login($user->email, $post['password'], TRUE);
$this->redirect(Route::url('user/id', array('user_id' => $user->id)));
} catch (ORM_Validation_Exception $e) {
$data['errors'] = $e->errors('orm');
}
}
$data += $post;
$this->template->content = View::factory('auth/signup', $data);
}
示例7: before
public function before()
{
if (!User::current()) {
$this->redirect('/login');
}
$url = str_replace('.', '_', URL::base() . $this->request->uri());
if (isset($_GET[$url])) {
unset($_GET[$url]);
}
if (isset($_GET[$url . '/'])) {
unset($_GET[$url . '/']);
}
if (Group::current('is_admin') || Group::current('show_all_jobs') && Group::current('allow_finance')) {
Pager::$counts[] = 2500;
}
if (Arr::get($_GET, 'limit') && in_array($_GET['limit'], Pager::$counts)) {
DB::update('users')->set(array('list_items' => intval($_GET['limit'])))->where('id', '=', User::current('id'))->execute();
die(json_encode(array('success' => 'true')));
}
if (Arr::get($_GET, 'dismiss')) {
DB::delete('notifications')->where('user_id', '=', User::current('id'))->and_where('id', '=', intval($_GET['dismiss']))->execute();
die(json_encode(array('success' => 'true')));
}
if (!Group::current('allow_assign')) {
Enums::$statuses[Enums::STATUS_UNALLOC] = 'Not active';
}
View::set_global('notifications', DB::select()->from('notifications')->where('user_id', '=', User::current('id'))->order_by('id', 'desc')->execute());
}
示例8: getClient
/**
* Validate a client
*
* Example SQL query:
*
* <code>
* # Client ID + redirect URI
* SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name,
* oauth_clients.auto_approve
* FROM oauth_clients LEFT JOIN oauth_client_endpoints ON oauth_client_endpoints.client_id = oauth_clients.id
* WHERE oauth_clients.id = :clientId AND oauth_client_endpoints.redirect_uri = :redirectUri
*
* # Client ID + client secret
* SELECT oauth_clients.id, oauth_clients.secret, oauth_clients.name, oauth_clients.auto_approve FROM oauth_clients
* WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret
*
* # Client ID + client secret + redirect URI
* SELECT oauth_clients.id, oauth_clients.secret, oauth_client_endpoints.redirect_uri, oauth_clients.name,
* oauth_clients.auto_approve FROM oauth_clients LEFT JOIN oauth_client_endpoints
* ON oauth_client_endpoints.client_id = oauth_clients.id
* WHERE oauth_clients.id = :clientId AND oauth_clients.secret = :clientSecret AND
* oauth_client_endpoints.redirect_uri = :redirectUri
* </code>
*
* Response:
*
* <code>
* Array
* (
* [client_id] => (string) The client ID
* [client secret] => (string) The client secret
* [redirect_uri] => (string) The redirect URI used in this request
* [name] => (string) The name of the client
* [auto_approve] => (bool) Whether the client should auto approve
* )
* </code>
*
* @param string $clientId The client's ID
* @param string $clientSecret The client's secret (default = "null")
* @param string $redirectUri The client's redirect URI (default = "null")
* @param string $grantType The grant type used in the request (default = "null")
* @return bool|array Returns false if the validation fails, array on success
*/
public function getClient($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
{
// NOTE: this implementation does not implement any grant type checks!
if (!$clientSecret and !$redirectUri) {
return FALSE;
}
if ($redirectUri and $clientId === $this->get_internal_client_id()) {
// The internal client only supports local redirects, so we strip the
// domain information from the URI. This also prevents accidental redirect
// outside of the current domain.
$redirectUri = parse_url($redirectUri, PHP_URL_PATH);
// We attempt to strip out the base URL, so that deployments work properly
// when installed to a sub-directory.
$baseUrl = preg_quote(URL::base(NULL, true), '~');
$redirectUri = preg_replace("~^{$baseUrl}~", '/', $redirectUri);
}
if ($clientSecret and $redirectUri) {
$query = $this->query_secret_and_redirect_uri($clientId, $clientSecret, $redirectUri);
} else {
if ($clientSecret) {
$query = $this->query_secret($clientId, $clientSecret);
} else {
if ($redirectUri) {
$query = $this->query_redirect_uri($clientId, $redirectUri);
}
}
}
$query->param(':clientId', $clientId)->param(':clientSecret', $clientSecret)->param(':redirectUri', $redirectUri);
return $this->select_one_result($query);
}
示例9: action_datatables_ajax
/**
* ajax-based serverside processed datatables example action
*/
public function action_datatables_ajax()
{
// Column definition
$columns = array("test1" => "Testcolumn #1", "test2" => "Testcolumn #2");
// Generate random data
$data = Session::instance()->get('dattables_example', array());
if (empty($data)) {
for ($i = 0; $i < 5000; $i++) {
$data[] = array('test1' => $this->generateRandomString(25), 'test2' => $this->generateRandomString(25));
}
}
// Create datatable
$datatable = new Datatable($columns);
// Here you could also pass in a orm model like this: $datatable->add_entries(ORM::factory('Model'));
// Then the model needs to have columns named like the keys in the column definition, so in this example
// test1 and test2 are needed properties on the model.
$datatable->add_entries($data);
$datatable->set_serverside(URL::base() . 'UIFWExamples/datatables_ajax');
// Render html code from datatable->render() with the html layout
if (Request::$current->is_ajax()) {
echo $datatable->ajax_render();
} else {
$this->renderHtml($datatable->render());
}
}
示例10: anchor
/**
* Create HTML link anchors. Note that the title is not escaped, to allow
* HTML elements within links (images, etc).
*
* @param string URL or URI string
* @param string link text
* @param array HTML anchor attributes
* @param string use a specific protocol
* @return string
*/
public static function anchor($uri, $title = NULL, array $attributes = NULL, $protocol = NULL)
{
if ($title === NULL) {
// Use the URI as the title
$title = $uri;
}
// Translate the title
$title = __($title);
if ($uri === '') {
// Only use the base URL
$uri = URL::base(FALSE, $protocol);
} else {
if (strpos($uri, '://') !== FALSE) {
if (HTML::$windowed_urls === TRUE and empty($attributes['target'])) {
// Make the link open in a new window
$attributes['target'] = '_blank';
}
} elseif ($uri[0] !== '#') {
// Make the URI absolute for non-id anchors
$uri = URL::site($uri, $protocol);
}
}
// Add the sanitized link to the attributes
$attributes['href'] = $uri;
return '<a' . HTML::attributes($attributes) . '>' . $title . '</a>';
}
示例11: url
public static function url()
{
if (empty(self::$base)) {
self::$base = dirname($_SERVER['PHP_SELF']) != '/' ? dirname($_SERVER['PHP_SELF']) : '';
}
return self::$base;
}
示例12: __construct
/**
* __construct
*
* @return void
*/
public function __construct()
{
parent::__construct();
API::$component = 'admin';
$this->url = Config::get('layla.admin.url_prefix') . '/';
View::share('base_url', URL::base());
}
示例13: redirect
protected function redirect($link = NULL, $code = 302)
{
if (empty($link)) {
$link = URL::base();
}
$this->request->current()->redirect($link, $code);
}
示例14: action_pay
/**
* [action_form] generates the form to pay at paypal
*/
public function action_pay()
{
$this->auto_render = FALSE;
$order_id = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
if ($order->loaded()) {
// case when selling advert
if ($order->id_product == Model_Order::PRODUCT_AD_SELL) {
$paypal_account = $order->ad->paypal_account();
$currency = i18n::get_intl_currency_symbol();
if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) {
$order->amount = $order->amount + $order->ad->cf_shipping;
}
} else {
$paypal_account = core::config('payment.paypal_account');
$currency = core::config('payment.paypal_currency');
}
$paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
$paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description);
$this->template = View::factory('paypal', $paypal_data);
$this->response->body($this->template->render());
} else {
Alert::set(Alert::INFO, __('Order could not be loaded'));
$this->redirect(Route::url('default'));
}
}
示例15: get_html_styles_and_scripts
/**
* Builds the html-code for all registered scripts and styles.
* This can get used to ouput them in the header of the main layout view.
*/
public static function get_html_styles_and_scripts()
{
$output = '';
// Build all styles
foreach (self::$_styles as $style) {
// Check if the style is remote
$is_remote = strpos($style, "http://") !== FALSE;
// Check if not remote and locally our file exists
if (!$is_remote && !file_exists(DOCROOT . $style)) {
throw new Exception('Style not found: ' . DOCROOT . $style);
}
$output .= '<link rel="stylesheet" type="text/css" href="' . ($is_remote ? '' : URL::base()) . $style . '">' . "\r\n";
}
// Build all scripts
foreach (self::$_scripts as $script) {
// Check if the style is remote
$is_remote = strpos($script, "http://") !== FALSE;
// Check if not remote and locally our file exists
if (!$is_remote && !file_exists(DOCROOT . $style)) {
throw new Exception('Style not found: ' . DOCROOT . $style);
}
$output .= '<script type="text/javascript" src="' . ($is_remote ? '' : URL::base()) . $script . '"></script>' . "\r\n";
}
return $output;
}