1 | <?php
|
---|
2 | if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
|
---|
3 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
4 |
|
---|
5 | eval( '
|
---|
6 | function b_'.$mydirname.'_widget_show($options){
|
---|
7 | return _b_widget_show($options) ;
|
---|
8 | }
|
---|
9 | function b_'.$mydirname.'_widget_edit($options){
|
---|
10 | return _b_widget_edit($options) ;
|
---|
11 | }
|
---|
12 | ' ) ;
|
---|
13 |
|
---|
14 | if( ! defined( 'XPRESS_WIDGET_BLOCK_INCLUDED' ) ) {
|
---|
15 | define( 'XPRESS_WIDGET_BLOCK_INCLUDED' , 1 ) ;
|
---|
16 |
|
---|
17 | function _b_widget_edit($options)
|
---|
18 | {
|
---|
19 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
20 | $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_widget_block.html' : trim( $options[1] );
|
---|
21 | $title_show = empty( $options[2] ) ? false : true ;
|
---|
22 | $widget_select = empty( $options[3] ) ? '' : $options[3] ;
|
---|
23 |
|
---|
24 | $selected = explode(',' , $widget_select);
|
---|
25 | $wp_prefix = preg_replace('/wordpress/','wp',$mydirname) . '_';
|
---|
26 | $xoopsDB =& Database::getInstance();
|
---|
27 | $myts =& MyTextSanitizer::getInstance();
|
---|
28 |
|
---|
29 | $db_xpress_options = $xoopsDB->prefix($wp_prefix . 'options');
|
---|
30 | $query = "SELECT option_value FROM $db_xpress_options WHERE option_name = 'sidebars_widgets' LIMIT 1";
|
---|
31 | $res = $xoopsDB->query($query, 0, 0);
|
---|
32 | if ($res !== false){
|
---|
33 | $row = $xoopsDB->fetchArray($res);
|
---|
34 | $sidebars_widgets = @unserialize( $row['option_value'] );
|
---|
35 | }
|
---|
36 | if ( !isset($sidebars_widgets['array_version']) )
|
---|
37 | $sidebars_widgets['array_version'] = 1;
|
---|
38 |
|
---|
39 |
|
---|
40 | require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
|
---|
41 |
|
---|
42 | $form = javascript_check();
|
---|
43 | $form .= "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n";
|
---|
44 | $form .= block_template_setting($mydirname,'options[1]',htmlspecialchars($this_template,ENT_QUOTES));
|
---|
45 | $form .= "<br />" . yes_no_radio_option('options[2]', _MB_XP2_WIDGET_TITLE_SHOW , $title_show);
|
---|
46 | $form .= "<br />";
|
---|
47 | $form .= _MB_XP2_SELECT_WIDGET .":<br />\n";
|
---|
48 | $form .= "<input type='hidden' name='options[3]' value='$widget_select' />\n";
|
---|
49 |
|
---|
50 | $select = " <select name='widget_sel' multiple=\"multiple\" onclick=\"WidgetSelect()\">\n";
|
---|
51 | $found = false;
|
---|
52 | foreach ( (array) $sidebars_widgets as $index => $sidebar ){
|
---|
53 | if ( is_array($sidebar) ){
|
---|
54 | $sidebar_id = $index;
|
---|
55 | foreach ( (array) $sidebar as $i => $name ) {
|
---|
56 | $found = true;
|
---|
57 | $widget = strtolower($name);
|
---|
58 | $widget_str = $sidebar_id . '::' . $widget;
|
---|
59 | if (in_array($widget_str, $selected))
|
---|
60 | $select .= "<option value='" . $widget_str . "' selected='selected'>" . $widget_str;
|
---|
61 | else
|
---|
62 | $select .= "<option value='" . $widget_str . "'>" . $widget_str;
|
---|
63 |
|
---|
64 | }
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | $select .= "</select><br/>\n";
|
---|
69 | $select .= '
|
---|
70 | <script type="text/javascript">
|
---|
71 | function WidgetSelect(){
|
---|
72 | var idx=new Array();
|
---|
73 | var sel=document.forms["blockform"].elements["widget_sel"].options;
|
---|
74 | for(var i=0, n=0; i<sel.length; i++){
|
---|
75 | if(sel[i].selected){ idx[n++]=sel[i].value; }
|
---|
76 | }
|
---|
77 | if(idx.length>0){
|
---|
78 | document.forms["blockform"].elements["options[3]"].value = idx;
|
---|
79 | }
|
---|
80 | }
|
---|
81 | </script>
|
---|
82 | ';
|
---|
83 |
|
---|
84 | if ($found){
|
---|
85 | $form = $form . $select;
|
---|
86 | } else {
|
---|
87 | $form = $form . " " . _MB_XP2_NO_WIDGET;
|
---|
88 | }
|
---|
89 |
|
---|
90 | return $form;
|
---|
91 | }
|
---|
92 |
|
---|
93 | function _b_widget_show($options)
|
---|
94 | {
|
---|
95 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
96 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
97 | $block_function_name = basename( __FILE__ );
|
---|
98 |
|
---|
99 | require_once $mydirpath.'/include/xpress_block_render.php';
|
---|
100 | return xpress_block_render($mydirname,$block_function_name,$options);
|
---|
101 | }
|
---|
102 | }
|
---|
103 | ?> |
---|