コード例 #1
0
 function displayCategoryTable()
 {
     global $wgOut;
     $catmap = Categoryhelper::getIconMap();
     ksort($catmap);
     $queryString = WikihowCategoryViewer::getViewModeParam();
     if (!empty($queryString)) {
         $queryString = "?" . $queryString;
     }
     $wgOut->addHTML("<div class='section_text'>");
     foreach ($catmap as $cat => $image) {
         $title = Title::newFromText($image);
         if ($title) {
             $file = wfFindFile($title, false);
             $sourceWidth = $file->getWidth();
             $sourceHeight = $file->getHeight();
             $heightPreference = false;
             if (self::CAT_HEIGHT > self::CAT_WIDTH && $sourceWidth > $sourceHeight) {
                 //desired image is portrait
                 $heightPreference = true;
             }
             $thumb = $file->getThumbnail(self::CAT_WIDTH, self::CAT_HEIGHT, true, true, $heightPreference);
             $category = urldecode(str_replace("-", " ", $cat));
             $catTitle = Title::newFromText("Category:" . $category);
             if ($catTitle) {
                 $wgOut->addHTML("<div class='thumbnail'><a href='{$catTitle->getLocalUrl()}{$queryString}'><img src='" . wfGetPad($thumb->getUrl()) . "' /><div class='text'><p><span>{$category}</span></p></div></a></div>");
             }
         }
     }
     $wgOut->addHTML("<div class='clearall'></div>");
     $wgOut->addHTML("</div><!-- end section_text -->");
 }
コード例 #2
0
 public function addArticles(&$data)
 {
     $rows = array();
     $dbw = wfGetDB(DB_MASTER);
     $timestamp = wfTimestampNow();
     foreach ($data as $datum) {
         // Get user id and user text if one exists
         $userId = 0;
         $userText = "";
         if (!empty($datum['userUrl'])) {
             $uname = ConciergeUtil::getUserNameFromUserUrl($datum['userUrl']);
             $u = ConciergeArtist::newFromName($uname);
             $uid = $u->getId();
             if (!empty($uid)) {
                 $userId = $uid;
                 $userText = $u->getName();
             }
         }
         // create the row data
         $t = $datum['t'];
         $rows[] = array('ct_page_id' => $t->getArticleId(), 'ct_page_title' => $dbw->strencode($t->getDBKey()), 'ct_catinfo' => Categoryhelper::getTitleCategoryMask($t), 'ct_categories' => implode(",", ConciergeDB::getTopLevelCategories($t)), 'ct_user_id' => $userId, 'ct_user_text' => $dbw->strencode($userText), 'ct_tag_list' => $dbw->strencode(implode(",", $datum['tags'])), 'ct_completed' => $datum['completed'], 'ct_completed_timestamp' => $timestamp, 'ct_reserved_timestamp' => $timestamp);
     }
     if (!empty($rows)) {
         $chunks = array_chunk($rows, 1000);
         foreach ($chunks as $chunk) {
             $sql = ConciergeUtil::makeBulkInsertStatement($chunk, 'concierge_articles');
             $dbw->query($sql);
         }
     }
 }
コード例 #3
0
 static function listCategories($includeDatesAndFullURLs)
 {
     $epoch = wfTimestamp(TS_MW, strtotime('January 1, 2010'));
     $ch = new Categoryhelper();
     $tree = $ch->getCategoryTreeArray();
     unset($tree['WikiHow']);
     $list = array();
     self::categoryTreeToList($tree, $list);
     foreach ($list as $cat) {
         $title = Title::makeTitle(NS_CATEGORY, $cat);
         if (!$title || $title->getArticleID() <= 0) {
             continue;
         }
         if ($includeDatesAndFullURLs) {
             $line = $title->getFullUrl() . ' lastmod=' . self::iso8601_date($epoch);
         } else {
             $line = $title->getArticleID() . ' ' . $title->getPrefixedDBkey();
         }
         print "{$line}\n";
     }
 }
コード例 #4
0
 public static function getCategoryContents($title = null)
 {
     $cats = array();
     $fArts = array();
     $arts = array();
     if (!$title) {
         $cats = wfGetTopLevelCats();
     } else {
         $tree = Categoryhelper::getCategoryTreeArray();
         self::getChildNodesFromTreeNode($tree, str_replace('-', ' ', $title->getBaseText()), $cats);
     }
     $catResult = array();
     foreach ($cats as $cat) {
         $catTitle = Title::newFromText($cat, NS_CATEGORY);
         $catResult[$cat] = $catTitle->getFullURL();
     }
     $fArtResult = array();
     $artResult = array();
     if ($title && $title->exists()) {
         $viewer = new WikihowCategoryViewer($title);
         $viewer->clearState();
         $viewer->doQuery();
         $viewer->finaliseCategoryState();
         // Featured articles:
         if ($viewer->articles_fa) {
             foreach ($viewer->articles_fa as $fArtHtml) {
                 // Extract article name from HTML
                 $matches = array();
                 preg_match('/<a ?.*>(.*)<\\/a>/', $fArtHtml, $matches);
                 $fArt = $matches[1];
                 $fArtTitle = Title::newFromText($fArt, NS_MAIN);
                 if ($fArtTitle && $fArtTitle->exists() && $fArtTitle->getNamespace() === NS_MAIN) {
                     $fArtResult[$fArt] = $fArtTitle->getFullURL();
                 }
             }
         }
         // General articles:
         if ($viewer->articles) {
             foreach ($viewer->articles as $artHtml) {
                 // Extract article name from HTML
                 $matches = array();
                 preg_match('/<a ?.*>(.*)<\\/a>/', $artHtml, $matches);
                 $art = $matches[1];
                 $artTitle = Title::newFromText($art, NS_MAIN);
                 if ($artTitle && $artTitle->exists() && $artTitle->getNamespace() === NS_MAIN) {
                     $artResult[$art] = $artTitle->getFullURL();
                 }
             }
         }
     }
     return array('subcats' => $catResult, 'f_articles' => $fArtResult, 'articles' => $artResult);
 }
コード例 #5
0
 function getCategoryDropDown()
 {
     global $wgRequest;
     $cats = Categoryhelper::getTopLevelCategoriesForDropDown();
     $selected = $wgRequest->getVal('cat');
     $html = '<select id="va_category" onchange="chooseCat();"><OPTION value="">All</OPTION>';
     foreach ($cats as $c) {
         $c = trim($c);
         if ($c == "" || $c == "WikiHow" || $c == "Other") {
             continue;
         }
         if ($c == $selected) {
             $html .= '<OPTION value="' . $c . '" SELECTED>' . $c . '</OPTION>';
         } else {
             $html .= '<OPTION value="' . $c . '">' . $c . '</OPTION>';
         }
     }
     $html .= '</select>';
     return $html;
 }
コード例 #6
0
ファイル: Categoryhelper.php プロジェクト: ErdemA/wikihow
function wfGetTopLevelCats()
{
    global $wgMemc;
    $key = wfMemcKey("toplevelcats_categorylinkstop");
    $val = $wgMemc->get($key);
    if ($val) {
        return $val;
    }
    //initialize the top level array of categories;
    $x = Categoryhelper::getTopLevelCategoriesForDropDown();
    $top = array();
    foreach ($x as $cat) {
        $cat = trim($cat);
        if ($cat == "" || $cat == "Other" || $cat == "WikiHow") {
            continue;
        }
        $top[] = $cat;
    }
    $wgMemc->set($key, $top, 86400);
    return $top;
}
コード例 #7
0
ファイル: CreatePage.php プロジェクト: ErdemA/wikihow
function wfGetTopCategory($title = null)
{
    $result = Categoryhelper::getTopCategory($title);
    return Title::makeTitle(NS_CATEGORY, $result);
}
コード例 #8
0
ファイル: Skin.php プロジェクト: ErdemA/wikihow
 function getCategoryLinks()
 {
     global $wgOut, $wgTitle, $wgUseCategoryBrowser;
     global $wgContLang;
     if (count($wgOut->mCategoryLinks) == 0) {
         return '';
     }
     # Separator
     $sep = wfMsgHtml('catseparator');
     // Use Unicode bidi embedding override characters,
     // to make sure links don't smash each other up in ugly ways.
     $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
     $embed = "<span dir='{$dir}'>";
     $pop = '</span>';
     $t = $embed . implode("{$pop} {$sep} {$embed}", $wgOut->mCategoryLinks) . $pop;
     $msg = wfMsgExt('pagecategories', array('parsemag', 'escape'), count($wgOut->mCategoryLinks));
     $s = $this->makeLinkObj(Title::newFromText(wfMsgForContent('pagecategorieslink')), $msg) . ': ' . $t;
     # optional 'dmoz-like' category browser. Will be shown under the list
     # of categories an article belong to
     if ($wgUseCategoryBrowser) {
         $s .= '<br /><hr />';
         # get a big array of the parents tree
         $parenttree = Categoryhelper::getCurrentParentCategoryTree();
         # Skin object passed by reference cause it can not be
         # accessed under the method subfunction drawCategoryBrowser
         $tempout = explode("\n", Skin::drawCategoryBrowser($parenttree, $this));
         # Clean out bogus first entry and sort them
         unset($tempout[0]);
         asort($tempout);
         # Output one per line
         $s .= implode("<br />\n", $tempout);
     }
     return $s;
 }
コード例 #9
0
ファイル: wikihowAds.class.php プロジェクト: ErdemA/wikihow
 function setCategories()
 {
     global $wgUser;
     $tree = Categoryhelper::getCurrentParentCategoryTree();
     if ($tree != null) {
         foreach ($tree as $key => $path) {
             $catString = str_replace("Category:", "", $key);
             self::$mCategories[$catString] = $catString;
             $subtree = Categoryhelper::flattenCategoryTree($path);
             for ($i = 0; $i < count($subtree); $i++) {
                 $catString = str_replace("Category:", "", $subtree[$i]);
                 self::$mCategories[$catString] = $catString;
             }
         }
     }
 }
