Changeset 423
- Timestamp:
- Oct 25, 2009, 8:00:30 PM (15 years ago)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/include/general_functions.php
r417 r423 155 155 } 156 156 157 // Get Prefix from Table name for WordPressMU 158 if (!function_exists('get_multi_prefix')){ 159 function get_multi_prefix($full_table_name,$table_name = ''){ 160 $pattern = '/'. $table_name . '/'; 161 return preg_replace($pattern,'',$full_table_name); 162 } 163 } 157 164 ?> -
branches/XPressMU/xpressme_integration_kit/include/sitemap.plugin.php
r29 r423 17 17 if(!function_exists('_sitemap_xpress')){ 18 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; 19 global $sitemap_configs , $xoopsDB; 32 20 33 21 if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')){ 34 22 return ''; 35 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 } 36 29 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(); 30 $disp_sub =@$sitemap_configs["show_subcategoris"]; 41 31 42 32 $prefix = $mydirname; 43 33 if ($prefix == 'wordpress') $prefix ='wp'; 44 $wp_prefix = $xoopsDB->prefix($prefix); 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'); 45 37 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;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++; 66 58 } 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 } 59 return xpress_get_categoires_map($blogs,$disp_sub); 93 60 } 94 61 } 95 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 } 121 } 122 $i++; 123 } else { 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 } 143 } 144 $i++; 145 } 146 } 147 return $sitemap; 148 } 149 } 150 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 96 167 ?> -
trunk/xpressme_integration_kit/include/general_functions.php
r417 r423 155 155 } 156 156 157 // Get Prefix from Table name for WordPressMU 158 if (!function_exists('get_multi_prefix')){ 159 function get_multi_prefix($full_table_name,$table_name = ''){ 160 $pattern = '/'. $table_name . '/'; 161 return preg_replace($pattern,'',$full_table_name); 162 } 163 } 157 164 ?> -
trunk/xpressme_integration_kit/include/sitemap.plugin.php
r29 r423 17 17 if(!function_exists('_sitemap_xpress')){ 18 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; 19 global $sitemap_configs , $xoopsDB; 32 20 33 21 if (!file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/wp-includes/version.php')){ 34 22 return ''; 35 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 } 36 29 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(); 30 $disp_sub =@$sitemap_configs["show_subcategoris"]; 41 31 42 32 $prefix = $mydirname; 43 33 if ($prefix == 'wordpress') $prefix ='wp'; 44 $wp_prefix = $xoopsDB->prefix($prefix); 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'); 45 37 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;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++; 66 58 } 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 } 59 return xpress_get_categoires_map($blogs,$disp_sub); 93 60 } 94 61 } 95 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 } 121 } 122 $i++; 123 } else { 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 } 143 } 144 $i++; 145 } 146 } 147 return $sitemap; 148 } 149 } 150 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 96 167 ?>
Note: See TracChangeset
for help on using the changeset viewer.