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


PHP Article::insertNewArticle方法代碼示例

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


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

示例1: addWiki

function addWiki($lang, $site, $dbName)
{
    global $IP, $wgLanguageNames, $wgDefaultExternalStore;
    $name = $wgLanguageNames[$lang];
    $dbw =& wfGetDB(DB_WRITE);
    $common = "/home/wikipedia/common";
    $maintenance = "{$IP}/maintenance";
    print "Creating database {$dbName} for {$lang}.{$site}\n";
    # Set up the database
    $dbw->query("SET table_type=Innodb");
    $dbw->query("CREATE DATABASE {$dbName}");
    $dbw->selectDB($dbName);
    print "Initialising tables\n";
    dbsource("{$maintenance}/tables.sql", $dbw);
    dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw);
    $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
    # Initialise external storage
    if ($wgDefaultExternalStore && preg_match('!^DB://(.*)$!', $wgDefaultExternalStore, $m)) {
        print "Initialising external storage...\n";
        require_once 'ExternalStoreDB.php';
        global $wgDBuser, $wgDBpassword, $wgExternalServers;
        $cluster = $m[1];
        # Hack
        $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
        $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
        $store = new ExternalStoreDB();
        $extdb =& $store->getMaster($cluster);
        $extdb->query("SET table_type=InnoDB");
        $extdb->query("CREATE DATABASE {$dbName}");
        $extdb->selectDB($dbName);
        dbsource("{$maintenance}/storage/blobs.sql", $extdb);
        $extdb->immediateCommit();
    }
    $wgTitle = Title::newMainPage();
    $wgArticle = new Article($wgTitle);
    $ucsite = ucfirst($site);
    $wgArticle->insertNewArticle("\n==This subdomain is reserved for the creation of a {$ucsite} in '''[[:en:{$name}|{$name}]]''' language==\n\nIf you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.\n\nGo ahead. Translate this page and start working on your encyclopedia.\n\nFor help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.\n\n==Sister projects==\n[http://meta.wikipedia.org Meta-Wikipedia] | [http://www.wiktionary.org Wikitonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource]\n\nSee the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.\n\n[[aa:]]\n[[af:]]\n[[als:]]\n[[ar:]]\n[[de:]]\n[[en:]]\n[[as:]]\n[[ast:]]\n[[ay:]]\n[[az:]]\n[[be:]]\n[[bg:]]\n[[bn:]]\n[[bo:]]\n[[bs:]]\n[[cs:]]\n[[co:]]\n[[cs:]]\n[[cy:]]\n[[da:]]\n[[el:]]\n[[eo:]]\n[[es:]]\n[[et:]]\n[[eu:]]\n[[fa:]]\n[[fi:]]\n[[fr:]]\n[[fy:]]\n[[ga:]]\n[[gl:]]\n[[gn:]]\n[[gu:]]\n[[he:]]\n[[hi:]]\n[[hr:]]\n[[hy:]]\n[[ia:]]\n[[id:]]\n[[is:]]\n[[it:]]\n[[ja:]]\n[[ka:]]\n[[kk:]]\n[[km:]]\n[[kn:]]\n[[ko:]]\n[[ks:]]\n[[ku:]]\n[[ky:]]\n[[la:]]\n[[ln:]]\n[[lo:]]\n[[lt:]]\n[[lv:]]\n[[hu:]]\n[[mi:]]\n[[mk:]]\n[[ml:]]\n[[mn:]]\n[[mr:]]\n[[ms:]]\n[[mt:]]\n[[my:]]\n[[na:]]\n[[nah:]]\n[[nds:]]\n[[ne:]]\n[[nl:]]\n[[no:]]\n[[oc:]]\n[[om:]]\n[[pa:]]\n[[pl:]]\n[[ps:]]\n[[pt:]]\n[[qu:]]\n[[ro:]]\n[[ru:]]\n[[sa:]]\n[[si:]]\n[[sk:]]\n[[sl:]]\n[[sq:]]\n[[sr:]]\n[[sv:]]\n[[sw:]]\n[[ta:]]\n[[te:]]\n[[tg:]]\n[[th:]]\n[[tk:]]\n[[tl:]]\n[[tr:]]\n[[tt:]]\n[[ug:]]\n[[uk:]]\n[[ur:]]\n[[uz:]]\n[[vi:]]\n[[vo:]]\n[[xh:]]\n[[yo:]]\n[[za:]]\n[[zh:]]\n[[zu:]]\n", '', false, false);
    print "Adding to dblists\n";
    # Add to dblist
    $file = fopen("{$common}/all.dblist", "a");
    fwrite($file, "{$dbName}\n");
    fclose($file);
    # Update the sublists
    system("cd {$common} && ./refresh-dblist");
    print "Constructing interwiki SQL\n";
    # Rebuild interwiki tables
    $sql = getRebuildInterwikiSQL();
    $tempname = tempnam('/tmp', 'addwiki');
    $file = fopen($tempname, 'w');
    if (!$file) {
        wfDie("Error, unable to open temporary file {$tempname}\n");
    }
    fwrite($file, $sql);
    fclose($file);
    print "Sourcing interwiki SQL\n";
    dbsource($tempname, $dbw);
    unlink($tempname);
    print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
}
開發者ID:BackupTheBerlios,項目名稱:blahtex,代碼行數:59,代碼來源:addwiki.php

示例2: execute


