Ejemplo n.º 1
0
 function displayBox($u, $displayAsArticle = true)
 {
     wfLoadExtensionMessages('ProfileBox');
     $display = "";
     $t = Title::newFromText($u->getUserPage() . '/profilebox-aboutme');
     if ($t->getArticleId() > 0) {
         $r = Revision::newFromTitle($t);
         $aboutme = $r->getText();
         $aboutme = strip_tags($aboutme, '<p><br><b><i>');
         $aboutme = preg_replace('/\\\\r\\\\n/s', "\n", $aboutme);
         $aboutme = stripslashes($aboutme);
     }
     if ($u->getOption('profilebox_stats') == 1) {
         $checkStats = 'true';
     } else {
         $checkStats = 'false';
     }
     if ($u->getOption('profilebox_startedEdited') == 1) {
         $checkStartedEdited = 'true';
     } else {
         $checkStartedEdited = 'false';
     }
     if ($u->getOption('profilebox_favs') == 1) {
         $checkFavs = 'true';
     } else {
         $checkFavs = 'false';
     }
     $profilebox_name = wfMsg('profilebox-name');
     $profilebox_contributions = wfMsg('profilebox-contributions');
     $profilebox_edited_more = wfMsg('profilebox-edited-more');
     $display .= "\n<script language='javascript' src='" . wfGetPad('/extensions/wikihow/profilebox/profilebox.js?') . WH_SITEREV . "'></script>\n<link rel='stylesheet' media='all' href='" . wfGetPad('/extensions/wikihow/profilebox/profilebox.css?') . WH_SITEREV . "' type='text/css' />\n\n<script language='javascript'>\n\tvar profilebox_username = '******';\n\tvar profilebox_name = '{$profilebox_name}';\n\tvar msg_contributions = '{$profilebox_contributions}';\n\tvar msg_edited_more = '{$profilebox_edited_more}';\n\tvar pbstats_check = {$checkStats};\n\tvar pbstartededited_check = {$checkStartedEdited};\n\tvar pbfavs_check = false;\n</script>\n";
     $display .= "<div id='profileBoxID'>\n";
     if ($displayAsArticle) {
         $display .= "<div class='article_inner'>";
     }
     if ($aboutme != '') {
         $display .= "<p id='pb-aboutme'><strong>About me. </strong>" . $aboutme . "</p>\n";
     }
     if ($checkStats == 'true' || $checkStartedEdited == 'true') {
         $stats = self::fetchStats("User:"******"<div class='clearall'></div>";
         $display .= "</div><!--end article_inner-->";
     }
     if ($checkStartedEdited == 'true') {
         $data = self::fetchCreatedData(mysql_real_escape_string("User:"******"\n\t\t\t\t<table class='pb-articles' id='pb-created' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t<thead><tr>\n\t\t\t\t\t\t<th class='first pb-title'><strong>" . wfMsg('pb-articlesstarted') . "</strong> (" . $stats['created'] . ")</th>\n\t\t\t\t\t\t<th class='middle pb-star'>Rising Stars</th>\n\t\t\t\t\t\t<th class='middle pb-feature'>Featured</th>\n\t\t\t\t\t\t<th class='last pb-view'>Views</th></tr></thead>";
         $display .= "<tbody>" . $createdHtml . "</tbody>";
         $display .= "<tfoot>";
         if ($hasMoreCreated) {
             $display .= "<tr><td class='pb-title'><a href='#' id='created_more' onclick='pbShow_articlesCreated(\"more\"); return false;'>View more &raquo;</a><a href='#' id='created_less' style='display:none;' onClick='pbShow_articlesCreated(); return false;'>&laquo; View Less</a></td><td colspan='3' class='pb-view'>&nbsp;</td></tr>";
         }
         $display .= "</tfoot>";
         $display .= "</table>";
         if (class_exists('ThumbsUp')) {
             $dataThumbs = self::fetchThumbsData(mysql_real_escape_string("User:"******"\n\t\t\t\t\t<table class='pb-articles' id='pb-thumbed' cellspacing='0' cellpadding='0'>\n\t\t\t\t\t\t<thead><tr>\n\t\t\t\t\t\t\t<th class='first pb-title'><strong>Thumbed Up Edits</strong></th>\n\t\t\t\t\t\t\t<!--<th class='middle pb-feature'>My Edit</th>\n\t\t\t\t\t\t\t<th class='last pb-view'>Thumbs</th>-->\n\t\t\t\t\t\t\t<th class='last pb-view'>Date</th>\n\t\t\t\t\t\t</tr></thead>";
             $display .= "<tbody>" . $thumbsHtml . "</tbody>";
             $display .= "<tfoot>";
             if ($hasMoreThumbs) {
                 $display .= "<tr><td class='pb-title'><a href='#' id='thumbed_more' onclick='pbShow_Thumbed(\"more\"); return false;'>View more &raquo;</a><a href='#' id='thumbed_less' style='display:none;' onClick='pbShow_Thumbed(); return false;'>&laquo; View Less</a></td><td colspan='1' class='pb-view'>&nbsp;</td></tr>";
             }
             $display .= "</tfoot>";
             $display .= "</table>";
         }
     }
     /*
     		if ($u->getOption('profilebox_favs') == 1) {
     			$display .= "
     <div id='pbFavs' class='profileBox'>
     <strong>Favorite Articles:</strong><br />
     <div id='pbFavsContent'></div>
     </div>";
     		}
     */
     $display .= "\n<div id='pbTalkpage' style='float:right; padding-top:10px; margin-right:27px; padding-bottom:10px;'><a href='/" . $u->getTalkPage() . "'>Go to My Talk Page &raquo;</a></div>\n<div style='clear:both'></div>\n\n<script language='javascript'>\nif (typeof jQuery == 'undefined') {\n\tEvent.observe(window, 'load', pbInit);\n} else {\n\tjQuery(window).load(pbInit);\n}\n</script>\n\n</div>\n\n\t\t";
     return $display;
 }
Ejemplo n.º 2
0
 function view($u = null)
 {
     global $wgOut, $wgTitle, $wgUser, $wgRequest;
     $diff = $wgRequest->getVal('diff');
     $rcid = $wgRequest->getVal('rcid');
     $this->user = $u ? $u : User::newFromName($wgTitle->getDBKey());
     if (!$u && $this->mTitle->getNamespace() != NS_USER || !$this->user || isset($diff) || isset($rcid)) {
         return Article::view();
     }
     if ($this->user->getID() == 0) {
         header('HTTP/1.1 404 Not Found');
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchuser', 'Noarticletext_user');
         return;
     }
     $this->isPageOwner = $wgUser->getID() == $this->user->getID();
     if ($this->user->isBlocked() && $this->isPageOwner) {
         $wgOut->blockedPage();
         return;
     }
     $wgOut->setRobotpolicy('index,follow');
     $skin = $wgUser->getSkin();
     //user settings
     $checkStats = $this->user->getOption('profilebox_stats') == 1;
     $checkStartedEdited = $this->user->getOption('profilebox_startedEdited') == 1;
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('profilebox.js'), '/extensions/wikihow/profilebox/', false));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('profilebox.css'), '/extensions/wikihow/profilebox/', false));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('rcwidget.css'), '/extensions/wikihow/rcwidget/', false));
     $profileStats = new ProfileStats($this->user);
     $badgeData = $profileStats->getBadges();
     $wgOut->addHTML(ProfileBox::getDisplayBadge($badgeData));
     if (!$u) {
         $skin->addWidget($this->getRCUserWidget());
     }
     if ($checkStats || $checkStartedEdited) {
         $createdData = $profileStats->getArticlesCreated(0);
     }
     //stats
     if ($checkStats) {
         $stats = ProfileBox::fetchStats("User:"******"<div class='clearall'></div>");
     }
 }