當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Draft::ListDrafts方法代碼示例

本文整理匯總了PHP中Draft::ListDrafts方法的典型用法代碼示例。如果您正苦於以下問題:PHP Draft::ListDrafts方法的具體用法?PHP Draft::ListDrafts怎麽用?PHP Draft::ListDrafts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Draft的用法示例。


在下文中一共展示了Draft::ListDrafts方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadForm

 /**
  * EditPage::showEditForm:initial hook
  * Load draft...
  */
 public static function loadForm(&$editpage)
 {
     global $wgUser, $wgRequest, $wgOut, $wgTitle, $wgLang;
     if (!wfRunHooks("ShouldUseDrafts", array())) {
         return true;
     }
     // Check permissions
     //XXCHANGED
     $adv = $editpage->mGuided == true ? "" : "&advanced=true";
     $wgRequest->setVal("guidededitor", $editpage->mGuided);
     if ($wgUser->isAllowed('edit') && $wgUser->isLoggedIn()) {
         // Get draft
         $draft = Draft::newFromID($wgRequest->getIntOrNull('draft'));
         // Load form values
         if ($draft->exists()) {
             // Override initial values in the form with draft data
             $editpage->textbox1 = $draft->getText();
             $editpage->summary = $draft->getSummary();
             $editpage->scrolltop = $draft->getScrollTop();
             $editpage->minoredit = $draft->getMinorEdit() ? true : false;
         }
         // Save draft on non-save submission
         if ($wgRequest->getVal('action') == 'submit' && $wgUser->editToken() == $wgRequest->getText('wpEditToken')) {
             // If the draft wasn't specified in the url, try using a form-submitted one
             if (!$draft->exists()) {
                 $draft = Draft::newFromID($wgRequest->getIntOrNull('wpDraftID'));
             }
             // Load draft with info
             $draft->setTitle(Title::newFromText($wgRequest->getText('wpDraftTitle')));
             $draft->setSection($wgRequest->getInt('wpSection'));
             $draft->setStartTime($wgRequest->getText('wpStarttime'));
             $draft->setEditTime($wgRequest->getText('wpEdittime'));
             $draft->setSaveTime(wfTimestampNow());
             $draft->setScrollTop($wgRequest->getInt('wpScrolltop'));
             $draft->setText($wgRequest->getText('wpTextbox1'));
             $draft->setSummary($wgRequest->getText('wpSummary'));
             $draft->setMinorEdit($wgRequest->getInt('wpMinoredit', 0));
             // Save draft
             $draft->save();
             // Use the new draft id
             $wgRequest->setVal('draft', $draft->getID());
         }
     }
     // Internationalization
     wfLoadExtensionMessages('Drafts');
     $numDrafts = Draft::countDrafts($wgTitle);
     // Show list of drafts
     if ($numDrafts > 0) {
         if ($wgRequest->getText('action') !== 'submit') {
             $wgOut->addHTML(Xml::openElement('div', array('id' => 'drafts-list-box', 'class' => 'minor_section')));
             $wgOut->addHTML(Xml::element('h2', null, wfMsg('drafts-view-existing')));
             Draft::ListDrafts($wgTitle);
             $wgOut->addHTML(Xml::closeElement('div'));
         } else {
             $link = Xml::element('a', array('href' => $wgTitle->getFullURL("action=edit" . $adv), 'onclick' => "if( !wgAjaxSaveDraft.insync ) return confirm('" . Xml::escapeJsString(wfMsgHTML('drafts-view-warn')) . "')"), wfMsgExt('drafts-view-notice-link', array('parsemag'), $wgLang->formatNum($numDrafts)));
             $wgOut->addHTML('<div class="minor_section">' . wfMsgHTML('drafts-view-notice', $link) . '</div>');
         }
     }
     // Continue
     return true;
 }
開發者ID:ErdemA,項目名稱:wikihow,代碼行數:65,代碼來源:Drafts.hooks.php


注:本文中的Draft::ListDrafts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。