//.........這裏部分代碼省略.........
            $wgOut->setArticleBodyOnly(true);
            $user = $wgUser->getName();
            $real_name = User::whoIsReal($wgUser->getID());
            if ($real_name == "") {
                $real_name = $user;
            }
            $dateStr = $wgLang->timeanddate(wfTimestampNow());
            $comment = $wgRequest->getVal("details");
            $text = $title->getFullText();
            wfDebug("STA: got text...");
            // filter out links
            $preg = "/[^\\s]*\\.[a-z][a-z][a-z]?[a-z]?/i";
            $matches = array();
            if (preg_match($preg, $comment, $matches) > 0) {
                $wgOut->addHTML(wfMsg('no_urls_in_kudos', $matches[0]));
                return;
            }
            $comment = strip_tags($comment);
            $formattedComment = wfMsg('postcomment_formatted_thanks', $dateStr, $user, $real_name, $comment, $text);
            wfDebug("STA: comment {$formattedComment}\n");
            wfDebug("STA: Checking blocks...");
            $tmp = "";
            if ($wgUser->isBlocked()) {
                $this->blockedIPpage();
                return;
            }
            if (!$wgUser->getID() && $wgWhitelistEdit) {
                $this->userNotLoggedInPage();
                return;
            }
            if ($target == "Spam-Blacklist") {
                $wgOut->readOnlyPage();
                return;
            }
            wfDebug("STA: checking read only\n");
            if (wfReadOnly()) {
                $wgOut->readOnlyPage();
                return;
            }
            wfDebug("STA: checking rate limiter\n");
            if ($wgUser->pingLimiter('userkudos')) {
                $wgOut->rateLimited();
                return;
            }
            wfDebug("STA: checking blacklist\n");
            if ($wgFilterCallback && $wgFilterCallback($title, $comment, "")) {
                // Error messages or other handling should be
                // performed by the filter function
                return;
            }
            wfDebug("STA: checking tokens\n");
            $usertoken = $wgRequest->getVal('token');
            $token1 = $this->getToken1();
            $token2 = $this->getToken2();
            if ($usertoken != $token1 && $usertoken != $token2) {
                wfDebug("STA: User kudos token doesn't match user: {$usertoken} token1: {$token1} token2: {$token2}");
                return;
            }
            wfDebug("STA: going through contributors\n");
            $article = new Article($title);
            //$contributors = $article->getContributors(0, 0, true);
            $contributors = ArticleAuthors::getAuthors($article->getID());
            foreach ($contributors as $k => $v) {
                $u = User::newFromName($k);
                $id = $u->getID();
                //$id = $c->getID();
                //$u = $c;
                wfDebug("STA: going through contributors {$u} {$id}\n");
                if ($id == "0") {
                    continue;
                }
                // forget the anon users.
                //notify via the echo notification system
                if (class_exists('EchoEvent')) {
                    EchoEvent::create(array('type' => 'kudos', 'title' => $title, 'extra' => array('kudoed-user-id' => $id), 'agent' => $wgUser));
                }
                $t = Title::newFromText("User_kudos:" . $u);
                $a = new Article($t);
                $update = $t->getArticleID() > 0;
                $text = "";
                if ($update) {
                    $text = $a->getContent(true);
                    $text .= "\n\n" . $formattedComment;
                    if ($wgFilterCallback && $wgFilterCallback($t, $text, $text)) {
                        // Error messages or other handling should be
                        // performed by the filter function
                        return;
                    }
                }
                if ($update) {
                    $a->updateArticle($text, "", true, false, false, '', false);
                } else {
                    $a->insertNewArticle($text, "", true, false, false, false, false);
                }
            }
            wfDebug("STA: done\n");
            $wgOut->addHTML("Done.");
            $wgOut->redirect('');
        }
    }
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:101,代碼來源:ThankAuthors.body.php

