本文整理汇总了PHP中uri类的典型用法代码示例。如果您正苦于以下问题:PHP uri类的具体用法?PHP uri怎么用?PHP uri使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了uri类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rel
public function rel($relativeUri)
{
$relativeUri = $relativeUri instanceof uri ? $relativeUri : uri::fromString(strval($relativeUri));
$rel = new uri();
$rel->setPath(array_merge($this->_uri->getPath(), $relativeUri->getPath()));
return $rel;
}
示例2: _fetch
function & _fetch(&$counter, $params)
{
$result =& parent :: _fetch($counter, $params);
$uri = new uri($_SERVER['PHP_SELF']);
foreach($result as $key => $data)
{
$nav_uri = new uri($data['url']);
if ($uri->get_host() != $nav_uri->get_host())
continue;
if(is_integer($res = $uri->compare_path($nav_uri)))
{
if($res >= 0)
{
$result[$key]['in_path'] = true;
$params['path'] = $data['path'];
$result[$key]['items'] = $this->_fetch(&$counter, $params);
}
if($res == 0)
$result[$key]['selected'] = true;
}
}
return $result;
}
示例3: _fetch
function & _fetch(&$counter, $params)
{
$result =& parent :: _fetch($counter, $params);
$uri = new uri($_SERVER['PHP_SELF']);
//we're trimming trailing slashes: thus /root/about == /root/about/
$uri->set_path(rtrim($uri->get_path(), '/'));
foreach($result as $key => $data)
{
$nav_uri = new uri($data['url']);
$nav_uri->set_path(rtrim($nav_uri->get_path(), '/'));
if ($uri->get_host() != $nav_uri->get_host())
continue;
if(is_integer($res = $uri->compare_path($nav_uri)))
{
if($res >= 0)
$result[$key]['in_path'] = true;
if($res == 0)
$result[$key]['selected'] = true;
}
}
return $result;
}
示例4: _compare_with_url
function _compare_with_url($url)
{
$uri = new uri($_SERVER['PHP_SELF']);
//we're trimming trailing slashes: thus /root/about == /root/about/
$uri->set_path(rtrim($uri->get_path(), '/'));
$nav_uri = new uri($url);
$nav_uri->set_path(rtrim($nav_uri->get_path(), '/'));
if ($uri->get_host() != $nav_uri->get_host()) {
return false;
}
return $uri->compare_path($nav_uri);
}
示例5: render
public function render()
{
if (!$this->links) {
throw new Kohana_User_Exception("Navbar not implemented correctly", "Links have not been set. Please call <code>$navbar->set_links({$links})</code>");
} else {
if ($this->view) {
return $this->render_to_view($this->view);
} else {
$html = "";
$i = 0;
foreach ($this->links as $link) {
$class = "";
if (str_replace("site", "", url::current()) == $link->seoURL || url::current() == $link->seoURL || uri::segment(1) == $link->seoURL) {
$class .= "selected";
}
if ($i == 0) {
$class .= " first";
}
if ($i == count($this->links) - 1) {
$class .= " last";
}
$html .= '<li class="' . $class . '" id="menu0' . ($i + 1) . '"><a href="' . url::site() . $link->seoURL . '" class="' . $class . '">' . $link->title . '</a></li>';
$i++;
}
# $html .= "</ul>";
return $html;
}
}
}
示例6: __construct
public function __construct()
{
parent::__construct();
if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') {
router::redirect('news/' . utf8::substr(uri::getURI(), 5));
}
}
示例7: delete
public function delete()
{
// Get URI vars
$slugID = urldecode(utf8::trim(uri::segment(4)));
// Do we have a slug ID?
if ($slugID == '') {
error::show404();
}
// Get user
if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) {
error::show404();
} elseif ($user['user_id'] == session::item('user_id')) {
router::redirect($user['slug']);
}
// Does user exist?
if (!($blocked = $this->users_blocked_model->getUser($user['user_id'], true))) {
view::setError(__('no_blocked_user', 'users_blocked'));
router::redirect('users/blocked');
}
// Delete blocked user
$this->users_blocked_model->deleteBlockedUser(session::item('user_id'), $user['user_id']);
// Success
view::setInfo(__('user_unblocked', 'users_blocked'));
router::redirect(input::get('page') ? 'users/blocked' : $user['slug']);
}
示例8: view
public function view()
{
// Get URI vars
$newsID = (int) uri::segment(3);
// Get news entry
if (!$newsID || !($news = $this->news_model->getEntry($newsID, 'in_view')) || !$news['active']) {
error::show404();
}
// Do we have views enabled?
if (config::item('news_views', 'news')) {
// Update views counter
$this->news_model->updateViews($newsID);
}
// Load ratings
if (config::item('news_rating', 'news') == 'stars') {
// Load votes model
loader::model('comments/votes');
// Get votes
$news['user_vote'] = $this->votes_model->getVote('news', $newsID);
} elseif (config::item('news_rating', 'news') == 'likes') {
// Load likes model
loader::model('comments/likes');
// Get likes
$news['user_vote'] = $this->likes_model->getLike('news', $newsID);
}
// Assign vars
view::assign(array('newsID' => $newsID, 'news' => $news));
// Set title
view::setTitle($news['data_title']);
// Set meta tags
view::setMetaDescription($news['data_meta_description']);
view::setMetaKeywords($news['data_meta_keywords']);
// Load view
view::load('news/view');
}
示例9: uri
function &_fetch(&$counter, $params)
{
$result =& parent::_fetch($counter, $params);
$uri = new uri($_SERVER['PHP_SELF']);
foreach ($result as $key => $data) {
if (is_integer($res = $uri->compare_path(new uri($data['url'])))) {
if ($res >= 0) {
$result[$key]['in_path'] = true;
}
if ($res == 0) {
$result[$key]['selected'] = true;
}
}
}
return $result;
}
示例10: render_summary
/**
* Returns the formatted html
*
* html example
* e.g <h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer"> </div>
*
* @param array $options Options for the rendering array('count', 'date_format','image' = array($width,$height), 'word_count', 'html')
* @return string $html Formatted HTML
*/
public function render_summary($options = null, $feedpost_options = null)
{
$array = array('per_page' => 5, 'pagination' => 'classic', 'template' => 'feed', 'html' => '{FEEDPOSTS}{PAGINATION}');
if (!$options) {
$config = Kohana::config_load('zest');
$options = $config['feed.summary'];
}
$array = arr::overwrite($array, $options);
$uri = uri::instance();
$page = $uri->segment('page', 1);
$feedposts = "";
$posts = $this->get_posts($array['per_page'], ($page - 1) * $array['per_page']);
foreach ($posts as $post) {
$feedposts .= $post->render_summary($feedpost_options);
}
$pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => count($this->get_posts()), 'items_per_page' => $array['per_page'], 'style' => $array['pagination']));
if ($array['template'] != '') {
$html = zest::template_to_html('snippets/' . $array['template']);
} else {
$html = $array['html'];
}
$html = str_replace("{RSS_LINK}", $this->get_rss(), $html);
$html = str_replace("{FEEDPOSTS}", $feedposts, $html);
$html = str_replace("{PAGINATION}", $pagination, $html);
$html = str_replace("{FEED_LINK}", $this->get_url(), $html);
return $html;
}
示例11: uri
function &_fetch(&$counter, $params)
{
$result =& parent::_fetch($counter, $params);
$requested_uri = new uri($_SERVER['REQUEST_URI']);
$nav_uri = new uri();
foreach ($result as $key => $data) {
$nav_uri->parse($data['url']);
if ($requested_uri->compare_path($nav_uri) === 0) {
$result[$key]['selected'] = true;
if ($nav_uri->get_query_item('action') !== $requested_uri->get_query_item('action')) {
$result[$key]['selected'] = false;
}
}
}
return $result;
}
示例12: uri
function &_fetch(&$counter, $params)
{
$result =& parent::_fetch($counter, $params);
$uri = new uri($_SERVER['PHP_SELF']);
foreach ($result as $key => $data) {
if ($uri->compare($data['url'], $url_rest, $query_match)) {
if ($url_rest >= 0) {
$result[$key]['in_path'] = true;
}
if ($url_rest == 0) {
$result[$key]['selected'] = true;
}
}
}
return $result;
}
示例13: delete
public function delete()
{
// Get URI vars
$fieldID = (int) uri::segment(7);
// Delete custom field
$this->deleteField('pages', 'pages_data', 0, $fieldID);
}
示例14: delete
public function delete()
{
// Get URI vars
$typeID = (int) uri::segment(6);
$fieldID = (int) uri::segment(7);
$typeID = $typeID == 0 || $typeID == 1 ? $typeID : 0;
// Delete custom field
$this->deleteField('pictures', 'pictures_' . ($typeID == 1 ? 'albums_' : '') . 'data', $typeID, $fieldID);
}
示例15: click
public function click()
{
$bannerID = (int) uri::segment(3);
if ($bannerID && $bannerID > 0) {
loader::model('banners/banners');
$this->banners_model->updateClicks($bannerID);
}
exit;
}