當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。