本文整理汇总了PHP中URL::query方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::query方法的具体用法?PHP URL::query怎么用?PHP URL::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute($method, $url, array $post = array())
{
$redirects_count = 1;
\Request::$initial = NULL;
$this->_request = \Request::factory($url)->method($method)->post($post)->body(http_build_query($post));
if ($this->_previous_url) {
$this->_request->referrer($this->_previous_url);
}
$this->_previous_url = $this->current_url() . \URL::query($this->_request->query(), FALSE);
\Request::$initial = $this->_request;
$this->_response = $this->_request->execute();
while ($this->_response->status() >= 300 and $this->_response->status() < 400) {
$redirects_count++;
if ($redirects_count >= $this->max_redirects()) {
throw new Exception_Toomanyredirects('Maximum Number of redirects (5) for url :url', array(':url' => $url));
}
$url_parts = parse_url($this->_response->headers('location'));
$query = isset($url_parts['query']) ? $url_parts['query'] : '';
parse_str($query, $query);
$_GET = $query;
$url = $url_parts['path'];
\Request::$initial = NULL;
$this->_request = \Request::factory($url);
\Request::$initial = $this->_request;
$this->_response = $this->_request->execute();
}
return $this->_response->body();
}
示例2: action_index
public function action_index($options = array("max" => 10, "current" => 1, "count" => 5))
{
$model = array();
$pages = array();
$max_page = $options["max"];
// Максимальное количество страниц
$current_page = $options["current"];
// Текущая страница
$pages_length = $options["count"];
// Количество номеров страниц (нечётное число)
$next_prev_pages = floor($pages_length / 2);
// Количество доп. страниц
$pages[] = array("href" => "#", "active" => "active", "num" => $current_page);
// Создание доп. страниц
for ($i = 1; $i <= $next_prev_pages; $i++) {
if ($current_page - $i > 1) {
array_unshift($pages, array("href" => URL::query(array("page" => $current_page - $i)), "num" => $current_page - $i));
}
if ($current_page + $i < $max_page) {
array_push($pages, array("href" => URL::query(array("page" => $current_page + $i)), "num" => $current_page + $i));
}
}
if ($current_page > 1) {
$model["min_page"] = array("num" => 1, "href" => URL::query(array("page" => 1)));
$model["prev_href"] = URL::query(array("page" => $current_page - 1));
}
if ($current_page < $max_page) {
$model["max_page"] = array("num" => $max_page, "href" => URL::query(array("page" => $max_page)));
$model["next_href"] = URL::query(array("page" => $current_page + 1));
}
$model["pages"] = $pages;
$this->set_template("/widgets/twig_pagination.php", "twig")->render($model)->body();
}
示例3: action_login
public function action_login()
{
if ($this->_auth->logged_in()) {
// redirect to the user account
$this->request->redirect(Route::get('admin')->uri(), 200);
}
// Disable sidebars on login page
$this->_sidebars = FALSE;
$this->title = __('Sign In');
$user = ORM::factory('user');
// Create form action
$destination = isset($_GET['destination']) ? $_GET['destination'] : 'admin';
$params = array('action' => 'login');
$action = Route::get('admin/login')->uri($params) . URL::query(array('destination' => $destination));
if ($layout = kohana::find_file('views', 'layouts/login')) {
$this->template->set_filename('layouts/login');
}
$view = View::factory('admin/login')->set('use_username', Config::get('auth.username'))->set('post', $user)->set('action', $action)->bind('errors', $this->_errors);
if ($this->valid_post('login')) {
try {
// Check Auth
$user->login($this->request->post());
// If the post data validates using the rules setup in the user model
Message::success(__('Welcome, %title!', array('%title' => $user->nick)));
Log::info('User :name logged in.', array(':name' => $user->name));
// redirect to the user account
$this->request->redirect(isset($_GET['destination']) ? $_GET['destination'] : 'admin', 200);
} catch (Validation_Exception $e) {
$this->_errors = $e->array->errors('login', TRUE);
}
}
$this->response->body($view);
}
示例4: action_post
/**
*
* @param Datasource_Section $ds
* @param Datasource_Document $doc
*/
public function action_post()
{
$id = (int) $this->request->post('id');
$doc = $this->_get_document($id);
Session::instance()->set('post_data', $this->request->post());
try {
$doc->read_values($this->request->post())->read_files($_FILES)->validate();
} catch (Validation_Exception $e) {
Messages::errors($e->errors('validation'));
$this->go_back();
} catch (DataSource_Exception_Document $e) {
Messages::errors($e->getMessage());
$this->go_back();
}
if ($doc->loaded()) {
$this->section()->update_document($doc);
} else {
$doc = $this->section()->create_document($doc);
}
Messages::success(__('Document saved'));
Session::instance()->delete('post_data');
// save and quit or save and continue editing?
if ($this->request->post('commit') !== NULL) {
$this->go(Route::get('datasources')->uri(array('directory' => 'datasources', 'controller' => 'data')) . URL::query(array('ds_id' => $this->section()->id()), FALSE));
} else {
$this->go(Route::get('datasources')->uri(array('directory' => $this->section()->type(), 'controller' => 'document', 'action' => 'view')) . URL::query(array('ds_id' => $this->section()->id(), 'id' => $doc->id), FALSE));
}
}
示例5: action_delete
public function action_delete()
{
$id = (int) $this->request->param('id', 0);
$comment = ORM::factory('comment', $id)->access('delete');
$this->title = __('Are you absolutely sure?');
$destination = empty($this->redirect) ? array() : array('destination' => $this->redirect);
$post = $this->request->post();
$route = Route::get('comment')->uri(array('action' => 'view', 'id' => $comment->id));
$view = View::factory('form/confirm')->set('action', Route::get('comment')->uri(array('action' => 'delete', 'id' => $comment->id)) . URL::query($destination))->set('title', $comment->title);
// If deletion is not desired, redirect to post
if (isset($post['no']) and $this->valid_post()) {
$this->request->redirect(empty($this->redirect) ? $route : $this->redirect);
}
// If deletion is confirmed
if (isset($post['yes']) and $this->valid_post()) {
$redirect = $comment->post->url;
$title = $comment->title;
try {
$comment->delete();
Log::info('Comment: :title deleted.', array(':title' => $title));
Message::success(__('Comment %title deleted successful!', array('%title' => $title)));
} catch (Exception $e) {
Log::error('Error occurred deleting comment id: :id, :msg', array(':id' => $comment->id, ':msg' => $e->getMessage()));
Message::error('An error occurred deleting comment %post.', array('%post' => $title));
$this->_errors = array('An error occurred deleting comment %post.', array('%post' => $title));
}
$redirect = empty($destination) ? $redirect : $this->redirect;
$this->request->redirect($redirect);
}
$this->response->body($view);
}
示例6: action_index
public function action_index($supplychain_id)
{
if (!is_numeric($supplychain_id)) {
$supplychain_id = $this->_match_alias($supplychain_id);
}
$supplychain = ORM::factory('supplychain', $supplychain_id);
$sc = $supplychain->kitchen_sink($supplychain_id);
if ($supplychain->loaded()) {
$current_user_id = Auth::instance()->logged_in() ? (int) Auth::instance()->get_user()->id : 0;
$owner_id = (int) $supplychain->user_id;
if ($supplychain->user_can($current_user_id, Sourcemap::READ)) {
$this->layout->supplychain_id = $supplychain_id;
// pass supplychain metadeta to template
$this->template->supplychain_id = $supplychain_id;
$this->template->supplychain_date = date('F j, Y', $sc->created);
$this->template->supplychain_name = isset($sc->attributes->name) ? $sc->attributes->name : "";
$this->template->supplychain_owner = isset($sc->owner->name) ? $sc->owner->name : "";
$this->template->supplychain_ownerid = isset($sc->owner->id) ? $sc->owner->id : "";
$this->template->supplychain_avatar = isset($sc->owner->avatar) ? $sc->owner->avatar : "";
$this->template->supplychain_desc = isset($sc->attributes->description) ? $sc->attributes->description : "";
$this->layout->scripts = array('blog-view');
$this->layout->styles = array('sites/default/assets/styles/reset.css', 'assets/styles/base.less', 'assets/styles/general.less');
// qrcode url
$qrcode_query = URL::query(array('q' => URL::site('view/' . $supplychain->id, true), 'sz' => 8));
$this->template->qrcode_url = URL::site('services/qrencode', true) . $qrcode_query;
} else {
Message::instance()->set('That map is private.');
$this->request->redirect('browse');
}
} else {
Message::instance()->set('That map could not be found.');
$this->request->redirect('browse');
}
}
示例7: th
/**
* Render a sortable <th> tag based on current request
*
* @param string $column
* @param string $name
* @param string|array $attributes
* @return string
*/
public static function th($column, $name, $attributes = null)
{
static $_query;
// Only get one per request
if ($_query === null) {
$_query = Request::current()->query();
// Default
$_query['sort'] = isset($_query['sort']) ? strtolower($_query['sort']) : 'id';
$_query['order'] = isset($_query['order']) ? strtolower($_query['order']) : 'desc';
}
// Attributes
if (!is_array($attributes)) {
$attributes = array('class' => $attributes);
}
// Init
$class = 'sorting';
$order = 'asc';
// This column is selected
if ($column == $_query['sort']) {
$class .= '_' . $_query['order'];
$order = $_query['order'] == 'asc' ? 'desc' : 'asc';
}
// Add class to element
$attributes['class'] = trim($class . ' ' . $attributes['class'], ' ');
// Build URL query
$url = URL::query(array('sort' => $column, 'order' => $order));
// Return HTML
return strtr('<th:attrs><a href=":url">:name</a></th>', array(':attrs' => HTML::attributes($attributes), ':url' => $url, ':name' => $name));
}
示例8: uri
/**
*
* @param string $action
* @param integer|string $ds_id
* @return string
*/
public static function uri($action = 'view', $ds_id = NULL)
{
if ($action == 'view') {
$uri = Route::get('datasources')->uri(array('controller' => 'data', 'directory' => 'datasources'));
return $ds_id !== NULL ? $uri . URL::query(array('ds_id' => (int) $ds_id)) : $uri;
}
return Route::get('datasources')->uri(array('controller' => 'section', 'directory' => 'datasources', 'action' => $action, 'id' => $ds_id));
}
示例9: action_code
public function action_code()
{
$query = URL::query();
$template = new View('oauth');
$view = new View('oauth-server-authorize', array('authorized' => TRUE, 'query' => $query));
$template->content = $view->render();
$this->request->response = $template;
}
示例10: url
public function url($page = 1)
{
$page = max(1, (int) $page);
if (isset($this->config['source']) && $this->config['source'] == 'route') {
return URL::site(Request::instance()->uri(array($this->config['current_page_key'] => $page))) . URL::query();
} else {
return URL::site(Request::instance()->uri()) . URL::query(array($this->config['current_page_key'] => $page));
}
}
示例11: add_section_to_menu
/**
* Добавление раздела в меню Backend
*
* @param Datasource_Section $section
* @param Model_Navigation_Section $parent_section
* return Model_Navigation_Section;
*/
public static function add_section_to_menu(Datasource_Section $section, Model_Navigation_Section $parent_section = NULL)
{
if ($parent_section === NULL) {
$parent_section = Model_Navigation::get_root_section();
}
if (!$section->has_access_view()) {
return $parent_section;
}
return $parent_section->add_page(new Model_Navigation_Page(array('name' => $section->name, 'url' => Route::get('datasources')->uri(array('controller' => 'data', 'directory' => 'datasources')) . URL::query(array('ds_id' => $section->id())), 'icon' => $section->icon(), 'permissions' => 'ds_id.' . $section->id() . '.section.view')), 999);
}
示例12: save_referer
/**
* Save referer to session
* @param string $name
* @param bool $referer
*/
protected function save_referer($name, $referer = true)
{
if ($referer === true) {
$referer = $this->request->uri();
} else {
$referer = (string) $referer;
}
$referer = URL::base() . $referer . URL::query();
$this->session->set($name, $referer);
}
示例13: next
public function next()
{
return Tart::html($this, function ($h, $self) {
if ($self->offset() < $self->total() - $self->per_page()) {
$h->anchor(Tart::uri($self->controller()) . URL::query(array('offset' => $self->offset() + $self->per_page())), __('Next »'));
} else {
$h('span', __('Next »'));
}
});
}
示例14: action_index
public function action_index()
{
// todo: try/catch OAuthClientException
$server = service('oauth.server.auth');
$params = $server->getGrantType('authorization_code')->checkAuthoriseParams();
$this->session->set('oauth', $params);
if (!$this->user) {
$this->redirect('user/login' . URL::query(array('from_url' => 'oauth/authorize' . URL::query()), FALSE));
}
$this->redirect('oauth/authorize' . URL::query(Arr::extract($params, $this->oauth_params)));
}
示例15: fetch_headline_value
public function fetch_headline_value($value, $document_id)
{
if (empty($value)) {
return parent::fetch_headline_value($value, $document_id);
}
$header = DataSource_Hybrid_Field_Utils::get_document_header($this->from_ds, $value);
if (!empty($header)) {
return HTML::anchor(Route::get('datasources')->uri(array('directory' => 'hybrid', 'controller' => 'document', 'action' => 'view')) . URL::query(array('ds_id' => $this->from_ds, 'id' => $value), FALSE), $header, array('class' => ' popup fancybox.iframe'));
}
return parent::fetch_headline_value($value, $document_id);
}