本文整理汇总了PHP中Uri::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::create方法的具体用法?PHP Uri::create怎么用?PHP Uri::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadPicture
public static function uploadPicture()
{
$user_id = Input::get('object_id');
$type = Input::get('object_type');
$user_id = Input::get('user_id');
$uploader = new Utils_Uploader(array('jpeg', 'jpg', 'png'));
$path = DOCROOT . 'assets/uploads' . DS;
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
$typeName = Model_Upload_Type::find($type)->types;
$pic_name = $typeName . "_" . time();
$original = $path . $pic_name;
$output = $uploader->handleUploadRename($path, $pic_name);
if (isset($output['success'])) {
$original = $path . $output['full_filename'];
$uploadAll = Model_Upload::forge();
$uploadAll->user_id = $user_id;
$uploadAll->type_id = $type;
$uploadAll->name = $output['full_filename'];
$uploadAll->original_name = $output['full_filename'];
$uploadAll->path = $original;
$uploadAll->save();
$output['upload_id'] = $uploadAll->id;
Image::load($original)->preset($typeName)->save($original);
$localFileName = $path . $output['full_filename'];
$remoteFileName = DOCROOT . 'assets/uploads/' . DS . $output['full_filename'];
$output['uri'] = Uri::create('upload/get_image/' . $output['full_filename'] . '/' . $output['upload_id']);
}
return $output;
}
示例2: action_execute
public function action_execute()
{
$database_settings = \Config::load('backup::db');
$backupfile = $database_settings['backup']['database'] . date("Y-m-d") . '.sql';
$backupzip = $backupfile . '.tar.gz';
system('mysqldump -u' . $database_settings['backup']['username'] . ' -p' . $database_settings['backup']['password'] . ' ' . $database_settings['backup']['database'] . ' > ' . $backupfile);
system("tar -czvf {$backupzip} {$backupfile}");
// Send autoresponder
$autoresponder = \Autoresponder\Autoresponder::forge();
$autoresponder->view_custom = 'database_backup';
$settings = \Config::load('autoresponder.db');
$content['company_name'] = $settings['company_name'];
$content['address'] = $settings['address'];
$content['website'] = $settings['website'];
$content['message'] = 'This is your database backup from ' . \Uri::create('/');
$content['subject'] = 'Database Backup';
$autoresponder->autoresponder_custom($content, 'backup', array(DOCROOT . $backupzip));
if ($autoresponder->send()) {
echo 'The mail has been sent successfully.';
} else {
echo 'There was an error while trying to sent email.';
}
// Delete the file from your server
unlink($backupfile);
unlink($backupzip);
exit;
}
示例3: displayList
/** @inheritdoc */
public static function displayList($value, $edit_link, &$settings, &$model)
{
if (empty($value) || is_null($value) || strlen($value) === 0) {
return '<a href="' . $edit_link . '" class="item-link">(none)</a>';
}
return '<a href="' . $edit_link . '" class="item-link"><img src="' . \Uri::create('/admin/assets/img/lang/' . $value . '.png') . '" style="width:24px;height:24px;" /> ' . \Lang::get("languages.{$value}") . '</a>';
}
示例4: notify
/**
* Because Paypal Ipn is redirected to \Payment\PayPal\ipn
* There is no need to notify customer here, we'll do that in Ipn method of Payment module
*/
public function notify()
{
$config = array('mode' => $this->config['mode'], 'acct1.UserName' => $this->config['user_name'], 'acct1.Password' => $this->config['password'], 'acct1.Signature' => $this->config['signature']);
$paypalService = new \PayPal\Service\PayPalAPIInterfaceServiceService($config);
$getExpressCheckoutDetailsRequest = new \PayPal\PayPalAPI\GetExpressCheckoutDetailsRequestType(\Session::get('paypal.token'));
$getExpressCheckoutDetailsRequest->Version = $this->config['version'];
$getExpressCheckoutReq = new \PayPal\PayPalAPI\GetExpressCheckoutDetailsReq();
$getExpressCheckoutReq->GetExpressCheckoutDetailsRequest = $getExpressCheckoutDetailsRequest;
$getECResponse = $paypalService->GetExpressCheckoutDetails($getExpressCheckoutReq);
// COMMIT THE PAYMENT
$paypalService = new \PayPal\Service\PayPalAPIInterfaceServiceService($config);
$paymentDetails = new \PayPal\EBLBaseComponents\PaymentDetailsType();
$orderTotal = new \PayPal\CoreComponentTypes\BasicAmountType($this->config['currency'], $this->getOrderTotal());
$paymentDetails->OrderTotal = $orderTotal;
$paymentDetails->PaymentAction = 'Sale';
$paymentDetails->NotifyURL = $this->config['notify_url'];
$DoECRequestDetails = new \PayPal\EBLBaseComponents\DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequestDetails->PayerID = $getECResponse->GetExpressCheckoutDetailsResponseDetails->PayerInfo->PayerID;
$DoECRequestDetails->Token = $getECResponse->GetExpressCheckoutDetailsResponseDetails->Token;
$DoECRequestDetails->PaymentDetails[0] = $paymentDetails;
$DoECRequest = new \PayPal\PayPalAPI\DoExpressCheckoutPaymentRequestType();
$DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;
$DoECRequest->Version = $this->config['version'];
$DoECReq = new \PayPal\PayPalAPI\DoExpressCheckoutPaymentReq();
$DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;
$DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
if ($DoECResponse->Ack == 'Success') {
$this->savePayment('Completed', 'Completed', $DoECResponse->toXMLString());
\Response::redirect(\Uri::create('order/checkout/finalise_order'));
}
$this->savePayment('Failed', 'Transaction failed', $DoECResponse->Errors[0]->LongMessage);
return true;
// failed
}
示例5: test_create
/**
* Tests Uri::create()
*
* @test
*/
public function test_create()
{
Config::set('url_suffix', '');
$prefix = Uri::create('');
$output = Uri::create('controller/method');
$expected = $prefix . "controller/method";
$this->assertEquals($expected, $output);
$output = Uri::create('controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
$expected = $prefix . "controller/thing?what=more";
$this->assertEquals($expected, $output);
Config::set('url_suffix', '.html');
$output = Uri::create('controller/method');
$expected = $prefix . "controller/method.html";
$this->assertEquals($expected, $output);
$output = Uri::create('controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
$expected = $prefix . "controller/thing.html?what=more";
$this->assertEquals($expected, $output);
$output = Uri::create('http://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
$expected = "http://example.com/controller/thing.html?what=more";
$this->assertEquals($expected, $output);
$output = Uri::create('http://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'), true);
$expected = "https://example.com/controller/thing.html?what=more";
$this->assertEquals($expected, $output);
$output = Uri::create('https://example.com/controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'), false);
$expected = "http://example.com/controller/thing.html?what=more";
$this->assertEquals($expected, $output);
}
示例6: open
/**
* Create a form open tag
*
* @param string|array action string or array with more tag attribute settings
* @return string
*/
public static function open($attributes = array(), array $hidden = array())
{
$attributes = !is_array($attributes) ? array('action' => $attributes) : $attributes;
// If there is still no action set, Form-post
if (!array_key_exists('action', $attributes) or $attributes['action'] === null) {
$attributes['action'] = \Uri::main();
} elseif (!strpos($attributes['action'], '://')) {
$attributes['action'] = \Uri::create($attributes['action']);
}
if (empty($attributes['accept-charset'])) {
$attributes['accept-charset'] = strtolower(\Fuel::$encoding);
}
// If method is empty, use POST
!empty($attributes['method']) || ($attributes['method'] = \Config::get('form.form_method', 'post'));
$form = '<form';
foreach ($attributes as $prop => $value) {
$form .= ' ' . $prop . '="' . $value . '"';
}
$form .= '>';
// Add hidden fields when given
foreach ($hidden as $field => $value) {
$form .= PHP_EOL . static::hidden($field, $value);
}
return $form;
}
示例7: test_anchor
/**
* Tests Html::anchor()
*
* @test
*/
public function test_anchor()
{
// External uri
$output = Html::anchor('http://google.com', 'Go to Google');
$expected = '<a href="http://google.com">Go to Google</a>';
$this->assertEquals($expected, $output);
$output = Html::anchor('javascript:do();', 'Do()');
$expected = '<a href="javascript:do();">Do()</a>';
$this->assertEquals($expected, $output);
$output = Html::anchor('http://google.com', 'Go to Google', array('rel' => 'example', 'class' => 'sample', 'style' => 'color:red;'));
$expected = '<a rel="example" class="sample" style="color:red;" href="http://google.com">Go to Google</a>';
$this->assertEquals($expected, $output);
// Internal uri
$output = Html::anchor('controller/method', 'Method');
$expected = '<a href="' . Uri::create('controller/method') . '">Method</a>';
$this->assertEquals($expected, $output);
// Get original values to reset once done
$index_file = Config::get('index_file');
$url_suffix = Config::get('url_suffix');
// Query string tests
Config::set('url_suffix', '');
Config::set('index_file', '');
$output = Html::anchor('search?q=query', 'Search');
$expected = '<a href="search?q=query">Search</a>';
$this->assertEquals($expected, $output);
Config::set('url_suffix', '.html');
$output = Html::anchor('search?q=query', 'Search');
$expected = '<a href="search.html?q=query">Search</a>';
$this->assertEquals($expected, $output);
// Reset to original values
Config::set('index_file', $index_file);
Config::set('url_suffix', $url_suffix);
}
示例8: get
/**
* Does reverse routing for a named route. This will return the FULL url
* (including the base url and index.php).
*
* WARNING: This is VERY limited at this point. Does not work if there is
* any regex in the route.
*
* Usage:
*
* <a href="<?php echo Router::get('foo'); ?>">Foo</a>
*
* @param string $name the name of the route
* @param array $named_params the array of named parameters
* @return string the full url for the named route
*/
public static function get($name, $named_params = array())
{
if (array_key_exists($name, static::$routes))
{
return \Uri::create(static::$routes[$name]->path, $named_params);
}
}
示例9: _send_instructions
/**
* Sends the instructions to a user's email address.
*
* @return bool
*/
private static function _send_instructions($name, Model_User $user)
{
$config_key = null;
switch ($name) {
case 'confirmation':
$config_key = 'confirmable';
break;
case 'reset_password':
$config_key = 'recoverable';
break;
case 'unlock':
$config_key = 'lockable';
break;
default:
throw new \InvalidArgumentException("Invalid instruction: {$name}");
}
$mail = \Email::forge();
$mail->from(\Config::get('email.defaults.from.email'), \Config::get('email.defaults.from.name'));
$mail->to($user->email);
$mail->subject(__("warden.mailer.subject.{$name}"));
$token_name = "{$name}_token";
$mail->html_body(\View::forge("warden/mailer/{$name}_instructions", array('username' => $user->username, 'uri' => \Uri::create(':url/:token', array('url' => rtrim(\Config::get("warden.{$config_key}.url"), '/'), 'token' => $user->{$token_name})))));
$mail->priority(\Email::P_HIGH);
try {
return $mail->send();
} catch (\EmailSendingFailedException $ex) {
logger(\Fuel::L_ERROR, "Warden\\Mailer failed to send {$name} instructions.");
return false;
}
}
示例10: action_openid_activate
public function action_openid_activate($activation_code = null)
{
$auth = Auth::instance();
$error = false;
if ($activation = Input::post('activation')) {
// Send the user off to openid provider
$auth->request_openid_credentials(Uri::create('auth/openid_activate') . '/' . $activation);
$error = true;
die('err, not supposed to see this' . $activation);
} elseif ($data = $auth->validate_openid_credentials()) {
// Try to activate the user
if ($auth->activate_user($activation_code, $data['email'], $data['identity'], $data['oauth_token'], $data['oauth_token_secret'])) {
// Login
if ($auth->login($data['identity'])) {
die('logged in!');
}
die('You\'re activated!');
} else {
var_dump($activation_code);
echo '<pre>';
print_r($data);
echo '</pre>';
die('failed activation');
}
}
// Show the form
$this->response->body = View::factory('auth/activation', array('error' => $error, 'activation' => Input::post('activation')));
}
示例11: url
/**
* Provides the url() functionality. Generates a full url (including
* domain and index.php).
*
* @param string URI to make a full URL for (or name of a named route)
* @param array Array of named params for named routes
* @return string
*/
public function url($uri = '', $named_params = array())
{
if ($named_uri = \Router::get($uri, $named_params)) {
$uri = $named_uri;
}
return \Uri::create($uri);
}
示例12: action_index
public function action_index()
{
// clear redirect referrer
\Session::delete('submitted_redirect');
// load language
\Lang::load('index');
// read flash message for display errors.
$form_status = \Session::get_flash('form_status');
if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
$output['form_status'] = $form_status['form_status'];
$output['form_status_message'] = $form_status['form_status_message'];
}
unset($form_status);
// get total accounts
$output['total_accounts'] = \Model_Accounts::count();
// <head> output ----------------------------------------------------------------------------------------------
$output['page_title'] = $this->generateTitle(\Lang::get('admin_administrator_dashbord'));
// <head> output ----------------------------------------------------------------------------------------------
// breadcrumb -------------------------------------------------------------------------------------------------
$page_breadcrumb = [];
$page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
$output['page_breadcrumb'] = $page_breadcrumb;
unset($page_breadcrumb);
// breadcrumb -------------------------------------------------------------------------------------------------
// the admin views or theme should follow this structure. (admin/templates/controller/method) and follow with _v in the end.
return $this->generatePage('admin/templates/index/index_v', $output, false);
}
示例13: action_login
public function action_login()
{
$url_redirect = \Uri::create('system/index/index');
if (\Auth::check()) {
\Response::redirect($url_redirect);
}
if (\Input::is_ajax()) {
$val = \Validation::forge('validate_login');
$val->add_field('email', 'Email', 'required|valid_email');
$val->add_field('password', 'Password', 'required');
if ($val->run(array())) {
if (\Auth::instance()->login(\Input::param('email'), \Input::param('password'))) {
if (\Input::param('remember', false)) {
\Auth::remember_me();
} else {
\Auth::dont_remember_me();
}
$response = array('status' => 'success', 'url' => $url_redirect);
} else {
$messages = \Auth::get_error();
$response = array('status' => 'error', 'msg' => $messages);
}
} else {
$messages = $val->error_message();
$response = array('status' => 'error', 'msg' => $messages);
}
return \Response::forge(json_encode($response));
}
$this->theme->set_template('login');
$this->theme->get_template()->set('content', \view::forge('default/login', $this->_arrParam));
}
示例14: include_client_scripts
protected function include_client_scripts($scripts = 'default')
{
if (empty($scripts)) {
return;
}
if (!is_array($scripts)) {
$scripts = array($scripts);
}
foreach ($scripts as $script) {
if (empty($this->client_scripts_included[$script])) {
switch ($script) {
case 'default':
$this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js");
$this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js");
$this->template->css[] = $this->create_css_link("//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css");
$this->template->css[] = $this->create_css_link(Uri::create('assets/css/style.css'));
break;
case 'jquery_forms':
$this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.js");
$this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/jquery.validate.min.js");
$this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.14.0/additional-methods.min.js");
$this->template->scripts[] = $this->create_js_link("//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js");
$this->template->scripts[] = $this->create_js_link(Uri::create('assets/js/jquery-forms-config.js'));
array_unshift($this->template->css, $this->create_css_link('//cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0/jquery.qtip.min.css'));
array_unshift($this->template->css, $this->create_css_link("//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css"));
break;
}
$this->client_scripts_included[$script] = true;
//don't include the same script more than once
}
}
}
示例15: set_twitter
protected function set_twitter($title = '', $tags = [], $url = '')
{
$title = empty($title) ? Config::get('twitter.title') : $title;
$tags = count($tags) == 0 ? Config::get('twitter.tags') : $tags;
$twitter = array('title' => $title, 'tags' => implode(',', $tags), 'url' => empty($url) ? Uri::create('/', [], [], false) : $url);
$this->template->set_global('twitter', $twitter);
}