364 /** |
364 /** |
365 * Updates (saves/changes/edits) the content of the page. |
365 * Updates (saves/changes/edits) the content of the page. |
366 * @param string The new text for the page |
366 * @param string The new text for the page |
367 * @param string A summary of edits made to the page. |
367 * @param string A summary of edits made to the page. |
368 * @param bool If true, the edit is marked as a minor revision |
368 * @param bool If true, the edit is marked as a minor revision |
369 * @param string Page format - wikitext or xhtml. REQUIRED, and new in 1.1.6. |
369 * @param string Page format. New in 1.1.6; defaults to "wikitext" |
370 * @param array Optional - the entire incoming request. Plugins can add their own data to it. |
370 * @param array Optional - the entire incoming request. Plugins can add their own data to it. |
371 * @return bool True on success, false on failure. When returning false, it will push errors to the PageProcessor error stack; read with $page->pop_error() |
371 * @return bool True on success, false on failure. When returning false, it will push errors to the PageProcessor error stack; read with $page->pop_error() |
372 */ |
372 */ |
373 |
373 |
374 function update_page($text, $edit_summary = false, $minor_edit = false, $page_format, $raw_request = array()) |
374 function update_page($text, $edit_summary = false, $minor_edit = false, $page_format = 'wikitext', $raw_request = array()) |
375 { |
375 { |
376 global $db, $session, $paths, $template, $plugins; // Common objects |
376 global $db, $session, $paths, $template, $plugins; // Common objects |
377 global $lang; |
377 global $lang; |
378 |
378 |
379 // Create the page if it doesn't exist |
379 // Create the page if it doesn't exist |
442 $this->raise_error($lang->get('editor_err_spamcheck_failed')); |
442 $this->raise_error($lang->get('editor_err_spamcheck_failed')); |
443 return false; |
443 return false; |
444 } |
444 } |
445 |
445 |
446 // Page format check |
446 // Page format check |
447 if ( !in_array($page_format, array('xhtml', 'wikitext')) ) |
447 $page_format = $db->escape($page_format); |
448 { |
448 if ( !preg_match('/^[a-z0-9_]+$/', $page_format) ) |
449 $this->raise_error("format \"$page_format\" not one of [xhtml, wikitext]"); |
449 { |
|
450 $this->raise_error('Page format must match /^[a-z0-9_]+$/'); |
450 return false; |
451 return false; |
451 } |
452 } |
452 |
453 |
453 // |
454 // |
454 // Protection validated; update page content |
455 // Protection validated; update page content |