XPressME Integration Kit

Trac


Ignore:
Timestamp:
Dec 26, 2008, 12:15:54 AM (15 years ago)
Author:
toemon
Message:

WordPress管理画面からXOOPSデータベースへのアクセス  #50 実装

xpressmeプラグインにより
XOOPS管理外(WordPress管理下)から$xoops_db(wpdbクラス)にてアクセス可能にしました。

コメントブロックのキャッシュへの書き込みを、WordPressのイベント(変更・追加・削除)へ書き込むよにしました。

このためコメントブロックのshow_function側からはキャッシュへの書き込みを削除してあります。

  

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/xpressme/include/custom_functions.php

    r33 r46  
    133133                echo $ret;       
    134134} 
     135function xpress_substr($str, $start, $length, $trimmarker = '...') 
     136{ 
     137    if (function_exists('mb_substr')){ 
     138        $str2 = mb_substr( $str , $start , $length); 
     139        return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' ); 
     140    } else { 
     141        return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker; 
     142    } 
     143} 
     144// xoops db 
     145function get_xpress_dir_path() 
     146{ 
     147        return ABSPATH; 
     148} 
     149 
     150function get_xpress_dir_name() 
     151{ 
     152        return basename(ABSPATH); 
     153} 
     154 
     155function get_wp_prefix_only() 
     156{ 
     157        $dir_name = get_xpress_dir_name(); 
     158        $prefix = $dir_name; 
     159        if ($prefix == 'wordpress') $prefix = 'wp'; 
     160         
     161        $prefix = $prefix . '_'; 
     162        return $prefix; 
     163} 
     164 
     165function get_xoops_prefix() 
     166{ 
     167        global $wpdb; 
     168         
     169        $prefix = $wpdb->prefix; 
     170        $ret = str_replace(get_wp_prefix_only(),'',$prefix); 
     171        return $ret; 
     172} 
     173 
     174function get_xpress_modid() 
     175{ 
     176        global $xoops_db; 
     177         
     178        $modulename = get_xpress_dir_name();     
     179        $sql = "SELECT mid FROM " . get_xoops_prefix() . "modules WHERE dirname = '$modulename'"; 
     180        $mid = $xoops_db->get_var($sql); 
     181        return $mid;     
     182} 
     183 
     184function block_cache_refresh() 
     185{ 
     186        global $xoops_db; 
     187        $mid = get_xpress_modid(); 
     188        $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid"; 
     189        $blocks = $xoops_db->get_results($sql); 
     190        $mydirname = get_xpress_dir_name(); 
     191        require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; 
     192 
     193 
     194        foreach($blocks as $block){ 
     195                $func_file = $block->func_file; 
     196                $call_theme_function_name = str_replace(".php", "", $func_file); 
     197                $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php'; 
     198                $cache_title = str_replace(".php", "", $func_file); 
     199                $blockID = $block->bid; 
     200                $options = explode("|", $block->options); 
     201                                         
     202                $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); 
     203                require_once $block_theme_file; 
     204                $block_render = $call_theme_function_name($options);            //The block name and the called function name should be assumed to be the same name.                     
     205                xpress_block_cache_write($mydirname,$cache_title. $blockID, $block_render); 
     206        } 
     207} 
     208 
    135209?> 
Note: See TracChangeset for help on using the changeset viewer.