Skip to content

Commit

Permalink
fix url bug
Browse files Browse the repository at this point in the history
  • Loading branch information
phpgao committed May 26, 2015
1 parent 571217b commit 48e6f73
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,23 @@ public static function update($contents, $class)
$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) : '#';

Expand Down

0 comments on commit 48e6f73

Please sign in to comment.