| [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 |  | 
|---|
| [583] | 32 | $prefix = preg_replace('/wordpress/','wp',$mydirname); | 
|---|
| [423] | 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'); | 
|---|
| [29] | 36 |  | 
|---|
| [423] | 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++; | 
|---|
| [29] | 57 | } | 
|---|
| [423] | 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 |  | 
|---|
| [835] | 66 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); | 
|---|
| [423] | 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 | } | 
|---|
| [29] | 120 | } | 
|---|
| [423] | 121 | $i++; | 
|---|
| [29] | 122 | } else { | 
|---|
| [423] | 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 | } | 
|---|
| [29] | 142 | } | 
|---|
| [423] | 143 | $i++; | 
|---|
| [29] | 144 | } | 
|---|
| [423] | 145 | } | 
|---|
|  | 146 | return $sitemap; | 
|---|
| [29] | 147 | } | 
|---|
|  | 148 | } | 
|---|
|  | 149 |  | 
|---|
| [423] | 150 | if( ! function_exists( 'get_blog_option' ) ) { | 
|---|
|  | 151 | function get_blog_option($option_table,$option_name){ | 
|---|
| [835] | 152 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); | 
|---|
| [423] | 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 |  | 
|---|
| [29] | 166 | ?> | 
|---|