[136] | 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 |
|
---|
[194] | 14 | if( ! defined( 'XPRESS_WIDGET_BLOCK_INCLUDED' ) ) {
|
---|
| 15 | define( 'XPRESS_WIDGET_BLOCK_INCLUDED' , 1 ) ;
|
---|
[136] | 16 |
|
---|
| 17 | function _b_widget_edit($options)
|
---|
| 18 | {
|
---|
| 19 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
[195] | 20 | $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_widget_block.html' : trim( $options[1] );
|
---|
[136] | 21 | $selected = array_slice($options,2); // get allowed cats
|
---|
[305] | 22 |
|
---|
| 23 | if ($mydirname == 'wordpress'){
|
---|
| 24 | $wp_prefix = 'wp_';
|
---|
| 25 | } else {
|
---|
| 26 | $wp_prefix = $mydirname . '_';
|
---|
| 27 | }
|
---|
| 28 | $xoopsDB =& Database::getInstance();
|
---|
| 29 | $myts =& MyTextSanitizer::getInstance();
|
---|
| 30 |
|
---|
| 31 | $db_xpress_options = $xoopsDB->prefix($wp_prefix . 'options');
|
---|
| 32 | $query = "SELECT option_value FROM $db_xpress_options WHERE option_name = 'sidebars_widgets' LIMIT 1";
|
---|
| 33 | $res = $xoopsDB->query($query, 0, 0);
|
---|
| 34 | if ($res !== false){
|
---|
| 35 | $row = $xoopsDB->fetchArray($res);
|
---|
| 36 | $sidebars_widgets = @unserialize( $row['option_value'] );
|
---|
| 37 | }
|
---|
| 38 | if ( !isset($sidebars_widgets['array_version']) )
|
---|
| 39 | $sidebars_widgets['array_version'] = 1;
|
---|
[136] | 40 |
|
---|
| 41 |
|
---|
| 42 | require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
|
---|
| 43 |
|
---|
| 44 | $form = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
|
---|
| 45 | $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
|
---|
| 46 | $form .= "<br />";
|
---|
[183] | 47 | $form .= _MB_XP2_SELECT_WIDGET .":<br />\n";
|
---|
[305] | 48 | $select = " <select name='options[]' multiple=\"multiple\">\n";
|
---|
| 49 | $found = false;
|
---|
| 50 | foreach ( (array) $sidebars_widgets as $index => $sidebar ){
|
---|
| 51 | if ( is_array($sidebar) ){
|
---|
| 52 | $sidebar_id = $index;
|
---|
| 53 | foreach ( (array) $sidebar as $i => $name ) {
|
---|
| 54 | $found = true;
|
---|
| 55 | $widget = strtolower($name);
|
---|
| 56 | $widget_str = $sidebar_id . '::' . $widget;
|
---|
| 57 | if (in_array($widget_str, $selected))
|
---|
[324] | 58 | $select .= "<option value='" . $widget_str . "' selected='selected'>" . $widget_str;
|
---|
[305] | 59 | else
|
---|
[324] | 60 | $select .= "<option value='" . $widget_str . "'>" . $widget_str;
|
---|
[305] | 61 |
|
---|
| 62 | }
|
---|
[136] | 63 | }
|
---|
| 64 | }
|
---|
[305] | 65 |
|
---|
| 66 | $select .= "</select><br/>\n";
|
---|
| 67 | if ($found){
|
---|
| 68 | $form = $form . $select;
|
---|
| 69 | } else {
|
---|
| 70 | $form = $form . " " . _MB_XP2_NO_WIDGET;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
[136] | 73 | return $form;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | function _b_widget_show($options)
|
---|
| 77 | {
|
---|
| 78 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
| 79 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
| 80 | $block_function_name = basename( __FILE__ );
|
---|
| 81 |
|
---|
| 82 | require_once $mydirpath.'/include/xpress_block_render.php';
|
---|
| 83 | return xpress_block_render($mydirname,$block_function_name,$options);
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | ?> |
---|