function &handle() { $req =& get_request("MW_RenameRequest"); $page =& get_current_page(); $new_name = $req->get_new_name(); if ($new_name === null) { $special_page = load_special_page(MW_SPECIAL_PAGE_RENAME); if ($special_page !== null) { render_ui(MW_LAYOUT_HEADER, _t("Renaming %0%", $page->name)); $special_page->render(); render_ui(MW_LAYOUT_FOOTER); return null_ref(); } } else { $success = $page->rename($new_name); add_info_text($success ? _t("Page renamed.") : _t("Page not renamed.")); # will not redirect itself if ($success && is_a($page, "MW_SpecialUploadPage")) { $new_page = new_upload_page($new_name, MW_REVISION_HEAD); set_current_page($new_page); } } return get_default_action(); }
function get_all_revisions() { $storage =& get_storage(); $resources = $storage->get_resource_history(MW_DS_UPLOADS, $this->upload_name, false); $ret = array(); $is_head = true; foreach ($resources as $res) { $page = new_upload_page($res->get(MW_RESOURCE_KEY_NAME), $res->get(MW_RESOURCE_KEY_REVISION)); $page->last_modified = $res->get(MW_RESOURCE_KEY_LAST_MODIFIED); $page->message = $res->get(MW_RESOURCE_KEY_MESSAGE); $page->user = $res->get(MW_RESOURCE_KEY_AUTHOR); if ($is_head) { $page->revision = MW_REVISION_HEAD; } $page->raw_content_length = $res->get(MW_RESOURCE_KEY_CONTENT_LENGTH); array_push($ret, $page); $is_head = false; } return $ret; }
/** * upload new file * @param content new content * @param message change message * @param name file name */ function upload($content, $message, $name) { $page = new_upload_page($name, MW_REVISION_HEAD); $page->update($content, $message); return $page; }