- Timestamp:
- Jun 22, 2009, 12:59:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver2.0/xpressme_integration_kit/blocks/widget_block.php
r295 r303 20 20 $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_widget_block.html' : trim( $options[1] ); 21 21 $selected = array_slice($options,2); // get allowed cats 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; 22 40 23 global $table_prefix,$wpdb,$xoops_db;24 global $wp_registered_sidebars, $wp_registered_widgets;25 41 26 42 require_once(XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/blocks/block_common.php'); … … 31 47 $form .= _MB_XP2_SELECT_WIDGET .":<br />\n"; 32 48 $form .= " <select name='options[]' multiple=\"multiple\">\n"; 33 $sidebars_widgets = wp_get_sidebars_widgets(); 34 foreach($wp_registered_sidebars as $sidebar){ 35 $sidebar_id = $sidebar['id']; 36 $widgets = $sidebars_widgets[$sidebar_id]; 37 foreach($widgets as $widget){ 38 if (empty($wp_registered_widgets[$widget])) continue; 39 $widget_str = $sidebar_id . '::' . $widget; 40 if (in_array($widget_str, $selected)) 41 $form .= "<option value='" . $widget_str . "' selected='selected'>" . $widget_str; 42 else 43 $form .= "<option value='" . $widget_str . "'>" . $widget_str; 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 } 44 61 } 45 62 } 63 46 64 $form .= "</select><br/>\n"; 47 65 return $form; … … 57 75 return xpress_block_render($mydirname,$block_function_name,$options); 58 76 } 59 60 function sidebar_select($wp_registered_sidebars,$option_name,$option_value)61 {62 63 }64 65 77 } 66 67 78 ?>
Note: See TracChangeset
for help on using the changeset viewer.