Changeset 305 for trunk/xpressme_integration_kit/blocks/widget_block.php
- Timestamp:
- Jun 22, 2009, 1:30:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/blocks/widget_block.php
r299 r305 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'); … … 30 46 $form .= "<br />"; 31 47 $form .= _MB_XP2_SELECT_WIDGET .":<br />\n"; 32 $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; 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)) 58 $$select .= "<option value='" . $widget_str . "' selected='selected'>" . $widget_str; 59 else 60 $$select .= "<option value='" . $widget_str . "'>" . $widget_str; 61 62 } 44 63 } 45 64 } 46 $form .= "</select><br/>\n"; 65 66 $select .= "</select><br/>\n"; 67 if ($found){ 68 $form = $form . $select; 69 } else { 70 $form = $form . " " . _MB_XP2_NO_WIDGET; 71 } 72 47 73 return $form; 48 74 } … … 57 83 return xpress_block_render($mydirname,$block_function_name,$options); 58 84 } 59 60 function sidebar_select($wp_registered_sidebars,$option_name,$option_value)61 {62 63 }64 65 85 } 66 67 86 ?>
Note: See TracChangeset
for help on using the changeset viewer.