[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
|
---|
[303] | 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";
|
---|
[136] | 48 | $form .= " <select name='options[]' multiple=\"multiple\">\n";
|
---|
[303] | 49 | foreach ( (array) $sidebars_widgets as $index => $sidebar ){
|
---|
| 50 | if ( is_array($sidebar) ){
|
---|
| 51 | $sidebar_id = $index;
|
---|
| 52 | foreach ( (array) $sidebar as $i => $name ) {
|
---|
| 53 | $widget = strtolower($name);
|
---|
| 54 | $widget_str = $sidebar_id . '::' . $widget;
|
---|
| 55 | if (in_array($widget_str, $selected))
|
---|
| 56 | $form .= "<option value='" . $widget_str . "' selected='selected'>" . $widget_str;
|
---|
| 57 | else
|
---|
| 58 | $form .= "<option value='" . $widget_str . "'>" . $widget_str;
|
---|
| 59 |
|
---|
| 60 | }
|
---|
[136] | 61 | }
|
---|
| 62 | }
|
---|
[303] | 63 |
|
---|
[136] | 64 | $form .= "</select><br/>\n";
|
---|
| 65 | return $form;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | function _b_widget_show($options)
|
---|
| 69 | {
|
---|
| 70 | $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
|
---|
| 71 | $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
|
---|
| 72 | $block_function_name = basename( __FILE__ );
|
---|
| 73 |
|
---|
| 74 | require_once $mydirpath.'/include/xpress_block_render.php';
|
---|
| 75 | return xpress_block_render($mydirname,$block_function_name,$options);
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | ?> |
---|