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


PHP Typecho_Router::url方法代碼示例

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


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

示例1: execute

 /**
  * 初始化函數
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 設置參數默認值 */
     $this->parameter->setDefault('format=Y-m&type=month&limit=0');
     $resource = $this->db->query($this->db->select('created')->from('table.contents')->where('type = ?', 'post')->where('table.contents.status = ?', 'publish')->where('table.contents.created < ?', $this->options->gmtTime)->order('table.contents.created', Typecho_Db::SORT_DESC));
     $offset = $this->options->timezone - $this->options->serverTimezone;
     $result = array();
     while ($post = $this->db->fetchRow($resource)) {
         $timeStamp = $post['created'] + $offset;
         $date = date($this->parameter->format, $timeStamp);
         if (isset($result[$date])) {
             $result[$date]['count']++;
         } else {
             $result[$date]['year'] = date('Y', $timeStamp);
             $result[$date]['month'] = date('m', $timeStamp);
             $result[$date]['day'] = date('d', $timeStamp);
             $result[$date]['date'] = $date;
             $result[$date]['count'] = 1;
         }
     }
     if ($this->parameter->limit > 0) {
         $result = array_slice($result, 0, $this->parameter->limit);
     }
     foreach ($result as $row) {
         $row['permalink'] = Typecho_Router::url('archive_' . $this->parameter->type, $row, $this->widget('Widget_Options')->index);
         $this->push($row);
     }
 }
開發者ID:r0ker,項目名稱:hctf2015-all-problems,代碼行數:34,代碼來源:Date.php

示例2: ___permalink

 /**
  * 獲取當前評論鏈接
  *
  * @access protected
  * @return string
  */
 protected function ___permalink()
 {
     if ($this->options->commentsPageBreak && 'approved' == $this->status) {
         $coid = $this->coid;
         $parent = $this->parent;
         while ($parent > 0 && $this->options->commentsThreaded) {
             $parentRows = $this->db->fetchRow($this->db->select('parent')->from('table.comments')->where('coid = ? AND status = ?', $parent, 'approved')->limit(1));
             if (!empty($parentRows)) {
                 $coid = $parent;
                 $parent = $parentRows['parent'];
             } else {
                 break;
             }
         }
         $select = $this->db->select('coid', 'parent')->from('table.comments')->where('cid = ? AND status = ?', $this->parentContent['cid'], 'approved')->where('coid ' . ('DESC' == $this->options->commentsOrder ? '>=' : '<=') . ' ?', $coid)->order('coid', Typecho_Db::SORT_ASC);
         if ($this->options->commentsShowCommentOnly) {
             $select->where('type = ?', 'comment');
         }
         $comments = $this->db->fetchAll($select);
         $commentsMap = array();
         $total = 0;
         foreach ($comments as $comment) {
             $commentsMap[$comment['coid']] = $comment['parent'];
             if (0 == $comment['parent'] || !isset($commentsMap[$comment['parent']])) {
                 $total++;
             }
         }
         $currentPage = ceil($total / $this->options->commentsPageSize);
         $pageRow = array('permalink' => $this->parentContent['pathinfo'], 'commentPage' => $currentPage);
         return Typecho_Router::url('comment_page', $pageRow, $this->options->index) . '#' . $this->theId;
     }
     return $this->parentContent['permalink'] . '#' . $this->theId;
 }
開發者ID:BlueBreeze,項目名稱:typecho,代碼行數:39,代碼來源:Comments.php

示例3: OutputArchives

