introspect($bag); $name = htmlspecialchars($bag->get('name')); $desc = htmlspecialchars($bag->get('description')); $desc .= '' . VERSION . ': ' . $bag->get('version') . ''; $title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']'); if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) { $can_configure = true; } else { $can_configure = false; } } if ($opts === null) { $opts = array( 'left' => LEFT, 'right' => RIGHT, 'hide' => HIDDEN ); } $event_opts = array( 'event' => PLUGIN_ACTIVE, 'eventh' => PLUGIN_INACTIVE, ); if ($event_only) { $gopts = $event_opts; } else { $gopts = $opts; } $data['placement'][$plugin_placement]['plugin_data'][$i]['sort_idx'] = $sort_idx; $data['placement'][$plugin_placement]['plugin_data'][$i]['css_key'] = $css_key; $data['placement'][$plugin_placement]['plugin_data'][$i]['is_plugin_editable'] = $is_plugin_editable; $data['placement'][$plugin_placement]['plugin_data'][$i]['is_plugin_owner'] = $is_plugin_owner; $data['placement'][$plugin_placement]['plugin_data'][$i]['name'] = $plugin_data['name']; $data['placement'][$plugin_placement]['plugin_data'][$i]['authorid'] = $plugin_data['authorid']; $data['placement'][$plugin_placement]['plugin_data'][$i]['can_configure'] = $can_configure; $data['placement'][$plugin_placement]['plugin_data'][$i]['key'] = $key; $data['placement'][$plugin_placement]['plugin_data'][$i]['title'] = $title; $data['placement'][$plugin_placement]['plugin_data'][$i]['desc'] = $desc; $data['placement'][$plugin_placement]['plugin_data'][$i]['placement'] = $plugin_data['placement']; $data['placement'][$plugin_placement]['plugin_data'][$i]['gopts'] = $gopts; $sort_idx++; } } $data['total'] = $i; return serendipity_smarty_show('admin/show_plugins.fnc.tpl', $data); } /** * Show the plugin configuration * * @access public * @param object A plugin object * @param object The plugins property bag object * @param string The name of the plugin * @param string The description of the plugin * @param array The property bag 'configuration' array, holding the array of config items. * @param boolean Shows the surrounding HTML table? * @param boolean Shows the FORM submit button? * @param boolean Shows a plugin's "example" method output? * @param boolean Spawn a plugins' configuration WYSIWYG items? * @param string The array index name of POSTed values ($serendipity['POST'][xxx]) * @param array An array that groups certain config keys * @return string The configuration HTML */ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_names, $showTable = true, $showSubmit = true, $showExample = true, $spawnNuggets = true, $postKey = 'plugin', $config_groups = NULL) { global $serendipity; if (empty($config_names)) { return false; } $tfile = "/admin/plugin_config_item.tpl"; $data = array(); if ($showSubmit && $postKey != 'plugin') { $data['showSubmit_head'] = true; } if ($showTable) { $data['showTable'] = true; } $elcount = 0; $htmlnugget = array(); $plugin_options = array(); $data['config_names'] = $config_names; foreach ($config_names as $config_item) { $elcount++; $cbag = new serendipity_property_bag; $plugin->introspect_config_item($config_item, $cbag); $data['cname'] = $cname = htmlspecialchars($cbag->get('name')); $data['cdesc'] = $cdesc = htmlspecialchars($cbag->get('description')); $value = $plugin->get_config($config_item, 'unset'); $lang_direction = htmlspecialchars($cbag->get('lang_direction')); if (empty($lang_direction)) { $lang_direction = LANG_DIRECTION; } $data['lang_direction'] = $lang_direction; /* Apparently no value was set for this config item */ if ($value === 'unset') { /* Try and the default value for the config item */ $value = $cbag->get('default'); /* Still, we don't have a value, try and get (bool)false - from an old plugin */ if ($value === '') { $value = $plugin->get_config($config_item, false, true); } } if (isset($_POST['serendipity'][$postkey][$config_item])) { if (is_array($_POST['serendipity'][$postkey][$config_item])) { $hvalue = $_POST['serendipity'][$postkey][$config_item]; array_walk($hvalue, 'htmlspecialchars'); } else { $hvalue = htmlspecialchars($_POST['serendipity'][$postkey][$config_item]); } } else { $hvalue = htmlspecialchars($value); } $radio = array(); $select = array(); $per_row = null; $text_rows = null; $input_type = null; $data['is_multi_select'] = $is_multi_select = false; $data['ctype'] = $ctype = $cbag->get('type'); $data['elcount'] = $elcount; $data['hvalue'] = $hvalue; $data['postKey'] = $postKey; $data['config_item'] = $config_item; switch ($ctype) { case 'seperator': $data['ctype'] = 'seperator'; $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'multiselect': $data['ctype'] = 'multiselect'; $data['is_multi_select'] = $is_multi_select = true; case 'select': $data['ctype'] = 'select'; if (is_array($hvalue)) { $selected_options = $hvalue; } elseif ($is_multi_select) { $selected_options = explode('^', $hvalue); } else { $selected_options = array($hvalue => $hvalue); } $data['selected_options'] = $selected_options; $data['pre_selected'] = $pre_selected = (array)$cbag->get('select_preselected'); $data['select_size'] = $select_size = $cbag->get('select_size'); $data['select'] = $select = $cbag->get('select_values'); $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'tristate': $data['ctype'] = 'tristate'; $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $data['ctype'] = 'boolean'; $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case 'radio': $data['ctype'] = 'radio'; if (!count($radio) > 0) { $radio = $cbag->get('radio'); } if (empty($per_row)) { $per_row = $cbag->get('radio_per_row'); if (empty($per_row)) { $per_row = 2; } } $data['per_row'] = $per_row; $data['radio_button'] = array(); $counter = 0; foreach($radio['value'] AS $radio_index => $radio_value) { $id = htmlspecialchars($config_item . $radio_value); $counter++; $checked = ""; if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) { $checked = " checked"; } elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue === 'false')) { $checked = " checked"; } elseif ($radio_value == $hvalue) { $checked = " checked"; } $data['radio_button'][$radio_index]['id'] = $id; $data['radio_button'][$radio_index]['checked'] = $checked; $data['radio_button'][$radio_index]['counter'] = $counter; $data['radio_button'][$radio_index]['value'] = $radio_value; $data['radio_button'][$radio_index]['index'] = htmlspecialchars($radio['desc'][$radio_index]); } $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'string': $data['ctype'] = 'string'; if (empty($input_type)) { $input_type = $cbag->get('input_type'); if (empty($input_type)) { $input_type = "text"; } } $data['input_type'] = $input_type; $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'html': $data['ctype'] = 'html'; case 'text': $data['ctype'] = 'text'; if (empty($text_rows)) { $text_rows = $cbag->get('rows'); if (empty($text_rows)) { $text_rows = 20; } } $data['text_rows'] = $text_rows; if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; if (!function_exists('serendipity_emit_htmlarea_code')) { @include_once dirname(__FILE__) . '/functions_entries_admin.inc.php'; } serendipity_emit_htmlarea_code("nuggets{$elcount}", 'nuggets', true); } $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'content': $data['ctype'] = 'content'; $data['cbag_default'] = $cbag->get('default'); $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'custom': $data['ctype'] = 'custom'; $data['cbag_custom'] = $cbag->get('custom'); $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'hidden': $data['ctype'] = 'hidden'; $data['cbag_value'] = $cbag->get('value'); $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'media': $data['ctype'] = 'media'; // Print the HTML to display the popup media selector $preview_width = $cbag->get('preview_width'); if (!$preview_width || $preview_width == "") { $preview_width = '400px'; } $preview_height = $cbag->get('preview_height'); if (!$preview_height || $preview_height == "") { $preview_height = '100px'; } $data['preview_width'] = $preview_width; $data['preview_height'] = $preview_height; $data['value'] = $value; $plugin_options[$config_item] = serendipity_smarty_show($tfile, $data); break; case 'sequence': $data['ctype'] = 'sequence'; // For the drag-n-drop to work, the list must be included in // a container (probably an