當前位置: 首頁>>代碼示例>>PHP>>正文


PHP uri::instance方法代碼示例

本文整理匯總了PHP中uri::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP uri::instance方法的具體用法?PHP uri::instance怎麽用?PHP uri::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在uri的用法示例。


在下文中一共展示了uri::instance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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">&nbsp;</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;
 }
開發者ID:sydlawrence,項目名稱:SocialFeed,代碼行數:36,代碼來源:feed.php

示例2: get_by_url

 public static function get_by_url()
 {
     static $instance;
     if (empty($instance)) {
         $uri = uri::instance();
         $page = $uri->segment(1);
         $page = ORM::factory('page')->where(array('seoURL' => $page, 'status_id' => 2))->find();
         if ($page->id > 0) {
             $instance = $page;
         } else {
             $instance = null;
         }
     }
     return $instance;
 }
開發者ID:sydlawrence,項目名稱:SocialFeed,代碼行數:15,代碼來源:zest_page.php

示例3: get_by_url

 /**
  * Returns a feedpost from the current url
  *
  * $param	bool	$unpublished	Return unpublished posts too?
  * @return	object|bool	$post		The feedpost generated by the url, or null if no feedpost found
  */
 public static function get_by_url($unpublished = false)
 {
     $uri = uri::instance();
     $feed = Feed_Model::get_by_url();
     if ($feed && $feed->id > 0) {
         $post_id = $uri->segment(2);
         $post = ORM::factory('feedpost', $post_id);
         if (!$unpublished) {
             if ($post->status_id == 2) {
                 return $post;
             }
         } else {
             return $post;
         }
     }
     return null;
 }
開發者ID:sydlawrence,項目名稱:SocialFeed,代碼行數:23,代碼來源:zest_feedpost.php


注:本文中的uri::instance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。