本文整理汇总了PHP中URI类的典型用法代码示例。如果您正苦于以下问题:PHP URI类的具体用法?PHP URI怎么用?PHP URI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseURI
public static function parseURI($uri, $validate = false, $default = null)
{
// Return the URI if it's an URI instance already
if ($uri instanceof URI) {
return $uri;
}
// Parse the URI, and make sure it's valid
$parsed = parse_url($uri);
if ($parsed === false) {
return $default;
}
// Parse the user info
$userInfo = null;
if (isset($parsed['user']) || isset($parsed['pass'])) {
$userInfo = new URIUserInfo(@$parsed['user'], @$parsed['pass']);
}
// Parse the URI
$uri = new URI(@$parsed['scheme'], @$parsed['host'], @$parsed['port'], $userInfo, @$parsed['path'], @$parsed['query'], @$parsed['fragment']);
// Make sure the URI is valid
if ($validate) {
if (!$uri->isValid()) {
return $default;
}
}
// Return the parsed URI
return $uri;
}
示例2: login
/**
* Show invite only page if enabled
*/
public function login()
{
$uri = new URI();
// Redirect to invite page if not logged or signing in
if (!in_array($uri->string(), array('invite', 'sign/in')) && strpos($uri->string(), 'sign/up') !== 0 && !Visitor::instance()->logged_in()) {
// Stop execution if ajax, ie. expired session and trying to do ajax call
if (request::is_ajax()) {
exit;
}
url::redirect('invite');
}
}
示例3: action_index
/**
* Инлексная страница
*/
public function action_index()
{
// Если была отправлена форма фильтрации или сортировка
if (\Input::method() == 'POST') {
$category_id = (int) \Input::post('category_id');
if ($category_id > 0) {
\Session::set('filter_articles_category_id', $category_id);
} else {
\Session::set('filter_articles_category_id', null);
}
$title = trim(\Input::post('title'));
\Session::set('filter_articles_title', $title);
// Сортировка
\Session::set('admin_articles_order_by', \Input::post('order_by', 'id'));
\Session::set('admin_articles_order_method', \Input::post('order_method', 'desc'));
}
// Запрос на извлечение кол-ва статей
$count = \Model_Article::get_articles_count(\Session::get('filter_articles_title'), \Session::get('filter_articles_category_id'));
// Пагинация
$config = array('pagination_url' => \URI::create('admin/articles/index'), 'total_items' => $count, 'per_page' => 15, 'uri_segment' => 4);
$pagination = \Pagination::forge('articles_pagination', $config);
$data['pagination'] = $pagination->render();
// Передаём в представление данные пагинации (для нумерации статей)
$data['current_page'] = is_null($pagination->current_page) ? 1 : $pagination->current_page;
$data['per_page'] = $pagination->per_page;
// Получение статей
$data['articles'] = \Model_Article::get_articles(\Session::get('filter_articles_title'), \Session::get('filter_articles_category_id'), $pagination->per_page, $pagination->offset, \Session::get('admin_articles_order_by', 'id'), \Session::get('admin_articles_order_method', 'desc'));
// Категории статей
$data['categories'] = \Model_Category::get_categories_for_select();
$this->template->title = "Статьи";
$this->template->content = \View::forge('articles/index', $data, false);
}
示例4: __construct
public function __construct()
{
parent::__construct();
$this->breadcrumb->add('Bewertungen', URI::build('airlines/admin/evals'));
$this->breadcrumb->add('Kategorien', URI::build('airlines/admin/categories'));
$this->breadcrumb->add('Felder', URI::build('airlines/admin/cfields'));
}
示例5: prepare_connection
/**
* Hook to prepare the database connection. Performs 2 tasks.
* 1) Initialises the search path, unless configured not to do this (e.g. if this is set at db level).
* 2) If this is a report request, sets the connection to read only.
*/
public static function prepare_connection()
{
$uri = URI::instance();
// we havent to proceed futher if a setup call was made
if ($uri->segment(1) == 'setup_check') {
return;
}
// continue to init the system
//
// add schema to the search path
//
$_schema = Kohana::config('database.default.schema');
$query = '';
if (!empty($_schema) && kohana::config('indicia.apply_schema') !== false) {
$query = "SET search_path TO {$_schema}, public, pg_catalog;\n";
}
// Force a read only connection for reporting.
if ($uri->segment(1) == 'services' && $uri->segment(2) == 'report') {
$query .= "SET default_transaction_read_only TO true;\n";
}
if (!empty($query)) {
$db = Database::instance();
$db->query($query);
}
}
示例6: cache_file
static function cache_file($f)
{
$css_file = Misc::key('css', $f) . '.css';
$cache_file = Cache::cache_filename($css_file);
$cache_path = ROOT_PATH . PUBLIC_BASE . $cache_file;
$version = (int) Config::get('page.css_version');
if (Config::get('debug.css_check_cache')) {
if (file_exists($cache_path)) {
$files = array_unique(explode(' ', $f));
$mtime = 0;
foreach ($files as $file) {
$file = trim($file);
list($category, $file) = explode(':', $file, 2);
if (!$file) {
$file = $category;
$category = NULL;
}
if (!$file) {
continue;
}
$path = Core::file_exists(PRIVATE_BASE . 'css/' . $file . '.css', $category);
if ($path) {
$mtime = max($mtime, filemtime($path));
}
}
if ($mtime <= filemtime($cache_path)) {
return $cache_file . '?v=' . $version;
}
}
} elseif (file_exists($cache_path)) {
return $cache_file . '?v=' . $version;
}
return URI::url('css', array('f' => $f, 'v' => $version));
}
示例7: __toString
public function __toString()
{
/**
* poa = product options atributes
*/
// echo Kohana::debug(@$_POST);
$opa = new fpp_product_has_attributes_product_Model();
$orm = $opa->db2cls();
$uri = URI::Instance();
$id = (int) $uri->segment("edit");
if (request::method() == 'post' and is_array(@$_POST['opt'])) {
$orm->delete(array('product_id_product' => $id));
foreach ($_POST['opt'] as $key => $value) {
$orm = $opa->db2cls();
$data['product_id_product'] = $id;
// $data['ap_id_attributes_product'] = @$_POST['atr'][$key];
$data['prefix'] = @$_POST['prefix'][$key];
$data['vap_id_values_atributtes_product'] = @$_POST['opt'][$key];
$data['value'] = @$_POST['val'][$key];
$data['extra'] = @$_POST['extra'][$key];
$orm->set_fields($data);
$orm->save();
}
}
$results = $this->GetAttr($id);
// fetch_where(array('product_id_product'=> ) );
$atr_p = new fpp_attributes_product_Model();
$orm_atrp = $atr_p->db2cls();
$attributes = form::dropdown("poa_id", $orm_atrp->select_list('id_attributes_product', 'name_attributes_product'));
$string = View::factory("extras/ajaxattributes")->set("attributes", $attributes)->set("results", $results)->render();
return $string;
}
示例8: get_list
function get_list($gid)
{
$data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role());
Event::run('steamcore.aclcheck', $data);
// which model are we using? one passed through or the default?
$model = steamcore::get_controls_model($this->gallery);
$controller = URI::segment(1);
$tdata = array();
$page = Input::instance()->get('page', 0);
$num = 18;
$offset = 0;
$limit = 18;
if ($page) {
$offset = $num * $page - $num;
}
$where = array();
if (isset($gid) and is_numeric($gid)) {
$where = array('galleries_id' => $gid);
}
// query the model
$data['query'] = $model->where($where)->limit($limit, $offset)->find_all();
$data['controller'] = $controller;
$total = $model->count_last_query();
$data['pagination'] = '';
if ($total > $num) {
$data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $num, 'query_string' => 'page', 'total_items' => $total));
}
// merge any passed data and the data returned from the model
$tdata = array_merge($tdata, $data);
// return the result
return $tdata;
}
示例9: sendEmail
private function sendEmail($xml)
{
try {
$emailConf = Config::get('email');
$mail = new PHPMailer();
$mail->isSMTP();
$mail->CharSet = $emailConf['charset'];
$mail->Host = $emailConf['host'];
$mail->SMTPAuth = $emailConf['auth'];
$mail->Username = $emailConf['username'];
$mail->Password = $emailConf['password'];
$mail->Port = $emailConf['port'];
$mail->From = $emailConf['from'];
$mail->FromName = $emailConf['from_name'];
$mail->Subject = 'Falha na integração';
$mail->Body = "Ocorreu erro na integração de dados com Vtex." . "\r\n" . "\r\n";
$mail->Body .= "Ambiente: " . (Config::get('development') === true ? 'Desenvolvimento' : 'Produção') . "\r\n" . "\r\n";
$mail->Body .= "URL Segments: " . json_encode(URI::get_segments()) . "\r\n" . "\r\n";
$mail->Body .= "POST: " . print_r($_POST, true) . "\r\n" . "\r\n";
$mail->Body .= "Response Header: " . self::$responseHeader . "\r\n" . "\r\n";
$mail->Body .= 'Saída do script: ' . $xml;
$mail->addAddress($emailConf['address']);
$mail->isHTML(false);
$mail->send();
return true;
} catch (Exception $e) {
return false;
}
}
示例10: extractPage
public function extractPage($pageID, $pageTitle, $pageSource)
{
$result = new ExtractionResult($pageID, $this->language, $this->getExtractorID());
$category = Util::getMediaWikiNamespace($this->language, MW_CATEGORY_NAMESPACE);
if (preg_match_all("/" . $category . ":(.*)/", $pageID, $match)) {
$result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_PREFLABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language));
$result->addTriple($this->getPageURI(), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(SKOS_CONCEPT, false));
if (preg_match_all("/\\[\\[" . $category . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// split on | sign
if (strpos($match[1], '|') === false) {
$object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($match[1]);
} else {
$split = explode('|', $match[1]);
$object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($split[0]);
}
try {
$object = RDFtriple::URI($object);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
continue;
}
$result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_BROADER, false), $object);
}
}
}
return $result;
}
示例11: __construct
/**
* Loads URI, and Input into this controller.
*
* @return void
*/
public function __construct()
{
if (Kohana::$instance == NULL) {
// Set the instance to the first controller loaded
Kohana::$instance = $this;
}
// URI should always be available
$this->uri = URI::instance();
// Input should always be available
$this->input = Input::instance();
$this->db = new Database();
$this->user_model = ORM::factory('user');
$this->supplier_model = ORM::factory('supplier');
$this->category_model = ORM::factory('category');
$this->item_model = ORM::factory('item');
$this->item_stock_model = ORM::factory('item_stock');
$this->district_model = ORM::factory('district');
$this->office_model = ORM::factory('office');
$this->budget_model = ORM::factory('office_budget');
$this->purchase_model = ORM::factory('purchase');
$this->request_model = ORM::factory('request');
$this->transaction_model = ORM::factory('transaction');
$this->setting_model = ORM::factory('setting');
$this->log_model = ORM::factory('log');
$this->email_model = ORM::factory('email');
}
示例12: post_pricing_view
public function post_pricing_view()
{
$price = QuotationPriceAdjustments::find(URI::Segment(4));
$update_layout = array('friendly_name' => trim(Input::get('friendly_name')), 'note' => trim(Input::get('note')));
$price->update($price->id, $update_layout);
return Redirect::to('/user/quotations/pricing_view/' . $price->id)->with('success', 'Update successfull');
}
示例13: extractPage
public function extractPage($pageID, $pageTitle, $pageSource)
{
$result = new ExtractionResult($pageID, $this->language, $this->getExtractorID());
$image_ar = $this->extract_image_url($pageSource);
$image = ucfirst($image_ar[0]);
$width = $image_ar[1];
if ($image == null) {
return $result;
}
$ImageURL = $this->make_image_url($image, false, true);
$ImageURLSmall = $this->make_image_url($image, $width);
$image = str_replace(" ", "_", trim($image));
if (!URI::validate($ImageURL) || !URI::validate($ImageURLSmall)) {
return $result;
}
// Add fullsize image
$result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(FOAF_DEPICTION), RDFtriple::URI($ImageURL));
// Add depiction has thumbnail
$result->addTriple(RDFtriple::URI($ImageURL), RDFtriple::URI(FOAF_THUMBNAIL), RDFtriple::URI($ImageURLSmall));
// Add object has thumbnail
$result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(DBO_THUMBNAIL), RDFtriple::URI($ImageURLSmall));
// add triples linking back to the Wikipedia image description
$image = urlencode($image);
$wikipediaImageDescription = 'http://' . $this->language . '.wikipedia.org/wiki/Image:' . $image;
$result->addTriple(RDFtriple::URI($ImageURLSmall), RDFtriple::URI(DC_RIGHTS), RDFtriple::URI($wikipediaImageDescription));
$result->addTriple(RDFtriple::URI($ImageURL), RDFtriple::URI(DC_RIGHTS), RDFtriple::URI($wikipediaImageDescription));
return $result;
}
示例14: main
public function main()
{
$page = Request::get(0, VAR_URI);
if (preg_match('/^(\\d+)-/', $page, $matches) > 0 && !empty($matches[1])) {
$airlineData = new CustomData($this->airlinePage->getPosition());
if ($airlineData->load($matches[1])) {
$uri = AirlineTools::buildUri($airlineData->getId(), $airlineData->getData('name'), true);
$this->flightPage->setBaseUri($uri);
$this->breadcrumb->add($airlineData->getData('name'), URI::build($uri));
$flight = Request::get(1, VAR_INT);
if (is_id($flight)) {
$this->flight($flight);
} else {
$this->airline($matches[1]);
}
} else {
$this->header();
$this->notFoundError();
$this->footer();
}
} else {
$this->header();
$this->airlinePage->overview('/Airlines/categories');
$this->footer();
}
}
示例15: load
public static function load($group, $save = true)
{
$paths = array();
$paths[] = J_PATH . "config" . DS . $group . EXT;
$paths[] = J_PATH . "config" . DS . strtolower(Request::env()) . DS . $group . EXT;
if (URI::isManager()) {
$paths[] = J_MANAGERPATH . DS . "config" . DS . $group . EXT;
$paths[] = J_MANAGERPATH . DS . "config" . DS . strtolower(Request::env()) . DS . $group . EXT;
} else {
$paths[] = J_APPPATH . "config" . DS . $group . EXT;
$paths[] = J_APPPATH . "config" . DS . strtolower(Request::env()) . DS . $group . EXT;
}
$items = array();
foreach ($paths as $path) {
if (file_exists($path)) {
$result = (require $path);
if (is_array($result)) {
$items = array_merge($items, $result);
}
}
}
if (count($items) > 0) {
if ($save) {
static::$items[$group] = $items;
}
return $items;
}
}