/** * Prints the form for editing/creating new blog entries * * This is the core file where your edit form appears. The Heart Of Gold, so to say. * * @access public * @param string The URL where the entry form is submitted to * @param array An array of hidden input fields that should be passed on to the HTML FORM * @param array The entry superarray with your entry's contents * @param string Any error messages that might have occured on the last run * @return null */ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "") { global $serendipity; $serendipity['EditorBrowsers'] = '@(IE|Mozilla|Opera)@i'; $draftD = ''; $draftP = ''; $categoryselector_expanded = false; $template_vars = array(); serendipity_plugin_api::hook_event('backend_entryform', $entry); if (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft']) || !isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') { $draftD = ' selected="selected"'; $template_vars['draft_mode'] = 'draft'; } else { $draftP = ' selected="selected"'; $template_vars['draft_mode'] = 'publish'; } if (isset($entry['moderate_comments']) && serendipity_db_bool($entry['moderate_comments'])) { $template_vars['moderate_comments'] = true; $moderate_comments = ' checked="checked"'; } elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) { // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration. $moderate_comments = ' checked="checked"'; $template_vars['moderate_comments'] = true; } else { $moderate_comments = ''; $template_vars['moderate_comments'] = false; } if (isset($entry['allow_comments']) && serendipity_db_bool($entry['allow_comments'])) { $template_vars['allow_comments'] = true; $allow_comments = ' checked="checked"'; } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) { // This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration. $template_vars['allow_comments'] = true; $allow_comments = ' checked="checked"'; } else { $template_vars['allow_comments'] = false; $allow_comments = ''; } // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost. if (is_array($entry['categories']) && !is_array($entry['categories'][0])) { $categories = (array) $entry['categories']; $entry['categories'] = array(); foreach ($categories as $catid) { $entry['categories'][] = serendipity_fetchCategoryInfo($catid); } } $n = "\n"; $cat_list = '<select id="categoryselector" name="serendipity[categories][]" style="vertical-align: middle;" multiple="multiple">' . $n; $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n; $selected = array(); if (is_array($entry['categories'])) { if (count($entry['categories']) > 1) { $categoryselector_expanded = true; } foreach ($entry['categories'] as $cat) { $selected[] = $cat['categoryid']; } } if (count($selected) > 1 || isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1) { $categoryselector_expanded = true; } if (is_array($cats = serendipity_fetchCategories())) { $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($cats as $cat) { if (in_array($cat['categoryid'], $selected)) { $cat['is_selected'] = true; } $cat['depth_pad'] = str_repeat(' ', $cat['depth']); $template_vars['category_options'][] = $cat; $cat_list .= '<option value="' . $cat['categoryid'] . '"' . ($cat['is_selected'] ? ' selected="selected"' : '') . '>' . $cat['depth_pad'] . $cat['category_name'] . '</option>' . "\n"; } } $cat_list .= '</select>' . $n; if (!empty($serendipity['GET']['title'])) { $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title'])); } if (!empty($serendipity['GET']['body'])) { $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body'])); } if (!empty($serendipity['GET']['url'])) { $entry['body'] .= "\n" . '<br /><a href="' . htmlspecialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>'; } $hidden = ''; foreach ($hiddens as $key => $value) { $hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $n; } $hidden .= ' <input type="hidden" id="entryid" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n; $hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n; $hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />'; $hidden .= ' ' . serendipity_setFormToken(); if (is_object($serendipity['smarty']) || !$_SESSION['no_smarty'] && serendipity_smarty_init()) { $use_smarty = true; } else { $use_smarty = false; } if (is_object($serendipity['smarty'])) { if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { $template_vars['allowDateManipulation'] = true; } if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { $template_vars['show_wysiwyg'] = true; } if (preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { $template_vars['wysiwyg_advanced'] = true; } $template_vars['timestamp'] = serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); $template_vars['reset_timestamp'] = serendipity_serverOffsetHour(time()); $template_vars['hidden'] = $hidden; $template_vars['errMsg'] = $errMsg; $template_vars['entry'] =& $entry; $template_vars['targetURL'] = $targetURL; $template_vars['cat_count'] = count($cats) + 1; $template_vars['cat_state'] = $categoryselector_expanded ? 'on' : 'off'; $template_vars['wysiwyg'] = $serendipity['wysiwyg']; $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; $template_vars['wysiwyg_blocks'] = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); $template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'); $serendipity['smarty']->registerPlugin('modifier', 'emit_htmlarea_code', 'serendipity_emit_htmlarea_code'); $serendipity['smarty']->assign('admin_view', 'entryform'); serendipity_plugin_api::hook_event('backend_entryform_smarty', $template_vars); $serendipity['smarty']->assignByRef('entry_vars', $template_vars); $serendipity['smarty']->display($template_vars['entry_template']); return true; } /* HTML CODE BELOW IS FOR FALLBACK PORTABILITY ONLY - MODIFY CODE IN TEMPLATE ADMIN/ENTRIES.TPL INSTEAD! */ if (!empty($errMsg)) { ?> <div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_error.png'); ?> " alt="" /><?php echo $errMsg; ?> </div> <?php } ?> <form <?php echo $entry['entry_form']; ?> action="<?php echo $targetURL; ?> " method="post" id="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px"> <?php echo $hidden; ?> <table class="serendipityEntryEdit" border="0" width="100%"> <tr> <td> <b><?php echo TITLE; ?> :</b> </td> <td colspan="2"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td><input class="input_textbox" type="text" id="entryTitle" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?> " size="60" /></td> <td align="right"> <select name="serendipity[isdraft]"> <?php if ($_SESSION['serendipityRightPublish']) { ?> <option value="false" <?php echo $draftP; ?> ><?php echo PUBLISH; ?> </option><?php } ?> <option value="true" <?php echo $draftD; ?> ><?php echo DRAFT; ?> </option> </select> </td> </tr> </table> </td> </tr> <tr> <?php if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { ?> <td> <b><?php echo DATE; ?> :</b> </td> <td> <input type="hidden" name="serendipity[chk_timestamp]" value="<?php echo serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); ?> " /> <input class="input_textbox" type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time())); ?> " /> <a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(time())); ?> '; return false;" title="<?php echo RESET_DATE_DESC; ?> "><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?> " border="0" style="vertical-align: text-top;" alt="<?php echo RESET_DATE; ?> " /></a> </td> <td align="right"> <?php } else { ?> <td align="right" colspan="3"> <?php } ?> <a style="border:0; text-decoration: none" href="#" onclick="showItem('categoryselector'); return false" title="<?php echo TOGGLE_OPTION; ?> "><img src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " id="option_categoryselector" style="border: 20px" alt="" border="0" /></a> <b><?php echo CATEGORY; ?> :</b> <?php echo $cat_list; ?> <script type="text/javascript" language="JavaScript"> function toggle_extended(setCookie) { var textarea = document.getElementById('serendipity[extended]'); var button = document.getElementById('option_extended'); var tools = document.getElementById('tools_extended'); if ( textarea.style.display == 'none' ) { textarea.style.display = ''; tools.style.display = ''; button.src = '<?php echo serendipity_getTemplateFile('img/minus.png'); ?> '; if (setCookie == true) { document.cookie = 'serendipity[toggle_extended]=true;'; } } else { textarea.style.display = 'none'; tools.style.display = 'none'; button.src = '<?php echo serendipity_getTemplateFile('img/plus.png'); ?> '; if (setCookie == true) { document.cookie = 'serendipity[toggle_extended]=;'; } } } var selector_toggle = new Array(); var selector_store = new Array(); var selector_restore = new Array(); function showItem(id) { var selected = 0; if (typeof(id) == 'undefined' || typeof(id) == 'object') { id = 'categoryselector'; } if (document.getElementById) { el = document.getElementById(id); if (selector_toggle[id] && selector_toggle[id] == 'off') { selector_restore[id] = new Array(); selector_toggle[id] = 'on'; /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */ last = 0; for (i=0; i < el.options.length; i++) { if (el.options[i].selected == true) { selected++; last = i; selector_restore[id][last] = 'on'; } if (selected > 1) { /* If there is more than one selected, we reset all those to false This is because otherwise the label will say 'No Category', but the categories will still be selected */ for (j=0; j < el.options.length; j++) { /* Save selection in array to later restore them */ if (el.options[j].selected == true) { el.options[j].selected = false; selector_restore[id][j] = 'on'; last = j; } else { selector_restore[id][j] = false; } } break; } } el.selectedIndex = null; if (last > 0) { el.selectedIndex = last; } el.size = 1; /* Show a normal dropdown */ if (el.multiple) { el.multiple = false; } document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png'); ?> '; } else { selector_store[id] = el.size; if (selector_store[id] == 0) { selector_store[id] = 5; } last = 0; if (el.selectedIndex > 0) { if (!selector_restore[id]) { selector_restore[id] = new Array(); } for (j=0; j < el.options.length; j++) { /* Save selection in array to later restore them */ if (el.options[j].selected == true) { selector_restore[id][j] = 'on'; last = j; } } } el.selectedIndex = -1; el.size = <?php echo count($cats) + 1; ?> ; selector_toggle[id] = 'off'; /* Show multiple items */ el.multiple = true; /* Restore previously selected items? */ last = 0; for (i = 0; i < el.options.length; i++) { if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') { val = el.options[i].value; if (el.options[i].selected != true) { el.options[i].selected = true; last = i; // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this: // alert('it doesnt matter what, just the alert is important'); } } } document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/minus.png'); ?> '; } } } function checkSave() { <?php $void = null; serendipity_plugin_api::hook_event('backend_entry_checkSave', $void); ?> return true; } selector_toggle['categoryselector'] = '<?php echo $categoryselector_expanded ? 'on' : 'off'; ?> '; addLoadEvent(showItem); </script> </td> </tr> <tr> <?php if (!$serendipity['wysiwyg']) { ?> <td colspan="2"><b><?php echo ENTRY_BODY; ?> </b></td> <td align="right"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (!$serendipity['wysiwyg'] && preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<em>\',\'</em>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<strong>\',\'</strong>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<u>\',\'</u>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<blockquote>\',\'</blockquote>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " style="" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); </script> <?php /* Do the "old" non-WYSIWYG editor */ } elseif (!$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'b\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'u\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'i\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no\');">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); </script> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); } else { ?> <td colspan="2"><b><?php echo ENTRY_BODY; ?> </b></td> <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?> <?php } ?> </td> </tr> <tr> <td colspan="3"> <textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?> </textarea> </td> </tr> <tr> <td colspan="3"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td align="left" width="70%"> <input class="input_checkbox" id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" <?php echo $allow_comments; ?> /><label for="checkbox_allow_comments"><?php echo COMMENTS_ENABLE; ?> </label><br /> <input class="input_checkbox" id="checkbox_moderate_comments" type="checkbox" name="serendipity[moderate_comments]" value="true" <?php echo $moderate_comments; ?> /><label for="checkbox_moderate_comments"><?php echo COMMENTS_MODERATE; ?> </label> </td> <td align="right" rowspan="2" valign="middle" width="30%"> <input accesskey="p" type="submit" value="- <?php echo PREVIEW; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" /><br /> <input accesskey="s" type="submit" onclick="return checkSave();" value="- <?php echo SAVE; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" /> </td> </tr> </table> <br /> </td> </tr> <tr> <td colspan="2"> <?php if (!$serendipity['wysiwyg']) { ?> <a style="border:0; text-decoration: none" href="#" onclick="toggle_extended(true); return false;" title="<?php echo TOGGLE_OPTION; ?> "><img src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " id="option_extended" alt="+/-" border="0" /></a> <?php } ?> <b><?php echo EXTENDED_BODY; ?> </b></td> <td align="right"> <?php if (!$serendipity['wysiwyg']) { ?> <div id="tools_extended" style="display: none"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<em>','</em>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<strong>','</strong>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<u>','</u>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<blockquote>','</blockquote>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[extended]'])" /> <input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" /> <input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[extended]'])" /> <?php /* Do the "old" non-WYSIWYG editor */ } else { ?> <input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'b')"> <input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'u')"> <input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'i')"> <input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[extended]'])"> <input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no');"> <input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[extended]'])"> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); ?> </div> <?php } else { serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); } ?> </td> </tr> <tr> <td colspan="3"> <textarea style="width: 100%;" name="serendipity[extended]" id="serendipity[extended]" cols="80" rows="20"><?php echo isset($entry['extended']) ? htmlspecialchars($entry['extended']) : ''; ?> </textarea> <?php if (!$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> toggle_extended(); </script> <?php } ?> </td> </tr> <tr> <td colspan="3"> <br /> <fieldset> <legend><b><?php echo ADVANCED_OPTIONS; ?> </b></legend> <?php serendipity_plugin_api::hook_event('backend_display', $entry); ?> </fieldset> </td> </tr> </table> </form> <?php if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> toggle_extended(); </script> <?php } if ($serendipity['wysiwyg']) { $fields = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); foreach ($fields as $f_jsname => $f_item) { serendipity_emit_htmlarea_code($f_item, $f_jsname); } serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $fields); } echo ' <script type="text/javascript" language="JavaScript" src="serendipity_define.js.php"></script>'; echo ' <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>'; }
function inspectConfig($is_smarty, $what, $elcount, $config_item, $config_value, $type, $cname, $cdesc, $value, $default, $lang_direction, $hvalue, $radio, $radio2, $select, $per_row, $per_row2) { global $serendipity; if ($is_smarty && $what == 'desc') { echo $cdesc; return true; } if ($is_smarty && $what == 'name') { echo $cname; return true; } switch ($type) { case 'seperator': ?> <tr> <td colspan="2"><hr noshade="noshade" size="1" /></td> </tr> <?php break; case 'select': if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle" width="250"> <div> <?php } ?> <select class="direction_<?php echo $lang_direction; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]"> <?php foreach ($select as $select_value => $select_desc) { $id = function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $select_value) : htmlspecialchars($config_item . $select_value, ENT_COMPAT, LANG_CHARSET); ?> <option title="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET); ?> "<?php echo $select_value == $hvalue ? ' selected="selected"' : ''; ?> value="<?php echo $select_value; ?> "><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET); ?> </option> <?php } ?> </select> <?php if (!$is_smarty) { ?> </div> </td> </tr> <?php } break; case 'tristate': $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case 'radio': if (!count($radio) > 0) { $radio = $radio2; } if (empty($per_row)) { $per_row = $per_row2; if (empty($per_row)) { $per_row = 2; } } if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br /><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle;" width="250"> <?php } $counter = 0; foreach ($radio['value'] as $radio_index => $radio_value) { $id = function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $radio_value) : htmlspecialchars($config_item . $radio_value, ENT_COMPAT, LANG_CHARSET); $counter++; $checked = ""; if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) { $checked = " checked"; } elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue === '0' || $hvalue === 'false')) { $checked = " checked"; } elseif ($radio_value == $hvalue) { $checked = " checked"; } if ($counter == 1) { ?> <div> <?php } ?> <input class="input_radio direction_<?php echo $lang_direction; ?> " type="radio" id="serendipity_plugin_<?php echo $id; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $radio_value; ?> " <?php echo $checked; ?> title="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET); ?> " /> <label for="serendipity_plugin_<?php echo $id; ?> "><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET); ?> </label> <?php if ($counter == $per_row) { $counter = 0; ?> </div> <?php } } if (!$is_smarty) { ?> </td> </tr> <?php } break; case 'string': if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000"> <strong><?php echo $cname; ?> </strong> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> <td style="border-bottom: 1px solid #000000" width="250"> <div> <?php } ?> <input class="input_textbox direction_<?php echo $lang_direction; ?> " type="text" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $hvalue; ?> " size="30" /> <?php if (!$is_smarty) { ?> </div> </td> </tr> <?php } break; case 'html': case 'text': if (!$is_smarty) { echo '<tr>'; } if (!$serendipity['wysiwyg']) { if (!$is_smarty) { ?> <td><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span></td> <td align="right"> <?php } if (!$serendipity['wysiwyg']) { ?> <nobr><span id="tools_<?php echo $config_item; ?> " style="display: none"> <?php if ($serendipity['nl2br']['iso2br']) { ?> <input type="button" class="serendipityPrettyButton input_button" name="insX" value="NoBR" accesskey="x" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<nl>','</nl>')" /> <?php } ?> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insI" value="I" accesskey="i" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="em" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<em>','</em>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insB" value="B" accesskey="b" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="strong" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<strong>','</strong>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insU" value="U" accesskey="u" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<u>','</u>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="blockquote" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<blockquote>','</blockquote>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_insimg" name="insJ" value="img" accesskey="j" data-tarea="nuggets<?php echo $elcount; ?> " onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'])" /> <?php if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) { ?> <button class="wrap_insmedia" type="button" name="insImage" data-tarea="nuggets<?php echo $elcount; ?> "><?php echo MEDIA; ?> </button> <?php } else { ?> <input type="button" class="serendipityPrettyButton input_button wrap_insmedia" name="insImage" value="<?php echo MEDIA; ?> " style="" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo urlencode('serendipity[plugin][' . $config_item . ']'); ?> ', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" /> <?php } ?> <input type="button" class="serendipityPrettyButton input_button wrap_insurl" name="insU" value="URL" accesskey="l" data-tarea="nuggets<?php echo $elcount; ?> " style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'])" /> </span></nobr> <?php } ?> <script type="text/javascript" language="JavaScript"> var tb_<?php echo $config_item; ?> = document.getElementById('tools_<?php echo $config_item; ?> '); tb_<?php echo $config_item; ?> .style.display = ''; </script> <?php if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) { ?> <script src="<?php echo serendipity_getTemplateFile('admin/js/jquery.magnific-popup.js'); ?> "></script><?php } // add extra data in the entry's array so that emoticonchooser plugin // behaves well with wysiwyg editors, then clean up ;-) (same apply below) $entry['backend_entry_toolbar_body:nugget'] = 'nuggets' . $elcount; $entry['backend_entry_toolbar_body:textarea'] = 'serendipity[plugin][' . $config_item . ']'; serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); unset($entry['backend_entry_toolbar_body:textarea']); unset($entry['backend_entry_toolbar_body:nugget']); } else { if (!$is_smarty) { ?> <td colspan="2"><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span></td> <td> <?php } if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) { serendipity_emit_htmlarea_code("nuggets{$elcount}", ""); ?> <script src="<?php echo serendipity_getTemplateFile('admin/js/jquery.magnific-popup.js'); ?> "></script><?php } $entry['backend_entry_toolbar_body:nugget'] = 'nuggets' . $elcount; $entry['backend_entry_toolbar_body:textarea'] = 'serendipity[plugin][' . $config_item . ']'; serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); unset($entry['backend_entry_toolbar_body:textarea']); unset($entry['backend_entry_toolbar_body:nugget']); ?> <?php } if (!$is_smarty) { ?> </td> </tr> <tr> <td colspan="2"> <?php } ?> <div> <textarea class="direction_<?php echo $lang_direction; ?> " style="width: 100%" id="nuggets<?php echo $elcount; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" rows="20" cols="80"><?php echo $hvalue; ?> </textarea> </div> <?php if (!$is_smarty) { ?> </td> </tr> <?php } if ($type == 'html') { $this->htmlnugget[] = $elcount; if (version_compare(preg_replace('@[^0-9\\.]@', '', $serendipity['version']), '0.9', '<')) { serendipity_emit_htmlarea_code('nuggets' . $elcount, 'nuggets' . $elcount); } else { serendipity_emit_htmlarea_code('nuggets', 'nuggets', true); } } break; case 'content': if (!$is_smarty) { ?> <tr><td colspan="2"><?php echo $default; ?> </td></tr><?php } else { echo $default; } break; case 'hidden': if (!$is_smarty) { ?> <tr><td colspan="2"><?php } ?> <input class="direction_<?php echo $lang_direction; ?> " type="hidden" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $value; ?> " /><?php if (!$is_smarty) { ?> </td></tr><?php } break; case 'timestamp': if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000"> <strong><?php echo $cname; ?> </strong> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> <td style="border-bottom: 1px solid #000000" width="250"> <div> <?php } ?> <input class="input_textbox direction_<?php echo $lang_direction; ?> " type="text" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo serendipity_strftime(DATE_FORMAT_SHORT, $hvalue); ?> " size="30" /> <?php if (!$is_smarty) { ?> </div> </td> </tr> <?php } break; } }
/** * 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 = serendipity_specialchars($cbag->get('name')); $data['cdesc'] = $cdesc = serendipity_specialchars($cbag->get('description')); $value = $plugin->get_config($config_item, 'unset'); $lang_direction = serendipity_specialchars($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, 'serendipity_specialchars'); } else { $hvalue = serendipity_specialchars($_POST['serendipity'][$postkey][$config_item]); } } else { $hvalue = serendipity_specialchars($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; $assign_plugin_config = function ($data) use(&$plugin_options, $tfile, $config_item) { $plugin_options[$config_item] = array('config' => serendipity_smarty_show($tfile, $data), 'ctype' => $data['ctype']); }; switch ($ctype) { case 'seperator': // compat, due being misspelled // compat, due being misspelled case 'separator': case 'suboption': $assign_plugin_config($data); break; case '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'); $assign_plugin_config($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 = serendipity_specialchars($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'] = serendipity_specialchars($radio['desc'][$radio_index]); } $assign_plugin_config($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; $assign_plugin_config($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'); } // use SpawnMulti false per default (for multi nugget textareas, eg linklist sidebar plugin) - but where do we use jsname though? serendipity_emit_htmlarea_code("nuggets{$elcount}", "nuggets{$elcount}"); } $assign_plugin_config($data); break; case 'content': $data['ctype'] = 'content'; $data['cbag_default'] = $cbag->get('default'); $assign_plugin_config($data); break; case 'custom': $data['ctype'] = 'custom'; $data['cbag_custom'] = $cbag->get('custom'); $assign_plugin_config($data); break; case 'hidden': $data['ctype'] = 'hidden'; $data['cbag_value'] = $cbag->get('value'); $assign_plugin_config($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; $assign_plugin_config($data); break; case 'sequence': $data['ctype'] = 'sequence'; // For the drag-n-drop to work, the list must be included in // a container (probably an <ol>) that JavaScript can access // (easiest by ID), with <li> children that have unique IDs, // and handles with ids of 'g'.$li_id. // I can't get it to work unless there's a class of // pluginmanager_container on the ol, either. // The drag-n-drop returns the list of IDs in order. $data['sequencejs_output'] = $sequencejs_output = $serendipity['sequencejs_output']; if (!$sequencejs_output) { $serendipity['sequencejs_output'] = true; } // I want this generic sequence widget to hide the ID, but // display a name or description with an optional picture. // (This would allow users to identify choices by thumbnail.) // Therefore, I need an array with keys 'id', 'display', and // 'imgurl' (or similar) to generate each list item. // Get the data we need to display the list if (!$value) { $value = $eventData['default']; } $data['value'] = $value; $data['cname'] = $cname = $cbag->get('name'); $data['cdesc'] = $cdesc = $cbag->get('description'); $data['checkable'] = $checkable = $cbag->get('checkable'); /** Unordered array of values */ $items = $cbag->get('values'); if (!is_array($items)) { $items = null; } /** Array specifying order to use values in $items */ $order = null; if ($value) { $data['store_order'] = $store_order = $order = explode(',', $value); } // $items is the list of things to sequence. It's not in // order, and reordering PHP arrays is problematic. So // we keep it unordered, and access its values according // to another array (appropriately named $order). if (is_array($items)) { // Allow simple value for any sequence item foreach ($items as $key => $item) { if (!is_array($item)) { // Replace this item with an empty array unset($items[$key]); $items[$item] = array(); } } // Make sure all the items are in the order list; new items // go on the end (new items could have been added without // this config item being updated) // Also fill out thumbnails and display names foreach ($items as $id => $junk) { if ($order == null) { $order = array($id); } else { if (!in_array($id, $order)) { $order[] = $id; } } // If there's no defined display name, default to the ID if (!isset($items[$id]['display'])) { $items[$id]['display'] = $id; } // If there's no image, we just won't display anything. } // Make sure all the items to be ordered exist! Otherwise // we could try to sequence nothing. $filtered = array(); foreach ($order as $id) { if (array_key_exists($id, $items)) { $filtered[] = $id; } } $order = $filtered; } else { // If there's nothing to sequence, make the order in // which to use them valid, but empty $order = array(); } // Start the row, add one cell for the name and description $data['items'] = $items; $sort_idx = 0; $data['last'] = $last = count($order) - 1; foreach ($order as $id) { // Create the variables required to print this item if ($sort_idx > 0) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx - 1)]; $swapping[(int) ($sort_idx - 1)] = $temp; $data['order_id'][$sort_idx]['oneup'] = $oneup = implode(',', $swapping); } if ($sort_idx < $last) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx + 1)]; $swapping[(int) ($sort_idx + 1)] = $temp; $data['order_id'][$sort_idx]['onedown'] = $onedown = implode(',', $swapping); } $data['order_id'][$sort_idx]['id'] = $id; $data['order_id'][$sort_idx]['sort_idx'] = $sort_idx; // Print the HTML // // Set the item and its ID // Make a handle with ID 'g$id' // Add the item contents // Luddite submit buttons (please, think of the scriptless!) // Next, please $sort_idx++; } // foreach end if (!is_array($items) or empty($order)) { // Print the empty message $data['no_sequence'] = sprint(NONE); } // Print the Javascript to drag-n-drop the list // Finish the row $assign_plugin_config($data); break; default: $data['ctype'] = 'default'; // Unknown configuration key. Let the plugin handle it. $addData = func_get_args(); $eventData = array('config_item' => $config_item, 'cbag' => $cbag, 'plugin' => $plugin, 'value' => $value, 'bag' => $bag, 'postKey' => $postKey); ob_start(); serendipity_plugin_api::hook_event('backend_pluginconfig_' . $ctype, $eventData, $addData); $plugin_options[$config_item]['config'] = ob_get_contents(); $plugin_options[$config_item]['ctype'] = 'default'; ob_end_clean(); break; } } $data['config_groups'] = $config_groups; $data['plugin_options'] = $plugin_options; if (is_array($config_groups)) { foreach ($config_groups as $config_header => $config_groupkeys) { foreach ($config_groupkeys as $config_groupkey) { unset($plugin_options[$config_groupkey]); } } } $data['plugin_options_ungrouped'] = $plugin_options; if ($showSubmit) { $data['showSubmit_foot'] = true; } if ($showExample && method_exists($plugin, 'example')) { $data['showExample'] = true; $data['plugin_example'] = $plugin->example(); } if ($spawnNuggets && isset($serendipity['wysiwyg']) && $serendipity['wysiwyg'] && count($htmlnugget) > 0) { $data['spawnNuggets'] = true; $ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false); serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev); $data['ev'] = $ev; } return serendipity_smarty_show('admin/plugin_config.tpl', $data); }
/** * Show a placement box on where to move a sidebar plugin to * * @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]) * @return boolean */ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_names, $showTable = true, $showSubmit = true, $showExample = true, $spawnNuggets = true, $postKey = 'plugin') { global $serendipity; if (empty($config_names)) { return false; } if ($showSubmit && $postKey != 'plugin') { ?> <div style="margin: 0px auto 0px 0px; text-align: right"> <input type="submit" name="SAVECONF" value="<?php echo SAVE; ?> " class="serendipityPrettyButton input_button" /> </div> <?php } if ($showTable) { ?> <table id="serendipity_plugin_config" border="0" cellspacing="0" cellpadding="3" width="100%"> <?php } $elcount = 0; $htmlnugget = array(); foreach ($config_names as $config_item) { $elcount++; $cbag = new serendipity_property_bag(); $plugin->introspect_config_item($config_item, $cbag); $cname = htmlspecialchars($cbag->get('name')); $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; } /* 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; $is_multi_select = false; $ctype = $cbag->get('type'); switch ($ctype) { case 'seperator': ?> <tr> <td colspan="2"><hr noshade="noshade" size="1" /></td> </tr> <?php break; case 'multiselect': $is_multi_select = true; case 'select': if (is_array($hvalue)) { $selected_options = $hvalue; } elseif ($is_multi_select) { $selected_options = explode('^', $hvalue); } else { $selected_options = array($hvalue => $hvalue); } $pre_selected = (array) $cbag->get('select_preselected'); $select_size = $cbag->get('select_size'); $select = $cbag->get('select_values'); ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle" width="250"> <div> <select class="direction_<?php echo $lang_direction; ?> " name="serendipity[<?php echo $postKey; ?> ][<?php echo $config_item; ?> ]<?php echo $is_multi_select ? '[]' : ''; ?> " <?php echo $is_multi_select ? 'multiple="multiple"' : ''; ?> <?php echo $is_multi_select && $select_size > 0 ? 'size="' . $select_size . '"' : ''; ?> > <?php foreach ($select as $select_value => $select_desc) { $id = htmlspecialchars($config_item . $select_value); ?> <option value="<?php echo $select_value; ?> " <?php echo in_array($select_value, $selected_options) || in_array($select_value, $pre_selected) ? 'selected="selected"' : ''; ?> title="<?php echo htmlspecialchars($select_desc); ?> "> <?php echo htmlspecialchars($select_desc); ?> </option> <?php } ?> </select> </div> </td> </tr> <?php break; case 'tristate': $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case '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; } } ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br /><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle;" width="250"> <?php $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"; } if ($counter == 1) { ?> <div> <?php } ?> <input class="direction_<?php echo $lang_direction; ?> input_radio" type="radio" id="serendipity_plugin_<?php echo $id; ?> " name="serendipity[<?php echo $postKey; ?> ][<?php echo $config_item; ?> ]" value="<?php echo $radio_value; ?> " <?php echo $checked; ?> title="<?php echo htmlspecialchars($radio['desc'][$radio_index]); ?> " /> <label for="serendipity_plugin_<?php echo $id; ?> "><?php echo htmlspecialchars($radio['desc'][$radio_index]); ?> </label> <?php if ($counter == $per_row) { $counter = 0; ?> </div> <?php } } ?> </td> </tr> <?php break; case 'string': if (empty($input_type)) { $input_type = $cbag->get('input_type'); if (empty($input_type)) { $input_type = "text"; } } ?> <tr> <td style="border-bottom: 1px solid #000000"> <strong><?php echo $cname; ?> </strong> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> <td style="border-bottom: 1px solid #000000" width="250"> <div> <input class="direction_<?php echo $lang_direction; ?> input_textbox" type="<?php echo $input_type; ?> " name="serendipity[<?php echo $postKey; ?> ][<?php echo $config_item; ?> ]" value="<?php echo $hvalue; ?> " size="30" /> </div> </td> </tr> <?php break; case 'html': case 'text': if (empty($text_rows)) { $text_rows = $cbag->get('rows'); if (empty($text_rows)) { $text_rows = 20; } } ?> <tr> <td colspan="2"><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> </tr> <tr> <td colspan="2"> <div> <textarea class="direction_<?php echo $lang_direction; ?> " style="width: 100%" id="nuggets<?php echo $elcount; ?> " name="serendipity[<?php echo $postKey; ?> ][<?php echo $config_item; ?> ]" rows="<?php echo $text_rows; ?> " cols="80"><?php echo $hvalue; ?> </textarea> </div> </td> </tr> <?php if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; if (!function_exists('serendipity_emit_htmlarea_code')) { @(include dirname(__FILE__) . '/functions_entries_admin.inc.php'); } serendipity_emit_htmlarea_code('nuggets', 'nuggets', true); } break; case 'content': ?> <tr><td colspan="2"><?php echo $cbag->get('default'); ?> </td></tr><?php break; case 'custom': ?> <tr><td colspan="2"> <input type="hidden" id="config_<?php echo $postKey; ?> _<?php echo $config_item; ?> " name="serendipity[<?php echo $postKey; ?> ][<?php echo $config_item; ?> ]" value="<?php echo $hvalue; ?> " size="30" /> <?php echo $cbag->get('custom'); ?> </td></tr><?php break; case 'hidden': ?> <tr><td colspan="2"><input class="direction_<?php echo $lang_direction; ?> " type="hidden" name="serendipity[<?php echo $postKey; ?> ][<?php echo $config_item; ?> ]" value="<?php echo $cbag->get('value'); ?> " /></td></tr><?php break; case 'media': // Output the JavaScript, if we haven't already $mediajs_output = $serendipity['mediajs_output']; if (!$mediajs_output) { print <<<EOS <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script> <script type="text/javascript"> function change_preview(id) { var text_box = document.getElementById('serendipity[template][' + id + ']'); var image_box = document.getElementById(id + '_preview'); var filename = text_box.value; image_box.style.backgroundImage = 'url(' + filename + ')'; image_box.style.backgroundRepeat = 'no-repeat'; } function choose_media(id) { window.open('serendipity_admin_image_selector.php?serendipity[htmltarget]=' + id + '&serendipity[filename_only]=true', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); } </script> EOS; $serendipity['mediajs_output'] = true; } // 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'; } $media_link_text = MEDIA_LIBRARY; print <<<EOS <tr><td colspan="2"> <strong>{$cname}</strong> <br /><span style="color: #5E7A94; font-size: 8pt;">{$cdesc}</span> </td> </tr> <tr> <td style="border-bottom: 1px solid #000000"> <div id="{$config_item}_preview" style="background-image: url({$value}); width:{$preview_width}; height: {$preview_height}; background-repeat: no-repeat;"> </div> </td> <td style="border-bottom: 1px solid #000000"> <input class="input_textbox" type="text" id="serendipity[{$postKey}][{$config_item}]" name="serendipity[{$postKey}][{$config_item}]" value="{$value}" onchange="change_preview('{$config_item}')"/> <br /><a href="#" onclick="choose_media('serendipity[{$postKey}][{$config_item}]')">{$media_link_text}</a> </td> </tr> EOS; break; case 'sequence': // For the drag-n-drop to work, the list must be included in // a container (probably an <ol>) that JavaScript can access // (easiest by ID), with <li> children that have unique IDs, // and handles with ids of 'g'.$li_id. // I can't get it to work unless there's a class of // pluginmanager_container on the ol, either. // The drag-n-drop returns the list of IDs in order. $sequencejs_output = $serendipity['sequencejs_output']; if (!$sequencejs_output) { echo '<script src="' . serendipity_getTemplateFile('dragdrop.js') . '" type="text/javascript"></script>'; $serendipity['sequencejs_output'] = true; } // I want this generic sequence widget to hide the ID, but // display a name or description with an optional picture. // (This would allow users to identify choices by thumbnail.) // Therefore, I need an array with keys 'id', 'display', and // 'imgurl' (or similar) to generate each list item. // Get the data we need to display the list if (!$value) { $value = $eventData['default']; } $cname = $cbag->get('name'); $cdesc = $cbag->get('description'); $checkable = $cbag->get('checkable'); /** Unordered array of values */ $items = $cbag->get('values'); if (!is_array($items)) { $items = null; } /** Array specifying order to use values in $items */ $order = null; if ($value) { $store_order = $order = explode(',', $value); } $uparrow_img = serendipity_getTemplateFile('admin/img/uparrow.png'); $downarrow_img = serendipity_getTemplateFile('admin/img/downarrow.png'); // $items is the list of things to sequence. It's not in // order, and reordering PHP arrays is problematic. So // we keep it unordered, and access its values according // to another array (appropriately named $order). if (is_array($items)) { // Allow simple value for any sequence item foreach ($items as $key => $item) { if (!is_array($item)) { // Replace this item with an empty array unset($items[$key]); $items[$item] = array(); } } // Make sure all the items are in the order list; new items // go on the end (new items could have been added without // this config item being updated) // Also fill out thumbnails and display names foreach ($items as $id => $junk) { if ($order == null) { $order = array($id); } else { if (!in_array($id, $order)) { $order[] = $id; } } // If there's no defined display name, default to the ID if (!isset($items[$id]['display'])) { $items[$id]['display'] = $id; } // If there's no image, we just won't display anything. } // Make sure all the items to be ordered exist! Otherwise // we could try to sequence nothing. $filtered = array(); foreach ($order as $id) { if (array_key_exists($id, $items)) { $filtered[] = $id; } } $order = $filtered; } else { // If there's nothing to sequence, make the order in // which to use them valid, but empty $order = array(); } // Start the row, add one cell for the name and description print <<<EOS <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"> <strong>{$cname}</strong> <br /><span style="color: #5E7A94; font-size: 8pt;">{$cdesc}</span> </td> EOS; // Now add one cell for the list print <<<EOS <td style="border-bottom: 1px solid #000000; vertical-align: middle"> EOS; // Print the list print <<<EOS <input type="hidden" name="serendipity[{$postKey}][{$config_item}]" id="{$config_item}_value" value="{$value}" /> <noscript> <!-- Replace standard submit button when using up/down submits --> <input type="hidden" name="SAVECONF" value="Save" /> </noscript> <ol id="{$config_item}" class="sequence_container pluginmanager_container"> EOS; $sort_idx == 0; $last = count($order) - 1; foreach ($order as $id) { // Create the variables required to print this item if ($sort_idx > 0) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx - 1)]; $swapping[(int) ($sort_idx - 1)] = $temp; $oneup = implode(',', $swapping); } if ($sort_idx < $last) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx + 1)]; $swapping[(int) ($sort_idx + 1)] = $temp; $onedown = implode(',', $swapping); } // Print the HTML // // Set the item and its ID print ' <li id="' . $id . '" class="sequence_item pluginmanager_item_even">' . "\n"; // Make a handle with ID 'g$id' print ' <div id="g' . $id . '" class="pluginmanager_grablet sequence_grablet"><a href="#"></a></div>' . "\n"; if ($checkable) { print ' <input type="checkbox" onclick="sort_' . $config_item . '_Sequence();" name="serendipity[' . $postKey . ']' . '[activate][' . $config_item . '][' . $id . ']" ' . (in_array($id, $store_order) ? ' checked="checked" ' : '') . ' value="true" id="activate_' . $id . '" />' . "\n"; } // Add the item contents print ' <span>' . $items[$id]['display'] . '</span>' . "\n"; if (isset($items[$id]['img'])) { print ' <img src="' . $items[$id]['img'] . '" />' . "\n"; } // Luddite submit buttons (please, think of the scriptless!) print "<noscript><div>\n"; if ($sort_idx == 0) { // Skip the move-up submit button print " \n"; } else { print <<<EOS <button type="submit" name="serendipity[{$postKey}][override][{$config_item}]" value="{$oneup}"> <img src="{$uparrow_img}" alt="Move Up"> </button> EOS; } if ($sort_idx == $last) { // Skip the move-down submit button print " \n"; } else { print <<<EOS <button type="submit" name="serendipity[{$postKey}][override][{$config_item}]" value="{$onedown}"> <img src="{$downarrow_img}" alt="Move Down"> </button> EOS; } print "</div></noscript>\n"; // Close the item print ' </li>' . "\n"; // Next, please $sort_idx++; } if (!is_array($items) or empty($order)) { // Print the empty message print NONE; } // Print the Javascript to drag-n-drop the list print <<<EOS <script type="text/javascript"> function sort_{$config_item}_Sequence() { //var seq = DragDrop.serData('{$config_item}_group', null); var seq = DragDrop.serData(null, '{$config_item}'); var start = seq.indexOf("("); var end = seq.indexOf(")"); seq = seq.slice((start + 1), end); checkable_seq = seq.split(","); out_seq = ''; for (i in checkable_seq) { if (document.getElementById('activate_' + checkable_seq[i]) && !document.getElementById('activate_' + checkable_seq[i]).checked) { continue; } else { if (out_seq != '') { out_seq += ','; } out_seq += checkable_seq[i]; } } var order = document.getElementById("{$config_item}_value"); order.value = out_seq; } function init_{$config_item}_Sequence() { var lst = document.getElementById("{$config_item}"); DragDrop.makeListContainer(lst, '{$config_item}_group'); lst.onDragOut = function() { sort_{$config_item}_Sequence(); }; } addLoadEvent(init_{$config_item}_Sequence); </script> EOS; // Finish the row print <<<EOS </td> EOS; break; default: // Unknown configuration key. Let the plugin handle it. $addData = func_get_args(); $eventData = array('config_item' => $config_item, 'cbag' => $cbag, 'plugin' => $plugin, 'value' => $value, 'bag' => $bag, 'postKey' => $postKey); serendipity_plugin_api::hook_event('backend_pluginconfig_' . $ctype, $eventData, $addData); break; } } if ($showTable) { ?> </table> <br /> <?php } if ($showSubmit) { ?> <div style="padding-left: 20px"> <input type="submit" name="SAVECONF" value="<?php echo SAVE; ?> " class="serendipityPrettyButton input_button" /> </div> <?php } if ($showExample && method_exists($plugin, 'example')) { ?> <div> <?php echo $plugin->example(); ?> </div> <?php } if ($spawnNuggets && isset($serendipity['wysiwyg']) && $serendipity['wysiwyg'] && count($htmlnugget) > 0) { $ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false); serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev); if ($ev['skip_nuggets'] === false) { ?> <script type="text/javascript"> function Spawnnugget() { /* blar */ <?php foreach ($htmlnugget as $htmlnuggetid) { ?> Spawnnuggets('<?php echo $htmlnuggetid; ?> '); <?php } ?> } </script> <?php } } return true; }
function showCategoryForm() { global $serendipity; $serendipity['EditorBrowsers'] = '@(IE|Mozilla|Safari)@i'; if (file_exists(S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php')) { include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; } ?> <table border="0" cellspacing="0" cellpadding="3" width="100%"> <?php $elcount = 0; $htmlnugget = array(); foreach ($this->config_category as $config_item) { $elcount++; $config_value = $this->category[$config_item]; $cbag = new serendipity_property_bag(); $this->introspect_category_item($config_item, $cbag); $cname = function_exists('serendipity_specialchars') ? serendipity_specialchars($cbag->get('name')) : htmlspecialchars($cbag->get('name'), ENT_COMPAT, LANG_CHARSET); $cdesc = function_exists('serendipity_specialchars') ? serendipity_specialchars($cbag->get('description')) : htmlspecialchars($cbag->get('description'), ENT_COMPAT, LANG_CHARSET); $value = $this->getCategory($config_item, 'unset'); $lang_direction = function_exists('serendipity_specialchars') ? serendipity_specialchars($cbag->get('lang_direction')) : htmlspecialchars($cbag->get('lang_direction'), ENT_COMPAT, LANG_CHARSET); if (empty($lang_direction)) { $lang_direction = LANG_DIRECTION; } if ($value === 'unset') { $value = $cbag->get('default'); } $hvalue = !isset($serendipity['POST']['categorySubmit']) && isset($serendipity['POST']['plugin'][$config_item]) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['POST']['plugin'][$config_item]) : htmlspecialchars($serendipity['POST']['plugin'][$config_item], ENT_COMPAT, LANG_CHARSET) : (function_exists('serendipity_specialchars') ? serendipity_specialchars($value) : htmlspecialchars($value, ENT_COMPAT, LANG_CHARSET)); $radio = array(); $select = array(); $per_row = null; switch ($cbag->get('type')) { case 'seperator': echo '<tr><td colspan="2"><hr noshade="noshade" size="1" /></td></tr>'; break; case 'select': $select = $cbag->get('select_values'); ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle" width="250"> <div> <select class="direction_<?php echo $lang_direction; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]"> <?php foreach ($select as $select_value => $select_desc) { $id = function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $select_value) : htmlspecialchars($config_item . $select_value, ENT_COMPAT, LANG_CHARSET); echo '<option value="' . $select_value . '" ' . ($select_value == $hvalue ? 'selected="selected"' : '') . ' title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)) . '" />' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET)) . '</option>'; } ?> </select> </div> </td> </tr> <?php break; case 'tristate': $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case '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; } } ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br /><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle;" width="250"> <?php $counter = 0; foreach ($radio['value'] as $radio_index => $radio_value) { $id = function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $radio_value) : htmlspecialchars($config_item . $radio_value, ENT_COMPAT, LANG_CHARSET); $counter++; $checked = ""; if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) { $checked = " checked"; } elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue === '0' || $hvalue === 'false')) { $checked = " checked"; } elseif ($radio_value == $hvalue) { $checked = " checked"; } if ($counter == 1) { ?> <div> <?php } ?> <input class="direction_<?php echo $lang_direction; ?> input_radio" type="radio" id="serendipity_plugin_<?php echo $id; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $radio_value; ?> " <?php echo $checked; ?> title="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET); ?> " /> <label for="serendipity_plugin_<?php echo $id; ?> "><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET); ?> </label> <?php if ($counter == $per_row) { $counter = 0; ?> </div> <?php } } ?> </td> </tr> <?php break; case 'string': ?> <tr> <td style="border-bottom: 1px solid #000000"> <strong><?php echo $cname; ?> </strong> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> <td style="border-bottom: 1px solid #000000" width="250"> <div> <input class="direction_<?php echo $lang_direction; ?> input_textbox" type="text" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $hvalue; ?> " size="30" /> </div> </td> </tr> <?php break; case 'html': case 'text': ?> <tr> <?php if (!$serendipity['wysiwyg']) { ?> <td><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span></td> <td align="right"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (!$serendipity['wysiwyg'] && preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <nobr> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'],\'<i>\',\'</i>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'],\'<b>\',\'</b>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'],\'<u>\',\'</u>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'],\'<blockquote>\',\'</blockquote>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'])" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " style="" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo urlencode('serendipity[plugin][' . $config_item . ']'); ?> \', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insU" value="URL" accesskey="l" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'])" />'); </script></nobr> <?php /* Do the "old" non-WYSIWYG editor */ } elseif (!$serendipity['wysiwyg']) { ?> <nobr> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'], \'b\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'], \'u\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'], \'i\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'])">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[filename_only]=<?php echo $config_item; ?> \', \'ImageSel\', \'width=800,height=600,toolbar=no\');">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[plugin][<?php echo $config_item; ?> ]\'])">'); </script></nobr> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); } else { ?> <td colspan="2"><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span></td> <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?> <?php } ?> </td> </tr> <tr> <td colspan="2"> <div> <textarea class="direction_<?php echo $lang_direction; ?> " style="width: 100%" id="nuggets<?php echo $elcount; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" rows="20" cols="80"><?php echo $hvalue; ?> </textarea> </div> </td> </tr> <?php if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; if (version_compare(preg_replace('@[^0-9\\.]@', '', $serendipity['version']), '0.9', '<')) { serendipity_emit_htmlarea_code('nuggets' . $elcount, 'nuggets' . $elcount); } else { serendipity_emit_htmlarea_code('nuggets', 'nuggets', true); } } break; case 'content': ?> <tr><td colspan="2"><?php echo $cbag->get('default'); ?> </td></tr><?php break; case 'hidden': ?> <tr><td colspan="2"><input class="direction_<?php echo $lang_direction; ?> " type="hidden" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $cbag->get('value'); ?> " /></td></tr><?php break; } } if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg'] && count($htmlnugget) > 0) { $ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false); serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev); if ($ev['skip_nuggets'] === false) { ?> <script type="text/javascript"> function Spawnnugget() { <?php foreach ($htmlnugget as $htmlnuggetid) { if (version_compare(preg_replace('@[^0-9\\.]@', '', $serendipity['version']), '0.9', '<')) { ?> Spawnnuggets<?php echo $htmlnuggetid; ?> (); <?php } else { ?> Spawnnuggets('<?php echo $htmlnuggetid; ?> '); <?php } ?> <?php } ?> } </script> <?php } } ?> </table> <br /> <div style="padding-left: 20px"> <input type="submit" name="serendipity[SAVECONF]" value="<?php echo SAVE; ?> " class="serendipityPrettyButton input_button" /> </div> <?php }
} ?> <?php if ($this->_tpl_vars['entry_vars']['wysiwyg']) { ?> <?php $_from = $this->_tpl_vars['entry_vars']['wysiwyg_blocks']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } if (count($_from)) { foreach ($_from as $this->_tpl_vars['wysiwyg_block_jsname'] => $this->_tpl_vars['wysiwyg_block_item']) { ?> <?php echo is_array($_tmp = $this->_tpl_vars['wysiwyg_block_item']) ? $this->_run_mod_handler('emit_htmlarea_code', true, $_tmp, $this->_tpl_vars['wysiwyg_block_jsname']) : serendipity_emit_htmlarea_code($_tmp, $this->_tpl_vars['wysiwyg_block_jsname']); ?> <?php } } unset($_from); ?> <?php echo serendipity_smarty_refhookPlugin($this->_tpl_vars['entry_vars']['wysiwyg_blocks'], 'backend_wysiwyg_finish'); ?> <?php } ?>
echo $lang_direction; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" rows="{$text_rows}"><?php echo $hvalue; ?> </textarea> </div> <?php if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; // SpawnMulti false per default (see multi nugget textareas, eg contactform) - where do we use jsname furthermore - or is that deprecated? serendipity_emit_htmlarea_code("nuggets{$elcount}", "nuggets{$elcount}"); } break; case 'content': ?> <div class="clearfix"> <?php echo $cbag->get('default'); ?> </div> <?php break; case 'hidden': ?> <div class="clearfix"> <input name="serendipity[plugin][<?php
echo $config_item; ?> ]" rows="20" cols="80"><?php echo $hvalue; ?> </textarea> </div> </td> </tr> <?php if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; if (version_compare(preg_replace('@[^0-9\\.]@', '', $serendipity['version']), '0.9', '<')) { serendipity_emit_htmlarea_code('nuggets' . $elcount, 'nuggets' . $elcount); } else { serendipity_emit_htmlarea_code('nuggets', 'nuggets', true); } } break; case 'content': ?> <tr><td colspan="2"><?php echo $cbag->get('default'); ?> </td></tr><?php break; case 'hidden': ?> <tr><td colspan="2"><input class="direction_<?php echo $lang_direction; ?>