/** * Cycle through the url list to call the removeIntroImages function */ private static function removeIntroImagesUrls(&$urls, $px, $text) { $dbr = wfGetDB(DB_SLAVE); foreach ($urls as &$url) { $err = ''; $final_step = ''; if (!$url['title']) { $err = 'Unable to load article'; } else { $introText = ''; $wikitext = Wikitext::getWikitext($dbr, $url['title']); if ($wikitext) { $introText = Wikitext::getIntro($wikitext); } if (!$introText) { $err = 'Unable to load wikitext'; } else { //first, let's use the intro image for the final step if ($px > 0) { $new_final_step = self::makeFinalStep($introText, $px, $text); if ($new_final_step) { list($stepsText, $sectionID) = Wikitext::getStepsSection($wikitext, true); $stepsText = $stepsText . $new_final_step; $wikitext = Wikitext::replaceStepsSection($wikitext, $sectionID, $stepsText, true); if (preg_match("@[\r\n]+===[^=]*===@m", $stepsText)) { $final_step = 'x (alt)'; //success! (yay!) but has alt methods (boo!) } else { $final_step = 'x'; //success! } } } $prevIntroText = $introText; $introText = self::removeIntroImages($prevIntroText, $url['title']); if ($introText && $introText != $prevIntroText) { $wikitext = Wikitext::replaceIntro($wikitext, $introText, true); $comment = 'Removing intro images'; if ($final_step == 'x') { $comment .= '; Made final step out of former intro image'; } $err = Wikitext::saveWikitext($url['title'], $wikitext, $comment); if (empty($err)) { //make sure the intro image adder doesn't grab it $id = $url['title']->getArticleID(); if ($id) { $dbw = wfGetDB(DB_MASTER); $dbw->update('imageadder', array('imageadder_hasimage' => 1), array('imageadder_page' => $id)); } } } else { $err = 'Either no intro image or no intro found'; } } } $url['err'] = $err; $url['final_step'] = $final_step; } }
$titles = array(); echo "Starting script at " . microtime(true) . "\n"; //first grab a list of all articles $res = $dbr->select('page', 'page_id', array('page_namespace' => 0, 'page_is_redirect' => 0), __FILE__); while ($row = $dbr->fetchObject($res)) { $titles[$row->page_id] = array(); } $dbr->freeResult($res); echo "Done grabbing all titles from db at " . microtime(true) . "\n"; $articles = array(); $count = 0; //first check to see if there are more than 3 steps in the photo foreach ($titles as $id => $info) { $title = Title::newFromID($id); $revision = Revision::newFromTitle($title); $intro = Wikitext::getIntro($revision->getText()); $hasIntroImage = preg_match('@\\[\\[Image:([^\\]|]*)(\\|[^\\]]*)?\\]\\]@s', $intro); if (!$hasIntroImage) { $section = Wikitext::getStepsSection($revision->getText(), true); $num_step_photos = preg_match_all('@\\[\\[Image:([^\\]|]*)(\\|[^\\]]*)?\\]\\]@s', $section[0], $matches); if ($num_step_photos > 0) { $articles[] = $id; } } $count++; if ($count % 1000 == 0) { echo "Done processing " . $count . " artciles\n"; } } echo "Done processing all titles. Left with " . count($articles) . " titles. At " . microtime(true) . "\n"; $fo = fopen($argv[0], 'w');
/** * Handle API calls to get the steps from an article */ private function doAPI() { global $wgRequest, $wgOut, $wgContLang; $articleIds = $wgRequest->getVal("articleIds"); $articleIds = preg_split("@,@", $articleIds); $dbr = wfGetDB(DB_SLAVE); $wgOut->setArticleBodyOnly(true); $articles = array(); foreach ($articleIds as $articleId) { if (is_numeric($articleId)) { $r = Revision::loadFromPageId($dbr, $articleId); if ($r) { $txt = $r->getText(); $intro = Wikitext::getIntro($txt); $text = Wikitext::getStepsSection($txt, true); $lines = preg_split("@\n@", $text[0]); $text = ""; // We remove extra lines technically in the 'steps' section, but which don't actually contain steps // Find the last line starting with a '#' $lastLine = 0; $n = 0; foreach ($lines as $line) { if ($line[0] == '#') { $lastLine = $n; } $n++; } // Truncate lines after the last line with a '#' $n = 0; foreach ($lines as $line) { if ($n > $lastLine) { break; } if ($n != 0) { $text .= "\n"; } $text .= $line; $n++; } if (strlen($text) > 0) { $articles[$articleId] = array("steps" => $text, "intro" => $intro, "altImageTags" => array($wgContLang->getNSText(NS_IMAGE))); } } } } $wgOut->addHTML(json_encode($articles)); }
<?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";
/** * Handle API calls to get the steps from an article */ private function doAPI() { global $wgRequest, $wgOut, $wgContLang; $articleIds = $wgRequest->getVal("articleIds"); $articleIds = preg_split("@,@", $articleIds); $dbr = wfGetDB(DB_SLAVE); $wgOut->setArticleBodyOnly(true); $articles = array(); foreach ($articleIds as $articleId) { if (is_numeric($articleId)) { $r = Revision::loadFromPageId($dbr, $articleId); if ($r) { $txt = $r->getText(); $intro = Wikitext::getIntro($txt); $text = Wikitext::getStepsSection($txt, true); if (is_array($text) && sizeof($text) > 0) { $articles[$articleId] = array("steps" => $text[0], "intro" => $intro, "altImageTags" => array($wgContLang->getNSText(NS_IMAGE))); } } } } $wgOut->addHTML(json_encode($articles)); }
function getDocData($row, $dbr, $printIntro = false) { $page_id = $row->page_id; $page_counter = $row->page_counter; $title = Title::newFromDBkey($row->page_title); if (!$title || !$title->exists()) { decho("unknown title for id", $page_id, false); return ""; } $wikitext = Wikitext::getWikitext($dbr, $title); $intro = Wikitext::getIntro($wikitext); //$intro = str_replace("{{toc}}", "", $intro); $intro = preg_replace('#\\{\\{.*?\\}\\}#s', '', $intro); $intro = trim(preg_replace('#\\[\\[.*?\\]\\]#s', '', $intro)); $intro = preg_replace('/\\s+/', ' ', trim($intro)); $intro = str_replace('<br>', '', $intro); //if (contains($intro, "Here's how:")) { if (stripos($intro, "here's how") !== FALSE || ":" == substr($intro, -1)) { //check the number of monthly page views... $data = getTitusData($row->page_id); if ($data->titus) { $ti30 = $data->titus->ti_30day_views; } if ($ti30 >= 5000 && $ti30 <= 6000) { echo $ti30 . " http://www.wikihow.com/" . $row->page_title . " "; if ($printIntro) { echo $intro; } echo "\n"; } } //echo $page_counter ." http://www.wikihow.com/".$row->page_title." ,> ".$intro."\n"; //echo "http://www.wikihow.com/".$row->page_title." ,> ".$intro."\n"; return $intro; }
/** * The process of adding and removing all articles from the randomizer * set. * * @param int $from unix timestamp indicates from when to process. 0 * means the epoch. */ private static function processArticles($from) { $dbr = wfGetDB(DB_SLAVE); $articles = self::loadArticles($dbr, $from); foreach ($articles as &$article) { $pr = array('pr_id' => $article['page_id'], 'pr_namespace' => NS_MAIN, 'pr_title' => $article['page_title'], 'pr_random' => wfRandom(), 'pr_catinfo' => $article['page_catinfo'], 'pr_updated' => wfTimestampNow()); $article = $pr; } $featured = self::loadFeaturedArticles($dbr); $rising = self::loadRisingStars($dbr); $views = self::loadHighViews($dbr); $edits = self::loadHighEdits($dbr); $rated = self::loadHighlyRated($dbr); $add = array(); $remove = array(); $reasons = array(); foreach ($articles as $i => $article) { //print "{$article['pr_title']}\n"; $reason = array(); $toadd = true; $id = $article['pr_id']; $title = Title::newFromDBkey($article['pr_title']); if (!$title) { $toadd = false; $reason[] = 'does-not-exist'; $wikitext = ''; } else { $wikitext = self::getWikitext($dbr, $title); if (!$wikitext) { $toadd = false; $reason[] = 'does-not-exist'; } } if ($wikitext) { $intro = Wikitext::getIntro($wikitext); list($steps, ) = Wikitext::getStepsSection($wikitext); if (self::excludeViaTemplates($intro)) { $reason[] = 'excluded-via-template'; $toadd = false; } else { $images = self::getNumStepsImages($steps); if (isset($featured[$id])) { $reason[] = 'featured'; } if ($images && isset($rising[$id])) { $reason[] = 'rising'; } if ($images && isset($rated[$id])) { $reason[] = 'highly-rated'; } if ($images && isset($views[$id]) && isset($edits[$id])) { $reason[] = 'views-and-edits'; } if ($images && self::hasAlternateMethods($steps)) { $reason[] = 'views-and-alternate-methods'; } if ($images && isset($views[$id]) && self::getNumSteps($steps) >= 9) { $reason[] = 'views-and-nine-steps'; } if (self::getNumStepsImages($steps) >= 3) { $reason[] = 'three-steps-images'; } if ($images && isset($views[$id]) && self::hasVideo($wikitext)) { $reason[] = 'views-and-video'; } if (empty($reason)) { $reason[] = 'no-match'; $toadd = false; } } } if ($toadd) { $add[] = $article; } else { $remove[] = $article; } $reasons[] = array('dprr_id' => $id, 'dprr_namespace' => NS_MAIN, 'dprr_title' => substr($article['pr_title'], 0, 255), 'dprr_reasons' => substr(join(',', $reason), 0, 255)); } $dbw = wfGetDB(DB_MASTER); if (!$from) { // do this right before we insert a bunch of new rows self::dbClearRandomizer($dbw); } else { self::dbSaveRandom($dbw, $remove, false); } self::dbSaveRandom($dbw, $add, true); self::dbReplaceReasons($dbw, $reasons); }
function categorize($aid) { global $wgRequest; $t = Title::newFromId($aid); if ($t && $t->exists()) { $dbr = wfGetDB(DB_MASTER); $wikitext = Wikitext::getWikitext($dbr, $t); $intro = Wikitext::getIntro($wikitext); $intro = $this->stripCats($intro); $cats = array_reverse($wgRequest->getArray('cats', array())); $intro .= $this->getCatsWikiText($cats); $wikitext = Wikitext::replaceIntro($wikitext, $intro); $result = Wikitext::saveWikitext($t, $wikitext, 'categorization'); // Article saved successfully if ($result === '') { wfRunHooks("CategoryHelperSuccess", array()); } } }
public function mobileSearch($q, $start, $limit = 20) { global $wgOut, $wgMemc; // Don't return more than 50 search results at a time to prevent abuse if ($limit > 50) { $limit = 50; } $key = wfMemcKey("MobileSearch", str_replace(" ", "-", $q), $start, $limit); if ($val = $wgMemc->get($key)) { return $val; } $contents = $this->googleSearchResultTitles($q, $start, $limit, 0, self::SEARCH_MOBILE); $results = array(); foreach ($contents as $t) { // Only return articles if ($t->getNamespace() != NS_MAIN) { continue; } $result = array(); $result['title'] = $t->getText(); $result['url'] = $t->getFullURL(); $result['imgurl'] = wfGetPad(SkinWikihowskin::getGalleryImage($t, 103, 80)); $result['intro'] = null; if ($r = Revision::newFromid($t->getLatestRevID())) { $intro = Wikitext::getIntro($r->getText()); $intro = trim(Wikitext::flatten($intro)); $result['intro'] = substr($intro, 0, 180); // Put an ellipsis on the end $len = strlen($result['intro']); $result['intro'] .= substr($result['intro'], $len - 1, $len) == '.' ? ".." : "..."; } if (!is_null($result['intro'])) { $results[] = array('article' => $result); } } $searchResults['results'] = $results; $json = json_encode($searchResults); $wgMemc->set($key, $json, 3600); // 1 hour header("Content-type: application/json"); $wgOut->disable(true); echo $json; }
function getImageFromIntro($articleId, $revid = '') { global $wgMemc; $key = wfMemcKey("GallerySlide_getImageFromIntro", $articleId, $revid); $result = $wgMemc->get($key); if ($result) { return $result; } $dbr = wfGetDB(DB_SLAVE); $rev = Revision::loadFromPageId($dbr, $articleId); if ($rev) { $intro = Wikitext::getIntro($rev->getText()); if ($intro) { preg_match("@\\[\\[Image:[^\\]|\\|]*@", $intro, $results); $results = $results[0]; if ($revid != '') { $wgMemc->set($key, $results); } } } return $results; }
public function parseArticle_02($article) { global $wgWikiHowSections, $wgTitle, $wgUser; $ads = $wgUser->getID() == 0; $sk = new SkinWikihowskin(); $sectionMap = array(wfMsg('Intro') => 'intro', wfMsg('Ingredients') => 'ingredients', wfMsg('Steps') => 'steps', wfMsg('Video') => 'video', wfMsg('Tips') => 'tips', wfMsg('Warnings') => 'warnings', wfMsg('relatedwikihows') => 'relatedwikihows', wfMsg('sourcescitations') => 'sources', wfMsg('thingsyoullneed') => 'thingsyoullneed'); foreach ($wgWikiHowSections as $section) { $reverse_msgs[wfMsg($section)] = $section; } $parts = preg_split("@(<h2.*</h2>)@im", $article, 0, PREG_SPLIT_DELIM_CAPTURE); $body = ''; $intro_img = ''; for ($i = 0; $i < sizeof($parts); $i++) { if ($i == 0) { //intro preg_match("/Image:(.*)\">/", $parts[$i], $matches); if (count($matches) > 0) { $img = $matches[1]; $img = preg_replace('@%27@', "'", $img); $image = Title::makeTitle(NS_IMAGE, $img); if ($image) { $file = wfFindFile($image); if ($file) { $thumb = $file->getThumbnail(200, -1, true, true); $intro_img = '<a href="' . $image->getFullUrl() . '"><img border="0" width="200" class="mwimage101" src="' . wfGetPad($thumb->url) . '" alt="" /></a>'; } } } if ($intro_img == '') { $intro_img = '<img border="0" width="200" class="mwimage101" src="' . wfGetPad('/skins/WikiHow/images/wikihow_sq_200.png') . '" alt="" />'; } $r = Revision::newFromTitle($wgTitle); $intro_text = Wikitext::getIntro($r->getText()); $intro_text = trim(Wikitext::flatten($intro_text)); $body .= '<br /><div id="color_div"></div><br />'; $body .= '<div id="article_intro">' . $intro_text . '</div>'; if ($ads) { $body .= '<div class="ad_noimage intro_ad">' . wikihowAds::getAdUnitPlaceholder('intro') . '</div>'; } } else { if (stripos($parts[$i], "<h2") === 0 && $i < sizeof($parts) - 1) { preg_match("@<span>.*</span>@", $parts[$i], $matches); $rev = ""; if (sizeof($matches) > 0) { $h2 = trim(strip_tags($matches[0])); $rev = isset($reverse_msgs[$h2]) ? $reverse_msgs[$h2] : ""; } if ($rev !== 'steps') { $body .= $parts[$i]; } $i++; if ($rev == "steps") { $body .= "\n<div id=\"steps\" class='editable'>{$parts[$i]}</div>\n"; } else { if ($rev != "") { $body .= "\n<div id=\"{$rev}\" class='article_inner editable'>{$parts[$i]}</div>\n"; } else { $body .= "\n<div class='article_inner editable'>{$parts[$i]}</div>\n"; } } } else { $body .= $parts[$i]; } } } $punct = "!\\.\\?\\:"; # valid ways of ending a sentence for bolding $i = strpos($body, '<div id="steps"'); if ($i !== false) { $j = strpos($body, '<div id=', $i + 5); } if ($j === false) { $j = strlen($body); } if ($j !== false && $i !== false) { $steps = substr($body, $i, $j - $i); $parts = preg_split("@(<[/]?ul>|<[/]?ol>|<[/]?li>)@im", $steps, 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $numsteps = preg_match_all('/<li>/m', $steps, $matches); $level = 0; $steps = ""; $upper_tag = ""; $levelstack = array(); $tagstack = array(); $current_tag = ""; $current_li = 1; $donefirst = false; // used for ads to tell when we've put the ad after the first step if ($numsteps < 100) { while ($p = array_shift($parts)) { switch (strtolower($p)) { case "<ol>": $level++; if ($level == 1) { $p = '<ol class="steps_list">'; $upper_tag = "ol"; } else { $p = " <div class='listbody'>{$p}"; } if ($current_tag != "") { $tagstack[] = $current_tag; } $current_tag = "ol"; $levelstack[] = $current_li; $current_li = 1; break; case "<ul>": if ($current_tag != "") { $tagstack[] = $current_tag; } $current_tag = "ul"; $levelstack[] = $current_li; $level++; break; case "</ol>": $p .= '<div id="steps_end"></div>'; case "</ul>": $level--; if ($level == 0) { $upper_tag = ""; } $current_tag = array_pop($tagstack); $current_li = array_pop($levelstack); break; case "<li>": $closecount = 0; if ($level == 1 && $upper_tag == "ol") { $li_number = $current_li++; //$p = '<li>'. str_pad($li_number,2,'0',STR_PAD_LEFT); $p = '<li>'; # this is where things get interesting. Want to make first sentence bold! # but we need to handle cases where there are tags in the first sentence # split based on HTML tags $next = array_shift($parts); $htmlparts = preg_split("@(<[^>]*>)@im", $next, 0, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $dummy = 0; $incaption = false; $apply_b = false; while ($x = array_shift($htmlparts)) { # if it's a tag, just append it and keep going if (preg_match("@(<[^>]*>)@im", $x)) { //tag $p .= $x; if ($x == "<span class='caption'>") { $incaption = true; } else { if ($x == "</span>" && $incaption) { $incaption = false; } } continue; } # put the closing </b> in if we hit the end of the sentence if (!$incaption) { if (!$apply_b && trim($x) != "") { $p .= '<p class="step_head"><span>' . str_pad($li_number, 2, '0', STR_PAD_LEFT) . '</span>'; $apply_b = true; } if ($apply_b) { $x = preg_replace("@([{$punct}])@im", "\$1</p>", $x, 1, &$closecount); } } $p .= $x; if ($closecount > 0) { break; } else { #echo "\n\n-----$x----\n\n"; } $dummy++; } # get anything left over $p .= implode("", $htmlparts); if ($closecount == 0) { $p .= "</b>"; } // close the bold tag if we didn't already if ($level == 1 && $current_li == 2 && $ads && !$donefirst) { $p .= '<br class="clearall" />' . wikihowAds::getAdUnitPlaceholder(0); $donefirst = true; } } break; case "</li>": $p = "<div class='clearall'></div>{$p}"; //changed BR to DIV b/c IE doesn't work with the BR clear tag break; } // switch $steps .= $p; } // while } else { $steps = substr($body, $i, $j - $i); $steps = "<div id='steps_notmunged'>\n" . $steps . "\n</div>\n"; } // we have to put the final_li in the last OL LI step, so reverse the walk of the tokens $parts = preg_split("@(<[/]?ul>|<[/]?ol>|<[/]?li>)@im", $steps, 0, PREG_SPLIT_DELIM_CAPTURE); $parts = array_reverse($parts); $steps = ""; $level = 0; $gotit = false; $donelast = false; foreach ($parts as $p) { $lp = strtolower($p); if ($lp == "</ol>") { $level++; $gotit = false; } else { if ($lp == "</ul>") { $level++; } else { if (strpos($lp, "<li") !== false && $level == 1 && !$gotit) { /// last OL step list f****r //$p = preg_replace("@<li[^>]*>@i", '<li class="steps_li final_li">', $p); $gotit = true; } else { if (strpos($lp, "<ul") !== false) { $level--; } else { if (strpos($lp, "<ol") !== false) { $level--; } else { if ($lp == "</li>" && !$donelast) { // ads after the last step if ($ads) { if (substr($body, $j) == "") { $p = "<script>missing_last_ads = true;</script>" . wikihowAds::getAdUnitPlaceholder(1) . $p; $no_third_ad = true; } else { $p = '<br />' . wikihowAds::getAdUnitPlaceholder(2) . $p; } } $donelast = true; } } } } } } $steps = $p . $steps; } $body = substr($body, 0, $i) . $steps . substr($body, $j); } /// if numsteps == 100? /// ads below tips, walk the sections and put them after the tips if ($ads) { $foundtips = false; $anchorTag = ""; foreach ($wgWikiHowSections as $s) { $isAtEnd = false; if ($s == "ingredients" || $s == "steps") { continue; } // we skip these two top sections $i = strpos($body, '<div id="' . $s . '"'); if ($i !== false) { $j = strpos($body, '<h2>', $i + strlen($s)); } else { continue; // we didnt' find this section } if ($j === false) { $j = strlen($body); // go to the end $isAtEnd = true; } if ($j !== false && $i !== false) { $section = substr($body, $i, $j - $i); if ($s == "video") { // special case for video $newsection = "<div id='video'><center>{$section}</center></div>"; $body = str_replace($section, $newsection, $body); continue; } else { if ($s == "tips") { //tip ad is now at the bottom of the tips section //need to account for the possibility of no sections below this and therefor //no anchor tag if ($isAtEnd) { $anchorTag = "<p></p>"; } $body = str_replace($section, $section . $anchorTag . wikihowAds::getAdUnitPlaceholder('2a') . '<p><br /></p>', $body); $foundtips = true; break; } else { $foundtips = true; if ($isAtEnd) { $anchorTag = "<p></p>"; } $body = str_replace($section, $section . $anchorTag . wikihowAds::getAdUnitPlaceholder(2), $body); break; } } } } if (!$foundtips && !$no_third_ad) { //must be the video section //need to put in the empty <p> tag since all the other sections have them for the anchor tags. $body .= "<p class='video_spacing'></p>" . wikihowAds::getAdUnitPlaceholder(2); } } $catlinks = $sk->getCategoryLinks($false); $authors = $sk->getAuthorFooter(); if ($authors != "" || is_array($this->data['language_urls']) || $catlinks != "") { //k, now grab the bottom stuff $article_bottom .= '<br />' . wfGetSuggestedTitles($wgTitle) . '<br /> <h2 class="section_head" id="article_info_header">' . wfMsg('article_info') . '</h2> <div id="article_info" class="article_inner"> <p>' . self::getLastEdited() . '</p> <p>' . wfMsg('categories') . ':<br/>' . $catlinks . '</p> <p>' . $authors . '</p> </div><!--end article_info-->'; } if ($wgUser->getID() == 0 && !$isMainPage && $action != 'edit' && $wgTitle->getNamespace() == NS_MAIN) { $article_bottom .= '<div class="final_ad">' . wikihowAds::getAdUnitPlaceholder(7) . '</div>'; } $article_bottom .= ' <div id="final_question"> ' . $userstats . ' <p><b>' . $sk->pageStats() . '</b></p> <div id="page_rating">' . RateArticle::showForm() . '</div> <p></p> </div> <!--end last_question--> </div> <!-- article -->'; //share buttons $url = urlencode($wgServer . "/" . $wgTitle->getPrefixedURL()); $fb = '<div class="like_button"><fb:like href="' . $url . '" send="false" layout="button_count" width="86" show_faces="false"></fb:like></div>'; $gp1 = '<div class="gplus1_button"><g:plusone size="medium" callback="plusone_vote"></g:plusone></div>'; // $fb_share = '<div class="like_button like_tools"><fb:like href="' . $url . '" send="false" layout="button_count" width="86" show_faces="false"></fb:like></div>'; $tb_admin = '<div class="admin_state"><a href="http://twitter.com/share" data-lang="' . $wgLanguageCode . '" style="display:none; background-image: none; color: #ffffff;" class="twitter-share-button" data-count="horizontal" data-via="wikiHow" data-text="How to ' . htmlspecialchars($wgTitle->getText()) . '" data-related="JackHerrick:Founder of wikiHow">Tweet</a></div>'; $tb = '<a href="http://twitter.com/share" data-lang="' . $wgLanguageCode . '" style="display:none; background-image: none; color: #ffffff;" class="twitter-share-button" data-count="horizontal" data-via="wikiHow" data-text="How to ' . htmlspecialchars($wgTitle->getText()) . '" data-related="JackHerrick:Founder of wikiHow">Tweet</a>'; $the_buttons = '<div id="share_buttons_top">' . $fb; if ($wgUser->isSysop() && $wgTitle->userCan('delete')) { $the_buttons .= $tb_admin; } else { $the_buttons .= $tb; } $the_buttons .= $gp1 . '</div>'; $title = '<h1>How to ' . $wgTitle->getText() . '</h1>'; $edited = $sk->getAuthorHeader(); $sidebar = '<div id="sidenav"><div id="showslideshow"></div><div id="pp_big_space">' . $intro_img . '</div></div>'; $main = '<div id="article_main">' . $title . $the_buttons . $edited . $body . $article_bottom . '</div>'; $article = '<div id="article_layout_' . self::ARTICLE_LAYOUT . '">' . $sidebar . $main . '</div>'; return $article; }
/** * Sets the meta description in the database to be part of the intro, part * of the first step, or 'original' which is something like "wikiHow * article on How to <title>". */ private function buildDescription($style) { if (self::DESC_STYLE_ORIGINAL == $style) { return array(true, ''); } if (self::DESC_STYLE_EDITED == $style) { return array(true, $this->row['ami_desc']); } $wikitext = $this->getArticleWikiText(); if (!$wikitext) { return array(false, ''); } if (self::DESC_STYLE_INTRO == $style || self::DESC_STYLE_INTRO_NO_TITLE == $style) { // grab intro $desc = Wikitext::getIntro($wikitext); // append first step to intro if intro maybe isn't long enough if (strlen($desc) < 2 * self::MAX_DESC_LENGTH) { list($steps, ) = Wikitext::getStepsSection($wikitext); if ($steps) { $desc .= ' ' . Wikitext::cutFirstStep($steps); } } } elseif (self::DESC_STYLE_STEP1 == $style) { // grab steps section list($desc, ) = Wikitext::getStepsSection($wikitext); // pull out just the first step if ($desc) { $desc = Wikitext::cutFirstStep($desc); } else { $desc = Wikitext::getIntro($wikitext); } } else { //throw new Exception('ArticleMetaInfo: unknown style'); return array(false, ''); } $desc = Wikitext::flatten($desc); $howto = wfMsg('howto', $this->titleText); if ($desc) { if (self::DESC_STYLE_INTRO_NO_TITLE != $style) { $desc = $howto . '. ' . $desc; } } else { $desc = $howto; } $desc = self::trimDescription($desc); return array(true, $desc); }
private function getIntroPhotoStats(&$r) { $text = Wikitext::getIntro($r->getText()); $stats['ti_intro_photo'] = intVal(preg_match('/\\[\\[Image:/im', $text)); // Photo is enlarged if it is great than 500px (and less than 9999px) $stats['ti_enlarged_intro_photo'] = intVal(preg_match('/\\|[5-9][\\d]{2,3}px\\]\\]/im', $text)); return $stats; }
$replacements = array(); $res = $dbr->select('page', '*', array('page_namespace' => 0, 'page_is_redirect' => 0), __FUNCTION__, array("LIMIT" => 20)); $ids = array(); while ($row = $dbr->fetchObject($res)) { $ids[] = $row->page_id; } $wgUser = User::newFromName("Broken-Internal-Link-Removal"); foreach ($ids as $id) { $title = Title::newFromID($id); if ($title) { $stepsChanged = false; $introChanged = false; $article = new Article($title); $revision = Revision::newFromTitle($title); $wikiText = $revision->getText(); $intro = Wikitext::getIntro($wikiText, true); if ($intro != "") { $intro = replaceBrokenLinksInSection($intro, $introChanged, $title); if ($introChanged) { $wikiText = Wikitext::replaceIntro($wikiText, $intro, true); } } list($steps, $sectionID) = Wikitext::getStepsSection($wikiText, true); if ($steps != "") { $steps = replaceBrokenLinksInSection($steps, $stepsChanged, $title); if ($stepsChanged) { $wikiText = Wikitext::replaceStepsSection($wikiText, $sectionID, $steps, true); } } if ($stepsChanged || $introChanged) { $article->doEdit($wikiText, "Removing broken links");