コード例 #1
0
ファイル: Drafts.classes.php プロジェクト: ErdemA/wikihow
 public static function getDrafts($title = null, $userID = null)
 {
     global $wgUser;
     Draft::cleanDrafts();
     // Get db connection
     $dbw = wfGetDB(DB_MASTER);
     // Build where clause
     $where = array();
     if ($title !== null) {
         $pageId = $title->getArticleId();
         if ($pageId) {
             $where['draft_page'] = $pageId;
         } else {
             $where['draft_page'] = 0;
             // page not created yet
             $where['draft_namespace'] = $title->getNamespace();
             $where['draft_title'] = $title->getDBKey();
         }
     }
     if ($userID !== null) {
         $where['draft_user'] = $userID;
     } else {
         $where['draft_user'] = $wgUser->getID();
     }
     // Create an array of matching drafts
     $drafts = array();
     $result = $dbw->select('drafts', '*', $where, __METHOD__);
     if ($result) {
         while ($row = $dbw->fetchRow($result)) {
             // Add a new draft to the list from the row
             $drafts[] = Draft::newFromRow($row);
         }
     }
     // Return array of matching drafts
     return count($drafts) ? $drafts : null;
 }