1 | <?php
|
---|
2 | function get_xpress_theme_name($mydirname)
|
---|
3 | {
|
---|
4 | $xoopsDB =& Database::getInstance();
|
---|
5 | $wp_prefix = $mydirname;
|
---|
6 | if ($wp_prefix == 'wordpress') $wp_prefix = 'wp';
|
---|
7 |
|
---|
8 | $module_tbl = $xoopsDB->prefix($wp_prefix).'_options';
|
---|
9 | $theme_name = '';
|
---|
10 |
|
---|
11 | $sql = "SELECT option_value FROM $module_tbl WHERE option_name LIKE 'template'";
|
---|
12 | $result = $xoopsDB->query($sql, 0, 0);
|
---|
13 | if ($xoopsDB->getRowsNum($result) > 0){
|
---|
14 | $row = $xoopsDB->fetchArray($result);
|
---|
15 | $theme_name = $row['option_value'];
|
---|
16 | }
|
---|
17 | return $theme_name;
|
---|
18 | }
|
---|
19 |
|
---|
20 | function get_block_stylesheet_url($mydirname)
|
---|
21 | {
|
---|
22 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
23 | $select_theme = get_xpress_theme_name($mydirname);
|
---|
24 | $style_file = $mydirpath . '/wp-content/themes/' . $select_theme . '/blocks/style.css';
|
---|
25 | if (file_exists($style_file))
|
---|
26 | return XOOPS_URL . '/modules/' .$mydirname . '/wp-content/themes/' . $select_theme . '/blocks/style.css';
|
---|
27 | else
|
---|
28 | return XOOPS_URL . '/modules/' .$mydirname . '/wp-content/themes/xpress_default/blocks/style.css';
|
---|
29 | }
|
---|
30 |
|
---|
31 | function xpress_block_css_set($mydirname = '')
|
---|
32 | {
|
---|
33 | if (empty($mydirname)) $mydirname = $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
34 |
|
---|
35 | $style_url = get_block_stylesheet_url($mydirname);
|
---|
36 |
|
---|
37 | $tplVars =& $GLOBALS['xoopsTpl']->get_template_vars();
|
---|
38 | $csslink = "\n".'<link rel="stylesheet" type="text/css" media="screen" href="'. $style_url .'" />';
|
---|
39 | if(array_key_exists('xoops_block_header', $tplVars)) {
|
---|
40 | if (!strstr($tplVars['xoops_block_header'],$csslink)) {
|
---|
41 | $GLOBALS['xoopsTpl']->assign('xoops_block_header',$tplVars['xoops_block_header'].$csslink);
|
---|
42 | }
|
---|
43 | } else {
|
---|
44 | $GLOBALS['xoopsTpl']->assign('xoops_block_header',$csslink);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | function get_block_file_path($mydirname,$block_name)
|
---|
48 | {
|
---|
49 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
50 | $select_theme = get_xpress_theme_name($mydirname);
|
---|
51 | $block_file = $mydirpath . '/wp-content/themes/' . $select_theme . '/blocks/' . $block_name.'.php';
|
---|
52 |
|
---|
53 | if (!file_exists($block_file))
|
---|
54 | $block_file = XOOPS_ROOT_PATH . '/modules/' .$mydirname . '/wp-content/themes/xpress_default/blocks/' . $block_name .'.php';
|
---|
55 | return $block_file;
|
---|
56 | }
|
---|
57 | ?> |
---|