function OutputArchives($db, $options)
{
    $select = $db->select('cid', 'title', 'slug', 'created', 'allowComment', 'commentsNum')->from('table.contents')->where('status = ?', 'publish')->where('type = ?', 'post');
    $rawposts = $db->fetchAll($select);
    $posts = array();
    // Loop through each post and sort it into a structured array
    foreach ($rawposts as $post) {
        /** 取出所有分類 */
        $categories = $isTypechoEX ? Cache_Plugin::meta_get($post['cid'], "category") : $db->fetchAll($db->select('slug')->from('table.metas')->join('table.relationships', 'table.metas.mid = table.relationships.mid')->where('table.relationships.cid = ?', $post['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC));
        /** 取出第一個分類作為slug條件 */
        $post['category'] = current(Typecho_Common::arrayFlatten($categories, 'slug'));
        $date = new Typecho_Date($post['created']);
        $post['year'] = $date->year;
        $post['month'] = $date->month;
        $post['day'] = $date->day;
        $type = 'post';
        //$p['type'];
        $routeExists = NULL != Typecho_Router::get($type);
        $permalink = $routeExists ? Typecho_Router::url($type, $post, $options->index) : '#';
        $post['permalink'] = $permalink;
        $posts[$post['year'] . '.' . $post['month']][] = $post;
    }
    $rawposts = null;
    // More memory cleanup
    // Sort the months based on $atts
    krsort($posts);
    // Sort the posts within each month based on $atts
    foreach ($posts as $key => $month) {
        $sorter = array();
        foreach ($month as $post) {
            $sorter[] = $post['created'];
        }
        array_multisort($sorter, SORT_DESC, $month);
        $posts[$key] = $month;
        unset($month);
    }
    // Generate the HTML
    $html = "";
    foreach ($posts as $yearmonth => $posts) {
        list($year, $month) = explode('.', $yearmonth);
        $html .= "<li><b><a href=\"" . Typecho_Router::url('archive_month', array('year' => $year, 'month' => $month), $options->index) . "\">" . $year . "年" . $month . "月</a></b> <span>(" . number_format(count($posts)) . " 篇文章)</span><ul>";
        foreach ($posts as $post) {
            $html .= "<li>" . $post['day'] . ": <a href=\"" . $post['permalink'] . "\">" . $post['title'] . "</a> <span>(" . number_format($post['commentsNum']) . ")</span></li>";
        }
        $html .= "</ul></li>";
    }
    return $html;
}
開發者ID:nbdarling,項目名稱:typechoi7-master,代碼行數:48,代碼來源:page.php

示例4: ___permalink

 /**
  * 獲取當前評論鏈接
  *
  * @access protected
  * @return string
  */
 protected function ___permalink()
 {
     if ($this->options->commentsPageBreak && 'approved' == $this->status) {
         $coid = $this->coid;
         $select = $this->db->select('coid')->from('table.comments')->where('cid = ? AND status = ?', $this->parentContent['cid'], 'approved')->where('coid ' . ('DESC' == $this->options->commentsOrder ? '>=' : '<=') . ' ?', $coid)->order('coid', Typecho_Db::SORT_ASC);
         if ($this->options->commentsShowCommentOnly) {
             $select->where('type = ?', 'comment');
         }
         $comments = $this->db->fetchAll($select);
         $total = count($comments);
         $currentPage = ceil($total / $this->options->commentsPageSize);
         $pageRow = array('permalink' => $this->parentContent['pathinfo'], 'commentPage' => $currentPage);
         return Typecho_Router::url('comment_page', $pageRow, $this->options->index) . '#' . $this->theId;
     }
     return $this->parentContent['permalink'] . '#' . $this->theId;
 }
開發者ID:dccecc,項目名稱:typecho,代碼行數:22,代碼來源:Comments.php

示例5: pageNav

 /**
  * 輸出分頁
  *
  * @access public
  * @param string $prev 上一頁文字
  * @param string $next 下一頁文字
  * @param int $splitPage 分割範圍
  * @param string $splitWord 分割字符
  * @param string $template 展現配置信息
  * @return void
  */
 public function pageNav($prev = '&laquo;', $next = '&raquo;', $splitPage = 3, $splitWord = '...', $template = '')
 {
     if ($this->options->commentsPageBreak && $this->_total > $this->options->commentsPageSize) {
         $default = array('wrapTag' => 'ol', 'wrapClass' => 'page-navigator');
         if (is_string($template)) {
             parse_str($template, $config);
         } else {
             $config = $template;
         }
         $template = array_merge($default, $config);
         $pageRow = $this->parameter->parentContent;
         $pageRow['permalink'] = $pageRow['pathinfo'];
         $query = Typecho_Router::url('comment_page', $pageRow, $this->options->index);
         /** 使用盒狀分頁 */
         $nav = new Typecho_Widget_Helper_PageNavigator_Box($this->_total, $this->_currentPage, $this->options->commentsPageSize, $query);
         $nav->setPageHolder('commentPage');
         $nav->setAnchor('comments');
         echo '<' . $template['wrapTag'] . (empty($template['wrapClass']) ? '' : ' class="' . $template['wrapClass'] . '"') . '>';
         $nav->render($prev, $next, $splitPage, $splitWord, $template);
         echo '</' . $template['wrapTag'] . '>';
     }
 }
開發者ID:Sunappnio,項目名稱:typecho,代碼行數:33,代碼來源:Archive.php

示例6: authorizeIcon

 public static function authorizeIcon()
 {
     return '<a href="' . Typecho_Router::url('sinauthAuthorize', array('feed' => '/atom/comments/')) . '">新浪登陸</a>';
 }
開發者ID:duxiangfei,項目名稱:plugins,代碼行數:4,代碼來源:Plugin.php

示例7: post_update

 /**
  * 編輯文章後更新緩存
  * @param $contents
  * @param $class
  */
 public static function post_update($contents, $class)
 {
     if ('publish' != $contents['visibility'] || $contents['created'] > time()) {
         return;
     }
     //獲取係統配置
     $options = Helper::options();
     if (!$options->plugin('TpCache')->cache_driver) {
         return;
     }
     //獲取文章類型
     $type = $contents['type'];
     //獲取路由信息
     $routeExists = NULL != Typecho_Router::get($type);
     if (!is_null($routeExists)) {
         $db = Typecho_Db::get();
         $contents['cid'] = $class->cid;
         $contents['categories'] = $db->fetchAll($db->select()->from('table.metas')->join('table.relationships', 'table.relationships.mid = table.metas.mid')->where('table.relationships.cid = ?', $contents['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC));
         $contents['category'] = urlencode(current(Typecho_Common::arrayFlatten($contents['categories'], 'slug')));
         $contents['slug'] = urlencode($contents['slug']);
         $contents['date'] = new Typecho_Date($contents['created']);
         $contents['year'] = $contents['date']->year;
         $contents['month'] = $contents['date']->month;
         $contents['day'] = $contents['date']->day;
     }
     //生成永久連接
     $path_info = $routeExists ? Typecho_Router::url($type, $contents) : '#';
     self::init();
     if (self::needCache($path_info)) {
         self::delete(self::$path);
     }
 }
開發者ID:wujunze,項目名稱:wujunze.com,代碼行數:37,代碼來源:Plugin.php

示例8: someAction

 public function someAction($route, $params = null, $echo = true)
 {
     $params['action'] = $route;
     $url = $this->widget('Widget_Security')->getTokenUrl(Typecho_Router::url('do', $params, $this->index));
     if ($echo) {
         echo $url;
     } else {
         return $url;
     }
 }
開發者ID:veryer,項目名稱:sisome,代碼行數:10,代碼來源:Options.php

示例9: ___registerAction

 /**
  * 獲取登錄提交地址
  *
  * @access protected
  * @return string
  */
 protected function ___registerAction()
 {
     return $this->widget('Widget_Security')->getTokenUrl(Typecho_Router::url('do', array('action' => 'register', 'widget' => 'Register'), $this->index));
 }
開發者ID:ldsink,項目名稱:typecho,代碼行數:10,代碼來源:Options.php

示例10: pageNav

 /**
  * 輸出分頁
  *
  * @access public
  * @param string $prev 上一頁文字
  * @param string $next 下一頁文字
  * @param int $splitPage 分割範圍
  * @param string $splitWord 分割字符
  * @return void
  */
 public function pageNav($prev = '&laquo;', $next = '&raquo;', $splitPage = 3, $splitWord = '...')
 {
     if ($this->options->commentsPageBreak && $this->_total > $this->options->commentsPageSize) {
         $pageRow = $this->parameter->parentContent;
         $pageRow['permalink'] = $pageRow['pathinfo'];
         $query = Typecho_Router::url('comment_page', $pageRow, $this->options->index);
         /** 使用盒狀分頁 */
         $nav = new Typecho_Widget_Helper_PageNavigator_Box($this->_total, $this->_currentPage, $this->options->commentsPageSize, $query);
         $nav->setPageHolder('commentPage');
         $nav->setAnchor('comments');
         echo '<ol class="page-navigator">';
         $nav->render($prev, $next, $splitPage, $splitWord);
         echo '</ol>';
     }
 }
開發者ID:menmenweiwei,項目名稱:blog,代碼行數:25,代碼來源:Archive.php

示例11: Comments_Pager

function Comments_Pager($obj)
{
    //set total
    $pagesize = MyTypechoTheme_Plugin::$_options->commentsPageSize;
    $total = $obj->getTotal();
    if (MyTypechoTheme_Plugin::$_options->commentsPageBreak && $total > $pagesize) {
        $currentPage = $obj->getCurrentPage();
        $totalPage = ceil($total / $pagesize);
        if ($currentPage < $totalPage) {
            $pageRow = $obj->parameter->parentContent;
            $pageRow['permalink'] = $pageRow['pathinfo'];
            //get url
            $query = Typecho_Router::url('comment_page', $pageRow, MyTypechoTheme_Plugin::$_options->index);
            echo "<div class=\"navigation\"><a class=\"loadmore\" role=\"navigation\" href=\"#\" data=\"" . str_replace('{commentPage}', $currentPage + 1, $query) . "\">更多評論</a></div>";
        }
    }
}
開發者ID:nbdarling,項目名稱:typechoi7-master,代碼行數:17,代碼來源:functions.php

示例12: ___registerAction

 /**
  * 獲取登錄提交地址
  *
  * @access protected
  * @return string
  */
 protected function ___registerAction()
 {
     return Typecho_Router::url('do', array('action' => 'register', 'widget' => 'Register'), $this->index);
 }
開發者ID:raindali,項目名稱:express,代碼行數:10,代碼來源:Options.php

示例13: array

include 'common.php';
include 'header.php';
include 'menu.php';
?>

<div class="main">
    <div class="body container">
        <?php 
include 'page-title.php';
?>
        <div class="row typecho-page-main" role="main">
            <div class="col-mb-12">
                <div id="typecho-welcome">
                    <form action="<?php 
echo $security->getTokenUrl(Typecho_Router::url('do', array('action' => 'upgrade', 'widget' => 'Upgrade'), Typecho_Common::url('index.php', $options->rootUrl)));
?>
" method="post">
                    <h3><?php 
_e('檢測到新版本!');
?>
</h3>
                    <ul>
                        <li><?php 
_e('您已經更新了係統程序, 我們還需要執行一些後續步驟來完成升級');
?>
</li>
                        <li><?php 
_e('此程序將把您的係統從 <strong>%s</strong> 升級到 <strong>%s</strong>', $options->version, Typecho_Common::VERSION);
?>
</li>
開發者ID:hongweipeng,項目名稱:typecho,代碼行數:30,代碼來源:upgrade.php

示例14: GetPosts

 /**
  * Grab all posts and filter them into an array
  *
  */
 public static function GetPosts()
 {
     $options = Typecho_Widget::widget('Widget_Options');
     /**
      * 獲取數據庫實例化對象
      * 用靜態變量存儲實例化的數據庫對象,可以保證數據連接僅進行一次
      */
     $db = Typecho_Db::get();
     $select = $db->select('cid', 'title', 'slug', 'created', 'allowComment', 'commentsNum')->from('table.contents')->where('status = ?', 'publish')->where('type = ?', 'post');
     $rawposts = $db->fetchAll($select);
     $posts = array();
     // Loop through each post and sort it into a structured array
     foreach ($rawposts as $post) {
         /** 取出所有分類 */
         $categories = $db->fetchAll($db->select('slug')->from('table.metas')->join('table.relationships', 'table.metas.mid = table.relationships.mid')->where('table.relationships.cid = ?', $post['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC));
         /** 取出第一個分類作為slug條件 */
         $post['category'] = current(Typecho_Common::arrayFlatten($categories, 'slug'));
         $date = new Typecho_Date($post['created']);
         $post['year'] = $date->year;
         $post['month'] = $date->month;
         $post['day'] = $date->day;
         $type = 'post';
         //$p['type'];
         $routeExists = NULL != Typecho_Router::get($type);
         $permalink = $routeExists ? Typecho_Router::url($type, $post, $options->index) : '#';
         $post['permalink'] = $permalink;
         $posts[$post['year'] . '.' . $post['month']][] = $post;
     }
     $rawposts = null;
     // More memory cleanup
     return $posts;
 }
開發者ID:RocFang,項目名稱:JustArchives,代碼行數:36,代碼來源:Plugin.php

示例15: array

          <div class="site-state-item site-state-posts">
            <a href="<?php 
echo Typecho_Router::url('page', array('slug' => 'archive'), $this->options->index);
?>
">
              <span class="site-state-item-count"><?php 
echo $stat->publishedPostsNum;
?>
</span>
              <span class="site-state-item-name">日誌</span>
          </a>
      </div>

      <div class="site-state-item site-state-categories">
        <a href="<?php 
echo Typecho_Router::url('page', array('slug' => 'categories'), $this->options->index);
?>
">
          <span class="site-state-item-count"><?php 
echo $stat->categoriesNum;
?>
</span>
          <span class="site-state-item-name">分類</span>
</a>
      </div>

      <div class="site-state-item site-state-tags">
          <span class="site-state-item-count"><?php 
echo $stat->publishedPagesNum;
?>
</span>
開發者ID:andyhuai,項目名稱:typecho-theme-next,代碼行數:31,代碼來源:sidebar.php


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