[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php # $Id: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $ 2 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) 3 # All rights reserved. See LICENSE file for licensing details 4 5 if (IN_serendipity !== true) { 6 die ("Don't hack!"); 7 } 8 9 if (defined('S9Y_FRAMEWORK_ENTRIES_ADMIN')) { 10 return; 11 } 12 @define('S9Y_FRAMEWORK_ENTRIES_ADMIN', true); 13 14 if (!defined('S9Y_FRAMEWORK_TRACKBACKS')) { 15 include (S9Y_INCLUDE_PATH . "include/functions_trackbacks.inc.php"); 16 } 17 18 /** 19 * Prints the form for editing/creating new blog entries 20 * 21 * This is the core file where your edit form appears. The Heart Of Gold, so to say. 22 * 23 * @access public 24 * @param string The URL where the entry form is submitted to 25 * @param array An array of hidden input fields that should be passed on to the HTML FORM 26 * @param array The entry superarray with your entry's contents 27 * @param string Any error messages that might have occured on the last run 28 * @return null 29 */ 30 function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "") { 31 global $serendipity; 32 33 $serendipity['EditorBrowsers'] = '(IE|Mozilla|Opera)'; 34 35 $draftD = ''; 36 $draftP = ''; 37 $categoryselector_expanded = false; 38 39 $template_vars = array(); 40 41 serendipity_plugin_api::hook_event('backend_entryform', $entry); 42 43 if ( (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft'])) || 44 (!isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') ) { 45 $draftD = ' selected="selected"'; 46 $template_vars['draft_mode'] = 'draft'; 47 } else { 48 $draftP = ' selected="selected"'; 49 $template_vars['draft_mode'] = 'publish'; 50 } 51 52 if (isset($entry['moderate_comments']) && (serendipity_db_bool($entry['moderate_comments']))) { 53 $template_vars['moderate_comments'] = true; 54 $moderate_comments = ' checked="checked"'; 55 } elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) { 56 // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration. 57 $moderate_comments = ' checked="checked"'; 58 $template_vars['moderate_comments'] = true; 59 } else { 60 $moderate_comments = ''; 61 $template_vars['moderate_comments'] = false; 62 } 63 64 65 if (isset($entry['allow_comments']) && (serendipity_db_bool($entry['allow_comments']))) { 66 $template_vars['allow_comments'] = true; 67 $allow_comments = ' checked="checked"'; 68 } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) { 69 // This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration. 70 $template_vars['allow_comments'] = true; 71 $allow_comments = ' checked="checked"'; 72 } else { 73 $template_vars['allow_comments'] = false; 74 $allow_comments = ''; 75 } 76 77 // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost. 78 if (is_array($entry['categories']) && !is_array($entry['categories'][0])) { 79 $categories = (array)$entry['categories']; 80 $entry['categories'] = array(); 81 foreach ($categories as $catid) { 82 $entry['categories'][] = serendipity_fetchCategoryInfo($catid); 83 } 84 } 85 86 $n = "\n"; 87 $cat_list = '<select id="categoryselector" name="serendipity[categories][]" style="vertical-align: middle;" multiple="multiple">' . $n; 88 $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n; 89 $selected = array(); 90 if (is_array($entry['categories'])) { 91 if (count($entry['categories']) > 1) { 92 $categoryselector_expanded = true; 93 } 94 95 foreach ($entry['categories'] as $cat) { 96 $selected[] = $cat['categoryid']; 97 } 98 } 99 100 if (count($selected) > 1 || 101 (isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1)) { 102 $categoryselector_expanded = true; 103 } 104 105 if (is_array($cats = serendipity_fetchCategories())) { 106 $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); 107 foreach ($cats as $cat) { 108 109 if (in_array($cat['categoryid'], $selected)) { 110 $cat['is_selected'] = true; 111 } 112 113 $cat['depth_pad'] = str_repeat(' ', $cat['depth']); 114 115 $template_vars['category_options'][] = $cat; 116 $cat_list .= '<option value="'. $cat['categoryid'] .'"'. ($cat['is_selected'] ? ' selected="selected"' : '') .'>'. $cat['depth_pad'] . $cat['category_name'] .'</option>' . "\n"; 117 } 118 } 119 120 $cat_list .= '</select>' . $n; 121 122 if (!empty($serendipity['GET']['title'])) { 123 $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title'])); 124 } 125 126 if (!empty($serendipity['GET']['body'])) { 127 $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body'])); 128 } 129 130 if (!empty($serendipity['GET']['url'])) { 131 $entry['body'] .= "\n" . '<br /><a href="' . htmlspecialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>'; 132 } 133 134 $hidden = ''; 135 foreach($hiddens as $key => $value) { 136 $hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $n; 137 } 138 $hidden .= ' <input type="hidden" id="entryid" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n; 139 $hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n; 140 $hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />'; 141 $hidden .= ' ' . serendipity_setFormToken(); 142 143 if (is_object($serendipity['smarty']) || (!$_SESSION['no_smarty'] && serendipity_smarty_init())) { 144 $use_smarty = true; 145 } else { 146 $use_smarty = false; 147 } 148 149 if (is_object($serendipity['smarty'])) { 150 if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { 151 $template_vars['allowDateManipulation'] = true; 152 } 153 154 if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { 155 $template_vars['show_wysiwyg'] = true; 156 } 157 158 if (eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) { 159 $template_vars['wysiwyg_advanced'] = true; 160 } 161 162 $template_vars['timestamp'] = serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); 163 $template_vars['reset_timestamp'] = serendipity_serverOffsetHour(time()); 164 $template_vars['hidden'] = $hidden; 165 $template_vars['errMsG'] = $errMsg; 166 $template_vars['entry'] =& $entry; 167 $template_vars['targetURL'] = $targetURL; 168 $template_vars['cat_count'] = count($cats)+1; 169 $template_vars['cat_state'] = $categoryselector_expanded ? 'on' : 'off'; 170 $template_vars['wysiwyg'] = $serendipity['wysiwyg']; 171 $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; 172 $template_vars['wysiwyg_blocks'] = array( 173 'body' => 'serendipity[body]', 174 'extended' => 'serendipity[extended]' 175 ); 176 177 $template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'); 178 179 $serendipity['smarty']->register_modifier('emit_htmlarea_code', 'serendipity_emit_htmlarea_code'); 180 $serendipity['smarty']->assign('admin_view', 'entryform'); 181 serendipity_plugin_api::hook_event('backend_entryform_smarty', $template_vars); 182 $serendipity['smarty']->assign_by_ref('entry_vars', $template_vars); 183 $serendipity['smarty']->display($template_vars['entry_template']); 184 return true; 185 } 186 187 /* HTML CODE BELOW IS FOR FALLBACK PORTABILITY ONLY - MODIFY CODE IN TEMPLATE ADMIN/ENTRIES.TPL INSTEAD! */ 188 if (!empty($errMsg)) { 189 ?> 190 <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> 191 <?php } ?> 192 <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"> 193 <?php echo $hidden; ?> 194 195 <table class="serendipityEntryEdit" border="0" width="100%"> 196 <tr> 197 <td> 198 <b><?php echo TITLE; ?>:</b> 199 </td> 200 <td colspan="2"> 201 <table width="100%" cellspacing="0" cellpadding="0" border="0"> 202 <tr> 203 <td><input class="input_textbox" type="text" id="entryTitle" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?>" size="60" /></td> 204 <td align="right"> 205 <select name="serendipity[isdraft]"> 206 <?php if ($_SESSION['serendipityRightPublish']) { ?><option value="false" <?php echo $draftP; ?>><?php echo PUBLISH; ?></option><?php } ?> 207 <option value="true" <?php echo $draftD; ?>><?php echo DRAFT; ?></option> 208 </select> 209 </td> 210 </tr> 211 </table> 212 </td> 213 </tr> 214 <tr> 215 <?php 216 if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { 217 ?> 218 <td> 219 <b><?php echo DATE; ?>:</b> 220 </td> 221 <td> 222 <input type="hidden" name="serendipity[chk_timestamp]" value="<?php echo serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); ?>" /> 223 <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())); ?>" /> 224 <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> 225 </td> 226 <td align="right"> 227 <?php 228 } else { 229 ?> 230 <td align="right" colspan="3"> 231 <?php 232 } 233 ?> 234 <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 ; ?> 235 <script type="text/javascript" language="JavaScript"> 236 237 function toggle_extended(setCookie) { 238 var textarea = document.getElementById('serendipity[extended]'); 239 var button = document.getElementById('option_extended'); 240 var tools = document.getElementById('tools_extended'); 241 if ( textarea.style.display == 'none' ) { 242 textarea.style.display = ''; 243 tools.style.display = ''; 244 button.src = '<?php echo serendipity_getTemplateFile('img/minus.png') ?>'; 245 if (setCookie == true) { 246 document.cookie = 'serendipity[toggle_extended]=true;'; 247 } 248 } else { 249 textarea.style.display = 'none'; 250 tools.style.display = 'none'; 251 button.src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>'; 252 if (setCookie == true) { 253 document.cookie = 'serendipity[toggle_extended]=;'; 254 } 255 } 256 } 257 258 var selector_toggle = new Array(); 259 var selector_store = new Array(); 260 var selector_restore = new Array(); 261 262 function showItem(id) { 263 var selected = 0; 264 if (typeof(id) == 'undefined' || typeof(id) == 'object') { 265 id = 'categoryselector'; 266 } 267 268 if (document.getElementById) { 269 el = document.getElementById(id); 270 if (selector_toggle[id] && selector_toggle[id] == 'off') { 271 selector_restore[id] = new Array(); 272 selector_toggle[id] = 'on'; 273 274 /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */ 275 last = 0; 276 277 for (i=0; i < el.options.length; i++) { 278 if (el.options[i].selected == true) { 279 selected++; 280 last = i; 281 selector_restore[id][last] = 'on'; 282 } 283 284 if (selected > 1) { 285 /* If there is more than one selected, we reset all those to false 286 This is because otherwise the label will say 'No Category', but the categories will still be selected */ 287 for (j=0; j < el.options.length; j++) { 288 /* Save selection in array to later restore them */ 289 if (el.options[j].selected == true) { 290 el.options[j].selected = false; 291 selector_restore[id][j] = 'on'; 292 last = j; 293 } else { 294 selector_restore[id][j] = false; 295 } 296 } 297 break; 298 } 299 } 300 301 el.selectedIndex = null; 302 if (last > 0) { 303 el.selectedIndex = last; 304 } 305 306 el.size = 1; 307 308 /* Show a normal dropdown */ 309 if (el.multiple) { 310 el.multiple = false; 311 } 312 313 document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>'; 314 } else { 315 selector_store[id] = el.size; 316 if (selector_store[id] == 0) { 317 selector_store[id] = 5; 318 } 319 320 last = 0; 321 if (el.selectedIndex > 0) { 322 if (!selector_restore[id]) { 323 selector_restore[id] = new Array(); 324 } 325 326 for (j=0; j < el.options.length; j++) { 327 /* Save selection in array to later restore them */ 328 if (el.options[j].selected == true) { 329 selector_restore[id][j] = 'on'; 330 last = j; 331 } 332 } 333 } 334 el.selectedIndex = -1; 335 el.size = <?php echo count($cats)+1; ?>; 336 selector_toggle[id] = 'off'; 337 338 /* Show multiple items */ 339 el.multiple = true; 340 341 /* Restore previously selected items? */ 342 last = 0; 343 for (i = 0; i < el.options.length; i++) { 344 if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') { 345 val = el.options[i].value; 346 if (el.options[i].selected != true) { 347 el.options[i].selected = true; 348 last = i; 349 // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this: 350 // alert('it doesnt matter what, just the alert is important'); 351 } 352 } 353 } 354 355 document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/minus.png') ?>'; 356 } 357 } 358 } 359 360 function checkSave() { 361 <?php 362 $void = null; 363 serendipity_plugin_api::hook_event('backend_entry_checkSave', $void); 364 ?> 365 return true; 366 } 367 368 selector_toggle['categoryselector'] = '<?php echo ($categoryselector_expanded ? 'on' : 'off'); ?>'; 369 addLoadEvent(showItem); 370 </script> 371 </td> 372 </tr> 373 <tr> 374 <?php 375 if (!$serendipity['wysiwyg']) { 376 ?> 377 <td colspan="2"><b><?php echo ENTRY_BODY; ?></b></td> 378 <td align="right"> 379 <?php 380 /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ 381 if (!$serendipity['wysiwyg'] && eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) { 382 ?> 383 <script type="text/javascript" language="JavaScript"> 384 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>\')" />'); 385 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>\')" />'); 386 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>\')" />'); 387 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>\')" />'); 388 document.write('<input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); 389 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\');" />'); 390 document.write('<input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); 391 </script> 392 <?php 393 /* Do the "old" non-WYSIWYG editor */ 394 } elseif (!$serendipity['wysiwyg']) { ?> 395 <script type="text/javascript" language="JavaScript"> 396 document.write('<input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'b\')">'); 397 document.write('<input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'u\')">'); 398 document.write('<input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'i\')">'); 399 document.write('<input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); 400 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\');">'); 401 document.write('<input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); 402 </script> 403 <?php } 404 405 serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); 406 } else { 407 ?> 408 <td colspan="2"><b><?php echo ENTRY_BODY; ?></b></td> 409 <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?> 410 411 <?php } ?> 412 </td> 413 </tr> 414 415 <tr> 416 <td colspan="3"> 417 <textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?></textarea> 418 </td> 419 </tr> 420 421 <tr> 422 <td colspan="3"> 423 <table width="100%" cellpadding="0" cellspacing="0"> 424 <tr> 425 <td align="left" width="70%"> 426 <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 /> 427 <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> 428 </td> 429 <td align="right" rowspan="2" valign="middle" width="30%"> 430 <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 /> 431 <input accesskey="s" type="submit" onclick="return checkSave();" value="- <?php echo SAVE; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" /> 432 </td> 433 </tr> 434 </table> 435 <br /> 436 </td> 437 </tr> 438 439 <tr> 440 <td colspan="2"> 441 <?php if (!$serendipity['wysiwyg']) { ?> 442 <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> 443 <?php } ?> <b><?php echo EXTENDED_BODY; ?></b></td> 444 <td align="right"> 445 <?php 446 if (!$serendipity['wysiwyg']) { 447 ?> 448 <div id="tools_extended" style="display: none"> 449 <?php 450 /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ 451 if (eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) { 452 ?> 453 <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>')" /> 454 <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>')" /> 455 <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>')" /> 456 <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>')" /> 457 <input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[extended]'])" /> 458 <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');" /> 459 <input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[extended]'])" /> 460 <?php 461 /* Do the "old" non-WYSIWYG editor */ 462 } else { ?> 463 <input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'b')"> 464 <input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'u')"> 465 <input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'i')"> 466 <input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[extended]'])"> 467 <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');"> 468 <input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[extended]'])"> 469 <?php 470 } 471 472 serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); 473 ?> 474 </div> 475 <?php } else { 476 serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); 477 } ?> 478 </td> 479 </tr> 480 481 <tr> 482 <td colspan="3"> 483 <textarea style="width: 100%;" name="serendipity[extended]" id="serendipity[extended]" cols="80" rows="20"><?php echo isset($entry['extended']) ? htmlspecialchars($entry['extended']) : ''; ?></textarea> 484 <?php if (!$serendipity['wysiwyg']) { ?> 485 <script type="text/javascript" language="JavaScript"> 486 toggle_extended(); 487 </script> 488 <?php } ?> 489 </td> 490 </tr> 491 492 <tr> 493 <td colspan="3"> 494 <br /> 495 <fieldset> 496 <legend><b><?php echo ADVANCED_OPTIONS; ?></b></legend> 497 <?php 498 serendipity_plugin_api::hook_event('backend_display', $entry); 499 ?> 500 </fieldset> 501 </td> 502 </tr> 503 </table> 504 </form> 505 <?php 506 if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { 507 ?> 508 <script type="text/javascript" language="JavaScript"> 509 toggle_extended(); 510 </script> 511 <?php } ?> 512 <?php 513 if ($serendipity['wysiwyg']) { 514 $fields = array( 515 'body' => 'serendipity[body]', 516 'extended' => 'serendipity[extended]' 517 ); 518 519 foreach($fields AS $f_jsname => $f_item) { 520 serendipity_emit_htmlarea_code($f_item, $f_jsname); 521 } 522 serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $fields); 523 } 524 525 echo ' <script type="text/javascript" language="JavaScript" src="serendipity_define.js.php"></script>'; 526 echo ' <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>'; 527 } 528 529 function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) { 530 static $init = false; 531 global $serendipity; 532 533 if ($init && $spawnMulti) { 534 return true; 535 } 536 537 if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg']) { 538 539 $eventData = array( 540 'init' => &$init, 541 'item' => &$item, 542 'jsname' => &$jsname, 543 'skip' => false 544 ); 545 serendipity_plugin_api::hook_event('backend_wysiwyg', $eventData); 546 547 if ($eventData['skip']) { 548 return true; 549 } 550 551 if (!$init) { 552 ?> 553 <script type="text/javascript"> 554 _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'htmlarea/'; ?>"; 555 _editor_lang = "<?php echo WYSIWYG_LANG; ?>"; 556 var editorref = ''; 557 </script> 558 <script type="text/javascript" src="htmlarea/htmlarea.js"></script> 559 <script type="text/javascript" src="htmlarea/lang/<?php echo WYSIWYG_LANG; ?>.js"></script> 560 <script type="text/javascript" src="htmlarea/dialog.js"></script> 561 <style type="text/css">@import url(htmlarea/htmlarea.css);</style> 562 <?php 563 } 564 565 $csscode = str_replace( 566 array( 567 "\n", 568 "'", 569 "\r", 570 "{LANG_DIRECTION}" 571 ), 572 573 array( 574 '\n', 575 "\'", 576 "", 577 (defined('LANG_DIRECTION') ? LANG_DIRECTION : 'ltr') 578 ), 579 580 file_get_contents(serendipity_getTemplateFile('htmlarea.css', 'serendipityPath')) 581 ); 582 ?> 583 <script type="text/javascript"> 584 // IF you want to enable HTMLArea's spellchecker, download the SpellChecker plugin from the HTMLArea homepage 585 // (http://www.sourceforge.net/projects/itools-htmlarea) and uncomment the lines suffixed with ' // [SPELLCHECK]' 586 // Note that the SpellChecker is a CGI-based application which needs setup in your Apache host ("Options +CGIExec") 587 // Thanks to Randall for pointing this out! 588 589 // HTMLArea.loadPlugin("SpellChecker"); // [SPELLCHECK] 590 <?php if($spawnMulti) { ?> 591 // when spawning multiple editors at once, keep track of instances in this array 592 var htmlarea_editors = new Array(); 593 <?php } else { ?> 594 var editor<?php echo $jsname; ?> = null; var config<?php echo $jsname; ?> = null; 595 <?php } // end if ?> 596 function Spawn<?php echo $jsname; ?>(<?php echo $spawnMulti ? 'id' : ''; ?>) { 597 editor<?php echo $jsname; ?> = new HTMLArea("<?php echo $item; ?>"<?php echo $spawnMulti ? ' + id' : ''; ?>); 598 <?php if($spawnMulti) { ?> 599 htmlarea_editors["<?php echo $item; ?>"<?php echo $spawnMulti ? ' + id' : ''; ?>] = editor<?php echo $jsname; ?>; 600 <?php } // end if ?> 601 config<?php echo $jsname; ?> = editor<?php echo $jsname; ?>.config; 602 config<?php echo $jsname; ?>.registerButton('image_selector', '<?PHP echo MANAGE_IMAGES; ?>', '<?php echo $serendipity['serendipityHTTPPath']; ?>htmlarea/images/ed_s9yimage.gif', false, 603 function(editor, id) { 604 window.open('<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo $jsname . ($spawnMulti ? "' + editor._textArea.id + '" : ''); ?>', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); 605 editorref = editor<?php echo $jsname; ?>; 606 } 607 ); 608 config<?php echo $jsname; ?>.toolbar.push([ "image_selector"]); 609 config<?php echo $jsname; ?>.cssFile = '<?php echo $csscode; ?>'; 610 config<?php echo $jsname; ?>.toolbar = [ 611 [ "fontname", "space", 612 "fontsize", "space", 613 "formatblock", "space", 614 "bold", "italic", "underline", "strikethrough", "separator", 615 "subscript", "superscript", "separator", 616 "copy", "cut", "paste", "space", "undo", "redo" ], 617 618 [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator", 619 "lefttoright", "righttoleft", "separator", 620 "orderedlist", "unorderedlist", "outdent", "indent", "separator", 621 "forecolor", "hilitecolor", "separator", 622 "inserthorizontalrule", "createlink", "insertimage", "image_selector", "inserttable", "htmlmode", "separator", 623 "popupeditor", "separator", "showhelp", "about" ] 624 ]; 625 // editor<?php echo $jsname; ?>.registerPlugin(SpellChecker); // [SPELLCHECK] 626 editor<?php echo $jsname; ?>.generate(); 627 editor<?php echo $jsname; ?>._textArea.className = 'serendipity_entry'; 628 } 629 </script> 630 <?php 631 } 632 633 $init = true; 634 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |