Skip to content

Instantly share code, notes, and snippets.

@reg2005
Last active December 16, 2015 03:29
Show Gist options
  • Save reg2005/5370069 to your computer and use it in GitHub Desktop.
Save reg2005/5370069 to your computer and use it in GitHub Desktop.
This extension library 'URI' to Codeigniter, http://habrahabr.ru/post/42172/ Allows you to take off GET parameters after the '?' Is used when redirecting. russian: Это расширение библиотеки URI для COdeigniter, взято мной тут http://habrahabr.ru/post/42172/ Позволяет при выключенном GET принимать параметры после ?, использую при редиректе.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
/* Автор: t1myrkq http://habrahabr.ru/users/t1myrkq/
* Это расширение библиотеки URI для COdeigniter, взято мной тут http://habrahabr.ru/post/42172/
* Очень полезная вещь, если делать поиск POST запросом, формировать 301 redirect с адресом: ЧПУ+переменные на хвосте через знак вопроса (как у Get)
* Позволяет оставить '$config['enable_query_strings'] = FALSE;'. и принимать GET запросы командой $current_page = $this->uri->getParam(‘page’);
* где url /catalog/produnction/?page=2
* Почему не воспользоваться обычным GET? - потому-что при использовании редиректа в начало попадает знак вопроса и портит внешний вид ссылки
* Евгений Рюмин - beatlelab@gamil.com
* 12.04.2013
*/
class MY_URI extends CI_URI {
var $_get_params = array();
function _fetch_uri_string() {
parse_str($_SERVER['QUERY_STRING'], $this->_get_params);
$_GET = array();
$_SERVER['QUERY_STRING'] = '';
parent::_fetch_uri_string();
}
function getParam($key) {
if (isset($this->_get_params[$key])) {
return $this->_get_params[$key];
} else {
return false;
}
}
function getParams() {
return $this->_get_params;
}
}
/*
* end
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment