@@ -124,6 +124,17 @@ public static function sitemap()
124124 }
125125 foreach ($ articles AS $ article ) {
126126 $ type = $ article ['type ' ];
127+ $ article ['categories ' ] = $ db ->fetchAll ($ db ->select ()->from ('table.metas ' )
128+ ->join ('table.relationships ' , 'table.relationships.mid = table.metas.mid ' )
129+ ->where ('table.relationships.cid = ? ' , $ article ['cid ' ])
130+ ->where ('table.metas.type = ? ' , 'category ' )
131+ ->order ('table.metas.order ' , Typecho_Db::SORT_ASC ));
132+ $ article ['category ' ] = urlencode (current (Typecho_Common::arrayFlatten ($ article ['categories ' ], 'slug ' )));
133+ $ article ['slug ' ] = urlencode ($ article ['slug ' ]);
134+ $ article ['date ' ] = new Typecho_Date ($ article ['created ' ]);
135+ $ article ['year ' ] = $ article ['date ' ]->year ;
136+ $ article ['month ' ] = $ article ['date ' ]->month ;
137+ $ article ['day ' ] = $ article ['date ' ]->day ;
127138 $ routeExists = (NULL != Typecho_Router::get ($ type ));
128139 $ article ['pathinfo ' ] = $ routeExists ? Typecho_Router::url ($ type , $ article ) : '# ' ;
129140 $ article ['permalink ' ] = Typecho_Common::url ($ article ['pathinfo ' ], $ options ->index );
@@ -181,6 +192,22 @@ public static function send($contents, $class)
181192 //获取路由信息
182193 $ routeExists = (NULL != Typecho_Router::get ($ type ));
183194
195+ if (!is_null ($ routeExists )){
196+ $ db = Typecho_Db::get ();
197+ $ contents ['cid ' ] = $ class ->cid ;
198+ $ contents ['categories ' ] = $ db ->fetchAll ($ db ->select ()->from ('table.metas ' )
199+ ->join ('table.relationships ' , 'table.relationships.mid = table.metas.mid ' )
200+ ->where ('table.relationships.cid = ? ' , $ contents ['cid ' ])
201+ ->where ('table.metas.type = ? ' , 'category ' )
202+ ->order ('table.metas.order ' , Typecho_Db::SORT_ASC ));
203+ $ contents ['category ' ] = urlencode (current (Typecho_Common::arrayFlatten ($ contents ['categories ' ], 'slug ' )));
204+ $ contents ['slug ' ] = urlencode ($ contents ['slug ' ]);
205+ $ contents ['date ' ] = new Typecho_Date ($ contents ['created ' ]);
206+ $ contents ['year ' ] = $ contents ['date ' ]->year ;
207+ $ contents ['month ' ] = $ contents ['date ' ]->month ;
208+ $ contents ['day ' ] = $ contents ['date ' ]->day ;
209+ }
210+
184211 //生成永久连接
185212 $ path_info = $ routeExists ? Typecho_Router::url ($ type , $ contents ) : '# ' ;
186213 $ permalink = Typecho_Common::url ($ path_info , $ options ->index );
0 commit comments