[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] );
|
---|
[339] | 21 | $title_show = empty( $options[2] ) ? false : true ;
|
---|
| 22 | $selected = array_slice($options,3); // get allowed cats
|
---|
[305] | 23 |
|
---|
| 24 | if ($mydirname == 'wordpress'){
|
---|
| 25 | $wp_prefix = 'wp_';
|
---|
| 26 | } else {
|
---|
| 27 | $wp_prefix = $mydirname . '_';
|
---|
| 28 | }
|
---|
| 29 | $xoopsDB =& Database::getInstance();
|
---|
| 30 | $myts =& MyTextSanitizer::getInstance();
|
---|
| 31 |
|
---|
| 32 | $db_xpress_options = $xoopsDB->prefix($wp_prefix . 'options');
|
---|
| 33 | $query = "SELECT option_value FROM $db_xpress_options WHERE option_name = 'sidebars_widgets' LIMIT 1";
|
---|
| 34 | $res = $xoopsDB->query($query, 0, 0);
|
---|
| 35 | if ($res !== false){
|
---|
| 36 | $row = $xoopsDB->fetchArray($res);
|
---|
| 37 | $sidebars_widgets = @unserialize( $row['option_value'] );
|
---|
| 38 | }
|
---|
| 39 | if ( !isset($sidebars_widgets['array_version']) )
|
---|
| 40 | $sidebars_widgets['array_version'] = 1;
|
---|
[136] | 41 |
|
---|
| 42 |
|
---|
| 43 | require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php');
|
---|
| 44 |
|
---|
| 45 | $form = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />";
|
---|
| 46 | $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />";
|
---|
[339] | 47 | $form .= "<br />" . yes_no_radio_option('options[2]', _MB_XP2_WIDGET_TITLE_SHOW , $title_show);
|
---|
[136] | 48 | $form .= "<br />";
|
---|
[183] | 49 | $form .= _MB_XP2_SELECT_WIDGET .":<br />\n";
|
---|
[305] | 50 | $select = " <select name='options[]' multiple=\"multiple\">\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))
|
---|
[324] | 60 | $select .= "<option value='" . $widget_str . "' selected='selected'>" . $widget_str;
|
---|
[305] | 61 | else
|
---|
[324] | 62 | $select .= "<option value='" . $widget_str . "'>" . $widget_str;
|
---|
[305] | 63 |
|
---|
| 64 | }
|
---|
[136] | 65 | }
|
---|
| 66 | }
|
---|
[305] | 67 |
|
---|
| 68 | $select .= "</select><br/>\n";
|
---|
| 69 | if ($found){
|
---|
| 70 | $form = $form . $select;
|
---|
| 71 | } else {
|
---|
| 72 | $form = $form . " " . _MB_XP2_NO_WIDGET;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[136] | 75 | return $form;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | function _b_widget_show($options)
|
---|
| 79 | {
|
---|
| 80 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
| 81 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
| 82 | $block_function_name = basename( __FILE__ );
|
---|
| 83 |
|
---|
| 84 | require_once $mydirpath.'/include/xpress_block_render.php';
|
---|
| 85 | return xpress_block_render($mydirname,$block_function_name,$options);
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | ?> |
---|