示例3: updateMainArticle

 function updateMainArticle($target, $editSummary)
 {
     global $wgOut, $wgRequest;
     $title = Title::makeTitle(NS_MAIN, $target);
     $vid = Title::makeTitle(NS_VIDEO, $target);
     $r = Revision::newFromTitle($title);
     $update = true;
     if (!$r) {
         $update = false;
         $text = "";
     } else {
         $text = $r->getText();
     }
     $tag = "{{" . $vid->getFullText() . "|}}";
     if ($wgRequest->getVal('description') != '') {
         $tag = "{{" . $vid->getFullText() . "|" . $wgRequest->getVal('description') . "}}";
     }
     $newsection .= "\n\n== " . wfMsg('video') . " ==\n{$tag}\n\n";
     $a = new Article($title);
     $newtext = "";
     // Check for existing video section in the target article
     preg_match("/^==[ ]*" . wfMsg('video') . "/im", $text, $matches, PREG_OFFSET_CAPTURE);
     if (sizeof($matches) > 0) {
         // There is an existing video section, replace it
         $i = $matches[0][1];
         preg_match("/^==/im", $text, $matches, PREG_OFFSET_CAPTURE, $i + 1);
         if (sizeof($matches) > 0) {
             $j = $matches[0][1];
             // == Video == was not the last section
             $newtext = trim(substr($text, 0, $i)) . $newsection . substr($text, $j, strlen($text));
         } else {
             // == Video == was the last section append it
             $newtext = trim($text) . $newsection;
         }
         // existing section, change it.
     } else {
         // There is not an existng video section, insert it after steps
         // This section could be cleaned up to handle it if there was an existing video section too I guess
         $arr = preg_split('/(^==[^=]*?==\\s*?$)/m', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
         $found = false;
         for ($i = 0; $i < sizeof($arr); $i++) {
             if (preg_match("/^==[ ]*" . wfMsg('steps') . "/", $arr[$i])) {
                 $newtext .= $arr[$i];
                 $i++;
                 if ($i < sizeof($arr)) {
                     $newtext .= $arr[$i];
                 }
                 $newtext = trim($newtext) . $newsection;
                 $found = true;
             } else {
                 $newtext .= $arr[$i];
             }
         }
         if (!$found) {
             $arr = preg_split('/(^==[^=]*?==\\s*?$)/m', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
             $newtext = "";
             $newtext = trim($arr[0]) . $newsection;
             for ($i = 1; $i < sizeof($arr); $i++) {
                 $newtext .= $arr[$i];
             }
         }
     }
     if ($newtext == "") {
         $newtext = $newsection;
     }
     $watch = $title->userIsWatching();
     if ($update) {
         $a->updateArticle($newtext, $editSummary, false, $watch);
     } else {
         $a->insertNewArticle($newtext, $editSummary, false, $watch);
     }
     if ($wgRequest->getVal("popup") == "true") {
         $wgOut->clearHTML();
         $wgOut->disable();
         echo "<script type='text/javascript'>\n\t\t\tfunction onLoad() {\n\t\t\t\tvar e = document.getElementById('video_text');\n\t\t\t\te.value = \"" . htmlspecialchars($tag) . "\";\n\t\t\t\tpv_Preview();\n\t\t\t\tvar summary = document.getElementById('wpSummary');\n\t\t\t\tif (summary.value != '')\n\t\t\t\t\tsummary.value += ',  " . ($update ? wfMsg('importvideo_changingvideo_summary') : $editSummary) . "';\n\t\t\t\telse\n\t\t\t\t\tsummary.value = '" . ($update ? wfMsg('importvideo_changingvideo_summary') : $editSummary) . "';\n\t\t\t\tcloseModal();\n\t\t\t}\n\t\t\tonLoad();\n\t\t\t\t</script>\n\t\t\t\t";
     }
     $me = Title::makeTitle(NS_SPECIAL, "Importvideo");
     if ($wgRequest->getVal('wasnew') || $wgRequest->getVal('new')) {
         // log it, we track when someone uploads a video for a new article
         $params = array($title->getArticleID());
         $log = new LogPage('vidsfornew', false);
         $log->addEntry('added', $title, 'added');
         $wgOut->redirect($me->getFullURL() . "?new=1&skip=" . $title->getArticleID());
         return;
     } else {
         if ($wgRequest->getVal('category')) {
             // they added a video to a category, keep them in the category mode
             $wgOut->redirect($me->getFullURL() . "?category=" . urlencode($wgRequest->getVal('category')));
             return;
         }
     }
 }
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:92,代碼來源:Importvideo.body.php

示例4: pbConfig

 function pbConfig()
 {
     global $wgUser, $wgRequest, $wgOut;
     $live = mysql_real_escape_string(strip_tags($wgRequest->getVal('live'), '<p><br><b><i>'));
     $occupation = mysql_real_escape_string(strip_tags($wgRequest->getVal('occupation'), '<p><br><b><i>'));
     $aboutme = mysql_real_escape_string(strip_tags($wgRequest->getVal('aboutme'), '<p><br><b><i>'));
     $t = Title::newFromText($wgUser->getUserPage() . '/profilebox-live');
     $article = new Article($t);
     if ($t->getArticleId() > 0) {
         $article->updateArticle($live, 'profilebox-live-update', true, $watch);
     } else {
         if ($live != '') {
             $article->insertNewArticle($live, 'profilebox-live-update', true, $watch, false, false, true);
         }
     }
     $t = Title::newFromText($wgUser->getUserPage() . '/profilebox-occupation');
     $article = new Article($t);
     if ($t->getArticleId() > 0) {
         $article->updateArticle($occupation, 'profilebox-occupation-update', true, $watch);
     } else {
         if ($occupation != '') {
             $article->insertNewArticle($occupation, 'profilebox-occupation-update', true, $watch, false, false, true);
         }
     }
     $t = Title::newFromText($wgUser->getUserPage() . '/profilebox-aboutme');
     $article = new Article($t);
     if ($t->getArticleId() > 0) {
         $article->updateArticle($aboutme, 'profilebox-aboutme-update', true, $watch);
     } else {
         if ($aboutme != '') {
             $article->insertNewArticle($aboutme, 'profilebox-aboutme-update', true, $watch, false, false, true);
         }
     }
     $userpageurl = $wgUser->getUserPage() . '';
     $t = Title::newFromText($userpageurl, NS_USER);
     $article = new Article($t);
     $userpage = " \n";
     if ($t->getArticleId() > 0) {
         /*
         $r = Revision::newFromTitle($t);
         $curtext .= $r->getText();
         
         if (!preg_match('/<!-- blank -->/',$curtext)) {
         	$userpage .= $curtext;
         	$article->updateArticle($userpage, 'profilebox-userpage-update', true, $watch);
         }
         */
     } else {
         $article->insertNewArticle($userpage, 'profilebox-userpage-update', true, $watch, false, false, true);
     }
     $wgUser->setOption('profilebox_fav1', $wgRequest->getVal('fav1'));
     $wgUser->setOption('profilebox_fav2', $wgRequest->getVal('fav2'));
     $wgUser->setOption('profilebox_fav3', $wgRequest->getVal('fav3'));
     if ($wgRequest->getVal('articleStats') == 'on') {
         $wgUser->setOption('profilebox_stats', 1);
     } else {
         $wgUser->setOption('profilebox_stats', 0);
     }
     if ($wgRequest->getVal('articleStartedEdited') == 'on') {
         $wgUser->setOption('profilebox_startedEdited', 1);
     } else {
         $wgUser->setOption('profilebox_startedEdited', 0);
     }
     /*
     		if ( ($wgRequest->getVal('articleFavs') == 'on') &&
     				($wgRequest->getVal('fav1') || $wgRequest->getVal('fav2') || $wgRequest->getVal('fav3')) )
     		{
     			$wgUser->setOption('profilebox_favs', 1);
     		} else {
     			$wgUser->setOption('profilebox_favs', 0);
     		}
     */
     $wgUser->setOption('profilebox_display', 1);
     $wgUser->saveSettings();
 }
開發者ID:ErdemA,項目名稱:wikihow,代碼行數:75,代碼來源:ProfileBox.body.php

示例5: execute

 function execute($par)
 {
     global $wgRequest, $wgTitle, $wgOut, $wgMemc, $wgUser;
     global $wgYTAS_User, $wgYTAS_Password, $wgYTAS_DeveloperId, $wgYTAS_ClientId;
     global $wgYTAS_DefaultCategory, $wgYTAS_UseClientLogin, $wgYTAS_EnableLogging, $wgYTAS_UseNamespace;
     $fname = "wfYouTubeAuthSub";
     # Check permissions
     if (!$wgUser->isAllowed('upload')) {
         if (!$wgUser->isLoggedIn()) {
             $wgOut->showErrorPage('uploadnologin', 'uploadnologintext');
         } else {
             $wgOut->permissionRequired('upload');
         }
         return;
     }
     if ($wgRequest->getVal('status') == '200' && $wgRequest->getVal('id') != null) {
         $wgOut->addHTML(wfMsg('youtubeauthsub_success', $wgRequest->getVal('id')));
         $descTitle = null;
         $desc = wfMsg('youtubeauthsub_summary');
         //TODO: can we grab the keywords and description the user has submitted?
         if ($wgYTAS_UseNamespace) {
             $descTitle = Title::makeTitle(NS_YOUTUBE, $wgRequest->getVal('id'));
             $a = new Article($descTitle);
             if ($a->getID() == 0) {
                 $title = $keywords = $description = $category = "";
                 if ($wgRequest->getVal('metaid') != null) {
                     $dbr = wfGetDB(DB_SLAVE);
                     $row = $dbr->selectRow('ytas_meta', array('ytas_title', 'ytas_description', 'ytas_keywords', 'ytas_category'), array("ytas_id={$wgRequest->getVal('metaid')}"));
                     if ($row) {
                         $title = $row->ytas_title;
                         $keywords = $row->ytas_keywords;
                         $description = $row->ytas_description;
                         $category = $row->ytas_category;
                     }
                 }
                 $content = "{{YoutubeVideo|{$wgRequest->getVal('id')}|{$title}|{$keywords}|{$description}|{$category}}}";
                 $a->insertNewArticle($content, wfMsg('youtubeauthsub_summary'), false, false);
                 $wgOut->redirect('');
             }
             $wgOut->addWikiText(wfMsg('youtubeauthsub_viewpage', $descTitle->getFullText()));
         }
         if ($wgYTAS_EnableLogging) {
             # Add the log entry
             $log = new LogPage('upload');
             $log->addEntry('upload', $descTitle, $desc);
         }
     }
     if ($wgYTAS_UseClientLogin) {
         $key = wfMemcKey('youtube', 'authsub', $wgYTAS_User);
         $token = $wgMemc->get($key);
         // regenerate the token
         if (!$token) {
             $result = $this->post("https://www.google.com/youtube/accounts/ClientLogin?", "Email={$wgYTAS_User}&Passwd={$wgYTAS_Password}&service=youtube&source=wikiHow");
             $YouTubeUser = "";
             $lines = split("\n", $result);
             foreach ($lines as $line) {
                 $params = split("=", $line);
                 switch ($params[0]) {
                     case "Auth":
                         $token = $params[1];
                         break;
                     case "YouTubeUser":
                         $YouTubeUser = $params[1];
                         break;
                 }
             }
             if (!$token) {
                 $wgOut->addHTML(wfMsg('youtubeauthsub_tokenerror'));
                 return;
             }
             $wgMemc->set($key, $token, time() + 3600);
         }
     } else {
         $token = $wgRequest->getVal('token');
         if (!$token) {
             $wgOut->addHTML(wfMsg('youtubeauthsub_authsubinstructions') . "\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\tvar gYTAS_nokeywords = '" . wfMsg('youtubeauthsub_jserror_nokeywords') . "';\n\t\t\t\t\t\tvar gYTAS_notitle = '" . wfMsg('youtubeauthsub_jserror_notitle') . "';\n\t\t\t\t\t</script>\n\t\t\t\t\t<script type='text/javascript' src='/extensions/YouTubeAuthSub/youtubeauthsub.js'>\n\t\t\t\t\t</script>\t\n\t\t\t\t\t<form action='https://www.google.com/accounts/AuthSubRequest' method='POST' onsubmit='return checkYTASForm();' name='ytas_form'/>\n\t\t\t\t\t<input type='hidden' name='next' value='{$wgTitle->getFullURL()}'/>\n\t\t\t\t\t<input type='hidden' name='scope' value='http://gdata.youtube.com/feeds'/>\n\t\t\t\t\t<input type='hidden' name='session' value='0'/>\n\t\t\t\t\t<input type='hidden' name='secure' value='0'/>\n\t\t\t\t\t<input type='submit' value='" . wfMsg('youtubeauthsub_clickhere') . "'/>");
             return;
         }
     }
     if ($wgRequest->wasPosted()) {
         $url = "http://uploads.gdata.youtube.com/feeds/api/users/{$wgYTAS_User}/uploads";
         $url = "http://gdata.youtube.com/action/GetUploadToken";
         $data = "<?xml version='1.0'?>\n\t<entry xmlns='http://www.w3.org/2005/Atom'\n\t  xmlns:media='http://search.yahoo.com/mrss/'\n\t  xmlns:yt='http://gdata.youtube.com/schemas/2007'>\n\t  <media:group>\n\t    <media:title type='plain'>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_title')) . "</media:title>\n\t    <media:description type='plain'>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_description')) . "</media:description>\n\t    <media:keywords>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_keywords')) . "</media:keywords>\n\t\t<media:category scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_category')) . "</media:category>\n\t  </media:group>\n\t</entry>\n\t";
         $headers = array("X-GData-Key: key={$wgYTAS_DeveloperId}", "X-GData-Client: {$wgYTAS_ClientId}", "Content-Type: application/atom+xml; charset=UTF-8", "Content-Length: " . strlen($data));
         if ($wgYTAS_UseClientLogin) {
             $headers[] = "Authorization: GoogleLogin auth={$token}";
         } else {
             $headers[] = "Authorization: AuthSub token={$token}";
         }
         $results = $this->post($url, $data, $headers);
         preg_match("/<token>.*<\\/token>/", $results, $matches);
         $token = strip_tags($matches[0]);
         preg_match("/'edit-media'[^>]*href='[^']*'>/", $results, $matches);
         preg_match("/<url>.*<\\/url>/", $results, $matches);
         $url = strip_tags($matches[0]);
         if ($url == "") {
             $wgOut->addHTML("Unable to extract URL, results where <pre>{$results}</pre>");
             return;
         }
         // CAPTURE THE META INFO AND STORE IT
//.........這裏部分代碼省略.........
開發者ID:ErdemA,項目名稱:wikihow,代碼行數:101,代碼來源:YouTubeAuthSub.body.php

示例6: execute

 public function execute()
 {
     global $IP, $wgDefaultExternalStore, $wgNoDBParam;
     $wgNoDBParam = true;
     $lang = $this->getArg(0);
     $site = $this->getArg(1);
     $dbName = $this->getArg(2);
     $domain = $this->getArg(3);
     $languageNames = Language::getLanguageNames();
     if (!isset($languageNames[$lang])) {
         $this->error("Language {$lang} not found in \$wgLanguageNames", true);
     }
     $name = $languageNames[$lang];
     $dbw = wfGetDB(DB_MASTER);
     $common = "/home/wikipedia/common";
     $this->output("Creating database {$dbName} for {$lang}.{$site} ({$name})\n");
     # Set up the database
     $dbw->query("SET table_type=Innodb");
     $dbw->query("CREATE DATABASE {$dbName}");
     $dbw->selectDB($dbName);
     $this->output("Initialising tables\n");
     $dbw->sourceFile($this->getDir() . '/tables.sql');
     $dbw->sourceFile("{$IP}/extensions/OAI/update_table.sql");
     $dbw->sourceFile("{$IP}/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql");
     $dbw->sourceFile("{$IP}/extensions/CheckUser/cu_changes.sql");
     $dbw->sourceFile("{$IP}/extensions/CheckUser/cu_log.sql");
     $dbw->sourceFile("{$IP}/extensions/TitleKey/titlekey.sql");
     $dbw->sourceFile("{$IP}/extensions/Oversight/hidden.sql");
     $dbw->sourceFile("{$IP}/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql");
     $dbw->sourceFile("{$IP}/extensions/AbuseFilter/abusefilter.tables.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/PrefStats/PrefStats.sql");
     $dbw->sourceFile("{$IP}/extensions/ProofreadPage/ProofreadPage.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/ClickTracking/ClickTrackingEvents.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/OptIn/OptIn.sql");
     $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
     # Initialise external storage
     if (is_array($wgDefaultExternalStore)) {
         $stores = $wgDefaultExternalStore;
     } elseif ($wgDefaultExternalStore) {
         $stores = array($wgDefaultExternalStore);
     } else {
         $stores = array();
     }
     if (count($stores)) {
         global $wgDBuser, $wgDBpassword, $wgExternalServers;
         foreach ($stores as $storeURL) {
             $m = array();
             if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) {
                 continue;
             }
             $cluster = $m[1];
             $this->output("Initialising external storage {$cluster}...\n");
             # Hack
             $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
             $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
             $store = new ExternalStoreDB();
             $extdb = $store->getMaster($cluster);
             $extdb->query("SET table_type=InnoDB");
             $extdb->query("CREATE DATABASE {$dbName}");
             $extdb->selectDB($dbName);
             # Hack x2
             $blobsTable = $store->getTable($extdb);
             $sedCmd = "sed s/blobs\\\\\\>/{$blobsTable}/ " . $this->getDir() . "/storage/blobs.sql";
             $blobsFile = popen($sedCmd, 'r');
             $extdb->sourceStream($blobsFile);
             pclose($blobsFile);
             $extdb->commit();
         }
     }
     global $wgTitle, $wgArticle;
     $wgTitle = Title::newFromText(wfMsgWeirdKey("mainpage/{$lang}"));
     $this->output("Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n");
     $wgArticle = new Article($wgTitle);
     $ucsite = ucfirst($site);
     $wgArticle->insertNewArticle($this->getFirstArticle($ucsite, $name), '', false, false);
     $this->output("Adding to dblists\n");
     # Add to dblist
     $file = fopen("{$common}/all.dblist", "a");
     fwrite($file, "{$dbName}\n");
     fclose($file);
     # Update the sublists
     shell_exec("cd {$common} && ./refresh-dblist");
     # print "Constructing interwiki SQL\n";
     # Rebuild interwiki tables
     # passthru( '/home/wikipedia/conf/interwiki/update' );
     $time = wfTimestamp(TS_RFC2822);
     // These arguments need to be escaped twice: once for echo and once for at
     $escDbName = wfEscapeShellArg(wfEscapeShellArg($dbName));
     $escTime = wfEscapeShellArg(wfEscapeShellArg($time));
     $escUcsite = wfEscapeShellArg(wfEscapeShellArg($ucsite));
     $escName = wfEscapeShellArg(wfEscapeShellArg($name));
     $escLang = wfEscapeShellArg(wfEscapeShellArg($lang));
     $escDomain = wfEscapeShellArg(wfEscapeShellArg($domain));
     shell_exec("echo notifyNewProjects {$escDbName} {$escTime} {$escUcsite} {$escName} {$escLang} {$escDomain} | at now + 15 minutes");
     $this->output("Script ended. You still have to:\n\t* Add any required settings in InitialiseSettings.php\n\t* Run sync-common-all\n\t* Run /home/wikipedia/conf/interwiki/update\n\t");
 }
開發者ID:GodelDesign,項目名稱:Godel,代碼行數:98,代碼來源:addwiki.php

示例7: createPreDefinedPages

 /**
  * Creates some predefined pages
  */
 protected function createPreDefinedPages($verbose)
 {
     global $smwgHaloContLang, $smwgContLang;
     DBHelper::reportProgress("Creating predefined pages...\n", $verbose);
     $ssp = $smwgHaloContLang->getSpecialSchemaPropertyArray();
     $propertyLabels = $smwgContLang->getPropertyLabels();
     $namespaces = $smwgContLang->getNamespaces();
     $datatypeLabels = $smwgContLang->getDatatypeLabels();
     foreach ($ssp as $key => $value) {
         $t = Title::newFromText($value, SMW_NS_PROPERTY);
         $article = new Article($t);
         if (!$t->exists()) {
             if (strtolower($ssp[SMW_SSP_HAS_DOMAIN_AND_RANGE_HINT]) == strtolower($t->getText())) {
                 $text = "\n\n[[" . $propertyLabels['_TYPE'] . "::Type:Record]]";
                 $text .= wfMsg('smw_predefined_props', $t->getText()) . "\n\n[[" . $propertyLabels['_LIST'] . "::" . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_wpg"] . "; " . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_wpg"] . "]]";
                 $article->insertNewArticle($text, "", false, false);
             } else {
                 if (strtolower($ssp[SMW_SSP_HAS_MAX_CARD]) == strtolower($t->getText())) {
                     // special handling for SMW_SSP_HAS_MAX_CARD.
                     $article->insertNewArticle(wfMsg('smw_predefined_props', $t->getText()) . "\n\n[[" . $propertyLabels['_TYPE'] . "::" . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_num"] . "]]", "", false, false);
                 } else {
                     if (strtolower($ssp[SMW_SSP_HAS_MIN_CARD]) == strtolower($t->getText())) {
                         // special handling for SMW_SSP_HAS_MIN_CARD.
                         $article->insertNewArticle(wfMsg('smw_predefined_props', $t->getText()) . "\n\n[[" . $propertyLabels['_TYPE'] . "::" . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_num"] . "]]", "", false, false);
                     } else {
                         $article->insertNewArticle(wfMsg('smw_predefined_props', $t->getText()), "", false, false);
                     }
                 }
             }
             DBHelper::reportProgress("   ... Create page " . $t->getNsText() . ":" . $t->getText() . "...\n", $verbose);
         } else {
             // save article again. Necessary when storage implementation has switched.
             $rev = Revision::newFromTitle($t);
             $article->doEdit($rev->getRawText(), $rev->getRawComment(), EDIT_UPDATE | EDIT_FORCE_BOT);
             DBHelper::reportProgress("   ... re-saved page " . $t->getNsText() . ":" . $t->getText() . ".\n", $verbose);
         }
     }
     $scs = $smwgHaloContLang->getSpecialCategoryArray();
     foreach ($scs as $key => $value) {
         $t = Title::newFromText($value, NS_CATEGORY);
         if (!$t->exists()) {
             $article = new Article($t);
             $article->insertNewArticle(wfMsg('smw_predefined_cats', $t->getText()), "", false, false);
             DBHelper::reportProgress("   ... Create page " . $t->getNsText() . ":" . $t->getText() . "...\n", $verbose);
         }
     }
     $this->createHelpAttributes($verbose);
     DBHelper::reportProgress("   ... done!\n", $verbose);
 }
