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 , $xoopsDB;
|
---|
20 |
|
---|
21 | if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')){
|
---|
22 | return '';
|
---|
23 | }
|
---|
24 | include (XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php');
|
---|
25 | if ($wp_db_version < 6124) { // UNDER WP2.3
|
---|
26 | $block = sitemap_get_categoires_map($xoopsDB->prefix("wp_categories"), "cat_ID", "category_parent", "cat_name", "index.php?cat=", "cat_name");
|
---|
27 | return $block;
|
---|
28 | }
|
---|
29 |
|
---|
30 | $disp_sub =@$sitemap_configs["show_subcategoris"];
|
---|
31 |
|
---|
32 | $prefix = preg_replace('/wordpress/','wp',$mydirname);
|
---|
33 | $prefix = $xoopsDB->prefix($prefix);
|
---|
34 | require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php');
|
---|
35 | $options_tables = get_table_list($prefix,'options');
|
---|
36 |
|
---|
37 | $index = 0;
|
---|
38 | $blogs =array();
|
---|
39 | foreach( $options_tables as $options_table){
|
---|
40 | $blog_url = get_blog_option($options_table , 'siteurl');
|
---|
41 | $blog_sub_url = preg_replace('/.*\/' . $mydirname . '/' , '' , $blog_url);
|
---|
42 | $blog_sub_url = preg_replace('/\//' , '' , $blog_sub_url);
|
---|
43 | if (!empty($blog_sub_url)) {
|
---|
44 | $blog_sub_url = $blog_sub_url . '/';
|
---|
45 | }
|
---|
46 | $blog_name = get_blog_option($options_table , 'blogname');
|
---|
47 | $db_prefix = get_multi_prefix($options_table , 'options');
|
---|
48 |
|
---|
49 | $data = array(
|
---|
50 | 'blog_name' => $blog_name ,
|
---|
51 | 'blog_sub_url' => $blog_sub_url ,
|
---|
52 | 'term_taxonomy' => $db_prefix. 'term_taxonomy' ,
|
---|
53 | 'terms' => $db_prefix . 'terms'
|
---|
54 | );
|
---|
55 | $blogs[$index] = $data;
|
---|
56 | $index++;
|
---|
57 | }
|
---|
58 | return xpress_get_categoires_map($blogs,$disp_sub);
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | if(!function_exists('xpress_get_categoires_map')){
|
---|
63 | function xpress_get_categoires_map($blogs ,$disp_sub){
|
---|
64 | global $sitemap_configs,$xoopsDB;
|
---|
65 |
|
---|
66 | $sitemap = array();
|
---|
67 | $myts =& MyTextSanitizer::getInstance();
|
---|
68 |
|
---|
69 | $blogs_count = count($blogs);
|
---|
70 | $i = 0;
|
---|
71 | $blog = array();
|
---|
72 | for ($b_no = 0 ; $b_no < $blogs_count ; $b_no++){
|
---|
73 | $blog = $blogs[$b_no];
|
---|
74 | $terms = $blog['terms'];
|
---|
75 | $term_taxonomy = $blog['term_taxonomy'];
|
---|
76 | $blog_sub_url = $blog['blog_sub_url'];
|
---|
77 | $cat_url = $blog['blog_sub_url'] . '?cat=';
|
---|
78 | $blog_name = $blog['blog_name'];
|
---|
79 |
|
---|
80 | $sql = "SELECT term_id , name FROM $terms";
|
---|
81 | $result = $xoopsDB->query($sql);
|
---|
82 | $cat_name = array();
|
---|
83 | while (list($id, $name) = $xoopsDB->fetchRow($result)){
|
---|
84 | $cat_name["'ID" . $id . "'"] = $name;
|
---|
85 | }
|
---|
86 | if ($blogs_count > 1){
|
---|
87 | $sitemap['parent'][$i]['id'] = 0;
|
---|
88 | $sitemap['parent'][$i]['title'] = $blog_name ;
|
---|
89 | $sitemap['parent'][$i]['image'] = 1 ;
|
---|
90 | $sitemap['parent'][$i]['url'] = $blog_sub_url;
|
---|
91 | $blog_index = $i;
|
---|
92 | $i++;
|
---|
93 | }
|
---|
94 |
|
---|
95 | $mytree = new XoopsTree($term_taxonomy, 'term_id' , 'parent');
|
---|
96 | $sql = "SELECT term_id FROM $term_taxonomy WHERE parent = 0 AND taxonomy = 'category'";
|
---|
97 | $result = $xoopsDB->query($sql);
|
---|
98 | while (list($catid) = $xoopsDB->fetchRow($result)){
|
---|
99 | if ($blogs_count <= 1){
|
---|
100 | $dipth = 1;
|
---|
101 | $sitemap['parent'][$i]['id'] = $catid;
|
---|
102 | $sitemap['parent'][$i]['title'] = $cat_name["'ID" . $catid . "'"] ; ;
|
---|
103 | $sitemap['parent'][$i]['image'] = $dipth ;
|
---|
104 | $sitemap['parent'][$i]['url'] = $cat_url.$catid;
|
---|
105 |
|
---|
106 | if($disp_sub){
|
---|
107 | $j = 0;
|
---|
108 | $child_ary = $mytree->getChildTreeArray($catid, '');
|
---|
109 | foreach ($child_ary as $child)
|
---|
110 | {
|
---|
111 | $count = strlen($child['prefix']) + $dipth;
|
---|
112 | $sitemap['parent'][$i]['child'][$j]['id'] = $child['term_id'];
|
---|
113 | $sitemap['parent'][$i]['child'][$j]['title'] = $cat_name["'ID" .$child['term_id'] . "'"];
|
---|
114 | $sitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count);
|
---|
115 | $sitemap['parent'][$i]['child'][$j]['url'] = $cat_url.$child['term_id'];
|
---|
116 | $j++;
|
---|
117 | }
|
---|
118 | }
|
---|
119 | $i++;
|
---|
120 | } else {
|
---|
121 | $dipth = 2;
|
---|
122 | $sitemap['parent'][$blog_index]['child'][$i]['id'] = $catid;
|
---|
123 | $sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" . $catid . "'"];
|
---|
124 | $sitemap['parent'][$blog_index]['child'][$i]['image'] = $dipth;
|
---|
125 | $sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$catid;
|
---|
126 | $i++;
|
---|
127 | $parent_id = $blog_index;
|
---|
128 | if($disp_sub){
|
---|
129 | $child_ary = $mytree->getChildTreeArray($catid, '');
|
---|
130 | foreach ($child_ary as $child)
|
---|
131 | {
|
---|
132 | $count = strlen($child['prefix']) + $dipth;
|
---|
133 | $sitemap['parent'][$blog_index]['child'][$i]['id'] = $child['term_id'];
|
---|
134 | $sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" .$child['term_id'] . "'"];
|
---|
135 | $sitemap['parent'][$blog_index]['child'][$i]['image'] = (($count > 3) ? 4 : $count);
|
---|
136 | $sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$child['term_id'];
|
---|
137 | $i++;
|
---|
138 | }
|
---|
139 | }
|
---|
140 | }
|
---|
141 | $i++;
|
---|
142 | }
|
---|
143 | }
|
---|
144 | return $sitemap;
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | if( ! function_exists( 'get_blog_option' ) ) {
|
---|
149 | function get_blog_option($option_table,$option_name){
|
---|
150 | global $xoopsDB;
|
---|
151 |
|
---|
152 | $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'";
|
---|
153 |
|
---|
154 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
155 | if ($xoopsDB->getRowsNum($result) > 0){
|
---|
156 | $row = $xoopsDB->fetchArray($result);
|
---|
157 | return $row['option_value'];
|
---|
158 | }
|
---|
159 | return 0;
|
---|
160 | }
|
---|
161 | }
|
---|
162 |
|
---|
163 |
|
---|
164 | ?> |
---|