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