コード例 #10
0
    $opts = array();
}
$res = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace' => NS_MAIN, 'page_is_redirect' => 0, 'page_catinfo' => 0), "init_toplevelcategories.php", $opts);
$count = 0;
$updates = array();
$titles = array();
while ($row = $dbr->fetchObject($res)) {
    $t = Title::makeTitle($row->page_namespace, $row->page_title);
    if (!$t) {
        continue;
    }
    $titles[] = $t;
}
// FIGURE OUT WHAT THE CATINFO COLUMN IS SUPPOSED TO BE
foreach ($titles as $t) {
    $val = Categoryhelper::getTitleCategoryMask($t);
    $count++;
    #if ($count % 1000 == 0)  {
    #	print "Done $count\n";
    #}
    $updates[] = "UPDATE page set page_catinfo={$val} where page_id={$t->getArticleID()};";
}
// DO THE UPDATES
print "doing " . sizeof($updates) . " updates\n";
$count = 0;
$dbw = wfGetDB(DB_MASTER);
foreach ($updates as $u) {
    $dbw = wfGetDB(DB_MASTER);
    $dbw->query($u);
    $count++;
    #if ($count % 1000 == 0)  {
コード例 #11
0
 public static function getCategoryTreeArray()
 {
     $ch = new Categoryhelper();
     return $ch->getCategoryTreeArray();
 }
コード例 #12
0
 function execute($par)
 {
     global $wgRequest, $wgUser, $wgOut, $wgLang, $wgServer;
     $dbr = wfGetDB(DB_SLAVE);
     $me = Title::makeTitle(NS_SPECIAL, "Docentsettings");
     if ($wgRequest->wasPosted()) {
         $new = array();
         $new_key = array();
         foreach ($wgRequest->getValues() as $key => $value) {
             if ($value && $key != 'title') {
                 $t = Title::makeTitle(NS_CATEGORY, $value);
                 if ($t->getArticleID() == 0) {
                     $wgOut->addHTML("Error: Unable to add category to settings for <b>{$key}</b>, please post this problem to <a href='http://www.wikihow.com/forum/viewforum.php?f=6'>Tech feedback</a>");
                 } else {
                     $new[] = $t;
                     $new_key[$t->getDBKEy()] = 1;
                 }
             }
         }
         $dbw = wfGetDB(DB_MASTER);
         //** UPDATE THE MAILMAN SETTINGS **//
         $old_key = array();
         $res = $dbr->select('docentcategories', array('dc_to'), array('dc_user' => $wgUser->getID()));
         while ($row = $dbr->fetchObject($res)) {
             $old_key[$row->dc_to] = 1;
         }
         $dbr->freeResult($res);
         $remove = array();
         foreach ($old_key as $key => $value) {
             if (!isset($new_key[$key])) {
                 $remove[] = $key;
             }
         }
         $add = array();
         foreach ($new_key as $key => $value) {
             if (!isset($old_key[$key])) {
                 $add[] = $key;
             }
         }
         foreach ($add as $a) {
             $t = Title::makeTitle(NS_CATEGORY, $a);
             $dbw->delete('mailman_unsubscribe', array('mm_user' => $wgUser->getID(), 'mm_list' => $t->getDBKey(), 'mm_done=0'));
             $dbw->insert('mailman_subscribe', array('mm_user' => $wgUser->getID(), 'mm_list' => $t->getDBKey()));
         }
         foreach ($remove as $a) {
             $t = Title::makeTitle(NS_CATEGORY, $a);
             $dbw->delete('mailman_subscribe', array('mm_user' => $wgUser->getID(), 'mm_list' => $t->getDBKey(), 'mm_done=0'));
             $dbw->insert('mailman_unsubscribe', array('mm_user' => $wgUser->getID(), 'mm_list' => $t->getDBKey()));
         }
         //** UPDATE THE MAILMAN SETTINGS **//
         $dbw->delete('docentcategories', array('dc_user' => $wgUser->getID()));
         foreach ($new as $t) {
             $dbw->insert('docentcategories', array('dc_user' => $wgUser->getID(), 'dc_to' => $t->getDBKey()));
         }
     }
     $wgOut->addHTML(wfMsg('docentsettings_info') . "<br/><br/>");
     $cats = Categoryhelper::getCategoryDropDownTree();
     $count = 0;
     $wgOut->addHTML("\t\n\t\t\t\t<form method='POST' action='{$me->getFullURL()}'>\n\t\t\t\t<style type='text/css'>\n\t\t\t\t\ttable.docentsettings {\n\t\t\t\t\t}\n\t\t\t\t\ttable.docentsettings td {\n\t\t\t\t\t\tborder: 1px solid #ccc;\n\t\t\t\t\t\tpadding: 10px;\n\t\t\t\t\t\tfont-size: 90%;\n\t\t\t\t\t\tvertical-align: top;\n\t\t\t\t\t}\n\t\t\t\t</style>\n\t\t\t");
     // check the referrer
     $refer = $_SERVER['HTTP_REFERER'];
     if ($refer && strpos($refer, $wgServer . "/Category") === 0) {
         $refer = str_replace($wgServer . "/", "", $refer);
         $t = Title::newFromURL($refer);
         if ($t && !isset($already_subscribed[$t->getText()])) {
             $already_subscribed[$t->getText()] = 1;
             $wgOut->addHTML("Add this category: <table width='100%' class='docentsettings'><tr>");
             $wgOut->addHTML("<td>" . $this->getcheckbox($t->getText(), $already_subscribed, "", false) . "</td>");
             $wgOut->addHTML("</tr><tr>");
             $wgOut->addHTML("</tr></table><br/>");
         }
     }
     $wgOut->addHTML("Here are the catgories you are currently subscribed to. To remove a category, uncheck it in this section.<br/><br/>\n\t  \t\t\t<table width='100%' class='docentsettings'><tr>\n\t\t\t");
     $count = 0;
     $res = $dbr->select('docentcategories', array('dc_to'), array('dc_user' => $wgUser->getID()));
     $already_subscribed = array();
     while ($row = $dbr->fetchObject($res)) {
         $t = Title::makeTitle(NS_CATEGORY, $row->dc_to);
         $already_subscribed[$t->getText()] = 1;
         $wgOut->addHTML("<td>" . $this->getcheckbox($t->getText(), $already_subscribed, "", false) . "</td>");
         if ($count % 2 == 1) {
             $wgOut->addHTML("</tr><tr>");
         }
         $count++;
     }
     $dbr->freeResult($res);
     $wgOut->addHTML("</tr><table>");
     $templates = wfMsgForContent('docentsettings_categories_to_ignore');
     $t_arr = split("\n", str_replace(" ", "-", str_replace(" \n", "\n", $templates)));
     $templates = "'" . implode("','", $t_arr) . "'";
     $sql = "select cl_to, count(*) as C \n\t\t\t\tfrom revision left join page on rev_page = page_id and page_namespace= 0 left join categorylinks on cl_from=page_id \n\t\t\t\twhere rev_user={$wgUser->getID()} and cl_to is not null and cl_to NOT IN ({$templates})\n\t\t\t\tgroup by cl_to having  C > 3 order by C desc limit 20;";
     $res = $dbr->query($sql);
     $wgOut->addHTML("\n\t\t\t<br/>Recommendations: Here are the categories you have edited most on wikiHow:<br/><br/><table width='100%' class='docentsettings'><tr>");
     $count = 0;
     while ($row = $dbr->fetchObject($res)) {
         $t = Title::makeTitle(NS_CATEGEORY, $row->cl_to);
         $wgOut->addHTML("<td> " . $this->getcheckbox($t->getText(), $already_subscribed, "({$row->C})") . "</td>");
         if ($count % 2 == 1) {
             $wgOut->addHTML("</tr><tr>");
         }
         $count++;
     }
     $wgOut->addHTML("</tr></table><br/>\n\t\t\t\t<script type='text/javascript'>\n\t                function showhide(id) {\n\t                    var box = document.getElementById(id);\n\t                    var style = box.getAttribute('style');\n\t                    if (style == 'display: none;')\n\t                        box.setAttribute('style', 'display: inline;');\n\t                    else\n\t                        box.setAttribute('style', 'display: none;');\n\t                \n\t                }\n\t            </script>\n\t\t\t\tAll categories:<br/><br/>\n\t\t\t\t<table width='100%' class='docentsettings'>            \n\t\t\t");
     $dbr->freeResult($res);
     foreach ($cats as $key => $subcat) {
         if ($key == "") {
             continue;
         }
         $float = 'float: left;';
         if ($count % 2 == 0) {
             $wgOut->addHTML("<tr>");
         }
         $id = strtolower(str_replace(" ", "_", $key));
         $wgOut->addHTML("<td> " . $this->getcheckbox($key, $already_subscribed, ""));
         $wgOut->addHTML("<br/><br/>");
         if (sizeof($subcat) > 0) {
             $wgOut->addHTML("\n\t\t\t\t\t<div style='font-size: 80%'><a onclick='javascript:showhide(\"subcats_{$id}\");'>Show/Hide Subcategories</a></div>\n\t\t\t\t<br/><div id='subcats_{$id}' style='display:none;'>");
             foreach ($subcat as $s) {
                 $s = substr($s, 2);
                 $i = 10 + 10 * substr_count($s, "*");
                 $s = str_replace("*", "", $s);
                 $wgOut->addHTML("<div style='margin-bottom: 5px; width: 260px; border: 1px solid #eee; padding: 3px; padding-left: {$i}px;'>" . $this->getcheckbox($s, $already_subscribed, "") . " <br/></div>");
             }
             $wgOut->addHTML("</div>");
         }
         $wgOut->addHTML("</td>");
         if ($count % 2 == 1) {
             $wgOut->addHTML("</tr>");
         }
         $count++;
     }
     $wgOut->addHTML("</table>\n\t\t\t<input type='submit' style='font-weight: bold; font-size: 110%' accesskey='s' value='" . wfMsg('submit') . "' />\n\t\t\t</form>");
 }
コード例 #13
0
function wfUpdateCatInfoMask(&$article, &$user)
{
    if ($article) {
        $title = $article->getTitle();
        if ($title && $title->getNamespace() == NS_MAIN) {
            $mask = Categoryhelper::getTitleCategoryMask($title);
            $dbw = wfGetDB(DB_MASTER);
            $dbw->update('page', array('page_catinfo' => $mask), array('page_id' => $article->getID()), __METHOD__);
        }
    }
    return true;
}
コード例 #14
0
 static function getCategoryOptionsForm($default, $cats = null)
 {
     global $wgUser, $wgMaxCategories, $wgRequest;
     if (!$wgUser->isLoggedIn()) {
         return "";
     }
     // get the top and bottom categories
     $valid_cats = array();
     if (is_array($cats)) {
         $valid_cats = array_flip($cats);
     }
     if ($wgRequest->getVal('oldid') != null && $default != "") {
         $fakeparent = array();
         $fakeparent[Title::makeTitle(NS_CATEGORY, $default)->getFullText()] = array();
         $tree = self::modifiedParentCategoryTree($fakeparent);
     } else {
         $tree = Categoryhelper::getCurrentParentCategoryTree();
     }
     if (!$tree) {
         $tree = array();
     }
     $toplevel = array();
     $bottomlevel = array();
     if ($wgRequest->getVal('topcategory0', null) != null) {
         // user has already submitted form, could be a preview, just set it to what they posted
         for ($i = 0; $i < $wgMaxCategories; $i++) {
             if ($wgRequest->getVal('topcategory' . $i, null) != null) {
                 $toplevel[] = $wgRequest->getVal('topcategory' . $i);
                 $bottomlevel[] = $wgRequest->getVal('category' . $i);
             }
         }
     } else {
         // fresh new form from existing article
         foreach ($tree as $k => $v) {
             $keys = array_keys($tree);
             $bottomleveltext = $k;
             $child = $v;
             $topleveltext = $k;
             while (is_array($child) && sizeof($child) > 0) {
                 $keys = array_keys($child);
                 $topleveltext = $keys[0];
                 $child = $child[$topleveltext];
             }
             $tl_title = Title::newFromText($topleveltext);
             $bl_title = Title::newFromText($bottomleveltext);
             if (isset($valid_cats[$bl_title->getText()])) {
                 if ($tl_title != null) {
                     $toplevel[] = $tl_title->getText();
                     $bottomlevel[] = $bl_title->getText();
                 } else {
                     $toplevel[] = $bl_title->getText();
                 }
             } else {
                 #print_r($tree);
                 #echo "shit! <b>{$bl_title->getText()}</b><br/><br/>"; print_r($bl_title); print_r($valid_cats);
             }
         }
     }
     $helper = Title::makeTitle(NS_SPECIAL, "Categoryhelper");
     $toplevels = self::getTopLevelCategoriesForDropDown();
     $options = self::getCategoryDropDownTree();
     $html = "<script type='text/javascript' src='/extensions/wikihow/categories.js'></script>";
     $html .= '<style type="text/css" media="all">/*<![CDATA[*/ @import "/extensions/wikihow/categories.css"; /*]]>*/</style>';
     $html .= " <script type='text/javascript'>\n\t\t\t\t\tvar gCatHelperUrl = \"{$helper->getFullURL()}\";\n\t\t\t\t\tvar gCatHelperSMsg = \"" . wfMessage('selectsubcategory')->text() . "\";\n\t\t\t\t\tvar gMaxCats = {$wgMaxCategories};\n\t\t\t\t\tvar gCatMsg = '" . wfMessage('categoryhelper_summarymsg')->text() . "';\n\t\t\t\t</script>\n\t\t\t\t\t<input type='hidden' name='TopLevelCategoryOk' value='" . (sizeof($toplevel) == sizeof($bottomlevel) ? "false" : "true") . "'/>\n\t\t\t\t<noscript>" . wfMessage('categoryhelper_javascript')->text() . "<br/></noscript>\n\t\t\t\t";
     $i = 0;
     $max = 1;
     if (sizeof($toplevel) > 0) {
         $max = sizeof($toplevel);
     }
     for ($i = 0; $i < $max || $i < $wgMaxCategories; $i++) {
         $top = $bot = '';
         $style = ' style="display:none;" ';
         if ($i < sizeof($toplevel) || $i == 0) {
             $top = $toplevel[$i];
             $bot = $bottomlevel[$i];
             $style = '';
         }
         if ($i > 0) {
             $html .= "<br/>";
         }
         $html .= "<SELECT class='topcategory_dropdown' name='topcategory{$i}' id='topcategory{$i}' onchange='updateCategories({$i});' {$style}>\n\t\t\t\t\t<OPTION VALUE=''>" . wfMessage('selectcategory')->text() . "</OPTION>";
         foreach ($toplevels as $c) {
             $c = trim($c);
             if ($c == "") {
                 continue;
             }
             $html .= "<OPTION VALUE=\"{$c}\" " . ($c == $top ? "SELECTED" : "") . " >{$c}</OPTION>\n";
         }
         $html .= "</SELECT>   <span id='category_div{$i}'><SELECT onchange='catHelperUpdateSummary();' class='subcategory_dropdown' name='category{$i}' id='category{$i}'  {$style}>";
         if (is_array($options[$top])) {
             if ($bot == "") {
                 $html .= "<OPTION VALUE=''>" . wfMessage('selectcategory')->text() . "</OPTION>";
             }
             foreach ($options[$top] as $sub) {
                 $html .= self::getHTMLForCategoryOption($sub, $bot);
             }
         }
         $html .= "</SELECT> </span> ";
     }
     if ($i >= sizeof($toplevel)) {
         $html .= "<a onclick='javascript:showanother();' id='showmorecats'>" . wfMessage('addanothercategory')->text() . "</a>";
     }
     return $html;
 }
コード例 #15
0
ファイル: WAPDB.class.php プロジェクト: biribogos/wikihow-src
 public function getTopLevelCategories(&$t)
 {
     global $wgLang;
     $cats = array();
     if ($t && $t->exists()) {
         $catTxt = $wgLang->getNsText(NS_CATEGORY) . ":";
         $cats = Categoryhelper::getTitleTopLevelCategories($t);
         foreach ($cats as $i => $cat) {
             if ($cat == $catTxt . "WikiHow") {
                 // Don't show wikiHow category
                 unset($cats[$i]);
             } else {
                 $cats[$i] = str_replace($catTxt, "", $cat);
             }
         }
     }
     if (empty($cats)) {
         $cats[] = "N/A";
     }
     return $cats;
 }
コード例 #16
0
 function getPinterestImage($title, $fromPad = true)
 {
     global $wgLanguageCode, $wgContLang;
     if (in_array($title->getNamespace(), array(NS_MAIN, NS_CATEGORY))) {
         if ($title->getNamespace() == NS_MAIN) {
             $file = Wikitext::getTitleImage($title);
             if ($file && isset($file)) {
                 $url = "/images/" . $file->getRel();
                 if ($fromPad) {
                     $url = wfGetPad($url);
                 }
                 return $url;
             }
         }
         $catmap = Categoryhelper::getIconMap();
         // still here? use default categoryimage
         // if page is a top category itself otherwise get top
         if (isset($catmap[urldecode($title->getPartialURL())])) {
             $cat = urldecode($title->getPartialURL());
         } else {
             $cat = Categoryhelper::getTopCategory($title);
             //INTL: Get the partial URL for the top category if it exists
             // For some reason only the english site returns the partial URL for getTopCategory
             if (isset($cat) && $wgLanguageCode != 'en') {
                 $title = Title::newFromText($cat);
                 if ($title != null) {
                     $cat = $title->getPartialURL();
                 }
             }
         }
         if (isset($catmap[$cat])) {
             $image = Title::newFromText($catmap[$cat]);
             $file = wfFindFile($image, false);
             if ($file) {
                 $url = "/images/" . $file->getRel();
                 if ($fromPad) {
                     $url = wfGetPad($url);
                 }
                 if ($url) {
                     return $url;
                 }
             } else {
                 $url = "/skins/WikiHow/images/wikihow_large.jpg";
                 if ($fromPad) {
                     $url = wfGetPad($url);
                 }
                 if ($url) {
                     return $url;
                 }
             }
         } else {
             $url = "/skins/WikiHow/images/wikihow_large.jpg";
             if ($fromPad) {
                 $url = wfGetPad($url);
             }
             if ($url) {
                 return $url;
             }
         }
     }
 }
コード例 #17
0
$res = $dbr->select('page', array('page_namespace', 'page_title'), array('page_namespace' => NS_MAIN, 'page_is_redirect' => 0), "init_toplevelcategories.php", $opts);
function flatten($arg, &$results = array())
{
    if (is_array($arg)) {
        foreach ($arg as $a => $p) {
            if (is_array($p)) {
                flatten($p, $results);
            } else {
                $results[] = $a;
            }
        }
    }
    return $results;
}
//initialize the top level array of categories;
$x = Categoryhelper::getTopLevelCategoriesForDropDown();
$top = array();
foreach ($x as $cat) {
    $cat = trim($cat);
    if ($cat == "" || $cat == "Other" || $cat == "WikiHow") {
        continue;
    }
    $top[] = $cat;
}
#print_r($top);
if ($batch == 0) {
    $dbw->query("delete from categorylinkstop;");
}
$count = 0;
$updates = array();
$titles = array();
コード例 #18
0
ファイル: Suggest.body.php プロジェクト: ErdemA/wikihow
 function execute($par)
 {
     global $wgOut, $wgUser, $wgTitle, $wgLanguageCode, $wgHooks;
     if ($wgLanguageCode != 'en') {
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         $wgOut->setRobotPolicy('noindex,nofollow');
         return;
     }
     require_once 'Leaderboard.body.php';
     wfLoadExtensionMessages('RequestTopic');
     $wgOut->addHTML('<style type="text/css" media="all">/*<![CDATA[*/ @import "' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.css?rev=') . WH_SITEREV . '"; /*]]>*/</style>');
     $wgOut->addScript('<script type="text/javascript" src="' . wfGetPad('/extensions/min/f/extensions/wikihow/suggestedtopics.js?rev=') . WH_SITEREV . '"></script>');
     ListRequestedTopics::setActiveWidget();
     ListRequestedTopics::setTopAuthorWidget();
     ListRequestedTopics::getNewArticlesWidget();
     $wgHooks["pageTabs"][] = array("wfRequestedTopicsTabs");
     $wgOut->setHTMLTitle('Articles Started By You - wikiHow');
     $wgOut->setRobotPolicy('noindex,nofollow');
     //heading with link
     $request = '<a href="/Special:RequestTopic" class="edit">' . wfMsg('requesttopic') . '</a>';
     $heading = $request . '<h2>' . wfMsg('your_articles_header') . '</h2>';
     //add surpise button
     $heading .= "<a href='/Special:RecommendedArticles?surprise=1' class='button buttonright secondary' id='suggested_surprise'>" . wfMsg('suggested_list_button_surprise') . "</a><br /><br /><br />";
     $wgOut->addHTML($heading);
     if ($wgUser->getID() > 0) {
         $dbr = wfGetDB(DB_SLAVE);
         $res = $dbr->query("select * from firstedit left join page on fe_page=page_id\n\t\t\t\t\tleft join suggested_titles on page_title=st_title and page_namespace= 0 where fe_user={$wgUser->getID()} and page_id is not NULL order by st_category");
         if ($dbr->numRows($res) == 0) {
             $wgOut->addHTML(wfMsg("yourarticles_none"));
             return;
         }
         $last_cat = "-";
         // group it by categories
         // sometimes st_category is not set, so we have to grab the top category
         // from the title object of the target article
         $articles = array();
         while ($row = $dbr->fetchObject($res)) {
             $t = Title::makeTitle(NS_MAIN, $row->page_title);
             $cat = $row->st_category;
             if ($cat == '') {
                 $str = Categoryhelper::getTopCategory($t);
                 if ($str != '') {
                     $title = Title::makeTitle(NS_CATEGORY, $str);
                     $cat = $title->getText();
                 } else {
                     $cat = "Other";
                 }
             }
             if (!isset($articles[$cat])) {
                 $articles[$cat] = array();
             }
             $articles[$cat][] = $row;
         }
         foreach ($articles as $cat => $article_array) {
             $image = ListRequestedTopics::getCategoryImage($cat);
             $style = "";
             if ($image == "") {
                 $style = "style='padding-left:67px;'";
             }
             $wgOut->addHTML('<h2>' . $cat . '</h2><div class="wh_block"><table class="suggested_titles_list">');
             foreach ($article_array as $row) {
                 $t = Title::makeTitle(NS_MAIN, $row->page_title);
                 $ago = wfTimeAgo($row->page_touched);
                 $authors = array_keys($this->getAuthors($t));
                 $a_out = array();
                 for ($i = 0; $i < 2 && sizeof($authors) > 0; $i++) {
                     $a = array_shift($authors);
                     if ($a == 'anonymous') {
                         $a_out[] = "Anonymous";
                         // duh
                     } else {
                         $u = User::newFromName($a);
                         if (!$u) {
                             echo "{$a} broke";
                             exit;
                         }
                         $a_out[] = "<a href='{$u->getUserPage()->getFullURL()}'>{$u->getName()}</a>";
                     }
                 }
                 $skin = $wgUser->getSkin();
                 $img = $skin->getGalleryImage($t, 46, 35);
                 $wgOut->addHTML("<tr><td class='article_image'><img src='{$img}' alt='' width='46' height='35' /></td>" . "<td><h3><a href='{$t->getFullURL()}' class='title'>" . wfMsg('howto', $t->getFullText()) . "</a></h3>" . "<p class='meta_info'>Authored by: <a href='{$wgUser->getUserPage()->getFullURL()}'>You</a></p>" . "<p class='meta_info'>Edits by: " . implode(", ", $a_out) . " (<a href='{$t->getFullURL()}?action=credits'>see all</a>)</p>" . "<p class='meta_info'>Last updated {$ago}</p>" . "</td>" . "<td class='view_count'>" . number_format($row->page_counter, 0, "", ",") . "</td></tr>");
             }
             $wgOut->addHTML('</table></div>');
         }
     } else {
         $rt = $wgTitle->getPrefixedURL();
         $q = "returnto={$rt}";
         $wgOut->addHTML(wfMsg('yourarticles_anon', $q));
     }
 }
コード例 #19
0
ファイル: WikiHowSkin.php プロジェクト: biribogos/wikihow-src
 function getCategoryLinks($usebrowser)
 {
     global $wgOut, $wgContLang;
     if (!$usebrowser && empty($wgOut->mCategoryLinks["normal"])) {
         return '';
     }
     // Use Unicode bidi embedding override characters,
     // to make sure links don't smash each other up in ugly ways.
     $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
     $embed = "<span dir='{$dir}'>";
     $pop = '</span>';
     if (empty($wgOut->mCategoryLinks["normal"])) {
         $t = $embed . "" . $pop;
     } else {
         $t = $embed . implode("{$pop} | {$embed}", $wgOut->mCategoryLinks["normal"]) . $pop;
     }
     if (!$usebrowser) {
         return $t;
     }
     $mainPageObj = Title::newMainPage();
     $sk = $this->getSkin();
     $sep = self::BREADCRUMB_SEPARATOR;
     $viewMode = WikihowCategoryViewer::getViewModeArray($this->getContext());
     $categories = Linker::link(Title::newFromText('Special:Categorylisting'), wfMessage('categories')->text(), array(), $viewMode);
     $s = "<li class='home'>" . Linker::link($mainPageObj, wfMessage('home')->text()) . "</li> <li>{$sep} {$categories}</li>";
     # optional 'dmoz-like' category browser. Will be shown under the list
     # of categories an article belong to
     if ($usebrowser) {
         $s .= ' ';
         # get a big array of the parents tree
         $parenttree = Categoryhelper::getCurrentParentCategoryTree();
         if (is_array($parenttree)) {
             $parenttree = array_reverse($parenttree);
         } else {
             return $s;
         }
         # Skin object passed by reference cause it can not be
         # accessed under the method subfunction drawCategoryBrowser
         $tempout = explode("\n", $this->drawCategoryBrowser($parenttree, $this));
         $newarray = array();
         foreach ($tempout as $t) {
             if (trim($t) != "") {
                 $newarray[] = $t;
             }
         }
         $tempout = $newarray;
         asort($tempout);
         $olds = $s;
         if ($tempout) {
             $s .= $tempout[0];
         }
         // this usually works
         if (strpos($s, "/Category:WikiHow") !== false || strpos($s, "/Category:Featured") !== false || strpos($s, "/Category:Nomination") !== false) {
             for ($i = 1; $i <= sizeof($tempout); $i++) {
                 // Reuben: changed to add this isset($tempout[$i]) stuff so that
                 // functionality remains identical but without variable not defined
                 // notice, even though I don't understand the functionality
                 if (strpos(@$tempout[$i], "/Category:WikiHow") === false && strpos(@$tempout[$i], "/Category:Featured") == false && strpos(@$tempout[$i], "/Category:Nomination") == false) {
                     $s = $olds;
                     $s .= isset($tempout[$i]) ? $tempout[$i] : '';
                     break;
                 }
             }
         }
     }
     return $s;
 }
コード例 #20
0
ファイル: WikiHowSkin.php プロジェクト: ErdemA/wikihow
 function getCategoryLinks($usebrowser)
 {
     global $wgOut, $wgUser, $wgContLang;
     if (!$usebrowser && count($wgOut->mCategoryLinks) == 0) {
         return '';
     }
     // Use Unicode bidi embedding override characters,
     // to make sure links don't smash each other up in ugly ways.
     $dir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
     $embed = "<span dir='{$dir}'>";
     $pop = '</span>';
     $t = $embed . implode("{$pop} | {$embed}", $wgOut->mCategoryLinks) . $pop;
     if (!$usebrowser) {
         return $t;
     }
     $mainPageObj = Title::newMainPage();
     $sk = $wgUser->getSkin();
     $sep = self::BREADCRUMB_SEPARATOR;
     $queryString = WikihowCategoryViewer::getViewModeParam();
     $categories = $sk->makeLinkObj(Title::newFromText('Special:Categorylisting'), wfMsg('categories'), $queryString);
     $s = "<li class='home'>" . $sk->makeLinkObj($mainPageObj, wfMsg('home')) . "</li> <li>{$sep} {$categories}</li>";
     # optional 'dmoz-like' category browser. Will be shown under the list
     # of categories an article belong to
     if ($usebrowser) {
         $s .= ' ';
         # get a big array of the parents tree
         $parenttree = Categoryhelper::getCurrentParentCategoryTree();
         if (is_array($parenttree)) {
             $parenttree = array_reverse($parenttree);
         } else {
             return $s;
         }
         # Skin object passed by reference cause it can not be
         # accessed under the method subfunction drawCategoryBrowser
         $tempout = explode("\n", $this->drawCategoryBrowser($parenttree, $this));
         $newarray = array();
         foreach ($tempout as $t) {
             if (trim($t) != "") {
                 $newarray[] = $t;
             }
         }
         $tempout = $newarray;
         asort($tempout);
         $olds = $s;
         $s .= $tempout[0];
         // this usually works
         if (strpos($s, "/Category:WikiHow") !== false || strpos($s, "/Category:Featured") !== false || strpos($s, "/Category:Nomination") !== false) {
             for ($i = 1; $i <= sizeof($tempout); $i++) {
                 if (strpos($tempout[$i], "/Category:WikiHow") === false && strpos($tempout[$i], "/Category:Featured") == false && strpos($tempout[$i], "/Category:Nomination") == false) {
                     $s = $olds;
                     $s .= $tempout[$i];
                     break;
                 }
             }
         }
     }
     return $s;
 }
コード例 #21
0
 protected function importBatch(&$data)
 {
     $dbw = wfGetDB(DB_MASTER);
     $rowPos = $this->rowPos;
     $langs = $this->getWAPConfig()->getSupportedLanguages();
     $invalidUrls = array();
     // Urls that are invalid for some reason or another
     $batchSize = sizeof($data);
     foreach ($langs as $lang) {
         $checkBatch = true;
         $tagMap = array();
         // Tags to be added to babelfish
         $rows = array();
         // The rows to be inserted into Babelfish
         foreach ($data as $i => $datum) {
             $url = $datum[$rowPos['url']];
             // Special case for Chinese.  Certain articles are excluded from being put into
             // babelfish for translation to stay on the good side of the Chinese firewalls
             if ($lang == 'zh' && 1 == $datum[$rowPos['zh_exclude']]) {
                 // A bit of a hack to account for the special zh case to exclude certain
                 // articles from babelfish.  Normally any url, so long as valid (ie title
                 // exists and not excluded) would be available for all languages in Babelfish.
                 // For zh we'll skip the article if excluded and set a flag not to check this
                 // batch (as the counts will be off between batchSize and valid/invalid urls)
                 // rather than unset the data since it will be imported by other
                 // languages in the next iteration of the foreach
                 $checkBatch = false;
             } else {
                 $state = $this->getArticleState($url, $lang);
                 if ($state == WAPArticle::STATE_INVALID || $state == WAPArticle::STATE_EXCLUDED) {
                     $invalidUrls[$url] = $state;
                     unset($data[$i]);
                     continue;
                 }
                 $aid = $datum[$rowPos['aid']];
                 $t = Title::newFromId($aid);
                 if ($t) {
                     // Add tags for language
                     $row['ct_page_id'] = $t->getArticleId();
                     $row['ct_lang_code'] = $lang;
                     $row['ct_page_title'] = $dbw->strencode($t->getDBKey());
                     $row['ct_catinfo'] = Categoryhelper::getTitleCategoryMask($t);
                     $row['ct_categories'] = implode(",", $this->getTopLevelCategories($t));
                     $row['ct_rank'] = $datum[$rowPos['rank']];
                     $row['ct_score'] = $datum[$rowPos['score']];
                     $rows[] = $row;
                     // Add tags to tag map for language
                     $tagMap[$lang][] = $aid;
                 } else {
                     $invalidUrls[$url] = 'title not found';
                 }
             }
         }
         if ($checkBatch) {
             $this->checkBatch($batchSize, $rows, $invalidUrls);
         }
         $this->insertRows($rows);
         $this->addTags($tagMap, $lang);
         // Complete articles that are in the Babelfish DB and have been translated
         $this->completeTranslatedArticlesInAids($this->getAidsFromRows($rows), $lang);
     }
     return $invalidUrls;
 }
コード例 #22
0
ファイル: ApiApp.body.php プロジェクト: ErdemA/wikihow
 static function getCategoryImageFile($title)
 {
     $catmap = Categoryhelper::getIconMap();
     // if page is a top category itself otherwise get top
     if (isset($catmap[urldecode($title->getPartialURL())])) {
         $cat = urldecode($title->getPartialURL());
     } else {
         $cat = Categoryhelper::getTopCategory($title);
         //INTL: Get the partial URL for the top category if it exists
         // For some reason only the english site returns the partial
         // URL for getTopCategory
         if (isset($cat) && $wgLanguageCode != 'en') {
             $title = Title::newFromText($cat);
             if ($title) {
                 $cat = $title->getPartialURL();
             }
         }
     }
     if (isset($catmap[$cat])) {
         $image = Title::newFromText($catmap[$cat]);
         $file = wfFindFile($image, false);
     } else {
         $image = Title::makeTitle(NS_IMAGE, "Book_266.png");
         $file = wfFindFile($image, false);
         if (!$file) {
             $file = wfFindFile("Book_266.png");
         }
     }
     return $file;
 }
コード例 #23
0
ファイル: EditPageWrapper.php プロジェクト: ErdemA/wikihow
 function showEditForm($formCallback = null)
 {
     global $wgOut, $wgLanguageCode, $wgRequest, $wgTitle, $wgUser, $wgLang;
     $whow = null;
     // conflict resolution
     if (!$wgRequest->wasPosted()) {
         EditPage::showEditForm();
     }
     $wgOut->clearHTML();
     //echo $this->textbox1; exit;
     wfRunHooks('EditPage::showEditForm:initial', array(&$this));
     // are we called with just action=edit and no title?
     $newArticle = false;
     if (($wgRequest->getVal("title") == "" || $wgTitle->getArticleID() == 0) && !$this->preview) {
         $newArticle = true;
     }
     $sk = $wgUser->getSkin();
     if (!$this->mTitle->getArticleID() && !$this->preview) {
         # new article
         $wgOut->addHTML(wfMsg("newarticletext"));
     }
     // do we have a new article? if so, format the title if it's English
     $wgRequest->getVal("new_article");
     if ($new_article && $wgLanguageCode == "en") {
         $title = $this->mTitle->getText();
         $old_title = $title;
         $title = $this->formatTitle($title);
         $titleObj = Title::newFromText($title);
         $this->mTitle = $titleObj;
         $this->mArticle = new Article($titleObj);
     }
     $conflictWikiHow = null;
     $conflictTitle = false;
     if ($this->isConflict) {
         $s = wfMsg("editconflict", $this->mTitle->getPrefixedText());
         $wgOut->setPageTitle($s);
         if ($new_article) {
             $wgOut->addHTML("<b><font color=red>" . wfMsg('page-name-exists') . "</b></font><br/><br/>");
             $conflictTitle = true;
         } else {
             $this->edittime = $this->mArticle->getTimestamp();
             $wgOut->addHTML(wfMsg("explainconflict"));
             // let the advanced editor handle the situation
             if ($this->isConflict) {
                 EditPage::showEditForm();
                 return;
             }
         }
         $this->textbox2 = $this->textbox1;
         $conflictWikiHow = WikihowArticleEditor::newFromText($this->textbox1);
         $this->textbox1 = $this->mArticle->getContent(true, true);
         $this->edittime = $this->mArticle->getTimestamp();
     } else {
         if ($this->mTitle->getArticleID() == 0) {
             $s = wfMsg('creating', "\"" . wfMsg('howto', $this->mTitle->getPrefixedText()) . "\"");
         } else {
             $s = wfMsg('editing', "\"" . wfMsg('howto', $this->mTitle->getPrefixedText()) . "\"");
         }
         if ($this->section != "") {
             if ($this->section == "new") {
                 $s .= wfMsg("commentedit");
             } else {
                 $s .= wfMsg("sectionedit");
             }
             if (!$this->preview) {
                 $sectitle = preg_match("/^=+(.*?)=+/mi", $this->textbox1, $matches);
                 if (!empty($matches[1])) {
                     $this->summary = "/* " . trim($matches[1]) . " */ ";
                 }
             }
         }
         $wgOut->setPageTitle($s);
         if ($this->oldid) {
             $this->mArticle->setOldSubtitle($this->oldid);
             $wgOut->addHTML(wfMsg("editingold"));
         }
     }
     if (wfReadOnly()) {
         $wgOut->addHTML("<strong>" . wfMsg("readonlywarning") . "</strong>");
     } elseif ($isCssJsSubpage and "preview" != $formtype) {
         $wgOut->addHTML(wfMsg("usercssjsyoucanpreview"));
     }
     if (!$newArticle && $this->mTitle->isProtected('edit')) {
         if ($this->mTitle->isSemiProtected()) {
             $notice = wfMsg('semiprotectedpagewarning');
             if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                 $notice = '';
             }
         } else {
             $notice = wfMsg('protectedpagewarning');
         }
         $wgOut->addHTML("<div class='article_inner'>\n ");
         $wgOut->addWikiText($notice);
         $wgOut->addHTML("</div>\n");
     }
     $q = "action=submit2&override=yes";
     #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
     $action = $this->mTitle->escapeLocalURL($q);
     if ($newArticle) {
         $main = str_replace(' ', '-', wfMsg('mainpage'));
         $action = str_replace("&title=" . $main, "", $action);
     }
     $summary = wfMsg("summary");
     $subject = wfMsg("subject");
     $minor = wfMsg("minoredit");
     $watchthis = wfMsg("watchthis");
     $save = wfMsg("savearticle");
     $prev = wfMsg("showpreview");
     $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsg("cancel"));
     $edithelpurl = Skin::makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
     $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
     $copywarn = wfMsg("copyrightwarning", $sk->makeKnownLink(wfMsg("copyrightpage")));
     $minoredithtml = '';
     if ($wgUser->isAllowed('minoredit')) {
         $minoredithtml = "<input tabindex='11' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n";
     }
     $watchhtml = '';
     if ($wgUser->isLoggedIn()) {
         $watchhtml = "<input tabindex='12' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis'  />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n";
     }
     $checkboxhtml = $minoredithtml . $watchhtml;
     $tabindex = 14;
     $buttons = $this->getEditButtons($tabindex);
     $footerbuttons = "";
     $buttons['preview'] = "<span id='gatGuidedPreview'>{$buttons['preview']}</span>";
     if ($wgUser->getOption('hidepersistantsavebar', 0) == 0) {
         $footerbuttons .= "<span id='gatPSBSave'>{$buttons['save']}</span>";
         $footerbuttons .= "<span id='gatPSBPreview'>{$buttons['preview']}</span>";
     }
     $saveBtn = str_replace('accesskey="s"', "", $buttons['save']);
     $buttons['save'] = "<span id='gatGuidedSave'>{$saveBtn}</span>";
     $buttonshtml = implode($buttons, "\n");
     # if this is a comment, show a subject line at the top, which is also the edit summary.
     # Otherwise, show a summary field at the bottom
     $summarytext = htmlspecialchars($wgLang->recodeForEdit($this->summary));
     # FIXME
     $editsummary1 = "";
     if ($wgRequest->getVal('suggestion')) {
         $summarytext .= ($summarytext == "" ? "" : ", ") . wfMsg('suggestion_edit_summary');
     }
     if ($this->section == "new") {
         $commentsubject = "{$subject}: <input tabindex='1' type='text' value=\"{$summarytext}\" name=\"wpSummary\" id='wpSummary' maxlength='200' size='60' />";
         $editsummary = "";
     } else {
         $commentsubject = "";
         if ($wgTitle->getArticleID() == 0 && $wgTitle->getNamespace() == NS_MAIN && $summarytext == "") {
             $summarytext = wfMsg('creating_new_article');
         }
         $editsummary = "<input tabindex='10' type='text' value=\"{$summarytext}\" name=\"wpSummary\" id='wpSummary' maxlength='200' size='60' /><br />";
         $editsummary1 = "<input tabindex='10' type='text' value=\"{$summarytext}\" name=\"wpSummary1\" id='wpSummary1' maxlength='200' size='60' /><br />";
     }
     // create the wikiHow
     if ($conflictWikiHow == null) {
         if ($this->textbox1 != "") {
             $whow = WikihowArticleEditor::newFromText($this->textbox1);
         } else {
             $whow = WikihowArticleEditor::newFromArticle($this->mArticle);
         }
     } else {
         $whow = $conflictWikiHow;
     }
     //********** SETTING UP THE FORM
     //
     //
     //
     //
     $confirm = "window.onbeforeunload = confirmExit;";
     if ($wgUser->getOption('disablewarning') == '1') {
         $confirm = "";
     }
     $wgOut->addHTML("<script language=\"JavaScript\">\n\t\t\t\tvar isGuided = true;\n\t\t\t\tvar needToConfirm = false;\n\t\t\t\tvar checkMinLength = true;\n\t\t\t\t{$confirm}\n\t\t\t\tfunction confirmExit() {\n\t\t\t\t\tif (needToConfirm)\n\t\t\t\t\t\treturn \"" . wfMsg('all-changes-lost') . "\";\n\t\t\t\t}\n\t\t\t\tfunction addrows(element) {\n\t\t\t\t\tif (element.rows < 32)  {\n\t\t\t\t\t\telement.rows += 4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfunction removerows(element) {\n\t\t\t\t\tif (element.rows > 4)  {\n\t\t\t\t\t\telement.rows -= 4;\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.rows = 4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfunction saveandpublish() {\n\t\t\t\t\twindow.onbeforeunload = null;\n\t\t\t\t\tdocument.editform.submit();\n\t\t\t\t}\n\t\t\t\t(function (\$) {\n\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\$('.button').click(function () {\n\t\t\t\t\t\t\tvar button = \$(this).not('.submit_button');\n\t\t\t\t\t\t\tif (button.length) {\n\t\t\t\t\t\t\t\tneedToConfirm = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$('textarea').focus(function () {\n\t\t\t\t\t\t\tneedToConfirm = true;\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\t\$('#ep_cat').live('click', function(e) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tvar title = 'Categorize ' + wgTitle;\n\t\t\t\t\t\tif (title.length > 54) {\n\t\t\t\t\t\t\ttitle = title.substr(0, 54) + '...';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tjQuery('#dialog-box').html('');\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('#dialog-box').load('/Special:Categorizer?a=editpage&id=' + wgArticleId, function() {\n\t\t\t\t\t\t\tjQuery('#dialog-box').dialog({\n\t\t\t\t\t\t\t\twidth: 673,\n\t\t\t\t\t\t\t\theight: 600,\n\t\t\t\t\t\t\t\tmodal: true,\n\t\t\t\t\t\t\t\ttitle: title,\n\t\t\t\t\t\t\t\tcloseText: 'Close',\t\n\t\t\t\t\t\t\t\tdialogClass: 'modal2',\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treCenter = function() {\n\t\t\t\t\t\t\t\tjQuery('#dialog-box').dialog('option', 'position', 'center');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetTimeout('reCenter()', 100);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$.getScript('/extensions/wikihow/cattool/categorizer.js');\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t})(jQuery);\n\t\t\t</script>\n\t\t\t<script type=\"text/javascript\" src=\"" . wfGetPad('/extensions/min/f/skins/common/clientscript.js,/skins/common/ac.js,/extensions/wikihow/video/importvideo.js&rev=') . WH_SITEREV . "\"></script>\n\n\t\t");
     if (!$this->preview) {
         # Don't select the edit box on preview; this interferes with seeing what's going on.
         $wgOut->setOnloadHandler("document.editform.title.focus(); load_cats();");
     }
     $title = "";
     //$wgOut->setOnloadHandler( "' onbeforeunload='return confirm(\"Are you sure you want to navigate away from this page? All changes will be lost!\");" );
     $suggested_title = "";
     if (isset($_GET["requested"])) {
         $t = Title::makeTitle(NS_MAIN, $_GET["requested"]);
         $suggested_title = $t->getText();
     }
     if ($wgRequest->getVal('title', null) == null || $conflictTitle || $suggested_title != "") {
         $title = "<div id='title'><h3>" . wfMsg('title') . "</h3><br/>" . wfMsg('howto', '') . " &nbsp;&nbsp;&nbsp;\n\t\t\t<input autocomplete=\"off\" size=60 type=\"text\" name=\"title\" id=category tabindex=\"1\" value=\"{$suggested_title}\"></div>";
     }
     $steps = htmlspecialchars($wgLang->recodeForEdit($whow->getSteps(true)), ENT_QUOTES);
     $video = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('video'))));
     $tips = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('tips'))));
     $warns = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('warnings'))));
     $related_text = htmlspecialchars($wgLang->recodeForEdit($whow->getSection(wfMsg('relatedwikihows'))));
     $summary = htmlspecialchars($wgLang->recodeForEdit($whow->getSummary()));
     if ($newArticle || $whow->mIsNew) {
         if ($steps == "") {
             $steps = "#  ";
         }
         if ($tips == "") {
             $tips = "*  ";
         }
         if ($warns == "") {
             $warns = "*  ";
         }
         if ($ingredients == "") {
             $ingredients = "*  ";
         }
     }
     $cat = $whow->getCategoryString();
     $advanced = "";
     $cat_array = explode("|", $whow->getCategoryString());
     $i = 0;
     $cat_string = "";
     foreach ($cat_array as $cat) {
         if ($cat == "") {
             continue;
         }
         if ($i != 0) {
             $cat_string .= "," . $cat;
         } else {
             $cat_string = $cat;
         }
         $i++;
     }
     $removeButton = "";
     $cat_advisory = "";
     if ($cat_string != "") {
         $removeButton = "<input type=\"button\" name=\"change_cats\" onclick=\"removeCategories();\" value=\"" . wfMsg('remove-categories') . "\">";
     } else {
         $cat_advisory = wfMsg('categorization-optional');
     }
     //$cat_string = str_replace("|", ", ", $whow->getCategoryString());
     //$cat_string = implode(", ", $raa);
     if (!$newArticle && !$whow->mIsNew && !$conflictTitle) {
         $oldparameters = "";
         if ($wgRequest->getVal("oldid") != "") {
             $oldparameters = "&oldid=" . $wgRequest->getVal("oldid");
         }
         if (!$this->preview) {
             $advanced = "<a class='' href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true{$oldparameters}'>" . wfMsg('advanced-editing') . "</a>";
         }
     } elseif ($newArticle && $wgRequest->getVal('title', null) != null) {
         $t = Title::newFromText("CreatePage", NS_SPECIAL);
         //$advanced = str_replace("href=", "class='guided-button' href=", $sk->makeLinkObj($t, wfMsg('advanced-editing'))) . " |";
         //$advanced = "<a href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true$oldparameters';\">".wfMsg('advanced-editing')."</a>";
         $advanced = "<a class='button secondary' style='float:left;' href='{$wgScript}?title=" . $wgTitle->getPrefixedURL() . "&action=edit&advanced=true{$oldparameters}'>" . wfMsg('advanced-editing') . "</a>";
     }
     $section_class = 'minor_section';
     // MODIFIED FOR POPUP
     $categoryHTML = "";
     if ($wgUser->getID() > 0) {
         $ctitle = $this->mTitle->getText();
         $css = HtmlSnips::makeUrlTags('css', array('categoriespopup.css'), 'extensions/wikihow', false);
         if ($wgLanguageCode == 'en') {
             $editCatMore = "<a href=\"{$wgScriptPath}/Writer%27s-Guide?section=2#" . wfMsg('more-info-categorization') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>";
             $editCatHtml = "<a href='#' id='ep_cat'>[" . wfMsg('editcategory') . "]</a><strong>{$editCatLink}</strong>";
         }
         $categoryHTML = "\n\t\t\t\t{$css}\n\t\t\t\t<div id='categories'>\n\t\t\t\t\t<h5>" . wfMsg('add-optional-categories') . "{$editCatMore}</h5>\n\t\t\t\t\t<div id='option_cats'>\n\t\t\t\t\t{$editCatHtml}" . Categoryhelper::getCategoryOptionsForm2($cat_string, $whow->mCategories) . "\t</div>\n\t\t\t\t</div>";
     }
     $requested = "";
     if (isset($_GET['requested'])) {
         $requested = $_GET['requested'];
     }
     $related_vis = "hide";
     $related_checked = "";
     $relatedHTML = "";
     if ($whow->getSection(wfMsg('relatedwikihows')) != "") {
         $related_vis = "show";
         $relatedHTML = $whow->getSection(wfMsg('relatedwikihows'));
         $relatedHTML = str_replace("*", "", $relatedHTML);
         $relatedHTML = str_replace("[[", "", $relatedHTML);
         $relatedHTML = str_replace("]]", "", $relatedHTML);
         $lines = split("\n", $relatedHTML);
         $relatedHTML = "";
         foreach ($lines as $line) {
             $xx = strpos($line, "|");
             if ($xx !== false) {
                 $line = substr($line, 0, $xx);
             }
             // Google+ hack.  We don't normally allow + but will for the Goog
             if (false === stripos($line, 'Google+')) {
                 $line = trim(urldecode($line));
             }
             if ($line == "") {
                 continue;
             }
             $relatedHTML .= "<OPTION VALUE=\"" . htmlspecialchars($line) . "\">{$line}</OPTION>\n";
         }
         $related_checked = " CHECKED ";
     }
     $vidpreview_vis = "hide";
     $vidbtn_vis = "show";
     $vidpreview = "<img src='" . wfGetPad('/extensions/wikihow/rotate.gif') . "'/>";
     if ($whow->getSection(wfMsg('video')) != "") {
         $vidpreview_vis = "show";
         $vidbtn_vis = "hide";
         try {
             #$vt = Title::makeTitle(NS_VIDEO, $this->mTitle->getText());
             #$r = Revision::newFromTitle($vt);
             $vidtext = $whow->getSection(wfMsg('video'));
             $vidpreview = $wgOut->parse($vidtext);
         } catch (Exception $e) {
             $vidpreview = "Sorry, preview is currently not available.";
         }
     } else {
         $vidpreview = wfMsg('video_novideoyet');
     }
     $video_disabled = "";
     $vid_alt = "";
     $video_msg = "";
     $video_button = "<a id='gatVideoImportEdit' type='button' onclick=\"changeVideo('" . urlencode($wgTitle->getDBKey()) . "'); return false;\" href='#' id='show_preview_button' class='button secondary'  >" . wfMsg('video_change') . "</a>";
     if ($wgUser->getID() == 0) {
         $video_disabled = "disabled";
         $video_alt = "<input type='hidden' name='video' value=\"" . htmlspecialchars($video) . "\"/>";
         $video_msg = wfMsg('video_loggedin');
         $video_button = "";
     }
     $things_vis = "hide";
     $things = "*  ";
     $things_checked = "";
     $tyn = $whow->getSection(wfMsg("thingsyoullneed"));
     if ($tyn != '') {
         $things_vis = "show";
         $things = $tyn;
         $things_checked = " CHECKED ";
     }
     $ingredients_vis = "hide";
     $section = $whow->getSection(wfMsg("ingredients"));
     $ingredients_checked = "";
     if ($section != '') {
         $ingredients_vis = "show";
         $ingredients = $section;
         $ingredients_checked = " CHECKED ";
     }
     $sources_vis = "hide";
     $sources = "*  ";
     $sources_checked = "";
     $sources = $whow->getSection(wfMsg("sources"));
     $sources = str_replace('<div class="references-small"><references/></div>', '', $sources);
     $sources = str_replace('{{reflist}}', '', $sources);
     if ($sources != "") {
         $sources_vis = "show";
         $sources_checked = " CHECKED ";
     }
     $new_field = "";
     if ($newArticle || $new_article) {
         $new_field = "<input type=hidden name=new_article value=true>";
     }
     $lang_links = htmlspecialchars($whow->getLangLinks());
     $vt = Title::makeTitle(NS_VIDEO, $this->mTitle->getText());
     $vp = SpecialPage::getTitleFor("Previewvideo", $vt->getFullText());
     $newArticleWarn = '<script type="text/javascript" src="' . wfGetPad('/extensions/min/f/extensions/wikihow/winpop.js?') . WH_SITEREV . '"></script>';
     $popup = Title::newFromText("UploadPopup", NS_SPECIAL);
     if ($wgUser->isLoggedIn()) {
         $token = htmlspecialchars($wgUser->editToken());
     } else {
         $token = EDIT_TOKEN_SUFFIX;
     }
     if ('preview' == $this->formtype) {
         $previewOutput = $this->getPreviewText();
         $this->showPreview($previewOutput);
         $show_weave = true;
     } else {
         $wgOut->addHTML('<div id="wikiPreview"></div>');
     }
     if ('diff' == $this->formtype) {
         $this->showDiff();
         $show_weave = true;
     }
     if ($show_weave) {
         $relBtn = $wgLanguageCode == 'en' ? PopBox::getGuidedEditorButton() : '';
         $relHTML = PopBox::getPopBoxJSGuided() . PopBox::getPopBoxDiv() . PopBox::getPopBoxCSS();
         $weave_links = $relHTML . '<div class="wh_block editpage_sublinks">' . $relBtn . '</div>';
     }
     $undo = '';
     if ($wgRequest->getVal('undo', null) != null) {
         $undo_id = $wgRequest->getVal('undo', null);
         $undo = "\n<input type='hidden' value=\"{$undo_id}\" name=\"wpUndoEdit\" />\n";
     }
     $wgOut->addHTML(Easyimageupload::getUploadBoxJS());
     $wgOut->addHTML("\t\n{$newArticleWarn}\n\n<div id='editpage'>\n<form id=\"editform\" name=\"editform\" method=\"post\" action=\"{$action}\"\nenctype=\"application/x-www-form-urlencoded\"  onSubmit=\"return checkForm();\">\t\t");
     if (is_callable($formCallback)) {
         call_user_func_array($formCallback, array(&$wgOut));
     }
     $hidden_cats = "";
     if (!$wgUser->isLoggedIn()) {
         $hidden_cats = "<input type=\"hidden\" name=\"categories22\" value=\"{$cat_string}\">";
     }
     $token1 = md5($wgUser->getName() . $this->mTitle->getArticleID() . time());
     wfTrackEditToken($wgUser, $token1, $this->mTitle, $this instanceof EditPageWrapper);
     $wgOut->addHTML("\n\t\t{$new_field}\n\t\t{$hidden_cats}\n\t\t<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n\t\t<input type=\"hidden\" name=\"requested\" value=\"{$requested}\">\n\t\t<input type=\"hidden\" name=\"langlinks\" value=\"{$lang_links}\">\n\t\t<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n\n\t\t{$commentsubject}\n\t\t{$title}\n\t\t<br clear='all'/>\n<script language='javascript'>\n\tvar vp_URL = '{$vp->getLocalUrl()}';\n</script>\n<script language='javascript' src='" . wfGetPad('/extensions/min/f/extensions/wikihow/previewvideo.js?rev=') . "'></script>\n<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/editpagewrapper.css,/extensions/wikihow/winpop.css,/extensions/wikihow/video/importvideo.css,/extensions/wikihow/cattool/categorizer.css,/extensions/wikihow/cattool/categorizer_editpage.css&rev=') . WH_SITEREV . "'; /*]]>*/</style>\n\n\t{$weave_links}\n\n\t<div id='introduction' class='{$section_class}'>\n\t\t<h2>" . wfMsg('introduction') . "\n\t\t\t<div class='head_details'>" . wfMsg('summaryinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('introduction-url') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea rows='4' cols='100' name='summary' id='summary' tabindex=\"2\" wrap=virtual>{$summary}</textarea>\n\t\t<!--a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"intro\"); return false;'>" . wfMsg('eiu-add-image-to-introduction') . "</a-->\n\t\t<div class='clearall'></div>\n\t</div>\n\n\n\t<div id='ingredients' class='{$ingredients_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('ingredients') . "\n\t\t\t<div class='head_details'>" . wfMsg('ingredients_tooltip') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('ingredients') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='ingredients' rows='4' cols='100' onKeyUp=\"addStars(event, document.editform.ingredients);\" tabindex='3' id='ingredients_text'>{$ingredients}</textarea>\n\t\t<a href='#' class='button secondary add_image_button'  onclick='easyImageUpload.doEIUModal(\"ingredients\"); return false;'>" . wfMsg('eiu-add-image-to-ingredients') . "</a>\n\t</div>\n\n\t<div id='steps' class='{$section_class}'>\n\t\t<h2>" . wfMsg('steps') . "\n\t\t\t<div class='head_details'>" . wfMsg('stepsinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('steps') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='steps' rows='{$wgRequest->getVal('txtarea_steps_text', 12)}' cols='100' wrap='virtual' onKeyUp=\"addNumToSteps(event);\" tabindex='4' id='steps_text'>{$steps}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"steps\", 0); return false;'>" . wfMsg('eiu-add-image-to-steps') . "</a>\n\t</div>");
     $wgOut->addHTML("<div id='video' class='{$section_class}'>\n\t\t<h2>" . wfMsg('video') . "\n\t\t\t<div class='head_details'>" . wfMsg('videoinfo') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('video') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t{$video_alt}\n\t\t<input type='text' name='video{$video_disabled}' size='60' id='video_text' style='float:left;' value=\"{$video}\" {$video_disabled}/><br />\n\t\t{$video_button}\n\t\t<a href='javascript:showHideVideoPreview();' id='show_preview_button' class='button secondary {$vidbtn_vis}'>" . wfMsg('show_preview') . "</a>\n\t\t{$video_msg}\n\t</div>\n\t<div id='viewpreview' class='{$vidpreview_vis} {$section_class}' style='text-align: center; margin-top: 5px;'>\n\t\t<center><a onclick='showHideVideoPreview();'>" . wfMsg('ep_hide_preview') . "</a></center><br/>\n\t\t<div id='viewpreview_innards'>{$vidpreview}</div>\n\t</div>\n\n\t<div id='tips' class='{$section_class}'>\n\t\t<h2>" . wfMsg('tips') . "\n\t\t\t<div class='head_details'>" . wfMsg('listhints') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('tips') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='tips' rows='{$wgRequest->getVal('txtarea_tips_text', 12)}' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.tips);' tabindex='5' id='tips_text'>{$tips}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"tips\"); return false;'>" . wfMsg('eiu-add-image-to-tips') . "</a>\n\t</div>\n\n\t<div id='warnings' class='{$section_class}'>\n\t\t<h2>" . wfMsg('warnings') . "\n\t\t\t<div class='head_details'>" . wfMsg('optionallist') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=3#" . wfMsg('warnings') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='warnings' rows='{$wgRequest->getVal('txtarea_warnings_text', 4)}' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.warnings);' id='warnings_text' tabindex=\"6\" id='warnings_text'>{$warns}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"warnings\"); return false;'>" . wfMsg('eiu-add-image-to-warnings') . "</a>\n\t</div>\n\n\t<div id='thingsyoullneed' class='{$things_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('thingsyoullneed') . "\n\t\t\t<div class='head_details'>" . wfMsg('items') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=4#" . wfMsg('thingsyoullneed') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='thingsyoullneed' rows='4' cols='65' wrap='virtual' onKeyUp='addStars(event, document.editform.thingsyoullneed);' tabindex='7' id='thingsyoullneed_text'>{$things}</textarea>\n\t\t<a href='#' class='button secondary add_image_button' onclick='easyImageUpload.doEIUModal(\"thingsyoullneed\"); return false;'>" . wfMsg('eiu-add-image-to-thingsyoullneed') . "</a>\n\t</div>\n\n\t<div id='relatedwikihows' class='{$related_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('relatedarticlestext') . "\n\t\t\t<div class='head_details'>" . wfMsg('relatedlist') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=5#" . wfMsg('related-wikihows-url') . "\" target=\"new\">" . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<div id='related_buttons'>\n\t\t\t<a href='#'  class='button secondary' onclick='moveRelated(true);return false;' >" . wfMsg('epw_move_up') . "</a>\n\t\t\t<a href='#' class='button secondary' onclick='moveRelated(false);return false;'>" . wfMsg('epw_move_down') . "</a>\n\t\t\t<a href='#' class='button red' onclick='removeRelated(); return false;'>" . wfMsg('epw_remove') . "</a>\n\t\t\t<br />\n\t\t\t<br />\n\t\t</div>\n\t\t<input type=hidden value=\"\" name=\"related_list\">\n\t\t<select size='4' name='related' id='related_select' ondblclick='viewRelated();'>\n\t\t\t{$relatedHTML}\n\t\t</select>\n\t\t<br />\n\t\t<br />\n\t\t<br class='clearall'/>\n\t\t<div>\n\t\t\t<b>" . wfMsg('addtitle') . "</b><br />\n\t\t\t<input type='text' autocomplete=\"off\" maxLength='256' name='q' value='' onKeyPress=\"return keyxxx(event);\" tabindex='8'>\n\t\t</div>\n\t\t<a href='#' id='add_button' class='button secondary' onclick='add_related();return false;'>" . wfMsg('epw_add') . "</a>\n\t\t<br class='clearall'/>\n\t</div>\n\n<script language=\"JavaScript\">\n\tvar js_enabled = document.getElementById('related');\n\t\t if (js_enabled != null) {\n\t\t\t\t js_enabled.className = 'display';\n\t\t\t}\n\t</script>\n\t<noscript>\n\t\t<input type='hidden' name='no_js' value='true'>\n\t\t<div id='related'>\n\t\t\t<textarea name='related_no_js' rows='4' cols='65' wrap='virtual' onKeyUp='addStars(event, document.editform.related_no_js);' id='related_no_js' tabindex='8'>{$related_text}</textarea>\n\t\t</div>\n\t</noscript>\n\n\t<div id='sources' class='{$sources_vis} {$section_class}'>\n\t\t<h2>" . wfMsg('sources') . "\n\t\t\t<div class='head_details'>" . wfMsg('linkstosites') . "</div>\n\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('sources-links-url') . "\" target=\"new\"> " . wfMsg('moreinfo') . "</a>\n\t\t</h2>\n\t\t<textarea name='sources' rows='3' cols='100' wrap='virtual' onKeyUp='addStars(event, document.editform.sources);' id='sources' tabindex='9'>{$sources}</textarea>\n\t</div>\n\n\t<div class='{$section_class}'>\n\t\t<h2>" . wfMsg('optional_options') . "</h2>\n\t\t{$categoryHTML}\n\n\t\t<div id='optional_sections'>\n\t\t\t<h5>" . wfMsg('optionalsections') . "</h5>\n\t\t\t<ul>\n\t\t\t\t<li><input type='checkbox' id='thingsyoullneed_checkbox' name='thingsyoullneed_checkbox' onclick='showhiderow(\"thingsyoullneed\", \"thingsyoullneed_checkbox\");' {$things_checked} /> <label for='thingsyoullneed_checkbox'>" . wfMsg('thingsyoullneed') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='related_checkbox' name='related_checkbox' onclick='showhiderow(\"relatedwikihows\", \"related_checkbox\");' {$related_checked} > <label for='related_checkbox'>" . wfMsg('relatedwikihows') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='sources_checkbox' name='sources_checkbox' onclick='showhiderow(\"sources\", \"sources_checkbox\");' {$sources_checked} > <label for='sources_checkbox'>" . wfMsg('sources') . "</label></li>\n\t\t\t\t<li><input type='checkbox' id='ingredients_checkbox' name='ingredients_checkbox' onclick='showhiderow(\"ingredients\", \"ingredients_checkbox\");' {$ingredients_checked} > <label for='ingredients_checkbox'>" . wfMsg('ingredients_checkbox') . "</label></li>\n\t\t\t</ul>\n\t\t</div>\n\t</div>\n\t\n\t<div class='{$section_class}'>\n\t\t<div class='editOptions'>\n\t\t\t<h2>" . wfMsg('editdetails') . "\n\t\t\t\t<div class='head_details'>" . wfMsg('summaryedit') . "</div>\n\t\t\t\t<a href=\"{$wgScriptPath}/" . wfMsg('writers-guide-url') . "?section=2#" . wfMsg('summary') . "\" target=\"new\"> " . wfMsg('moreinfo') . "</a>\n\t\t\t</h2>\n\t\t\t{$editsummary}\n\t\t\t{$checkboxhtml}\n\t\t\t{$undo}\n\t\t\t<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n\t\t\t<input type='hidden' value=\"{$token1}\" name=\"wpEditTokenTrack\" />\n\t\t\t<div class='editButtons'>\n\t\t\t\t<a href=\"javascript:history.back()\" id=\"wpCancel\" class=\"button secondary\">" . wfMsg('cancel') . "</a>\n\t\t\t\t{$buttonshtml}\n\t\t\t</div>\n\t\t\t{$copywarn}\n\t\t</div>\n\t</div>\n\t<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n\t<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n");
     if ($this->isConflict) {
         require_once "DifferenceEngine.php";
         $wgOut->addHTML("<h2>" . wfMsg("yourdiff") . "</h2>\n");
         DifferenceEngine::showDiff($this->textbox2, $this->textbox1, wfMsg("yourtext"), wfMsg("storedversion"));
     }
     if ($wgUser->getOption('hidepersistantsavebar', 0) == 0) {
         $wgOut->addHTML(" <div id='edit_page_footer'>\n\t\t\t\t<table class='edit_footer'><tr><td class='summary'>\n\t\t\t\t" . wfMsg('editsummary') . ": &nbsp; {$editsummary1}</td>\n\t\t\t\t<td class='buttons'>{$footerbuttons}</td></tr></table>\n\t\t\t\t</div> ");
     }
     $wgOut->addHTML("</form></div>\n");
 }
コード例 #24
0
<?php

require_once 'commandLine.inc';
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('page', array('page_title', 'page_namespace'), array('page_namespace' => NS_MAIN, 'page_is_redirect' => 0), "who_has_intro_image");
$titles = array();
$wanted = array("Personal Care and Style", "Computers and Electronics", "Pets and Animals", "Sports and Fitness");
$count = 0;
while ($row = $dbr->fetchObject($res)) {
    $t = Title::makeTitle($row->page_namespace, $row->page_title);
    if (!$t) {
        continue;
    }
    $cats = Categoryhelper::getTitleTopLevelCategories($t);
    foreach ($cats as $c) {
        if (in_array($c->getText(), $wanted)) {
            $titles[$t->getText()] = $c;
            break;
        }
    }
    $count++;
    if ($count % 1000 == 0) {
        echo "Done {$count}\n";
    }
}
echo "got " . sizeof($titles) . " titles\n";
foreach ($titles as $t => $c) {
    $t = Title::newFromText($t);
    $r = Revision::newFromTitle($t);
    if (!$r) {
        continue;