開發者ID:seedbank,項目名稱:old-repo,代碼行數:52,代碼來源:SMW_SemanticStoreSQL.php

示例8: recordUpload

 /**
  * Record an image upload in the upload log and the image table
  */
 function recordUpload($oldver, $desc, $copyStatus = '', $source = '', $watch = false)
 {
     global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList;
     global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
     $fname = 'Image::recordUpload';
     $dbw =& wfGetDB(DB_MASTER);
     $this->checkDBSchema($dbw);
     // Delete thumbnails and refresh the metadata cache
     $this->purgeCache();
     // Fail now if the image isn't there
     if (!$this->fileExists || $this->fromSharedDirectory) {
         wfDebug("Image::recordUpload: File " . $this->imagePath . " went missing!\n");
         return false;
     }
     if ($wgUseCopyrightUpload) {
         $textdesc = '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n" . '== ' . wfMsg('filestatus') . " ==\n" . $copyStatus . "\n" . '== ' . wfMsg('filesource') . " ==\n" . $source;
     } else {
         $textdesc = $desc;
     }
     $now = $dbw->timestamp();
     #split mime type
     if (strpos($this->mime, '/') !== false) {
         list($major, $minor) = explode('/', $this->mime, 2);
     } else {
         $major = $this->mime;
         $minor = "unknown";
     }
     # Test to see if the row exists using INSERT IGNORE
     # This avoids race conditions by locking the row until the commit, and also
     # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
     $dbw->insert('image', array('img_name' => $this->name, 'img_size' => $this->size, 'img_width' => IntVal($this->width), 'img_height' => IntVal($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), $fname, 'IGNORE');
     $descTitle = $this->getTitle();
     $purgeURLs = array();
     if ($dbw->affectedRows() == 0) {
         # Collision, this is an update of an image
         # Insert previous contents into oldimage
         $dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text'), array('img_name' => $this->name), $fname);
         # Update the current image row
         $dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), array('img_name' => $this->name), $fname);
     }
     $article = new Article($descTitle);
     $minor = false;
     $watch = $watch || $wgUser->isWatched($descTitle);
     $suppressRC = true;
     // There's already a log entry, so don't double the RC load
     if ($descTitle->exists()) {
         // TODO: insert a null revision into the page history for this update.
         if ($watch) {
             $wgUser->addWatch($descTitle);
         }
         # Invalidate the cache for the description page
         $descTitle->invalidateCache();
         $purgeURLs[] = $descTitle->getInternalURL();
     } else {
         // New image; create the description page.
         $article->insertNewArticle($textdesc, $desc, $minor, $watch, $suppressRC);
     }
     # Invalidate cache for all pages using this image
     $linksTo = $this->getLinksTo();
     if ($wgUseSquid) {
         $u = SquidUpdate::newFromTitles($linksTo, $purgeURLs);
         array_push($wgPostCommitUpdateList, $u);
     }
     Title::touchArray($linksTo);
     $log = new LogPage('upload');
     $log->addEntry('upload', $descTitle, $desc);
     return true;
 }
