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


PHP Typecho_Router::get方法代码示例

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


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

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

示例2: filter

 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     /** 取出所有分类 */
     $value['categories'] = $this->db->fetchAll($this->db->select()->from('table.metas')->join('table.relationships', 'table.relationships.mid = table.metas.mid')->where('table.relationships.cid = ?', $value['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC), array($this->widget('Widget_Abstract_Metas'), 'filter'));
     /** 取出第一个分类作为slug条件 */
     $value['category'] = current(Typecho_Common::arrayFlatten($value['categories'], 'slug'));
     $value['date'] = new Typecho_Date($value['created']);
     /** 生成日期 */
     $value['year'] = $value['date']->year;
     $value['month'] = $value['date']->month;
     $value['day'] = $value['date']->day;
     /** 生成访问权限 */
     $value['hidden'] = false;
     /** 获取路由类型并判断此类型在路由表中是否存在 */
     $type = $value['type'];
     $routeExists = NULL != Typecho_Router::get($type);
     $tmpSlug = $value['slug'];
     $tmpCategory = $value['category'];
     $value['slug'] = urlencode($value['slug']);
     $value['category'] = urlencode($value['category']);
     /** 生成静态路径 */
     $value['pathinfo'] = $routeExists ? Typecho_Router::url($type, $value) : '#';
     /** 生成静态链接 */
     $value['permalink'] = Typecho_Common::url($value['pathinfo'], $this->options->index);
     /** 处理附件 */
     if ('attachment' == $type) {
         $content = @unserialize($value['text']);
         //增加数据信息
         $value['attachment'] = new Typecho_Config($content);
         $value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp'));
         $value['attachment']->url = Widget_Upload::attachmentHandle($value);
         if ($value['attachment']->isImage) {
             $value['text'] = '<img src="' . $value['attachment']->url . '" alt="' . $value['title'] . '" />';
         } else {
             $value['text'] = '<a href="' . $value['attachment']->url . '" title="' . $value['title'] . '">' . $value['title'] . '</a>';
         }
     }
     /** 处理Markdown **/
     $value['isMarkdown'] = 0 === strpos($value['text'], '<!--markdown-->');
     if ($value['isMarkdown']) {
         $value['text'] = substr($value['text'], 15);
     }
     /** 生成聚合链接 */
     /** 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['category'] = $tmpCategory;
     /** 处理密码保护流程 */
     if (!empty($value['password']) && $value['password'] != $this->request->protectPassword && $value['authorId'] != $this->user->uid && !$this->user->pass('editor', true)) {
         $value['hidden'] = true;
         /** 抛出错误 */
         if ($this->request->isPost() && isset($this->request->protectPassword)) {
             throw new Typecho_Widget_Exception(_t('对不起,您输入的密码错误'), 403);
         }
     }
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     /** 如果访问权限被禁止 */
     if ($value['hidden']) {
         $value['text'] = '<form class="protected" action="' . $value['permalink'] . '" method="post">' . '<p class="word">' . _t('请输入密码访问') . '</p>' . '<p><input type="password" class="text" name="protectPassword" />
         <input type="submit" class="submit" value="' . _t('提交') . '" /></p>' . '</form>';
         $value['title'] = _t('此内容被密码保护');
         $value['tags'] = array();
         $value['commentsNum'] = 0;
     }
     return $value;
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:77,代码来源:Contents.php

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

示例4: send

 /**
  * 准备数据
  * @param $contents 文章内容
  * @param $class 调用接口的类
  * @throws Typecho_Plugin_Exception
  */
 public static function send($contents, $class)
 {
     //如果文章属性为隐藏或滞后发布
     if ('publish' != $contents['visibility'] || $contents['created'] > time()) {
         return;
     }
     //获取系统配置
     $options = Helper::options();
     //判断是否配置好API
     if (is_null($options->plugin('BaiduSubmit')->api)) {
         throw new Typecho_Plugin_Exception(_t('api未配置'));
     }
     //获取文章类型
     $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) : '#';
     $permalink = Typecho_Common::url($path_info, $options->index);
     //调用post方法
     self::post($permalink);
 }
开发者ID:wujunze,项目名称:wujunze.com,代码行数:39,代码来源:Action.php

示例5: filter

 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     //生成静态链接
     $routeExists = NULL != Typecho_Router::get('author');
     $value['permalink'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->index) : '#';
     /** 生成聚合链接 */
     /** RSS 2.0 */
     $value['feedUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedUrl) : '#';
     /** RSS 1.0 */
     $value['feedRssUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedRssUrl) : '#';
     /** ATOM 1.0 */
     $value['feedAtomUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedAtomUrl) : '#';
     // modified_by_jiangmuzi 2015.09.22
     $avatar = Forum_Common::parseUserAvatar($value['uid']);
     $value = array_merge($value, $avatar);
     $value['ucenter'] = $this->options->someUrl('ucenter', array('u' => $value['name']), false);
     // end modified
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     return $value;
 }
开发者ID:Jsechoo,项目名称:sisome,代码行数:27,代码来源:Users.php

示例6: filter

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

示例7:

                <div class="typecho-option-tabs">
                    <ul class="typecho-option-tabs clearfix">
                        <li class="current">
                           <form action="<?php 
$options->index('/action/golinks?add');
?>
" method="post" >
                          &nbsp;&nbsp;&nbsp;&nbsp;KEY:<input name="key" id="key" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;
                          目标:<input name="target" id="target" type="text" value="http://" />
                          <input type="submit" class="btn-s primary" value="添加" />  
                           </form> 
                        </li>
               
                    <li class="right current">                    
                        <?php 
$ro = Typecho_Router::get('go');
?>
                            自定义链接:<input id="links" name="links" value="<?php 
echo $ro['url'];
?>
" type="text">
                        <button id="qlinks" type="button">修改</button>
                    </li>
                     </ul>
               </div>               
                <div class="typecho-table-wrap">
                <table class="typecho-list-table">
                    <colgroup>                       
                        <col width="15%"/>
                        <col width="25%"/>
                        <col width="47%"/>
开发者ID:duxiangfei,项目名称:plugins,代码行数:31,代码来源:panel.php

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

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

示例10: filter

 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     //生成静态链接
     $routeExists = NULL != Typecho_Router::get('author');
     $value['permalink'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->index) : '#';
     /** 生成聚合链接 */
     /** RSS 2.0 */
     $value['feedUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedUrl) : '#';
     /** RSS 1.0 */
     $value['feedRssUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedRssUrl) : '#';
     /** ATOM 1.0 */
     $value['feedAtomUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedAtomUrl) : '#';
     // modified_by_jiangmuzi 2015.09.22
     if (!empty($value['extend'])) {
         $value['extend'] = unserialize($value['extend']);
     }
     $value['ucenter'] = $this->options->someUrl('ucenter', array('u' => $value['name']), false);
     // end modified
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     return $value;
 }
开发者ID:dccecc,项目名称:typecho,代码行数:28,代码来源:Users.php


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