| 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; | 
|---|
| 65 |  | 
|---|
| 66 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); | 
|---|
| 67 |  | 
|---|
| 68 | $sitemap = array(); | 
|---|
| 69 | $myts =& MyTextSanitizer::getInstance(); | 
|---|
| 70 |  | 
|---|
| 71 | $blogs_count = count($blogs); | 
|---|
| 72 | $i = 0; | 
|---|
| 73 | $blog = array(); | 
|---|
| 74 | for ($b_no = 0 ; $b_no < $blogs_count ; $b_no++){ | 
|---|
| 75 | $blog = $blogs[$b_no]; | 
|---|
| 76 | $terms = $blog['terms']; | 
|---|
| 77 | $term_taxonomy = $blog['term_taxonomy']; | 
|---|
| 78 | $blog_sub_url = $blog['blog_sub_url']; | 
|---|
| 79 | $cat_url = $blog['blog_sub_url'] . '?cat='; | 
|---|
| 80 | $blog_name = $blog['blog_name']; | 
|---|
| 81 |  | 
|---|
| 82 | $sql  = "SELECT term_id , name FROM $terms"; | 
|---|
| 83 | $result = $xoopsDB->query($sql); | 
|---|
| 84 | $cat_name = array(); | 
|---|
| 85 | while (list($id, $name) = $xoopsDB->fetchRow($result)){ | 
|---|
| 86 | $cat_name["'ID" . $id . "'"] = $name; | 
|---|
| 87 | } | 
|---|
| 88 | if ($blogs_count > 1){ | 
|---|
| 89 | $sitemap['parent'][$i]['id'] = 0; | 
|---|
| 90 | $sitemap['parent'][$i]['title'] = $blog_name ; | 
|---|
| 91 | $sitemap['parent'][$i]['image'] = 1 ; | 
|---|
| 92 | $sitemap['parent'][$i]['url'] = $blog_sub_url; | 
|---|
| 93 | $blog_index = $i; | 
|---|
| 94 | $i++; | 
|---|
| 95 | } | 
|---|
| 96 |  | 
|---|
| 97 | $mytree = new XoopsTree($term_taxonomy, 'term_id' , 'parent'); | 
|---|
| 98 | $sql  = "SELECT term_id  FROM $term_taxonomy WHERE parent = 0 AND taxonomy = 'category'"; | 
|---|
| 99 | $result = $xoopsDB->query($sql); | 
|---|
| 100 | while (list($catid) = $xoopsDB->fetchRow($result)){ | 
|---|
| 101 | if ($blogs_count <= 1){ | 
|---|
| 102 | $dipth = 1; | 
|---|
| 103 | $sitemap['parent'][$i]['id'] = $catid; | 
|---|
| 104 | $sitemap['parent'][$i]['title'] = $cat_name["'ID" . $catid . "'"] ; ; | 
|---|
| 105 | $sitemap['parent'][$i]['image'] = $dipth ; | 
|---|
| 106 | $sitemap['parent'][$i]['url'] = $cat_url.$catid; | 
|---|
| 107 |  | 
|---|
| 108 | if($disp_sub){ | 
|---|
| 109 | $j = 0; | 
|---|
| 110 | $child_ary = $mytree->getChildTreeArray($catid, ''); | 
|---|
| 111 | foreach ($child_ary as $child) | 
|---|
| 112 | { | 
|---|
| 113 | $count = strlen($child['prefix']) + $dipth; | 
|---|
| 114 | $sitemap['parent'][$i]['child'][$j]['id'] = $child['term_id']; | 
|---|
| 115 | $sitemap['parent'][$i]['child'][$j]['title'] = $cat_name["'ID" .$child['term_id'] . "'"]; | 
|---|
| 116 | $sitemap['parent'][$i]['child'][$j]['image'] = (($count > 3) ? 4 : $count); | 
|---|
| 117 | $sitemap['parent'][$i]['child'][$j]['url'] = $cat_url.$child['term_id']; | 
|---|
| 118 | $j++; | 
|---|
| 119 | } | 
|---|
| 120 | } | 
|---|
| 121 | $i++; | 
|---|
| 122 | } else { | 
|---|
| 123 | $dipth = 2; | 
|---|
| 124 | $sitemap['parent'][$blog_index]['child'][$i]['id'] = $catid; | 
|---|
| 125 | $sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" . $catid . "'"]; | 
|---|
| 126 | $sitemap['parent'][$blog_index]['child'][$i]['image'] = $dipth; | 
|---|
| 127 | $sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$catid; | 
|---|
| 128 | $i++; | 
|---|
| 129 | $parent_id = $blog_index; | 
|---|
| 130 | if($disp_sub){ | 
|---|
| 131 | $child_ary = $mytree->getChildTreeArray($catid, ''); | 
|---|
| 132 | foreach ($child_ary as $child) | 
|---|
| 133 | { | 
|---|
| 134 | $count = strlen($child['prefix']) + $dipth; | 
|---|
| 135 | $sitemap['parent'][$blog_index]['child'][$i]['id'] = $child['term_id']; | 
|---|
| 136 | $sitemap['parent'][$blog_index]['child'][$i]['title'] = $cat_name["'ID" .$child['term_id'] . "'"]; | 
|---|
| 137 | $sitemap['parent'][$blog_index]['child'][$i]['image'] = (($count > 3) ? 4 : $count); | 
|---|
| 138 | $sitemap['parent'][$blog_index]['child'][$i]['url'] = $cat_url.$child['term_id']; | 
|---|
| 139 | $i++; | 
|---|
| 140 | } | 
|---|
| 141 | } | 
|---|
| 142 | } | 
|---|
| 143 | $i++; | 
|---|
| 144 | } | 
|---|
| 145 | } | 
|---|
| 146 | return $sitemap; | 
|---|
| 147 | } | 
|---|
| 148 | } | 
|---|
| 149 |  | 
|---|
| 150 | if( ! function_exists( 'get_blog_option' ) ) { | 
|---|
| 151 | function get_blog_option($option_table,$option_name){ | 
|---|
| 152 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); | 
|---|
| 153 |  | 
|---|
| 154 | $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'"; | 
|---|
| 155 |  | 
|---|
| 156 | $result =  $xoopsDB->query($sql, 0, 0); | 
|---|
| 157 | if ($xoopsDB->getRowsNum($result)  > 0){ | 
|---|
| 158 | $row = $xoopsDB->fetchArray($result); | 
|---|
| 159 | return $row['option_value']; | 
|---|
| 160 | } | 
|---|
| 161 | return 0; | 
|---|
| 162 | } | 
|---|
| 163 | } | 
|---|
| 164 |  | 
|---|
| 165 |  | 
|---|
| 166 | ?> | 
|---|