1 | <?php
|
---|
2 | // $Id: xpress.php
|
---|
3 | // FILE :: xpress.php
|
---|
4 | // AUTHOR :: toemon
|
---|
5 | //
|
---|
6 | // WordPress 2.0+
|
---|
7 |
|
---|
8 | if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
|
---|
9 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
10 |
|
---|
11 | eval( '
|
---|
12 | function b_sitemap_' . $mydirname . '(){
|
---|
13 | return _sitemap_xpress("'.$mydirname.'");
|
---|
14 | }
|
---|
15 | ') ;
|
---|
16 |
|
---|
17 | if(!function_exists('_sitemap_xpress')){
|
---|
18 | function _sitemap_xpress($mydirname){
|
---|
19 | global $sitemap_configs;
|
---|
20 |
|
---|
21 | $xpress_sitemap =array();
|
---|
22 | $disp_sub =@$sitemap_configs["show_subcategoris"];
|
---|
23 | get_sitemap_category_list($mydirname,&$xpress_sitemap, 0, 0, $disp_sub,1);
|
---|
24 | return $xpress_sitemap;
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | if(!function_exists('get_sitemap_category_list')){
|
---|
29 | function get_sitemap_category_list($mydirname,$xpress_sitemap,$parent = 0, $parent_index ,$disp_sub,$depth)
|
---|
30 | {
|
---|
31 | global $xoopsModule, $wp_db_version;
|
---|
32 |
|
---|
33 | if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')){
|
---|
34 | return '';
|
---|
35 | }
|
---|
36 |
|
---|
37 | include_once (XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php');
|
---|
38 | $db_version = $wp_db_version;
|
---|
39 | $xoopsDB =& Database::getInstance();
|
---|
40 | $myts =& MyTextSanitizer::getInstance();
|
---|
41 |
|
---|
42 | $prefix = $mydirname;
|
---|
43 | if ($prefix == 'wordpress') $prefix ='wp';
|
---|
44 | $wp_prefix = $xoopsDB->prefix($prefix);
|
---|
45 |
|
---|
46 | switch($db_version){
|
---|
47 | case ($db_version>= 6000):
|
---|
48 | $id_name = "term_taxonomy_id";
|
---|
49 | $pid_name = "parent";
|
---|
50 | $title_name = "name";
|
---|
51 | $term_taxonomy_db = $wp_prefix . '_term_taxonomy';
|
---|
52 | $terms_db = $wp_prefix . '_terms';
|
---|
53 | $sql = "SELECT $term_taxonomy_db.$id_name,$terms_db.$title_name ";
|
---|
54 | $sql .= "FROM $term_taxonomy_db INNER JOIN $terms_db ON $term_taxonomy_db.term_id = $terms_db.term_id ";
|
---|
55 | $sql .= "WHERE $term_taxonomy_db.parent = $parent AND $term_taxonomy_db.taxonomy = 'category'";
|
---|
56 | break;
|
---|
57 | default:
|
---|
58 | $id_name = "cat_ID";
|
---|
59 | $pid_name = "category_parent";
|
---|
60 | $title_name = "cat_name";
|
---|
61 | $cat_db = $wp_prefix . '_categories';
|
---|
62 | $sql = "SELECT $id_name , $title_name ";
|
---|
63 | $sql .= "FROM $cat_db ";
|
---|
64 | $sql .= "WHERE $pid_name = $parent";
|
---|
65 | break;
|
---|
66 | }
|
---|
67 |
|
---|
68 | $res = $xoopsDB->query($sql, 0, 0);
|
---|
69 | if ($res === false){
|
---|
70 | return ;
|
---|
71 | } else {
|
---|
72 | $index = 0;
|
---|
73 | while($row = $xoopsDB->fetchArray($res)){
|
---|
74 | if ($depth == 1){
|
---|
75 | $xpress_sitemap['parent'][$index]['id'] = $row[$id_name];
|
---|
76 | $xpress_sitemap['parent'][$index]['title'] = $myts->makeTboxData4Show( $row[$title_name] ) ;
|
---|
77 | $url = "index.php?cat=";
|
---|
78 | $xpress_sitemap['parent'][$index]['url'] = $url.$row[$id_name];
|
---|
79 | if ($disp_sub){
|
---|
80 | get_sitemap_category_list($mydirname,&$xpress_sitemap,$row[$id_name] , $index, $disp_sub,$depth + 1);
|
---|
81 | }
|
---|
82 | } else {
|
---|
83 | $xpress_sitemap['parent'][$parent_index]['child'][$index]['id'] = $row[$id_name];
|
---|
84 | $xpress_sitemap['parent'][$parent_index]['child'][$index]['title'] = $myts->makeTboxData4Show( $row[$title_name] ) ;
|
---|
85 | $url = "index.php?cat=";
|
---|
86 | $xpress_sitemap['parent'][$parent_index]['child'][$index]['url'] = $url.$row[$id_name];
|
---|
87 | $xpress_sitemap['parent'][$parent_index]['child'][$index]['image'] = (($depth > 3) ? 4 : $depth);;
|
---|
88 | // get_sitemap_category_list($mydirname,&$xpress_sitemap,$row[$id_name] , $index, $disp_sub,$depth +1);
|
---|
89 | }
|
---|
90 | $index++;
|
---|
91 | }
|
---|
92 | }
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | ?> |
---|