Index: trunk/include/xpress_block_theme.php
===================================================================
--- trunk/include/xpress_block_theme.php	(revision 38)
+++ trunk/include/xpress_block_theme.php	(revision 38)
@@ -0,0 +1,57 @@
+<?php
+function get_xpress_theme_name($mydirname)
+{
+	$xoopsDB =& Database::getInstance();
+	$wp_prefix = $mydirname;
+	if ($wp_prefix == 'wordpress') $wp_prefix = 'wp';
+
+	$module_tbl = $xoopsDB->prefix($wp_prefix).'_options';	
+	$theme_name = '';	
+
+	$sql = "SELECT option_value FROM $module_tbl WHERE option_name LIKE 'template'";
+	$result =  $xoopsDB->query($sql, 0, 0);
+	if ($xoopsDB->getRowsNum($result)  > 0){
+		$row = $xoopsDB->fetchArray($result);
+		$theme_name = $row['option_value'];
+	}
+	return $theme_name;
+}
+
+function get_block_stylesheet_url($mydirname)
+{
+	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+	$select_theme = get_xpress_theme_name($mydirname);
+	$style_file = $mydirpath . '/wp-content/themes/' . $select_theme . '/blocks/style.css';
+	if (file_exists($style_file))
+		return XOOPS_URL . '/modules/' .$mydirname . '/wp-content/themes/' . $select_theme . '/blocks/style.css';
+	else	
+		return XOOPS_URL . '/modules/' .$mydirname . '/wp-content/themes/xpress_default/blocks/style.css';
+}
+
+function xpress_block_css_set($mydirname = '')
+{
+	if (empty($mydirname)) $mydirname = $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
+
+	$style_url =  get_block_stylesheet_url($mydirname);
+	  
+	$tplVars =& $GLOBALS['xoopsTpl']->get_template_vars();
+	$csslink = "\n".'<link rel="stylesheet" type="text/css" media="screen" href="'. $style_url .'" />';
+		if(array_key_exists('xoops_block_header', $tplVars)) {
+			if (!strstr($tplVars['xoops_block_header'],$csslink)) {
+				$GLOBALS['xoopsTpl']->assign('xoops_block_header',$tplVars['xoops_block_header'].$csslink);
+			}
+		} else {
+			$GLOBALS['xoopsTpl']->assign('xoops_block_header',$csslink);
+		}
+}
+function get_block_file_path($mydirname,$block_name)
+{
+	$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
+	$select_theme = get_xpress_theme_name($mydirname);
+	$block_file = $mydirpath . '/wp-content/themes/' . $select_theme . '/blocks/' . $block_name.'.php';
+
+	if (!file_exists($block_file))
+		$block_file =  XOOPS_ROOT_PATH . '/modules/' .$mydirname . '/wp-content/themes/xpress_default/blocks/' . $block_name .'.php';
+	return $block_file;
+}
+?>
Index: trunk/include/xpress_chache.php
===================================================================
--- trunk/include/xpress_chache.php	(revision 37)
+++ 	(revision )
@@ -1,49 +1,0 @@
-<?php
-	
-if(!function_exists("xpress_block_cache_set")):
-    function xpress_block_cache_set($mydirname,$collation_key)
-    {
-		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
-		$cache_time = 0;
-        $filename = $cache_dir .$mydirname . '_' . $collation_key;
-        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {
-            return file_get_contents($filename);
-        } else {
-			return '';
-		}
-    } 
-endif;
-
-if(!function_exists("xpress_cache_make")):
-    function xpress_cache_make($mydirname,$collation_key,$content)
-    {
-		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
-		$cache_time = 0;
-
-        $filename = $cache_dir .$mydirname . '_' . $collation_key;
-        if ((time() - @filemtime($filename)) > $cache_time) {
-            $fp = fopen($filename, "w");
-            flock($fp, 2);
-            fputs($fp, $content);
-            fclose($fp);
-        } 
-    } 
-endif;
-
-if(!function_exists("xpress_block_cache_clear")):
-    function xpress_cache_clear($mydirname)
-    {
-		$cache_dir = XOOPS_ROOT_PATH . '/cache/';
-		$cache_time = 0;
-        if ($dh = opendir($cache_dir)) {
-            while (($file = readdir($dh)) !== false) {
-                if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) {
-                    unlink($cache_dir.$file);
-                } 
-            } 
-            closedir($dh);
-        } 
-    } 
-endif;
-
-?>
