当前位置: 首页>>代码示例>>PHP>>正文


PHP Typecho_Router类代码示例

本文整理汇总了PHP中Typecho_Router的典型用法代码示例。如果您正苦于以下问题:PHP Typecho_Router类的具体用法?PHP Typecho_Router怎么用?PHP Typecho_Router使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Typecho_Router类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ___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

示例2: execute

 /**
  * 入口函数,初始化路由器
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 对变量赋值 */
     $options = $this->widget('Widget_Options');
     /** 开始会话 */
     @session_start();
     /** 初始化charset */
     Typecho_Common::$charset = $options->charset;
     /** 初始化exception */
     Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle';
     /** 设置路径 */
     if (defined('__TYPECHO_PATHINFO_ENCODING__')) {
         $pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset);
     } else {
         $pathInfo = $this->request->getPathInfo();
     }
     Typecho_Router::setPathInfo($pathInfo);
     /** 初始化路由器 */
     Typecho_Router::setRoutes($options->routingTable);
     /** 初始化插件 */
     Typecho_Plugin::init($options->plugins);
     /** 初始化回执 */
     $this->response->setCharset($options->charset);
     $this->response->setContentType($options->contentType);
     /** 默认时区 */
     if (!ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
         @date_default_timezone_set('UTC');
     }
     /** 初始化时区 */
     Typecho_Date::setTimezoneOffset($options->timezone);
     /** 监听缓冲区 */
     ob_start();
 }
开发者ID:raindali,项目名称:express,代码行数:39,代码来源:Init.php

示例3: 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

示例4: 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

示例5: ___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

示例6: execute

 /**
  * 入口函数,初始化路由器
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 对变量赋值 */
     $options = $this->widget('Widget_Options');
     /** 语言包初始化 */
     if ($options->lang && $options->lang != 'zh_CN') {
         $dir = defined('__TYPECHO_LANG_DIR__') ? __TYPECHO_LANG_DIR__ : __TYPECHO_ROOT_DIR__ . '/usr/langs';
         Typecho_I18n::setLang($dir . '/' . $options->lang . '.mo');
     }
     /** cookie初始化 */
     Typecho_Cookie::setPrefix($options->rootUrl);
     /** 初始化charset */
     Typecho_Common::$charset = $options->charset;
     /** 初始化exception */
     Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle';
     /** 设置路径 */
     if (defined('__TYPECHO_PATHINFO_ENCODING__')) {
         $pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset);
     } else {
         $pathInfo = $this->request->getPathInfo();
     }
     Typecho_Router::setPathInfo($pathInfo);
     /** 初始化路由器 */
     Typecho_Router::setRoutes($options->routingTable);
     /** 初始化插件 */
     Typecho_Plugin::init($options->plugins);
     /** 初始化回执 */
     $this->response->setCharset($options->charset);
     $this->response->setContentType($options->contentType);
     /** 默认时区 */
     if (function_exists("ini_get") && !ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
         @date_default_timezone_set('UTC');
     }
     /** 初始化时区 */
     Typecho_Date::setTimezoneOffset($options->timezone);
     /** 开始会话, 减小负载只针对后台打开session支持 */
     // modified_by_jiangmuzi 2015.09.23
     // 开始会话
     @session_start();
     // end modified
     /** 监听缓冲区 */
     ob_start();
 }
开发者ID:dccecc,项目名称:typecho,代码行数:49,代码来源:Init.php

示例7: 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

示例8: authorizeIcon

 public static function authorizeIcon()
 {
     return '<a href="' . Typecho_Router::url('sinauthAuthorize', array('feed' => '/atom/comments/')) . '">新浪登陆</a>';
 }
开发者ID:duxiangfei,项目名称:plugins,代码行数:4,代码来源:Plugin.php

示例9: setRoutes

 /**
  * 设置路由器默认配置
  *
  * @access public
  * @param mixed $routes 配置信息
  * @return void
  */
 public static function setRoutes($routes)
 {
     if (isset($routes[0])) {
         self::$_routingTable = $routes[0];
     } else {
         /** 解析路由配置 */
         $parser = new Typecho_Router_Parser($routes);
         self::$_routingTable = $parser->parse();
     }
 }
开发者ID:jiusanzhou,项目名称:spacms,代码行数:17,代码来源:Router.php

示例10: 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

示例11: 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

示例12: filter

 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     //生成静态链接
     $type = $value['type'];
     $routeExists = NULL != Typecho_Router::get($type);
     $tmpSlug = $value['slug'];
     $value['slug'] = urlencode($value['slug']);
     $value['permalink'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->index) : '#';
     /** 生成聚合链接 */
     /** RSS 2.0 */
     $value['feedUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedUrl) : '#';
     /** RSS 1.0 */
     $value['feedRssUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedRssUrl) : '#';
     /** ATOM 1.0 */
     $value['feedAtomUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedAtomUrl) : '#';
     $value['slug'] = $tmpSlug;
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     return $value;
 }
开发者ID:dccecc,项目名称:typecho,代码行数:26,代码来源:Metas.php

示例13: setRoutes

 /**
  * 设置路由器默认配置
  *
  * @access public
  * @param mixed $routes 配置信息
  * @return void
  */
 public static function setRoutes($routes)
 {
     /** 载入路由解析支持 */
     require_once 'Typecho/Router/Parser.php';
     if (isset($routes[0])) {
         self::$_routingTable = $routes[0];
     } else {
         /** 解析路由配置 */
         $parser = new Typecho_Router_Parser($routes);
         self::$_routingTable = $parser->parse();
     }
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:19,代码来源:Router.php

示例14: ___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

示例15: 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


注:本文中的Typecho_Router类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。