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