開發者ID:BackupTheBerlios,項目名稱:openzaurus-svn,代碼行數:71,代碼來源:Image.php

示例9: addWiki

function addWiki($lang, $site, $dbName)
{
    global $IP, $wgLanguageNames, $wgDefaultExternalStore;
    $name = $wgLanguageNames[$lang];
    $dbw = wfGetDB(DB_WRITE);
    $common = "/home/wikipedia/common";
    $maintenance = "{$IP}/maintenance";
    print "Creating database {$dbName} for {$lang}.{$site}\n";
    # Set up the database
    $dbw->query("SET table_type=Innodb");
    $dbw->query("CREATE DATABASE {$dbName}");
    $dbw->selectDB($dbName);
    print "Initialising tables\n";
    dbsource("{$maintenance}/tables.sql", $dbw);
    dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw);
    dbsource("{$IP}/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw);
    dbsource("{$IP}/extensions/CheckUser/cu_changes.sql", $dbw);
    $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
    # Initialise external storage
    if (is_array($wgDefaultExternalStore)) {
        $stores = $wgDefaultExternalStore;
    } elseif ($stores) {
        $stores = array($wgDefaultExternalStore);
    } else {
        $stores = array();
    }
    if (count($stores)) {
        require_once 'ExternalStoreDB.php';
        print "Initialising external storage {$store}...\n";
        global $wgDBuser, $wgDBpassword, $wgExternalServers;
        foreach ($stores as $storeURL) {
            $m = array();
            if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) {
                continue;
            }
            $cluster = $m[1];
            # Hack
            $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
            $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
            $store = new ExternalStoreDB();
            $extdb =& $store->getMaster($cluster);
            $extdb->query("SET table_type=InnoDB");
            $extdb->query("CREATE DATABASE {$dbName}");
            $extdb->selectDB($dbName);
            dbsource("{$maintenance}/storage/blobs.sql", $extdb);
            $extdb->immediateCommit();
        }
    }
    global $wgTitle, $wgArticle;
    $wgTitle = Title::newMainPage();
    $wgArticle = new Article($wgTitle);
    $ucsite = ucfirst($site);
    $wgArticle->insertNewArticle(<<<EOT
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|{$ucsite}]] in '''[[w:en:{$name}|{$name}]]''' language==

* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|BetaWikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.

* If you would like to help translating the interface to this language, please do not translate here, but go to [[betawiki:|Betawiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].

* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].

== Sister projects ==
<span class="plainlinks">
[http://www.wikipedia.org Wikipedia] |
[http://www.wiktionary.org Wiktonary] |
[http://www.wikibooks.org Wikibooks] |
[http://www.wikinews.org Wikinews] |
[http://www.wikiquote.org Wikiquote] |
[http://www.wikisource.org Wikisource]
[http://www.wikiversity.org Wikiversity]
</span>

See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.

[[aa:]]
[[af:]]
[[als:]]
[[ar:]]
[[de:]]
[[en:]]
[[as:]]
[[ast:]]
[[ay:]]
[[az:]]
[[bcl:]]
[[be:]]
[[bg:]]
[[bn:]]
[[bo:]]
[[bs:]]
[[cs:]]
[[co:]]
[[cs:]]
[[cy:]]
[[da:]]
[[el:]]
[[eo:]]
[[es:]]
[[et:]]
[[eu:]]
//.........這裏部分代碼省略.........
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:101,代碼來源:addwiki.php

示例10: wfGetDB

// is to "close" the non-existent connection then request another.
$db->close();
$db = wfGetDB(DB_SLAVE);
$db->ping();
// Check if any of these noembed vids have links on the site
$start = microtime(true);
foreach ($vids as $i => $vid) {
    if ($vid['noembed']) {
        $sql = "SELECT count(*) AS C\n\t\t\t\tFROM pagelinks LEFT JOIN page ON pl_from = page_id\n\t\t\t\tWHERE pl_namespace=" . NS_VIDEO . "\n\t\t\t\t\tAND pl_title=" . $db->addQuotes($vid['text']) . "\n\t\t\t\t\tAND page_namespace=0";
        $res = $db->query($sql);
        if ($row = $res->fetchObject()) {
            if ($row->C == 0) {
                echo "{$vid['full-text']} has no links...skipping\n";
                continue;
            }
        }
        $list .= "# [[{$vid['full-text']}]]\n";
    }
}
if ($list == "") {
    $list = "There are no videos at this time.";
}
$t = Title::makeTitle(NS_PROJECT, "Videos that can no longer be embedded");
$a = new Article($t);
$date = date("Y-m-d");
$text = wfMsg('no_more_embed_video') . "\n\n{$list}\nThis page was last updated {$date}\n";
if ($t->getArticleID() == 0) {
    $a->insertNewArticle($text, "list of videos that cannot be embedded", false, false);
} else {
    $a->updateArticle($text, "list of videos that cannot be embedded", false, false);
}
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:31,代碼來源:checkEmbeddedVideos.php

示例11: execute

 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgHooks;
     if (!in_array('sysop', $wgUser->getGroups()) and !in_array('newarticlepatrol', $wgUser->getRights())) {
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $wgHooks['PreWikihowProcessHTML'][] = array('Misc::removePostProcessing');
     $this->setHeaders();
     $wgOut->addHTML("<div class='minor_section'>");
     $wgOut->addHTML(wfMsg('proposedredirects_info'));
     $t = Title::makeTitle(NS_PROJECT, "Proposed Redirects");
     $a = new Article($t);
     $wgOut->addHTML("<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/createpage/createpage.css?') . WH_SITEREV . "'; /*]]>*/</style> ");
     if ($wgRequest->wasPosted()) {
         // deal with collisions of loading and saving
         $changes = array();
         foreach ($wgRequest->getValues() as $key => $value) {
             if (strpos($key, "id-") === false) {
                 continue;
             }
             $id = str_replace("id-", "btn-", $key);
             $newval = $wgRequest->getVal($id);
             switch ($newval) {
                 case 'accept':
                 case 'reject':
                     $changes[$value] = $newval;
             }
         }
         foreach ($changes as $c => $v) {
             $params = split("_", $c);
             $from = Title::makeTitle(NS_MAIN, str_replace("_", " ", $params[0]));
             $to = Title::makeTitle(NS_MAIN, str_replace("_", " ", $params[1]));
             if ($v == 'accept') {
                 $a = new Article($from);
                 if ($from->getArticleID() == 0) {
                     $a->insertNewArticle("#REDIRECT [[{$to->getText()}]]\n", "Creating proposed redirect", false, false);
                     $log = new LogPage('redirects', true);
                     $log->addEntry('added', $from, 'added', array($to, $from));
                 } else {
                     $wgOut->addHTML("{$to->getText()} is an existing article, skipping<br/>");
                 }
             }
             $this->deleteProposedRedirect($from->getDBKey(), $to->getDBKey());
         }
         $wgOut->redirect('');
     }
     // regrab the text if necessary
     $r = Revision::newFromTitle($t);
     $text = "";
     if ($r) {
         $text = $r->getText();
     }
     $lines = split("\n", $text);
     $s = "";
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('proposedredirects', array('pr_from', 'pr_to', 'pr_user_text'), array(), "ProposedRedirects::execute", array("LIMIT" => 250));
     while ($row = $dbr->fetchObject($res)) {
         $u = User::newFromName($row->pr_user_text);
         $to = Title::newFromText($row->pr_to);
         $from = Title::newFromText($row->pr_from);
         $key = htmlspecialchars($from->getDBKey() . "_" . $to->getDBKey());
         if (!$u) {
             $url = "/User:{$row->pr_user_text}";
         } else {
             $url = $u->getUserPage()->getFullURL();
         }
         $id = rand(0, 10000);
         $s .= "<tr>\n\t\t\t\t\t<td>{$row->pr_user_text}</td>\n\t\t\t\t\t<td><a href='{$from->getFullURL()}' target='new'>{$from->getText()}</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<input type='hidden' name='id-{$id}' value=\"{$key}\"/>\n\t\t\t\t\t\t<a href='{$to->getFullURL()}' target='new'>{$to->getText()}</td>\n\t\t\t\t\t<td class='btn'><input type='radio' name='btn-{$id}' value='accept'/></td>\n\t\t\t\t\t<td class='btn'><input type='radio' name='btn-{$id}' value='skip' CHECKED/></td>\n\t\t\t\t\t<td class='btn'><input type='radio' name='btn-{$id}' value='reject'/></td>\n\t\t\t\t\t</tr>";
     }
     if ($s == "") {
         $wgOut->addHTML("There are currently no proposed redirects to show. Please check again later.");
     } else {
         $wgOut->addHTML("\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\tfunction clearForm(){\n\t\t\t\t\t\t\tfor (i = 0; i < document.proposedform.elements.length; i++) {\n\t\t\t\t\t\t\t\tvar e = document.proposedform.elements[i];\n\t\t\t\t\t\t\t\tif (e.type=='radio') {\n\t\t\t\t\t\t\t\t\tif (e.value=='skip') {\n\t\t\t\t\t\t\t\t\t\te.checked = true;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\te.checked = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfunction rejectAll(){\n\t\t\t\t\t\t\tfor (i = 0; i < document.proposedform.elements.length; i++) {\n\t\t\t\t\t\t\t\tvar e = document.proposedform.elements[i];\n\t\t\t\t\t\t\t\tif (e.type=='radio') {\n\t\t\t\t\t\t\t\t\tif (e.value=='reject') {\n\t\t\t\t\t\t\t\t\t\te.checked = true;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\te.checked = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\talert('Warning! You have chosen to reject all of the proposed redirects, please use this carefully. Press Reset to Undo.');\n\t\t\t\t\t\t}\n\t\t\t\t\t</script>\n\t\t\t\t\t<form method='POST' action='/Special:ProposedRedirects' name='proposedform'>\n\t\t\t\t\t\t<table class='p_redirects'>\n\t\t\t\t\t\t<tr class='toprow'>\n\t\t\t\t\t\t\t<td>User</td><td>Title</td><td>Current Article</td><td>Accept</td><td>Skip</td><td>Reject</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t{$s}\n\t\t\t\t\t\t</table>\n\t\t\t\t\t<table width='100%'>\n\t\t\t\t\t\t<tr><td>\n\t\t\t");
         if ($wgUser->isSysop()) {
             $wgOut->addHTML("<input type='button' class='guided-button' value='Reject all' onclick='rejectAll();'>");
         }
         $wgOut->addHTML("</td><td style='text-align: right;'>\n\t\t\t\t\t\t\t\t<input type='button' class='guided-button' value='Reset' onclick='clearForm();'>\n\t\t\t\t\t\t\t\t<input type='button' class='guided-button' value='" . wfMsg('Submit') . "'onclick='document.proposedform.submit();'>\n\t\t\t\t\t\t\t</td></tr></table>\n\t\t\t\t\t\t</form>");
     }
     $wgOut->addHTML("</div><!--end minor_section-->");
 }
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:81,代碼來源:CreatePage.body.php

示例12: createPage

 private function createPage(&$title, &$data)
 {
     $article = new Article($title);
     return $article->insertNewArticle($data, '', false, false, false, false);
 }
開發者ID:mediawiki-extensions,項目名稱:bizzwiki,代碼行數:5,代碼來源:SpecialPagesManagerUpdater.php

示例13: createUntitled

 /**
  * Create a dummy article for rendering content not associated with any title (unless it already exists)
  * - there's probably a better way to do this
  */
 function createUntitled()
 {
     $title = Title::newFromText(SIMPLEFORMS_UNTITLED);
     if (!$title->exists()) {
         $article = new Article($title);
         $article->insertNewArticle('Dummy article used by [http://www.mediawiki.org/wiki/Extension:Simple_Forms Extension:SimpleForms]', 'Dummy article created for Simple Forms extension', true, false);
     }
 }
開發者ID:hala54,項目名稱:DSMW,代碼行數:12,代碼來源:SimpleForms.php

示例14: recordUpload

 /**
  * Record an image upload in the upload log and the image table
  */
 function recordUpload($oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false)
 {
     global $wgUser, $wgUseCopyrightUpload;
     $dbw = wfGetDB(DB_MASTER);
     $this->checkDBSchema($dbw);
     // Delete thumbnails and refresh the metadata cache
     $this->purgeCache();
     // Fail now if the image isn't there
     if (!$this->fileExists || $this->fromSharedDirectory) {
         wfDebug("Image::recordUpload: File " . $this->imagePath . " went missing!\n");
         return false;
     }
     if ($wgUseCopyrightUpload) {
         if ($license != '') {
             $licensetxt = '== ' . wfMsgForContent('license') . " ==\n" . '{{' . $license . '}}' . "\n";
         }
         $textdesc = '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n" . '== ' . wfMsgForContent('filestatus') . " ==\n" . $copyStatus . "\n" . "{$licensetxt}" . '== ' . wfMsgForContent('filesource') . " ==\n" . $source;
     } else {
         if ($license != '') {
             $filedesc = $desc == '' ? '' : '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n";
             $textdesc = $filedesc . '== ' . wfMsgForContent('license') . " ==\n" . '{{' . $license . '}}' . "\n";
         } else {
             $textdesc = $desc;
         }
     }
     $now = $dbw->timestamp();
     #split mime type
     if (strpos($this->mime, '/') !== false) {
         list($major, $minor) = explode('/', $this->mime, 2);
     } else {
         $major = $this->mime;
         $minor = "unknown";
     }
     # Test to see if the row exists using INSERT IGNORE
     # This avoids race conditions by locking the row until the commit, and also
     # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
     $dbw->insert('image', array('img_name' => $this->name, 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), __METHOD__, 'IGNORE');
     if ($dbw->affectedRows() == 0) {
         # Collision, this is an update of an image
         # Insert previous contents into oldimage
         $dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text'), array('img_name' => $this->name), __METHOD__);
         # Update the current image row
         $dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), array('img_name' => $this->name), __METHOD__);
     } else {
         # This is a new image
         # Update the image count
         $site_stats = $dbw->tableName('site_stats');
         $dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
     }
     $descTitle = $this->getTitle();
     $article = new Article($descTitle);
     $minor = false;
     $watch = $watch || $wgUser->isWatched($descTitle);
     $suppressRC = true;
     // There's already a log entry, so don't double the RC load
     if ($descTitle->exists()) {
         // TODO: insert a null revision into the page history for this update.
         if ($watch) {
             $wgUser->addWatch($descTitle);
         }
         # Invalidate the cache for the description page
         $descTitle->invalidateCache();
         $descTitle->purgeSquid();
     } else {
         // New image; create the description page.
         $article->insertNewArticle($textdesc, $desc, $minor, $watch, $suppressRC);
     }
     # Hooks, hooks, the magic of hooks...
     wfRunHooks('FileUpload', array($this));
     # Add the log entry
     $log = new LogPage('upload');
     $log->addEntry('upload', $descTitle, $desc);
     # Commit the transaction now, in case something goes wrong later
     # The most important thing is that images don't get lost, especially archives
     $dbw->immediateCommit();
     # Invalidate cache for all pages using this image
     $update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
     $update->doUpdate();
     return true;
 }
開發者ID:Jobava,項目名稱:diacritice-meta-repo,代碼行數:83,代碼來源:Image.php

示例15: execute

 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
     global $wgRequest, $wgSitename, $wgLanguageCode, $IP;
     global $wgScript, $wgParser, $wgFilterCallback, $wgScriptPath;
     $fname = "wfSpecialRequestTopic";
     $action = "";
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (!$wgRequest->wasPosted()) {
         $wgOut->addHTML("<b>" . wfMsg('lookingforhow') . "</b> <br/> " . wfMsg('requestarticleexdog') . "<br/><br/> ");
         $this->getForm();
     } else {
         // this is a post, accept the POST data and create the
         // Request article
         $topic = $wgRequest->getVal('topic');
         $details = $wgRequest->getVal('details');
         if ($wgUser->getID() == 0 && preg_match("@http://@i", $details)) {
             $wgOut->addHTML("Error: anonymous users are not allowed to include links in requests.");
             return;
         }
         if (!isset($_POST['override']) && $wgLanguageCode == 'en') {
             $l = new LSearch();
             $titles = $l->googleSearchResultTitles($topic, 0, 5);
             if (sizeof($titles) > 0) {
                 $wgOut->addHTML(wfMsg('already-related-topics') . "<br>\n\t\t\t\t\t<ul id=Things_You27ll_Need>");
                 $count = 0;
                 foreach ($titles as $t) {
                     if ($count == 10) {
                         break;
                     }
                     if ($t == null) {
                         continue;
                     }
                     $wgOut->addHTML("<li style='margin-bottom: 0px'><a href=" . $t->getFullURL() . ">How to " . $t->getText() . "</a></li>");
                     $count++;
                 }
                 $wgOut->addHTML("</ul>");
                 $wgOut->addHTML(wfMsg('no-submit-existing-topic'));
                 $this->getForm(true);
                 return;
             }
         }
         // cut off extra ?'s or whatever
         if ($wgLanguageCode == 'en') {
             while (!ereg('[a-zA-Z0-9)\\"]$', $topic)) {
                 $topic = substr($topic, 0, strlen($topic) - 1);
             }
         }
         if ($wgLanguageCode == 'en') {
             require_once 'EditPageWrapper.php';
             $topic = EditPageWrapper::formatTitle($topic);
         }
         $title = Title::newFromText($topic, NS_ARTICLE_REQUEST);
         $category = $wgRequest->getVal("category", "");
         if ($category == "") {
             $category = "Other";
         }
         $details .= "\n[[Category:{$category} Requests]]";
         // check if we can do this
         if ($wgUser->isBlocked()) {
             $wgOut->addWikiText(wfMsg('blocked-ip'));
             return;
         }
         if ($wgUser->pingLimiter()) {
             $wgOut->rateLimited();
             return;
         }
         if ($wgFilterCallback && $wgFilterCallback($title, $details, $tmp)) {
             // Error messages or other handling should be performed by
             // the filter function
             return;
         }
         // create a user
         $user = null;
         if ($wgUser->getID() == 0) {
             if ($wgRequest->getVal('email', null)) {
                 $user = WikihowUser::createTemporaryUser($wgRequest->getVal('name'), $wgRequest->getVal('email'));
                 $wgUser = $user;
             }
         }
         if ($title->getArticleID() <= 0) {
             // not yet created. good.
             $article = new Article($title);
             $ret = $article->insertNewArticle($details, "", false, false, false, $user);
             wfRunHooks('ArticleSaveComplete', array(&$article, &$user, $details, "", false, false, NULL));
             //clear the redirect that is set by insertNewArticle
             $wgOut->redirect('');
             $options = ParserOptions::newFromUser($wgUser);
             $wgParser->parse($details, $title, $options);
         } else {
             // TODO: what to do here? give error / warning? append details?
             // this question has already been asked, if you want to ask
             // a slightly different question, go here:
         }
         $wgOut->addWikiText(wfMsg('thank-you-requesting-topic'));
         $wgOut->returnToMain(false);
     }
//.........這裏部分代碼省略.........
開發者ID:ErdemA,項目名稱:wikihow,代碼行數:101,代碼來源:RequestTopic.body.php


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