/** * Returns HTML internals of the widget box. */ public function getHTML($initialData) { $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('data' => $initialData, 'completedToday' => $this->getCompletion(), 'thresholds' => $this->getThresholds(), 'header' => $this->getHeaderHTML(), 'weather' => $this->getWeatherClass($initialData['ct']), 'countDescription' => $this->getCountDescription(), 'moreLink' => $this->getMoreLink(), 'widgetName' => $this->getName(), 'title' => $this->getLeaderboardTitle(), 'getAvatarLink' => array($this, 'getAvatarLink'), 'getUserLink' => array($this, 'getUserLink'), 'status' => $this->getWidgetStatus(), 'login' => $this->getLoginLink(), 'widgetMWName' => $this->getMWName(), 'extraInternalHTML' => $this->getExtraInternalHTML())); $html = $tmpl->execute('widgets/dashboardWidget.tmpl.php'); return $html; }
public static function getCTA(&$t) { if (self::isActivePage() && !self::isReferredFromArticleCreator() && self::isValidTitle($t)) { $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('title' => $t->getText())); return $tmpl->execute('AltMethodAdder.tmpl.php'); } }
public function addBubbleTipToElement($element, $cookiePrefix, $text) { global $wgOut; $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('tipsbubble.css'), 'extensions/wikihow/interfaceelements', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('interfaceelements/tipsbubble.js', 'common/jquery.cookie.js'), 'extensions/wikihow', false)); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('text' => $text)); InterfaceElements::addJSVars(array('bubble_target_id' => $element, 'cookieName' => $cookiePrefix . '_b')); $wgOut->addHTML($tmpl->execute('TipsBubble.tmpl.php')); }
function execute($par) { global $wgOut, $wgRequest, $wgUser, $wgParser; wfLoadExtensionMessages("MethodGuardian"); if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if ($wgUser->isAnon()) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext'); return; } $this->skipTool = new ToolSkip("methodguardian", MethodGuardian::TABLE_NAME, "ama_checkout", "ama_checkout_user", "ama_id"); if ($wgRequest->getVal('getNext')) { $wgOut->disable(); $result = $this->getNextMethod(); echo json_encode($result); return; } else { if ($wgRequest->getVal('skipMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $this->skipTool->skipItem($methodId); $this->skipTool->unUseItem($methodId); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('deleteMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $this->deleteMethod($methodId, $articleId); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('keepMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $this->keepMethod($methodId, $articleId); $result = $this->getNextMethod(); echo json_encode($result); return; } } $wgOut->setHTMLTitle(wfMsg('methodguardian')); $wgOut->setPageTitle(wfMsg('methodguardian')); $wgOut->addScript(HtmlSnips::makeUrlTags('css', array('methodguardian.css'), 'extensions/wikihow/altmethodadder', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('methodguardian.js'), 'extensions/wikihow/altmethodadder', false)); $tmpl = new EasyTemplate(dirname(__FILE__)); $wgOut->addHTML($tmpl->execute('MethodGuardian.tmpl.php')); $this->displayLeaderboards(); }
function getCalculator($widget) { global $wgArticleWidgets; if (isset($wgArticleWidgets[$widget])) { $tmpl = new EasyTemplate(dirname(__FILE__)); $html = $tmpl->execute($widget . '/' . $widget . '.tmpl.php'); } else { $html = ''; } return $html; }
public function addBubbleTipToElement($element, $cookiePrefix, $text) { global $wgOut; $wgOut->addJSCode('jqck'); //jQuery Cookie. Add as JS code so we don't have duplicate includes $wgOut->addCSSCode('tbc'); // Tips Bubble CSS InterfaceElements::addJSVars(array('bubble_target_id' => $element, 'cookieName' => $cookiePrefix . '_b')); $wgOut->addHTML(HtmlSnips::makeUrlTags('js', array('interfaceelements/tipsbubble.js'), 'extensions/wikihow', false)); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('text' => $text)); $wgOut->addHTML($tmpl->execute('TipsBubble.tmpl.php')); }
public function getLogin($isHead = false) { global $wgTitle; $action_url = '/index.php?title=Special:Userlogin&action=submitlogin&' . 'type=login&returnto=' . urlencode($wgTitle->getPrefixedURL()) . '&sitelogin=1'; if (SSL_LOGIN_DOMAIN) { $action_url = 'https://' . SSL_LOGIN_DOMAIN . $action_url; } if ($isHead) { $head_suffix = "_head"; } else { $head_suffix = ""; } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('social_buttons' => self::getSocialLogin($head_suffix), 'suffix' => $isHead ? '_head' : '', 'action_url' => htmlspecialchars($action_url))); $html = $tmpl->execute('userloginbox.tmpl.php'); return $html; }
public static function getSplashPage($firstURL) { $vars = array('firstURL' => $firstURL); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars($vars); return $tmpl->execute('splash.tmpl.php'); }
public static function afterAjaxLoginHTML(&$html) { $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); if (!LoginForm::getLoginToken()) { LoginForm::setLoginToken(); } $tmpl->set("loginToken", LoginForm::getLoginToken()); $tmpl->set("fbButtton", FBConnect::getFBButton("sendToConnectOnLoginForSpecificForm();", "fbPrefsConnect")); $html = $tmpl->execute('ajaxLoginMerge'); return true; }
function getAdUnitTaboola($show = true) { global $wgTitle; if (self::adExclusions($wgTitle)) { $placement = 'below-article-thumbs-pg-13'; } else { $placement = 'below-article-thumbs'; } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('placement' => $placement)); $s = $tmpl->execute('wikiHowAdTaboola.tmpl.php'); $hideit_style = ''; if (!$show) { $hideit_style = ' style="display: none;"'; } $s = "<div class='wh_ad'{$hideit_style}>{$s}</div>"; return $s; }
/** * * Returns an image strip of images in the given title * */ function getImageSlider($title) { global $wgOut, $wgUser, $wgMemc, $wgLanguageCode, $wgTitle; wfLoadExtensionMessages('ImageHelper'); $exceptions = wfMsg('ih_exceptions'); $imageExceptions = split("\n", $exceptions); $revid = $title->getLatestRevID(); $imageName = $title->getDBkey(); // $result = $wgMemc->get(wfMemcKey("gs_pp_" . $imageName . "_" . $revid)); // if ($result) { // return $result; // } if (in_array($imageName, $imageExceptions)) { //$wgMemc->set(wfMemcKey("gs_pp_" . $imageName . "_" . $revid), ""); return ""; } $html = ""; $imageUrl = array(); $thumbUrl = array(); $imageTitle = array(); $imageWidth = array(); $imageHeight = array(); $results = self::getImagesFromSteps($title->getArticleID(), $revid); if (empty($results)) { return; } $intro_image = self::getImageFromIntro($title->getArticleID(), $revid); if (!empty($intro_image)) { //add it to the beginning array_unshift($results, $intro_image); } $sk = $wgUser->getSkin(); $titleLink = $sk->makeKnownLinkObj($title, ""); $count = 0; foreach ($results as $img) { $img = preg_replace('@\\[\\[@', '', $img); $image = Title::newFromText($img); if ($image && $image->getArticleID() > 0) { $file = wfFindFile($image); if ($file && isset($file)) { // if (!self::thumbnail_exists($file)) { //log this so we can act on it later /* CREATE TABLE slideshow_todo ( ss2d_page_id INT(8) PRIMARY KEY, ss2d_done TINYINT(1) NOT NULL DEFAULT 0, ss2d_error TINYINT(1) NOT NULL DEFAULT 0, ss2d_created TIMESTAMP DEFAULT NOW() ) */ /* $dbw = wfGetDB(DB_MASTER); $dbw->ignoreErrors(true); $dbw->insert('slideshow_todo', array('ss2d_page_id' => $title->getArticleID())); return ""; }*/ //$thumb = $file->getThumbnail(60, -1, true, true); $thumb = $file->getThumbnail(60, -1, true, true); $fileUrl[] = $image->getLocalURL(); $imageUrl[] = $image->getFullURL(); $thumbUrl[] = $thumb->getUrl(); $imageTitle[] = $row['il_to']; $count++; } } } if ($count > 3) { $a = new Article($title); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('fileUrl' => $fileUrl, 'imageUrl' => $imageUrl, 'thumbUrl' => $thumbUrl, 'imageTitle' => $imageTitle, 'title' => $titleLink, 'numImages' => count($imageUrl), 'imgStrip' => true, 'articleID' => $title->getArticleID(), 'revid' => $revid)); if ($this->bNewLayout_02) { $html .= $tmpl->execute('prettyPhoto3.tmpl.php'); } else { if ($this->bInline) { $html .= $tmpl->execute('prettyPhoto2.tmpl.php'); } else { $html .= $tmpl->execute('prettyPhoto.tmpl.php'); } } } $result = array('content' => $html, 'num_images' => count($imageUrl)); //$wgMemc->set(wfMemcKey("gs_pp_" . $imageName . "_" . $revid), $result); return $result; }
function execute($par) { global $IP, $wgOut, $wgUser, $wgRequest; if ($wgUser->getID() == 0 || !($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()))) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } wfLoadExtensionMessages("Spellchecker"); $this->skipTool = new ToolSkip("spellchecker", "spellchecker", "sc_checkout", "sc_checkout_user", "sc_page"); $message = ""; if ($wgRequest->wasPosted()) { $articleUrl = $wgRequest->getVal('articleName'); $title = Title::newFromURL($articleUrl); if ($title && $title->getArticleID() > 0) { if ($this->addArticleToWhitelist($title)) { $message = $title->getText() . " was added to the article whitelist."; } else { $message = $articleUrl . " could not be added to the article whitelist."; } } else { $message = $articleUrl . " could not be added to the article whitelist."; } } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('message' => $message)); $wgOut->addHTML($tmpl->execute('ArticleWhitelist.tmpl.php')); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select("spellchecker", "sc_page", array("sc_exempt" => 1)); $wgOut->addHTML("<ol>"); while ($row = $dbr->fetchObject($res)) { $title = Title::newFromID($row->sc_page); if ($title) { $wgOut->addHTML("<li><a href='" . $title->getFullURL() . "'>" . $title->getText() . "</a></li>"); } } $wgOut->addHTML("</ol>"); $wgOut->setHTMLTitle(wfMsg('spch-articlewhitelist')); $wgOut->setPageTitle(wfMsg('spch-articlewhitelist')); }
function execute($par) { global $wgOut, $wgRequest, $wgParser; wfLoadExtensionMessages("MethodEditor"); $user = $this->getContext()->getUser(); if (!$user || $user->isBlocked()) { $wgOut->blockedPage(); return; } if (!$this->userAllowed($user)) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } $this->skipTool = new ToolSkip("methodeditor", MethodEditor::TABLE_NAME, "ama_checkout", "ama_checkout_user", "ama_page"); if ($wgRequest->getVal('allarticles')) { $wgOut->setArticleBodyOnly(true); $dbr = wfGetDB(DB_SLAVE); $date = date('Y-m-d'); header('Content-type: application/force-download'); header('Content-disposition: attachment; filename="methods_' . $date . '.xls"'); $res = $dbr->select(MethodEditor::TABLE_NAME, array('ama_page'), array('ama_patrolled' => '1'), __METHOD__, array('GROUP BY' => 'ama_page')); foreach ($res as $row) { $title = Title::newFromID($row->ama_page); if ($title) { echo $title->getFullURL() . "\n"; } } return; } if ($wgRequest->getVal('getNext')) { $wgOut->disable(); $result = $this->getNextMethod($wgRequest->getVal('aid')); echo json_encode($result); return; } else { if ($wgRequest->getVal('skipMethod')) { $wgOut->disable(); $articleId = $wgRequest->getVal('articleId'); $this->skipTool->skipItem($articleId); $this->skipTool->unUseItem($articleId); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('deleteMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $method = $wgRequest->getVal('method'); $this->deleteMethod($methodId, $articleId, $method); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('keepMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $altMethod = $wgRequest->getVal('method'); $altSteps = $wgRequest->getVal('steps'); $this->keepMethod($methodId, $articleId, $altMethod, $altSteps); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('quickEdit')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $this->quickEditRecord($methodId, $articleId); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('clearSkip')) { $wgOut->disable(); $this->skipTool->clearSkipCache(); echo "Skip cache has been cleared"; return; } } $wgOut->setPageTitle(wfMessage('methodeditor')->text()); $wgOut->addJScode('csjs'); $wgOut->addCSScode('methc'); $wgOut->addJScode('methj'); $wgOut->addJScode('jcookj'); $wgOut->addHTML(PopBox::getPopBoxJSAdvanced()); $groups = $user->getGroups(); $showList = in_array('staff', $groups) || in_array('staff_widget', $groups); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('showList' => $showList)); $wgOut->addHTML($tmpl->execute('MethodEditor.tmpl.php')); $this->displayLeaderboards(); $wgOut->addHTML(QuickNoteEdit::displayQuickEdit()); }
function showForm($id, $username, $email, $avatar, $error = '') { global $wgOut; $origname = $username; //make sure we have a good username //$username = $username !== null ? $username : $this->getProposedUsername($username); $username = $this->getProposedUsername($username); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('username' => $username, 'origname' => $origname, 'avatar' => $avatar, 'email' => $email, 'id' => $id, 'error' => $error)); $html = $tmpl->execute('gplusform.tmpl.php'); $wgOut->addHeadItem('gpluslogin_css', HtmlSnips::makeUrlTags('css', array('gpluslogin.css'), 'extensions/wikihow/GPlusLogin', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('gpluslogin.js'), 'extensions/wikihow/GPlusLogin', false)); $wgOut->addHtml($html); }
function execute($par) { global $wgOut, $wgUser, $wgRequest, $wgLang; $err = ""; $target = isset($par) ? $par : $wgRequest->getVal('target'); $restore = $wgRequest->getVal('restore', null); $sk = $wgUser->getSkin(); $wgOut->setHTMLTitle('Clear Ratings - Accuracy Patrol'); $type = $wgRequest->getVal('type', 'article'); $rateItem = new RateItem(); $ratingTool = $rateItem->getRatingTool($type); if ($ratingTool) { $t = $ratingTool->makeTitle($target); } if ($t == '') { $wgOut->addHTML(wfMsg('clearratings_notitle')); $this->addClearForm($target, $type, $err); return; } $me = SpecialPage::getTitleFor('Clearratings', $target); if ($wgUser->getID() == 0) { return; } if ($wgRequest->wasPosted()) { // clearing ratings $clearId = $wgRequest->getVal('clearId', null); if ($clearId != null) { $ratingTool->clearRatings($clearId, $wgUser); $wgOut->addHTML(wfMsg('clearratings_clear_finished') . "<br/><br/>"); } } if ($restore != null && $wgRequest->getVal('reason', null) == null) { //ask why the user wants to resotre $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('postUrl' => $me->getFullURL(), 'params' => $_GET)); $wgOut->addHTML($tmpl->execute('restore.tmpl.php')); return; } else { if ($restore != null) { $user = $wgRequest->getVal('user'); $page = $wgRequest->getVal('page'); $reason = $wgRequest->getVal('reason'); $u = User::newFromId($user); $up = $u->getUserPage(); $hi = $wgRequest->getVal('hi'); $low = $wgRequest->getVal('low'); $count = $ratingTool->getUnrestoredCount($page); $ratingTool->restore($page, $user, $hi, $low); $wgOut->addHTML("<br/><br/>" . wfMsg('clearratings_clear_restored', $sk->makeLinkObj($up, $u->getName()), $when) . "<br/><br/>"); // add the log entry $ratingTool->logRestore($page, $low, $hi, $reason, $count); } } if ($target != null && $type != null) { $id = $ratingTool->getId($t); if ($id === 0) { $err = wfMsg('clearratings_no_such_title', $target); } else { if ($type == "article" && $t->getNamespace() != NS_MAIN) { $err = wfMsg('clearratings_only_main', $target); } else { // clearing info $ratingTool->showClearingInfo($t, $id, $me, $target); $ap = Title::makeTitle(NS_SPECIAL, "AccuracyPatrol"); $wgOut->addHTML($sk->makeLinkObj($ap, "Return to accuracy patrol")); } } } $this->addClearForm($target, $type, $err); }
/** * Display the HTML for this special page */ public static function displayContainer($doc_name = '', $is_mobile) { global $wgServer, $wgUploadDirectory, $wgUser; $ads = ""; $ads2 = ""; $ads3 = ""; $sampleDocsURIbase = '/images/sampledocs'; $sampleDocsFileBase = $wgUploadDirectory . '/sampledocs'; if (!$doc_name) { $doc_name = self::getSampleFromUrl(); } if ($doc_name) { //grab data from the db $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('dv_sampledocs', '*', array('dvs_doc' => $doc_name), __METHOD__); //did we catch anything? if (!$res->fetchObject()) { return false; } $doc_array = array(); foreach ($res as $row) { $doc_hash = preg_replace('@^.*/([^/]+)$@', '$1', $row->dvs_doc_folder); $doc_uri_path = "{$sampleDocsURIbase}/{$doc_hash}"; $doc_file_path = "{$sampleDocsFileBase}/{$doc_hash}"; $full_path = $row->dvs_doc_folder . '/' . $row->dvs_doc . '.' . $row->dvs_doc_ext; $doc_array[$row->dvs_doc_ext] = $full_path; } //docx, xlsx, doc, xls...we're all cool here if ($doc_array['docx']) { $doc_array['doc'] = $doc_array['docx']; } if ($doc_array['xlsx']) { $doc_array['xls'] = $doc_array['xlsx']; } //what are we sending to gdoc? if ($doc_array['doc']) { $doc_array['gdoc'] = urlencode($wgServer . $doc_array['doc']); } elseif ($doc_array['xls']) { $doc_array['gdoc'] = urlencode($wgServer . $doc_array['xls']); } if (!$is_mobile && wikihowAds::isEligibleForAds()) { $ads = wikihowAds::getAdUnitPlaceholder("docviewer"); if (!self::showPdf($doc_name)) { $ads2 = wikihowAds::getAdunitPlaceholder("docviewer2a"); } $ads3 = wikihowAds::getAdUnitPlaceholder("docviewer3"); } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('doc_title' => self::getDisplayName($doc_name), 'header_get' => wfMsg('header_get'), 'header_found' => wfMsg('header_found'), 'header_related' => wfMsg('header_related'), 'show_staff_stats' => self::showStaffStats(), 'dv_download' => wfMsg('dv-download'), 'dv_found' => self::getFoundInArticles($doc_name, $is_mobile), 'dv_related' => self::getRelatedArticles($doc_name), 'dv_fallback_img' => self::getFallbackImg($doc_name), 'dv_ads' => $ads, 'dv_ads2' => $ads2, 'dv_ads3' => $ads3, 'dv_share_buttons' => WikihowShare::getTopShareButtons(), 'dv_sample_html' => self::getSampleHtml($doc_uri_path, $doc_file_path, $doc_name), 'dv_pdf_carrot' => self::$pdf_carrot, 'doc_name' => $doc_name, 'dv_open_in' => wfMsg('dv-open-in'), 'dv_dl_text_pdf' => wfMsg('dv-dl-text-pdf'), 'dv_dl_file_pdf' => $doc_array['pdf'], 'dv_display_pdf' => 'http://www.wikihow.com/Sample/' . str_replace($doc_array['pdf'], 'sampledocs', 'samplepdfs'), 'dv_dl_text_doc' => wfMsg('dv-dl-text-doc'), 'dv_dl_file_doc' => $doc_array['doc'], 'dv_dl_text_xls' => wfMsg('dv-dl-text-xls'), 'dv_dl_file_xls' => $doc_array['xls'], 'dv_dl_text_txt' => wfMsg('dv-dl-text-txt'), 'dv_dl_file_txt' => $doc_array['txt'], 'dv_dl_text_gdoc' => wfMsg('dv-dl-text-gdoc'), 'dv_dl_file_gdoc' => $doc_array['gdoc'])); if ($is_mobile) { $tmpl_name = 'docviewer_mobile.tmpl.php'; } else { $tmpl_name = 'docviewer.tmpl.php'; } $html = $tmpl->execute($tmpl_name); self::addWidgets($tmpl); } else { //no name passed in? return false; } //now shows via the wikiHowSkin on the page, so we don't need to ad it in //if ($ads) $html = wikihowAds::getSetup() . $html; return $html; }
/** * utility to create and execute a WH template */ public static function html($name, $vars = array()) { $tmpl = new EasyTemplate(); if (!empty($vars)) { $tmpl->set_vars($vars); } return $tmpl->execute($name); }
/** * Display the HTML for this special page with all the widgets in it */ private function displayContainer() { global $wgWidgetList, $wgUser, $wgWidgetShortCodes; $containerJS = array('community-dashboard.js', 'dashboard-widget.js', 'jquery.ui.sortable.min.js', 'jquery.json-2.2.min.js'); $containerCSS = array('community-dashboard.css'); $jsTags = $this->makeUrlTags('js', $containerJS); $cssTags = $this->makeUrlTags('css', $containerCSS); // get all commonly updating stats, to see the initial widget // displays with $this->refreshData = $this->dashboardData->getStatsData(); // get all data such as wikihow-defined structure goals, dynamic // global data, and user-specific data $staticData = $this->dashboardData->loadStaticGlobalOpts(); $priorities = json_decode($staticData['cdo_priorities_json'], true); if (!is_array($priorities)) { $priorities = array(); } $thresholds = json_decode($staticData['cdo_thresholds_json'], true); DashboardWidget::setThresholds($thresholds); $baselines = (array) json_decode($staticData['cdo_baselines_json']); DashboardWidget::setBaselines($baselines); DashboardWidget::setMaxUsernameLength(CommunityDashboard::USERNAME_MAX_LENGTH); // display the user-defined ordering of widgets inside an outside // container $userData = $this->dashboardData->loadUserData(); $prefs = !empty($userData['prefs']) ? $userData['prefs'] : array(); $userOrdering = isset($prefs['ordering']) ? $prefs['ordering'] : array(); $completion = !empty($userData['completion']) ? $userData['completion'] : array(); DashboardWidget::setCompletion($completion); // add any new widgets that have been added since the user last // customized foreach ($wgWidgetList as $name) { $found = false; foreach ($userOrdering as $arr) { if ($arr['wid'] == $name) { $found = true; break; } } if (!$found) { $userOrdering[] = array('wid' => $name, 'show' => 1); } } // create the user-defined ordering list, removing any community // priority widgets from the list so their not displayed twice $userWidgets = array(); foreach ($userOrdering as $arr) { $found = false; foreach ($priorities as $name) { if ($arr['wid'] == $name) { $found = true; break; } } if (!$found && $arr['show']) { $userWidgets[] = $arr['wid']; } } $func = array($this, 'displayWidgets'); $out = call_user_func($func, array('test')); $langKeys = array('howto', 'cd-pause-updates', 'cd-resume-updates', 'cd-current-priority', 'cd-network-error'); $langScript = Wikihow_i18n::genJSMsgs($langKeys); //TODO: Likely should move this somewhere else //but not sure where yet //load user specific info that only needs to be loaded //once if ($wgUser->getID() > 0) { $u = new User(); $u->setID($wgUser->getID()); $img = Avatar::getPicture($u->getName(), true); if ($img == '') { $img = Avatar::getDefaultPicture(); } $sk = $wgUser->getSkin(); $userName = $sk->makeLinkObj($u->getUserPage(), $u->getName()); $tipsLink = "/Special:TipsPatrol"; } else { $tipsLink = "/Special:Userlogin?returnto=Special:TipsPatrol"; } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('jsTags' => $jsTags, 'cssTags' => $cssTags, 'thresholds' => $staticData['cdo_thresholds_json'], 'GLOBAL_DATA_REFRESH_TIME_SECS' => self::GLOBAL_DATA_REFRESH_TIME_SECS, 'USER_DATA_REFRESH_TIME_SECS' => self::USER_DATA_REFRESH_TIME_SECS, 'USERNAME_MAX_LENGTH' => self::USERNAME_MAX_LENGTH, 'widgetTitles' => DashboardData::getTitles(), 'priorityWidgets' => $priorities, 'userWidgets' => $userWidgets, 'prefsOrdering' => $userOrdering, 'userCounts' => $userData['counts'], 'userImage' => $img, 'userName' => $userName, 'displayWidgetsFunc' => array($this, 'displayWidgets'), 'appShortCodes' => $wgWidgetShortCodes, 'tipsLink' => $tipsLink)); $html = $tmpl->execute('dashboard-container.tmpl.php'); return $langScript . $html; }
/** * * Returns the html for the confirmation dialog * after a user has edited an article * */ function confirmationModal($articleId) { $t = Title::newFromID($articleId); if ($t) { $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('titleUrl' => $t->getLocalURL(), 'title' => $t->getText())); $html = $tmpl->execute('NFDconfirmation.tmpl.php'); return $html; } }
function getUserWidgetData() { if (!class_exists('RCWidget')) { return ''; } $data = RCWidget::pullData($this->user->getID()); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('elements' => $data)); $html = $tmpl->execute('rcuserwidget.tmpl.php'); return $html; }
/** * Display the HTML for this special page */ public function displayContainer($quiz_name = '') { global $wgServer; $ads = ""; $ads2 = ""; $ads3 = ""; $ads_interstitial = ""; if (!$quiz_name) { $quiz_name = self::getQuizNameFromUrl(); } if ($quiz_name) { //load that blob of quiz data $quiz_blob = self::loadQuiz($quiz_name); //did we catch anything? if (!$quiz_blob) { return false; } $quiz_title = preg_replace('@-@', ' ', $quiz_name); // if(!$is_mobile && wikihowAds::isEligibleForAds()) { // $ads_interstitial = wikihowAds::getAdUnitInterstitial(false); // // $ads = wikihowAds::getAdUnitPlaceholder("docviewer"); // // $ads3 = wikihowAds::getAdUnitPlaceholder("docviewer3"); // } list($question, $answers, $progress) = self::formatQuiz($quiz_blob); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('quiz_title' => $quiz_title, 'quiz_progress' => $progress, 'quiz_question' => $question, 'quiz_answers' => $answers, 'quiz_name' => $quiz_name, 'full_quiz' => htmlspecialchars($quiz_blob), 'quiz_quips' => self::addQuips(), 'quiz_found' => self::getFoundInArticles($quiz_name), 'quiz_related' => self::getRelatedArticles($quiz_name), 'quiz_ads' => $ads, 'quiz_ads2' => $ads2, 'quiz_ads3' => $ads3, 'quiz_bg' => self::$quizBG, 'quiz_ads_interstitial' => $ads_interstitial)); $html = $tmpl->execute('quizzes.tmpl.php'); } else { //no name passed in? return false; } //now shows via the wikiHowSkin on the page, so we don't need to ad it in //if ($ads) $html = wikihowAds::getSetup() . $html; return $html; }
function getAdUnitInterstitial($show = true) { $slot = '6356699771'; $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('slot' => $slot)); $s = $tmpl->execute('wikiHowAdInterstitial.tmpl.php'); if (!$show) { $hideit_style = ' style="display: none;"'; } $s = "<div class='wh_ad wh_ad_interstitial'{$hideit_style}>{$s}</div>"; return $s; }
public static function showTopImage() { global $wgUser, $wgLanguageCode; $items = array(); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(WikihowHomepageAdmin::HP_TABLE, array('*'), array('hp_active' => 1), __METHOD__, array('ORDER BY' => 'hp_order')); $i = 0; foreach ($res as $result) { $item = new stdClass(); $title = Title::newFromID($result->hp_page); $item->url = $title->getLocalURL(); $item->text = $title->getText(); $imageTitle = Title::newFromID($result->hp_image); if ($imageTitle) { $file = wfFindFile($imageTitle->getText()); if ($file) { $item->imagePath = wfGetPad($file->getUrl()); $item->itemNum = ++$i; $items[] = $item; } } } if ($wgLanguageCode == 'en') { //using BOSS here only $searchTitle = Title::makeTitle(NS_SPECIAL, "LSearch"); $search = ' <form id="cse-search-hp" name="search_site" action="/wikiHowTo" method="get"> <input type="text" class="search_box" name="search" /> </form>'; } else { //PUNTING FOR NOW //INTL: International search just uses Google custom search $search = GoogSearch::getSearchBox("cse-search-hp"); } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('items' => $items, 'imagePath' => wfGetPad('/skins/owl/images/home1.jpg'), 'login' => $wgUser->getID() == 0 ? UserLoginBox::getLogin() : "", 'search' => $search)); $html = $tmpl->execute('top.tmpl.php'); echo $html; return true; }
function displayForm() { global $wgOut, $wgRequest; $articleName = ""; if ($this->errorTitle != "") { $articleName = $wgRequest->getVal('articleName'); } $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('errorTitle' => $this->errorTitle, 'errorFile' => $this->errorFile, 'articleName' => $articleName)); $html = $tmpl->execute('form.tmpl.php'); $wgOut->addHTML($html); }
/** * * This function takes an array of titles and finds other images * that are in those articles. */ function getConnectedImages($articles, $title) { global $wgOut, $wgUser, $wgMemc; wfLoadExtensionMessages('ImageHelper'); $exceptions = wfMsg('ih_exceptions'); $imageExceptions = split("\n", $exceptions); $sk = $wgUser->getSkin(); $result = $wgMemc->get(wfMemcKey("ImageHelper_getConnectedImages" . $imageName)); if ($result) { $wgOut->addHTML($result); return; } $imageName = $title->getDBkey(); if (in_array($imageName, $imageExceptions)) { $wgMemc->set(wfMemcKey("ImageHelper_getConnectedImages" . $imageName), ""); return; } $html = ''; $noImageArray = array(); foreach ($articles as $title) { $imageUrl = array(); $thumbUrl = array(); $imageTitle = array(); $imageWidth = array(); $imageHeight = array(); $results = ImageHelper::getImages($title->getArticleID()); $count = 0; if (count($results) <= 1) { $noImageArray[] = $title; continue; } $titleLink = $sk->makeKnownLinkObj($title, ""); $found = false; foreach ($results as $row) { if ($count >= 4) { break; } if ($row['il_to'] != $imageName && !in_array($row['il_to'], $imageExceptions)) { $image = Title::newFromText("Image:" . $row['il_to']); if ($image && $image->getArticleID() > 0) { $file = wfFindFile($image); if ($file && isset($file)) { $heightPreference = ImageHelper::heightPreference(127, 140, $file); $thumb = $file->getThumbnail(127, 140, true, true, $heightPreference); $imageUrl[] = $image->getFullURL(); $thumbUrl[] = $thumb->url; $imageTitle[] = $row['il_to']; $imageWidth[] = $thumb->getWidth(); $imageHeight[] = $thumb->getHeight(); $count++; $found = true; } } } } if ($count > 0) { $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('imageUrl' => $imageUrl, 'thumbUrl' => $thumbUrl, 'imageTitle' => $imageTitle, 'title' => $titleLink, 'numImages' => count($imageUrl), 'imageWidth' => $imageWidth, 'imageHeight' => $imageHeight, 'imgStrip' => false)); $html .= $tmpl->execute('connectedImages.tmpl.php'); } else { $noImageArray[] = $title; } } if (sizeof($noImageArray) > 0) { $html .= "<div class='minor_section'>\n\t\t\t\t\t\t<h2>" . wfMsg('ih_otherlinks') . "</h2><ul class='im-images'>"; foreach ($noImageArray as $title) { $link = $sk->makeKnownLinkObj($title, ""); $html .= "<li>{$link}</li>\n"; } $html .= "</ul></div>"; } $wgMemc->set(wfMemcKey("ImageHelper_getConnectedImages" . $imageName), $html); $wgOut->addHTML($html); }
/** * Execute special page. Only available to wikihow staff. */ public function execute() { global $wgUser, $wgRequest, $wgOut, $wgLang, $wgMemc; if (!$this->userAllowed()) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } if ($wgRequest->wasPosted()) { switch ($wgRequest->getVal('action')) { case 'nextUser': $this->nextUser(); break; case 'logMessage': $wgOut->disable(); $toId = $wgRequest->getVal('toId'); $revId = $wgRequest->getVal('revId'); $message = $wgRequest->getVal('message'); $this->logMessage($wgUser->getId(), $toId, $revId, $message); echo json_encode(array('stats' => $this->getStats())); break; case 'switchTab': $this->tabSwitch(); break; default: break; } return; } $target = $wgRequest->getVal('target'); if ($target) { $targetUser = User::newFromName($target); if ($targetUser->getId() > 0) { InterfaceElements::addJSVars($this->getOutputVariables($targetUser)); } } if (!$wgMemc->get($this->cacheOk)) { $this->resetCache(); } $wgOut->setPageTitle('Welcome Wagon'); $wgOut->setHTMLTitle('Welcome Wagon'); $tmpl = new EasyTemplate(dirname(__FILE__)); $wgOut->addHTML($tmpl->execute('WelcomeWagon.tmpl.php')); $wgOut->addCSScode('diffc'); $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('welcomewagon.css'), 'extensions/wikihow/WelcomeWagon', false)); $wgOut->addHTML(HtmlSnips::makeUrlTags('js', array('welcomewagon.js'), 'extensions/wikihow/WelcomeWagon', false)); InterfaceElements::addBubbleTipToElement('form-header', 'wwagon', 'No matter what happens keep the message positive and personalized.'); $this->displayLeaderboards(); }
static function getDisplayThumbData($data, $maxCount) { global $wgUser, $wgTitle; wfLoadExtensionMessages("ProfileBox"); $profileOwner = $wgUser->getId() != 0 && $wgUser->getName() == $wgTitle->getText(); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('data' => $data, 'max' => $maxCount, 'isOwner' => $profileOwner)); return $tmpl->execute('thumb.tmpl.php'); }
function execute($par) { global $wgOut, $wgRequest, $wgUser, $wgParser; wfLoadExtensionMessages("MethodEditor"); if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if (!($wgUser->isSysop() || in_array('newarticlepatrol', $wgUser->getRights()))) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext'); return; } $this->skipTool = new ToolSkip("methodeditor", MethodEditor::TABLE_NAME, "ama_checkout", "ama_checkout_user", "ama_id"); if ($wgRequest->getVal('getNext')) { $wgOut->disable(); $result = $this->getNextMethod(); echo json_encode($result); return; } else { if ($wgRequest->getVal('skipMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $this->skipTool->skipItem($methodId); $this->skipTool->unUseItem($methodId); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('deleteMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $method = $wgRequest->getVal('method'); $this->deleteMethod($methodId, $articleId, $method); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('keepMethod')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $altMethod = $wgRequest->getVal('method'); $altSteps = $wgRequest->getVal('steps'); $this->keepMethod($methodId, $articleId, $altMethod, $altSteps); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('quickEdit')) { $wgOut->disable(); $methodId = $wgRequest->getVal('methodId'); $articleId = $wgRequest->getVal('articleId'); $this->quickEditRecord($methodId, $articleId); $result = $this->getNextMethod(); echo json_encode($result); return; } elseif ($wgRequest->getVal('clearSkip')) { $wgOut->disable(); $this->skipTool->clearSkipCache(); echo "Skip cache has been cleared"; return; } } $wgOut->setHTMLTitle(wfMsg('methodeditor')); $wgOut->setPageTitle(wfMsg('methodeditor')); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('clientscript.js'), 'skins/common', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('css', array('methodeditor.css'), 'extensions/wikihow/altmethodadder', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('methodeditor.js'), 'extensions/wikihow/altmethodadder', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('jquery.cookie.js'), 'extensions/wikihow/common', false)); $wgOut->addHTML(PopBox::getPopBoxJSAdvanced()); $tmpl = new EasyTemplate(dirname(__FILE__)); $wgOut->addHTML($tmpl->execute('MethodEditor.tmpl.php')); $this->displayLeaderboards(); $wgOut->addHTML(QuickNoteEdit::displayQuickEdit()); }
/** * Display the admin settings form. */ private function showSettingsForm() { global $wgOut, $wgWidgetList; $opts = $this->dashboardData->loadStaticGlobalOpts(); $titles = DashboardData::getTitles(); $priorities = json_decode($opts['cdo_priorities_json'], true); if (!is_array($priorities)) { $priorities = array(); } $thresholds = json_decode($opts['cdo_thresholds_json'], true); $baselines = json_decode($opts['cdo_baselines_json'], true); $rwidgets = array_flip($wgWidgetList); $order = $priorities; foreach ($priorities as $widget) { unset($rwidgets[$widget]); } foreach ($rwidgets as $widget => $i) { $order[] = $widget; } $widgets = $this->dashboardData->getWidgets(); $current = array(); $dbr = wfGetDB(DB_SLAVE); foreach ($widgets as $widget) { $current[$widget->getName()] = $widget->getCount($dbr); } $wgOut->setHTMLTitle('Admin - Change Community Dashboard Settings - wikiHow'); $wgOut->addScript('<script src="/extensions/wikihow/dashboard/jquery.json-2.2.min.js"></script>'); $tmpl = new EasyTemplate(dirname(__FILE__)); $tmpl->set_vars(array('widgets' => $order, 'titles' => $titles, 'priorities' => array_flip($priorities), 'thresholds' => $thresholds, 'baselines' => $baselines, 'current' => $current)); $html = $tmpl->execute('admin-community-dashboard.tmpl.php'); $wgOut->addHTML($html); }