当前位置: 首页>>代码示例>>PHP>>正文


PHP Draft::countDrafts方法代码示例

本文整理汇总了PHP中Draft::countDrafts方法的典型用法代码示例。如果您正苦于以下问题:PHP Draft::countDrafts方法的具体用法?PHP Draft::countDrafts怎么用?PHP Draft::countDrafts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Draft的用法示例。


在下文中一共展示了Draft::countDrafts方法的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::countDrafts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。