Ejemplo n.º 1
0
 /**
  * Utility method to return the wikitext for an article
  */
 protected static function getWikitext(&$dbr, $title)
 {
     $rev = Revision::loadFromTitle($dbr, $title);
     if (!$rev) {
         return false;
     }
     $wikitext = $rev->getText();
     return $wikitext;
 }
Ejemplo n.º 2
0
/**
 * Extracts pages from the given namespace. Creates for
 * every page an article with the given extension containing all
 * the wiki markup.
 * 
 * @param $type namespace
 * @param $fext file extension
 */
function extractFromNamespace($type, $fext)
{
    global $helpDirectory, $dbr;
    print "\nExtracting pages from namespace {$type}...";
    $helpPages = smwfGetSemanticStore()->getPages(array($type));
    foreach ($helpPages as $hp) {
        print "\nExtract: " . $hp->getText() . "...";
        $rev = Revision::loadFromTitle($dbr, $hp);
        $wikitext = $rev->getText();
        $fname = rawurlencode($hp->getDBKey());
        $handle = fopen($helpDirectory . "/" . $fname . "." . $fext, "w");
        fwrite($handle, $wikitext);
        fclose($handle);
        extractImages($hp);
        print "done!";
    }
    print "\n\nAll pages from namespace {$type} extracted!\n";
}
Ejemplo n.º 3
0
 /**
  * Attempts to do 3-way merge of edit content with a base revision
  * and current content, in case of edit conflict, in whichever way appropriate
  * for the content type.
  *
  * @since 1.21
  *
  * @param Content $editContent
  *
  * @return bool
  */
 private function mergeChangesIntoContent(&$editContent)
 {
     wfProfileIn(__METHOD__);
     $db = wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = $this->getBaseRevision();
     $baseContent = $baseRevision ? $baseRevision->getContent() : null;
     if (is_null($baseContent)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mTitle);
     $currentContent = $currentRevision ? $currentRevision->getContent() : null;
     if (is_null($currentContent)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $handler = ContentHandler::getForModelID($baseContent->getModel());
     $result = $handler->merge3($baseContent, $editContent, $currentContent);
     if ($result) {
         $editContent = $result;
         wfProfileOut(__METHOD__);
         return true;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
Ejemplo n.º 4
0
 /**
  * @since 1.1
  *
  * @param UploadForm $image
  *
  * @return true
  */
 public function onUploadComplete(UploadForm $image)
 {
     global $wgServerName, $wgScriptPath, $wgServer, $wgVersion;
     $urlServer = 'http://' . $wgServerName . $wgScriptPath;
     // $classe = get_class($image);
     if (compareMWVersion($wgVersion, '1.16.0') == -1) {
         $localfile = $image->mLocalFile;
     } else {
         $localfile = $image->getLocalFile();
     }
     $path = utils::prepareString($localfile->mime, $localfile->size, $wgServer . urldecode($localfile->url));
     if (!file_exists($path)) {
         $dbr = wfGetDB(DB_SLAVE);
         $lastRevision = Revision::loadFromTitle($dbr, $localfile->getTitle());
         if ($lastRevision->getPrevious() == null) {
             $rev_id = 0;
         } else {
             $rev_id = $lastRevision->getPrevious()->getId();
         }
         $revID = $lastRevision->getId();
         $model = DSMWRevisionManager::loadModel($rev_id);
         $patch = new DSMWPatch(false, true, null, $urlServer, $rev_id, null, null, null, $localfile->mime, $localfile->size, urldecode($localfile->url), null);
         $patch->storePage($localfile->getTitle(), $revID);
         // stores the patch in a wikipage
         DSMWRevisionManager::storeModel($revID, $sessionId = session_id(), $model, $blobCB = 0);
     }
     return true;
 }
 /**
  *replaces the deleted semantic attribute in the feed page (pullfeed:.... or
  * pushfeed:....)
  * This aims to "virtualy" delete the article, it will no longer appear in the
  * special page (Special:ArticleAdminPage)
  *
  * @param <String> $feed
  * @return <boolean>
  */
 function deleteFeed($feed)
 {
     // if the browser page is refreshed, feed keeps the same value
     // but [[deleted::false| ]] isn't found and nothing is done
     preg_match("/^(.+?)_*:_*(.*)\$/S", $feed, $m);
     $articleName = $m[2];
     if ($m[1] == "PullFeed") {
         $title = Title::newFromText($articleName, PULLFEED);
     } elseif ($m[1] == "PushFeed") {
         $title = Title::newFromText($articleName, PUSHFEED);
     } else {
         throw new MWException(__METHOD__ . ': no valid namespace detected');
     }
     // get PushFeed by name
     $dbr = wfGetDB(DB_SLAVE);
     $revision = Revision::loadFromTitle($dbr, $title);
     $pageContent = $revision->getText();
     $dbr = wfGetDB(DB_SLAVE);
     $revision = Revision::loadFromTitle($dbr, $title);
     $pageContent = $revision->getText();
     // update deleted Value
     $result = str_replace("[[deleted::false| ]]", "[[deleted::true| ]]", $pageContent);
     if ($result == "") {
         return true;
     }
     $pageContent = $result;
     // save update
     $article = new Article($title);
     $article->doEdit($pageContent, $summary = "");
     return true;
 }
/**
 *In a pullfeed page, the value of [[hasPullHead::]] has to be updated with the
 *ChangeSetId of the last pulled ChangeSet
 *
 * @param <String> $name Pullfeed name (with namespace)
 * @param <String> $CSID ChangeSetID (without namespace)
 * @return <boolean> returns true if the update is successful
 */
function updatePullFeed($name, $CSID)
{
    // split NS and name
    preg_match("/^(.+?)_*:_*(.*)\$/S", $name, $m);
    $articleName = $m[2];
    // get PushFeed by name
    $title = Title::newFromText($articleName, PULLFEED);
    $dbr = wfGetDB(DB_SLAVE);
    $revision = Revision::loadFromTitle($dbr, $title);
    $pageContent = $revision->getText();
    // get hasPushHead Value if exists
    $start = "[[hasPullHead::";
    $val1 = strpos($pageContent, $start);
    if ($val1 !== false) {
        // if there is an occurence of [[hasPushHead::
        $startVal = $val1 + strlen($start);
        $end = "]]";
        $endVal = strpos($pageContent, $end, $startVal);
        $value = substr($pageContent, $startVal, $endVal - $startVal);
        // update hasPullHead Value
        $result = str_replace($value, $CSID, $pageContent);
        $pageContent = $result;
        if ($result == "") {
            return false;
        }
    } else {
        // no occurence of [[hasPushHead:: , we add
        $pageContent .= ' hasPullHead: [[hasPullHead::' . $CSID . ']]';
    }
    // save update
    $article = new Article($title);
    $article->doEdit($pageContent, $summary = "");
    return true;
}
Ejemplo n.º 7
0
 /**
  * Add blanked pages back to the blank_page table when they are undeleted
  */
 public static function PureWikiDeletionUndeleteHook($title, $create)
 {
     $dbr = wfGetDB(DB_SLAVE);
     $myRevision = Revision::loadFromTitle($dbr, $title);
     if ($myRevision->getRawText() == "") {
         $dbw = wfGetDB(DB_MASTER);
         $blank_row = array('blank_page_id' => $title->getArticleID(), 'blank_user_id' => $myRevision->getRawUser(), 'blank_user_name' => $myRevision->getRawUserText(), 'blank_timestamp' => $myRevision->getTimeStamp(), 'blank_summary' => $myRevision->getRawComment(), 'blank_parent_id' => $myRevision->getParentId());
         $dbw->insert('blanked_page', $blank_row);
     }
     return true;
 }
Ejemplo n.º 8
0
 /**
  * @private
  * @todo document
  *
  * @parma $editText string
  *
  * @return bool
  */
 function mergeChangesInto(&$editText)
 {
     wfProfileIn(__METHOD__);
     $db = wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = $this->getBaseRevision();
     if (is_null($baseRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $baseText = $baseRevision->getText();
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mTitle);
     if (is_null($currentRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $currentText = $currentRevision->getText();
     $result = '';
     if (wfMerge($baseText, $editText, $currentText, $result)) {
         $editText = $result;
         wfProfileOut(__METHOD__);
         return true;
     } else {
         wfProfileOut(__METHOD__);
         return false;
     }
 }
Ejemplo n.º 9
0
 /**
  * Utility method to return the wikitext for an article
  */
 public static function getWikitext(&$dbr, $title)
 {
     global $wgTitle;
     if (!$title) {
         return false;
     }
     // an optimization if $title is $wgTitle
     if ($wgTitle && $wgTitle->getText() == $title->getText()) {
         $whow = WikihowArticleEditor::newFromCurrent();
         $wikitext = $whow->mLoadText;
     } else {
         $rev = Revision::loadFromTitle($dbr, $title);
         if (!$rev) {
             return false;
         }
         $wikitext = $rev->getText();
     }
     return $wikitext;
 }
Ejemplo n.º 10
0
function newRev($article)
{
    global $wgCanonicalNamespaceNames;
    $indexNS = 0;
    $dbr = wfGetDB(DB_SLAVE);
    $article = str_replace(" ", "_", $article);
    preg_match("/^(.+?)_*:_*(.*)\$/S", $article, $tmp);
    $articleWithoutNS = $tmp[2];
    $NS = $tmp[1];
    if (in_array($NS, $wgCanonicalNamespaceNames)) {
        foreach ($wgCanonicalNamespaceNames as $key => $value) {
            if ($NS == $value) {
                $indexNS = $key;
            }
        }
    }
    $title = Title::newFromText($article);
    if (!$title->exists()) {
        $article = new Article($title);
        $article->doEdit('', '');
    } else {
        $lastRevision = Revision::loadFromTitle($dbr, $title);
        $rev_id = $lastRevision->getPrevious()->getId();
        $revID = $lastRevision->getId();
        $model = manager::loadModel($rev_id);
        $article = new Article($title);
        $article->quickEdit($model->getText(), '');
    }
}
Ejemplo n.º 11
0
 private function loadPerson($titleText)
 {
     $xml = null;
     $title = Title::newFromText($titleText, NS_PERSON);
     $revision = Revision::loadFromTitle($this->dbr, $title);
     // use load instead of new because I don't want to ever access DB_MASTER
     if ($revision) {
         $xml = StructuredData::getXml('person', $revision->getText());
     }
     return $xml;
 }
Ejemplo n.º 12
0
 /**
  * Grab the wikitext for the article record
  */
 private function getArticleWikiText()
 {
     // cache this if it was already pulled
     if ($this->wikitext) {
         return $this->wikitext;
     }
     if (!$this->title || !$this->title->exists()) {
         //throw new Exception('ArticleMetaInfo: title not found');
         return '';
     }
     $good = GoodRevision::newFromTitle($this->title, $this->articleID);
     $revid = $good ? $good->latestGood() : 0;
     $dbr = $this->getDB();
     $rev = Revision::loadFromTitle($dbr, $this->title, $revid);
     if (!$rev) {
         //throw new Exception('ArticleMetaInfo: could not load revision');
         return '';
     }
     $this->wikitext = $rev->getText();
     return $this->wikitext;
 }
Ejemplo n.º 13
0
 /**
  * Utility method to return the wikitext for an article
  */
 public static function getWikitext(&$dbr, $title)
 {
     global $wgTitle;
     if (!$title) {
         return false;
     }
     // try to see if the wikihow article editor instance already has this title loaded
     $whow = WikihowArticleEditor::wikiHowArticleIfMatchingTitle($title);
     if ($whow) {
         $wikitext = $whow->mLoadText;
     } else {
         $rev = Revision::loadFromTitle($dbr, $title);
         if (!$rev) {
             return false;
         }
         $wikitext = $rev->getText();
     }
     return $wikitext;
 }
Ejemplo n.º 14
0
 private function loadPedigree()
 {
     // read the person
     if ($this->title->getNamespace() == NS_PERSON) {
         $revision = Revision::loadFromTitle($this->dbr, $this->title);
         // use load instead of new because I don't want ShowPedigree to ever access DB_MASTER
         if ($revision) {
             $xml = StructuredData::getXml('person', $revision->getText());
             if ($xml) {
                 foreach ($xml->spouse_of_family as $spouseFamily) {
                     $pos = ShowPedigree::SPOUSE_FAMILY_BASE + $this->numSpouseFamilies;
                     $this->loadFamily((string) $spouseFamily['title'], $pos, 0);
                     if (@$this->families[$pos]['exists']) {
                         $this->numSpouseFamilies += 1;
                     } else {
                         $this->families[$pos] = null;
                     }
                 }
                 $this->loadFamily((string) $xml->child_of_family['title'], 1, ShowPedigree::MAX_FAMILIES);
                 if ($this->numSpouseFamilies == 0) {
                     // no spouse families exist; get information on self from the person page (put into ['husband'] - it shouldn't matter)
                     $this->loadSelf($this->families[ShowPedigree::SPOUSE_FAMILY_BASE]['husband'], $xml);
                 }
             }
         }
         $selfTitle = @$this->families[ShowPedigree::SPOUSE_FAMILY_BASE]['husband']['title'];
         if ($selfTitle) {
             $this->selfTag = $selfTitle == $this->title->getText() ? 'husband' : 'wife';
             $this->spouseTag = $this->selfTag == 'husband' ? 'wife' : 'husband';
         }
     } else {
         $this->loadFamily($this->title->getText(), 1, ShowPedigree::MAX_FAMILIES);
         $this->selfTag = '';
         $this->spouseTag = '';
     }
 }
Ejemplo n.º 15
0
 /**
  * Follow redirect (if any) in the text and return the target article.
  * Set the error if there is an error in the redirects.
  *
  * @param String $text
  * @param int $ns namespace of starting page
  * @param String $error
  * @param bool $redirTargetMustExist
  * @param bool $returnArticle if true, this function returns an article; otherwise it returns a revision
  * @return Revision/Article the final target of the redirects if there is a redirect and it exists
  */
 private static function followRedirects($text, $titleString, $ns, &$error, $redirTargetMustExist = false, $returnArticle = false, $useMDB = false)
 {
     $rt = Title::newFromRedirect($text);
     $ra = null;
     // Revision or Article
     if ($rt) {
         $seenTitles = array();
         $t = Title::newFromText($titleString, $ns);
         $seenTitles[] = $t->getPrefixedText();
     }
     // while redirected, follow redir but avoid loops and don't stray outside the namespace (redirecting mysource to source and source to repo is ok)
     while ($rt) {
         if ($rt->getInterwiki() != '' || $rt->getNamespace() != $ns && !($ns == NS_MYSOURCE && $rt->getNamespace() == NS_SOURCE) && !($ns == NS_SOURCE && ($rt->getNamespace() == NS_REPOSITORY || $rt->getNamespace() == NS_MAIN))) {
             // !!! this is ugly; should check outside of namespace in caller, not here
             $error = "Redirect is outside of namespace";
             return null;
         }
         if (!$rt->exists()) {
             if ($redirTargetMustExist) {
                 $error = "Redirect target does not exist";
             }
             return null;
         }
         $rtString = $rt->getPrefixedText();
         if (in_array($rtString, $seenTitles)) {
             $error = "Loop in redirects";
             return null;
         }
         $seenTitles[] = $rtString;
         if ($returnArticle) {
             $newTitle =& Title::makeTitle($rt->getNamespace(), $rt->getDBkey());
             $ra = new Article($newTitle, 0);
             $text =& $ra->fetchContent();
         } else {
             if ($useMDB) {
                 $dbw =& wfGetDb(DB_MASTER);
                 $ra = Revision::loadFromTitle($dbw, $rt);
             } else {
                 $ra = Revision::newFromTitle($rt);
             }
             $text =& $ra->getText();
         }
         $rt = Title::newFromRedirect($text);
     }
     return $ra;
 }
Ejemplo n.º 16
0
<?php

require_once 'commandLine.inc';
$dbw = wfGetDB(DB_MASTER);
print "Getting articles...\n";
$wgUser = User::newFromName('MiscBot');
$title_array = array('Make-a-LEGO-Key-Holder', 'Use-DigiArty-WinX-DVD-Author', 'Make-a-Shanghai-Cocktail', 'Switch-Tabs-in-Chrome', 'Catch-Walleye', 'Detect-Nofollow-Links', 'Make-a-Line-Plot', 'Make-the-Drink-the-Brain', 'Calculate-Stocking-Rates-for-Your-Pastures', 'Plead-Against-a-Ban-on-RuneScape', 'Make-Idli-Gunpowder-(Molagapodi)', 'Treat-Costochondritis', 'Enjoy-Calculus', 'Remove-Pips-from-Grapes', 'Alleviate-a-Sore-Nose-With-Petroleum-Jelly', 'Crochet-Shawls', 'Clean-and-Disinfect-Ice-Trays', 'Record-an-Upright-Acoustic-Bass', 'Make-a-Survival-Kit-in-a-Bottle', 'Carry-a-Football', 'Fix-a-Leaking-Roof', 'Write-a-Robots.Txt-File', 'Cope-With-Disruptive-People-During-a-Movie', 'Have-a-Private-Conversation-in-Public', 'Celebrate-National-Poetry-Month', 'Have-Fun-With-People-That-You-Don%27t-Like', 'Make-Premium-Pizzeria-Pizza', 'Create-a-Feeding-Routine-for-Your-Dog', 'Make-Hydrogen-from-Muriatic-Acid', 'Integrate-Music-Into-Creative-Writing', 'Be-an-Awesome-Girl-Without-Being-Athletic', 'Do-a-Buoyancy-Check', 'Make-Dryer-Sheets', 'Recite-the-Spanish-Alphabet', 'Use-Magnets-to-Locate-Studs', 'Do-Drive-By-Editing-While-Patrolling-wikiHow', 'Avoid-Awkward-Silences-when-You-Meet-Someone-Again-After-Sleeping-With-Them', 'Copy-an-Encrypted-DVD-to-a-Smaller-Capacity', 'Organize-Cloth-Diapers', 'Love-Your-Child-(Indian-Culture)', 'Cook-Fish-in-a-Double-Boiler', 'Get-Someone-to-Let-You-Draw-Them-Naked', 'Tie-a-Snapping-Turtle-So-It-Won%27t-Bite-You', 'Record-a-Kick-Drum', 'Reject-a-Homecoming-Date-(Girls)', 'Diagnose-High-Thyroid-Levels-in-a-Cat', 'Plan-a-Date-for-a-Foodie', 'Brew-Amber-Beer', 'Choose-an-Online-Dog-Training-Course', 'Make-Pickles-from-Leftover-Brine', 'Eradicate-the-Fear-of-Stuttering', 'Create-Nintendo-Wii-Skins', 'Convince-Your-Parents-to-Celebrate-4th-of-July', 'Improve-Your-Swim-School-Business', 'Unlock-the-Death-Count-in-Super-Mario-Galaxy', 'Buy-a-Waterproof-Camera', 'Make-Mock-Chicken-Filling', 'Make-Yogurt-Berry-Muffins', 'Make-a-Sphagnum-Moss-Wreath', 'Resist-the-Firemen%27s-Carry', 'Change-Instruments-from-Bb-Clarinet-to-Soprano-Saxophone', 'Get-the-Best-from-Fine-Scotch-Whiskies', 'Avoid-Unscrupulous-Bad-Credit-Loan-Brokers', 'Take-Care-of-a-Deaf-Great-Dane', 'Have-a-Gay-Marriage-in-New-York-Even-if-the-Church-Says-No', 'Protest-TSA-Screening-As-Sexual-Assault', 'Keep-Germs-off-Your-Purse', 'Teach-Your-Kids-to-Enjoy-Classic-Books', 'Appreciate-Patrick-Swayze', 'Cut-Down-on-Your-Medical-Costs', 'Change-the-Feel-of-a-Scene', 'Market-Your-Music-Like-Sir-Alan-Sugar', 'Make-Watercress-Potato-Salad', 'Be-a-Word-Collector', 'Get-the-IP-Address-of-Any-Website', 'Read-Supermarket-Labels', 'Make-Teriyaki-Grilled-Corn', 'Visit-the-Westminster-Clock-Tower', 'Build-a-Childrens-Ministry', 'Go-Green-at-the-Trade-Show', 'Pick-a-Mezuzah-Case', 'Get-a-Steady-Violin-Bow', 'Take-Your-Dog-for-a-Walk-in-Winter', 'Make-Wheat,-Beet-and-Walnut-Salad', 'Edit-wikiHow-Using-an-iPod-Touch', 'Make-Orange-(the-Fruit)-Jelly-Pumpkins', 'Leave-Home-for-the-First-Time', 'Hold-a-Cello-when-Resting', 'Destroy-a-Fortified-Position-in-Nerf', 'Get-a-Friend-to-Stop-Playing-the-Race-Card', 'Follow-Recent-Earthquakes-in-New-Zealand', 'Get-over-Your-Fear-of-Banks', 'Enjoy-the-Process-of-Drawing-Despite-Any-Messups', 'Get-to-Glasgow', 'Persuade-a-Friend-to-Let-You-Borrow-Her-Clothes', 'Look-Like-a-Tennis-Player', 'Make-Orange-and-Mustard-Chicken-Drummers', 'Wear-Boyfriend-Jeans', 'Vote-for-American-Idol', 'Use-the-Internet', 'Use-a-Proxy', 'Get-Good-at-Quick-Scoping-and-No-Scoping-on-Call-of-Duty-Black-Ops', 'Prune-Clematis', 'Play-Dota-2', 'Make-Hot-Fudge', 'Make-French-Onion-Soup', 'Make-a-Drum', 'Live', 'Have-Fun-With-Friends', 'Fly-in-Pandaria', 'Evolve-Clamperl-in-Pokemon', 'Come-out-of-One%27s-Shell', 'Catch-a-Pokemon-(Advanced)', 'Breed-the-Rainbow-Dragon-on-DragonVale', 'Update-Minecraft-for-the-Xbox-360-Version', 'Force-a-Burp', 'Immigrate-Into-the-United-States-Permanently', 'Install-Google-Talk-on-Your-Computer', 'Make-YouTube-Stop-Buffering', 'Burn-an-ISO-File-on-Windows-7', 'Do-the-%22Gallon-of-Milk%22-Challenge', 'Get-Unlimited-Money-on-the-Sims-3-for-PC', 'Camp-in-Call-of-Duty-Ghosts', 'Get-Hats-in-Team-Fortress-2', 'Start-a-Writer%27s-Notebook', 'Install-Windows-8-from-USB', 'Know-if-Your-Fish-Is-Male-or-Female', 'Use-a-Computer-Printer', 'Cook-Green-Split-Peas', 'Cook-Steak-in-the-Oven-So-It%27s-Tender', 'Adopt-a-Kid-in-the-Sims-3', 'Put-a-SIM-Card-Into-an-iPhone-3GS', 'Trim-a-String-in-Java', 'Make-Lavender-Tea', 'Change-Your-Name-in-Massachusetts', 'Make-a-Coffee-Milkshake', 'Make-Your-Own-Emergency-Eyeliner', 'Fix-Yu-Gi-Oh-Power-of-Chaos%27s-Data-Saving-Problem', 'Export-Audio-in-Audacity', 'Grow-Breasts-Without-Surgery', 'Use-Nasturtiums-in-Food', 'Catch-Bagon-on-Pokemon-Ruby', 'Use-Yahoo!-Answers', 'Transfer-Contacts-from-Windows-Mobile-Phone-to-Pc-with-GodswMobile.Com', 'Remove-an-Application-Off-Your-Twitter-Account', 'Edit-a-Facebook-Business-Page', 'Delete-Something-from-the-History-Section-of-Favourites', 'Make-a-Microphone-from-a-Speaker', 'Get-Rid-of-a-Beer-Belly', 'Live-a-Holistic-Life-of-Personal-Development', 'Get-Pichu-in-Pokemon-Ruby', 'Get-to-the-North-Pole', 'Delete-Your-iTunes-Library-(Mac)', 'Change-Your-Name-in-Kentucky', 'Get-a-Riolu-Egg-in-Pokemon-Diamond', 'Rent-a-Private-Mailbox', 'Incorporate-in-New-York', 'Text-a-Girl-(Young-Teens)', 'Fix-Usb-Device-Not-Recognized-Error', 'Find-the-Best-Muscle-Building-Workout', 'Access-a-Web-Page-That-Doesn%27t-Load-Fully', 'Be-Friends-With-Everyone-in-Sims-2', 'Hold-a-Guitar', 'Disable-a-Stolen-Mobile-Phone', 'Grow-Bird%27s-Nest-Fern-As-an-Indoor-Plant', 'Travel-with-Your-Guitar', 'Be-Familiar-with-the-Falcon-Crest-TV-Series', 'Use-E-Liquid', 'Draw-a-Sad-Face', 'Evolve-Electabuzz', 'Dump-Your-Boyfriend-in-Middle-School', 'Look-Goth-While-Traveling-for-a-Long-Time-on-a-Plane', 'Jailbreak-Your-iDevice-Right-from-It', 'Call-and-Text-With-Google-Voice-on-an-iPod-Touch', 'Build-a-Snail-House', 'Create-a-Website-With-Weebly.Com', 'K-Style-in-Gunz', 'Be-Bad', 'Be-Optimistic-in-a-Pessimistic-World', 'Become-a-Playback-Singer-in-Mumbai', 'Set-up-FTP-in-cPanel', 'Bypass-Impero-Blocking', 'Choose-Shaolin-Kung-Fu-Style', 'Use-an-Overhead-Projector', 'Make-Hair-Gel-Using-Aloe-Vera-Pulp', 'Have-Fresh-Breath', 'Make-a-Quick-Comic-Book', 'Make-a-Roblox-Username', 'Remove-DRM-from-Amazon-Video-on-Demand', 'Sound-Exactly-Like-Green-Day-for-Under-$500', 'Qualify-for-Innocent-Spouse-Tax-Relief', 'Dye-Your-Hair-with-a-Sharpie-Marker', 'Find-the-Big-Dipper', 'Create-the-Ultimate-Stamina-Type-Metal-Fight-Beyblade', 'Make-Windows-7-Calculator-Crash', 'Perform-a-Math-Trick', 'Use-Retinol', 'Get-Console-on-Counter-Strike-Source', 'Close-Your-Golf-Stance', 'Remove-a-Door-Panel-on-a-Chevy-Tracker', 'Apply-Individual-Eyelashes', 'Practise-Your-Weaker-Foot-for-Soccer', 'Obtain-a-Kentucky-Concealed-Deadly-Weapons-License', 'Get-a-Boyfriend-on-Animal-Jam', 'Practice-Drum-Rolls', 'Change-Your-Modern-Warfare-2-Name-Color', 'Play-Blindfolded-Makeover', 'Make-Easy-No-Bake-Cheesecake', 'Check-Your-Webpage-Loading-Time-with-Google-Analytics', 'Give-Your-Dog-a-Massage', 'Avoid-Awkward-Conversations', 'Check-Linux-Distribution', 'Host-a-Shower-for-a-Second-Wedding', 'Return-to-Sender', 'Deal-With-Parents', 'Fix-Slippery-Basketball-Shoes', 'Use-an-MLS', 'Check-Your-PSP-Firmware', 'Apply-for-a-Marriage-License-in-Nevada', 'Turn-Safely-on-a-Motorcycle', 'Look-Great-for-Swimming', 'Make-Nickelodeon-Slime', 'Set-up-a-Laptop-Computer-Station', 'Write-Declarative-Sentences', 'Open-the-Shed-on-Virtual-Families', 'Change-Pink-Paint-Into-an-Orange-Color', 'Sync-Files-Between-Computers-Using-Dropbox', 'Measure-a-Box', 'Do-a-Cartwheel-in-Gymnastics', 'Save-Text-Messages-on-a-Cell-Phone', 'Remove-Screws-That-Have-Been-Painted-Over', 'Commit-to-a-Relationship', 'Hit-the-Smash-Shot-in-Table-Tennis', 'Roleplay-a-Warrior-Cat-Online', 'Do-General-Maintenance-on-Airsoft-Gas-Blowback-Pistols', 'Write-a-Cheesy-Song', 'Make-a-Collage-Poster', 'Operate-a-CB-Radio', 'Do-a-Frontflip-With-a-Full-Twist-in-Gymnastics', 'Get-a-Soccer-Coaching-License', 'Act-Like-a-Hunter-from-Left-4-Dead', 'Draw-Insects', 'Win-a-Zynga-Poker-Sit-and-Go-Tournament', 'Handle-Being-Stuck-in-the-Middle-of-a-Fight', 'Become-an-Accountant-in-Florida', 'Do-a-Side-Effect', 'Get-Cat-Hairs-off-Your-Tongue', 'Tell-if-It-Is-Raining', 'Make-Your-Glasses-White-by-Reflection', 'Get-Ink-Flowing-in-Gel-Pens', 'Apply-for-a-Citibank-Credit-Card', 'Take-an-Online-Defensive-Driving-Course-for-Ticket-Dismissal-in-Florida', 'Set-a-GPS-with-a-Location', 'Deal-With-a-Guy-Who-Has-Used-You', 'Care-for-an-Ant', 'Tell-a-Girl-She-Has-Nice-Feet', 'Talk-Like-Stitch', 'Stop-a-Horse-from-Chewing-Wood', 'Make-Canadian-Style-Steak-Seasoning', 'Use-Nearbytweets.Com-to-Find-Tweeters-Near-You', 'Get-the-Rarest-Fish-on-Fish-Tycoon', 'Set-a-Noise-Gate-for-Vocals', 'Comment-in-HTML', 'Stop-Corruption-in-Your-Work-Place', 'Learn-Welsh', 'Decorate-a-Square-Living-Room', 'Defeat-Silver-the-Hedgehog-in-Sonic-the-Hedgehog-Next-Gen', 'Design-a-Simple-Web-Page-in-Div', 'Get-the-Best-Deal-when-Trading-Games-in-at-Gamestop', 'Ride-an-Electric-Scooter', 'Convince-Your-Parents-to-Get-You-a-Double-Bed', 'Perform-a-Shining-Wizard-Combo-Move-in-Pro-Wrestling', 'Thicken-Fake-Blood', 'Recover-Lost-Filezilla-FTP-Client-Passwords', 'Have-to-Pack-Your-Bag-for-Cheerleading', 'Make-a-Fart-Noise-With-a-Straw', 'Save-All-Your-Pocket-Money-Without-Spending-It', 'Act-Like-Spongebob-Squarepants', 'Build-a-Computer-Using-Tangible-Acoustic-Interfaces', 'Attract-Latin-Guys', 'Sleep-With-Your-Best-Friend-Nude', 'Cure-Hiccups-With-the-Sugar-Method', 'Prove-that-you-are-an-Eminem-Fan', 'Skip-and-Criss-Cross', 'Create-a-Template-for-Your-ID-Cards', 'Get-Tested-for-Chlamydia', 'Be-an-Easygoing-Parent', 'Be-Friends-With-Someone-Who-Shares-Your-First-Name', 'Do-a-Right-Leap', 'Create-a-Facebook-Account-Behind-Your-Parents-Back', 'Set-up-a-Spy-or-CSI-Agency', 'Activate-a-Blackberry-on-BES', 'Prevent-a-Dog-and-Cat-Tapeworm-Infection-(Dipylidium-Infection)', 'Not-Kick-in-Bed', 'Celebrate-Beltane', 'Cope-with-a-Staff-Shortage', 'Avoid-a-Guy-at-School', 'Draw-a-Lego-Spiderman', 'Build-Muscle-for-Weightlifting', 'Develop-a-Southern-Accent', 'Snowshoe', 'Make-a-Lean-To-Shelter', 'Make-Mini-Fruit-Pizzas-on-Sugar-Cookies', 'Recognize-a-Handball-in-Soccer', 'Find-Insurance-Records-from-a-Previous-Owner-of-a-Car', 'Use-Lowe%27s-Coupons', 'Come-up-With-a-Great-Quiz-Idea', 'Have-a-Beyonce-Makeup-Look', 'Pitch-Submarine', 'Make-a-Diaper-for-a-Male-Dog', 'Avoid-Keeping-Hair-Dye-in-Too-Long', 'Guess-Someone%27s-Age-Correctly', 'Convince-Your-Parents-to-Let-You-Buy-a-Mouse', 'Play-Fade-to-Black', 'Get-a-Homeschooled-Girl-to-Like-You', 'Buy-a-Video-Capture-Card', 'Be-an-Anti-Emo-Christian', 'Fix-a-Hanging-GM-Headliner', 'Break-up-With-Someone-Without-Hurting-Their-Feelings', 'Find-Someone-Else%27s-Marriage-License', 'Measure-Ski-Poles', 'Become-a-Real-Life-Tekken-Fighter', 'Improve-Your-Beer-Bong%27s-Effectiveness', 'Write-a-Romantic-Poem-at-the-Top-of-Your-Head', 'Thank-Someone-for-Coming-to-Your-Graduation-Party', 'Execute-a-Go-Around-in-a-Cessna-172', 'Order-a-Free-Watchtower-Bible', 'Decorate-a-Tween-Girl%27s-Room', 'Make-Your-Clothes-Emo-or-Goth', 'Act-Like-an-Addams-from-the-Addams-Family', 'Know-How-Often-to-Instant-Message-Someone-Without-Being-Clingy', 'Speak-With-a-Hindu-Accent', 'Watch-Football-on-Android', 'Make-a-Kissgloss-Lip-Scrub', 'Catch-Sardines-in-RuneScape', 'Invest-in-a-Store-in-Oblivion', 'Draw-a-Kiwi', 'Put-Together-a-Goodie-Bag', 'Deal-With-a-Crush-on-a-Relative', 'Play-with-Earthshaker-in-Defense-of-the-Ancients-(DotA)', 'Remove-Strawberry-Stains', 'Play-Smash-Well', 'Buy-a-50th-Wedding-Anniversary-Gift', 'Take-a-Bath-Without-Getting-Your-Hair-Wet', 'Complete-All-Poptropica-Islands-Quickly', 'Make-Aromatic-Blend-Bath-Salts', 'Find-Out-Your-GMAT-Results', 'Remove-Wax-from-Concrete', 'Highlight-the-Mouth-With-Makeup', 'Do-an-Impression', 'Be-a-Girly-Tomboy-in-Fifth-Grade', 'Do-the-Moonwalk-Forwards', 'Catch-a-Ditto-in-Pokemon-Diamond', 'Find-the-Best-Online-Dating-Sites', 'Recover-from-a-Bad-Round-of-Golf', 'Make-Money-by-Selling-Shirts-Online-for-Free', 'Find-Video-Game-Cheats-Online', 'Cut-Holes-in-a-T-Shirt', 'Buy-a-Personal-Jet', 'Place-the-Cake-at-Your-Wedding-Reception', 'Eat-Gross-Food', 'Communicate-With-Your-Spouse', 'Get-Plenty-of-Sleep-Before-a-Test', 'Get-Pid-in-Java', 'Kill-Most-Bosses-in-Resident-Evil-4', 'Hatch-Frog-Eggs', 'Make-a-Justin-Bieber-Poster', 'Be-a-Feminist-Without-Displaying-Your-Victimhood-Complex', 'Create-a-Clan-Cat', 'Not-Start-Drama', 'Buy-a-Shaver', 'Make-a-Barbie-Cooking-Show', 'Use-Spell-Scrolls-in-Ultima-IX-Multiple-Times-Without-Losing-the-Scroll', 'Buy-a-Keg', 'Make-the-Laptop-More-Secure-Operating-System', 'Choose-an-Iron-Supplement', 'Have-a-Fake-Phone-Conversation', 'Spot-a-Manipulator', 'Stop-a-Dog-from-Climbing-up-on-Things', 'Prevent-Your-Computer-from-Restarting-in-the-Middle-of-the-Night', 'Act-As-More-Than-One-Anime-Character-at-Once', 'Calculate-Family-Medical-and-Leave-Act-Leave-Time-Used', 'Evolve-Pichu-Into-Pikachu-on-Pokemon-Diamond', 'Be-the-Perfect-Bride', 'Fix-Avast-Setup-Registry-Errors', 'Make-Money-With-Domain-Parking', 'Kill-Your-Sim-With-Fire-on-the-Sims-2', 'Get-Leafeon-on-Pokemon-Diamond,-Pearl,-or-Platinum', 'Catch-Cod', 'Keep-Calm-on-Exam-Results-Day', 'Add-Moderators-to-a-Chat-Room-on-Justin.Tv', 'Shift-on-a-Quad-With-Clutch');
print "Done. Let us process the " . count($title_array) . " articles.\n";
$count = 0;
foreach ($title_array as $title_name) {
    $title = Title::newFromText($title_name);
    if (!$title) {
        continue;
    }
    $rev = Revision::loadFromTitle($dbw, $title);
    if ($rev) {
        $wikitext = $rev->getText();
        $intro = Wikitext::getIntro($rev->getText());
        if (preg_match("@{{stub[^}]*}}@i", $intro)) {
            $intro = preg_replace("@{{stub[^}]*}}@i", "", $intro);
            $wikitext = Wikitext::replaceIntro($wikitext, $intro, true);
            print "Removing from: " . $title->getText() . "\n";
            $article = new Article($title);
            $article->doEdit($wikitext, "Removing incorrectly placed stub template");
            $count++;
        }
    }
}
print "Deleted from {$count} articles\n";
Ejemplo n.º 17
0
 /**
  * @desc Saving CSS content
  * If there is more recent edit it will try to merge text and save.
  * Returns false when conflict is found and cannot be resolved
  *
  * @param string $content
  * @param string $summary
  * @param bool $isMinor
  * @param int $editTime timestamp
  * @param User $user
  * @return Status|bool
  */
 public function saveCssFileContent($content, $summary, $isMinor, $editTime, $user)
 {
     $cssTitle = $this->getCssFileTitle();
     $flags = 0;
     if ($cssTitle instanceof Title) {
         $aid = $cssTitle->getArticleID(Title::GAID_FOR_UPDATE);
         $flags |= $aid == 0 ? EDIT_NEW : EDIT_UPDATE;
         if ($isMinor) {
             $flags |= EDIT_MINOR;
         }
         $db = wfGetDB(DB_MASTER);
         $currentRevision = Revision::loadFromTitle($db, $cssTitle);
         // we handle both - edit and creation conflicts below
         if (!empty($currentRevision) && $editTime != $currentRevision->getTimestamp()) {
             $result = '';
             $currentText = $currentRevision->getText();
             if (!$editTime) {
                 // the css did not exist when the editor was started, so the base revision for
                 // parallel edits is an empty file
                 $baseText = '';
             } else {
                 $baseText = Revision::loadFromTimestamp($db, $this->getCssFileTitle(), $editTime)->getText();
             }
             // remove windows endlines from input before merging texts
             $content = str_replace("\r", "", $content);
             if (wfMerge($baseText, $content, $currentText, $result)) {
                 // This conflict can be resolved
                 $content = $result;
             } else {
                 // We have real conflict here
                 return false;
             }
         }
         $page = new WikiPage($cssTitle);
         $status = $page->doEdit($content, $summary, $flags, false, $user);
         return $status;
     }
     return Status::newFatal('special-css-saving-internal-error');
 }
Ejemplo n.º 18
0
 /**
  * @access private
  * @todo document
  */
 function mergeChangesInto(&$editText)
 {
     $fname = 'EditPage::mergeChangesInto';
     wfProfileIn($fname);
     $db =& wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = Revision::loadFromTimestamp($db, $this->mArticle->mTitle, $this->edittime);
     if (is_null($baseRevision)) {
         wfProfileOut($fname);
         return false;
     }
     $baseText = $baseRevision->getText();
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mArticle->mTitle);
     if (is_null($currentRevision)) {
         wfProfileOut($fname);
         return false;
     }
     $currentText = $currentRevision->getText();
     if (wfMerge($baseText, $editText, $currentText, $result)) {
         $editText = $result;
         wfProfileOut($fname);
         return true;
     } else {
         wfProfileOut($fname);
         return false;
     }
 }
function FrontBackForcedParserBeforeStripHook(&$parser, &$text, &$strip_state)
{
    global $wgLang;
    $frontMsg = wfMsgForContent('frontbackforced-front');
    $backMsg = wfMsgForContent('frontbackforced-back');
    $forcedMsg = wfMsgForContent('frontbackforced-forced');
    $dbr = wfGetDB(DB_SLAVE);
    $title = $parser->getTitle();
    if ($title->getNamespace() == NS_SPECIAL || $title->getNamespace() == NS_MEDIA || $title->getNamespace() == NS_FILE || $title->isExternal()) {
        return true;
    }
    $myRevision = Revision::loadFromTitle($dbr, $title);
    if ($myRevision != null) {
        $myText = $myRevision->getRawText();
        if ($text == $myText) {
            $frontMatterTitle = Title::newFromDBkey($title->getPrefixedDBkey() . $frontMsg);
            $frontMatterRev = Revision::loadFromTitle($dbr, $frontMatterTitle);
            if ($frontMatterRev != null) {
                $frontMatterText = $frontMatterRev->getRawText();
                $text = $frontMatterText . $text;
            }
            $backMatterTitle = Title::newFromDBkey($title->getPrefixedDBkey() . $backMsg);
            $backMatterRev = Revision::loadFromTitle($dbr, $backMatterTitle);
            if ($backMatterRev != null) {
                $backMatterText = $backMatterRev->getRawText();
                $text = $text . $backMatterText;
            }
            $forcedMatterTitle = Title::newFromDBkey($title->getPrefixedDBkey() . $forcedMsg);
            $forcedMatterRev = Revision::loadFromTitle($dbr, $forcedMatterTitle);
            if ($forcedMatterRev != null) {
                $forcedMatterText = $forcedMatterRev->getRawText();
                $strPosition = 0;
                $endPosition = 0;
                $endSubstPosition = 0;
                $thisCount = 0;
                while (1) {
                    $oldStrPosition = $strPosition;
                    $strPosition = strpos($forcedMatterText, '>', $strPosition);
                    if ($strPosition === false || $strPosition <= $oldStrPosition && $thisCount > 0) {
                        break;
                    }
                    $oldEndPosition = $endPosition;
                    $endPosition = strpos($forcedMatterText, '<', $strPosition);
                    if ($endPosition === false || $endPosition <= $oldEndPosition && $thisCount > 0) {
                        break;
                    }
                    $wfyText = substr($forcedMatterText, $strPosition + 1, $endPosition - $strPosition - 1);
                    $oldEndSubstPosition = $endSubstPosition;
                    $endSubstPosition = strpos($forcedMatterText, '#', $endPosition);
                    if ($endSubstPosition === false || $endSubstPosition - $endPosition == 1 || $endSubstPosition <= $oldEndSubstPosition && $thisCount > 0) {
                        $wfyToText = $wfyText;
                    } else {
                        $wfyToText = substr($forcedMatterText, $endPosition + 1, $endSubstPosition - $endPosition - 1);
                    }
                    $articleStartPos = strpos($text, $wfyText);
                    $continueThis = true;
                    if ($articleStartPos === false) {
                        $continueThis = false;
                    }
                    if ($articleStartPos > 2) {
                        if (substr($text, $articleStartPos - 2, 2) == '[[') {
                            $continueThis = false;
                        }
                    }
                    if ($continueThis == true) {
                        $text = substr($text, 0, $articleStartPos) . '[[' . $wfyToText . '|' . $wfyText . ']]' . substr($text, $articleStartPos + strlen($wfyText), strlen($text) - $articleStartPos - strlen($wfyText));
                    }
                    $thisCount++;
                    $strPosition++;
                }
            }
        }
    }
    return true;
}