protected function generateContent() { /***********/ /* Infobox */ /***********/ $infobox = $contrib = $groups = []; foreach (Lang::account('groups') as $idx => $key) { if ($idx >= 0 && $this->user['userGroups'] & 1 << $idx) { $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null) . Lang::account('groups', $idx); } } $infobox[] = Lang::user('joinDate') . Lang::main('colon') . '[tooltip name=joinDate]' . date('l, G:i:s', $this->user['joinDate']) . '[/tooltip][span class=tip tooltip=joinDate]' . date(Lang::main('dateFmtShort'), $this->user['joinDate']) . '[/span]'; $infobox[] = Lang::user('lastLogin') . Lang::main('colon') . '[tooltip name=lastLogin]' . date('l, G:i:s', $this->user['prevLogin']) . '[/tooltip][span class=tip tooltip=lastLogin]' . date(Lang::main('dateFmtShort'), $this->user['prevLogin']) . '[/span]'; $infobox[] = Lang::user('userGroups') . Lang::main('colon') . ($groups ? implode(', ', $groups) : Lang::account('groups', -1)); $infobox[] = Lang::user('consecVisits') . Lang::main('colon') . $this->user['consecutiveVisits']; $infobox[] = Util::ucFirst(Lang::main('siteRep')) . Lang::main('colon') . Lang::nf($this->user['sumRep']); // contrib -> [url=http://www.wowhead.com/client]Data uploads: n [small]([tooltip=tooltip_totaldatauploads]xx.y MB[/tooltip])[/small][/url] $co = DB::Aowow()->selectRow('SELECT COUNT(DISTINCT c.id) AS sum, SUM(IFNULL(cr.value, 0)) AS nRates FROM ?_comments c LEFT JOIN ?_comments_rates cr ON cr.commentId = c.id AND cr.userId <> 0 WHERE c.replyTo = 0 AND c.userId = ?d', $this->user['id']); if ($co['sum']) { $contrib[] = Lang::user('comments') . Lang::main('colon') . $co['sum'] . ($co['nRates'] ? ' [small]([tooltip=tooltip_totalratings]' . $co['nRates'] . '[/tooltip])[/small]' : null); } $ss = DB::Aowow()->selectRow('SELECT COUNT(*) AS sum, SUM(IF(status & ?d, 1, 0)) AS nSticky, SUM(IF(status & ?d, 0, 1)) AS nPending FROM ?_screenshots WHERE userIdOwner = ?d AND (status & ?d) = 0', CC_FLAG_STICKY, CC_FLAG_APPROVED, $this->user['id'], CC_FLAG_DELETED); if ($ss['sum']) { $buff = []; if ($ss['nSticky'] || $ss['nPending']) { if ($normal = $ss['sum'] - $ss['nSticky'] - $ss['nPending']) { $buff[] = '[tooltip=tooltip_normal]' . $normal . '[/tooltip]'; } if ($ss['nSticky']) { $buff[] = '[tooltip=tooltip_sticky]' . $ss['nSticky'] . '[/tooltip]'; } if ($ss['nPending']) { $buff[] = '[tooltip=tooltip_pending]' . $ss['nPending'] . '[/tooltip]'; } } $contrib[] = Lang::user('screenshots') . Lang::main('colon') . $ss['sum'] . ($buff ? ' [small](' . implode($buff, ' + ') . ')[/small]' : null); } $vi = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) AS nSticky, SUM(IF(status & ?d, 0, 1)) AS nPending FROM ?_videos WHERE userIdOwner = ?d AND (status & ?d) = 0', CC_FLAG_STICKY, CC_FLAG_APPROVED, $this->user['id'], CC_FLAG_DELETED); if ($vi['sum']) { $buff = []; if ($vi['nSticky'] || $vi['nPending']) { if ($normal = $vi['sum'] - $vi['nSticky'] - $vi['nPending']) { $buff[] = '[tooltip=tooltip_normal]' . $normal . '[/tooltip]'; } if ($vi['nSticky']) { $buff[] = '[tooltip=tooltip_sticky]' . $vi['nSticky'] . '[/tooltip]'; } if ($vi['nPending']) { $buff[] = '[tooltip=tooltip_pending]' . $vi['nPending'] . '[/tooltip]'; } } $contrib[] = Lang::user('videos') . Lang::main('colon') . $vi['sum'] . ($buff ? ' [small](' . implode($buff, ' + ') . ')[/small]' : null); } // contrib -> Forum posts: 5769 [small]([tooltip=topics]579[/tooltip] + [tooltip=replies]5190[/tooltip])[/small] $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]'; if ($contrib) { $this->contributions = '[ul][li]' . implode('[/li][li]', $contrib) . '[/li][/ul]'; } /****************/ /* Main Content */ /****************/ $this->name = $this->user['title'] ? $this->user['displayName'] . ' <' . $this->user['title'] . '>' : sprintf(Lang::user('profileTitle'), $this->user['displayName']); /**************/ /* Extra Tabs */ /**************/ $this->lvTabs = []; $this->forceTabs = true; // [unused] Site Achievements // Reputation changelog (params only for comment-events) if ($repData = DB::Aowow()->select('SELECT action, amount, date AS \'when\', IF(action IN (3, 4, 5), sourceA, 0) AS param FROM ?_account_reputation WHERE userId = ?d', $this->user['id'])) { foreach ($repData as &$r) { $r['when'] = date(Util::$dateFormatInternal, $r['when']); } $this->lvTabs[] = ['reputationhistory', ['data' => $repData]]; } // Comments if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => false], $nFound)) { $tabData = array('data' => $_, 'hiddenCols' => ['author'], 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $tabData['name'] = '$LANG.tab_latestcomments'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, ' . $nFound . ')'; } $this->lvTabs[] = ['commentpreview', $tabData]; } // Comment Replies if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => true], $nFound)) { $tabData = array('data' => $_, 'hiddenCols' => ['author'], 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $tabData['name'] = '$LANG.tab_latestreplies'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, ' . $nFound . ')'; } $this->lvTabs[] = ['replypreview', $tabData]; } // Screenshots if ($_ = CommunityContent::getScreenshots(-$this->user['id'], 0, $nFound)) { $tabData = array('data' => $_, '_totalCount' => $nFound); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $tabData['name'] = '$LANG.tab_latestscreenshots'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, ' . $nFound . ')'; } $this->lvTabs[] = ['screenshot', $tabData]; } // Videos if ($_ = CommunityContent::getVideos(-$this->user['id'], 0, $nFound)) { $tabData = array('data' => $_, '_totalCount' => $nFound); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $tabData['name'] = '$LANG.tab_latestvideos'; $tabData['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, ' . $nFound . ')'; } $this->lvTabs[] = ['video', $tabData]; } // forum -> latest topics [unused] // forum -> latest replies [unused] // Characters [todo] $this->user['characterData'] = []; /* us_addCharactersTab([ { id:763, "name":"Lilywhite", "achievementpoints":"0", "guild":"whatever", "guildrank":"0", "realm":"draenor", "realmname":"Draenor", "battlegroup":"cyclone", "battlegroupname":"Cyclone", "region":"us", "level":"10", "race":"7", "gender":"0", "classs":"1", "faction":"0", "gearscore":"0", "talenttree1":"0", "talenttree2":"0", "talenttree3":"0", "talentspec":0, "published":1, "pinned":0 } ]); */ // Profiles [todo] $this->user['profileData'] = []; }
protected function generateContent() { /****************/ /* Main Content */ /****************/ if (in_array(array_search($this->page, $this->validPages), [0, 1, 2, 3, 11, 12])) { $this->h1Links = '<small><a href="?' . $this->page . ($this->category ? '=' . $this->category[0] : null) . '&rss" class="icon-rss">' . Lang::main('subscribe') . '</a></small>'; } switch ($this->page) { case 'random': $type = array_rand(array_filter(Util::$typeClasses)); $typeId = (new Util::$typeClasses[$type](null))->getRandomId(); header('Location: ?' . Util::$typeStrings[$type] . '=' . $typeId, true, 302); die; case 'latest-comments': // rss $data = CommunityContent::getCommentPreviews(); if ($this->rss) { foreach ($data as $d) { // todo (low): preview should be html-formated $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($d['subject'])], 'link' => [false, [], HOST_URL . '/?go-to-comment&id=' . $d['id']], 'description' => [true, [], htmlentities($d['preview']) . "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true))], 'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])], 'guid' => [false, [], HOST_URL . '/?go-to-comment&id=' . $d['id']]); } } else { $this->lvTabs[] = ['commentpreview', ['data' => $data]]; } break; case 'latest-screenshots': // rss $data = CommunityContent::getScreenshots(); if ($this->rss) { foreach ($data as $d) { $desc = '<a href="' . HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id'] . '"><img src="' . STATIC_URL . '/uploads/screenshots/thumb/' . $d['id'] . '.jpg" alt="" /></a>'; if ($d['caption']) { $desc .= '<br />' . $d['caption']; } $desc .= "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true)); // enclosure/length => filesize('static/uploads/screenshots/thumb/'.$d['id'].'.jpg') .. always set to this placeholder value though $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($d['subject'])], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])], 'enclosure' => [false, ['url' => STATIC_URL . '/uploads/screenshots/thumb/' . $d['id'] . '.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], 'guid' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#screenshots:id=' . $d['id']]); } } else { $this->lvTabs[] = ['screenshot', ['data' => $data]]; } break; case 'latest-videos': // rss $data = CommunityContent::getVideos(); if ($this->rss) { foreach ($data as $d) { $desc = '<a href="' . HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id'] . '"><img src="//i3.ytimg.com/vi/' . $d['videoId'] . '/default.jpg" alt="" /></a>'; if ($d['caption']) { $desc .= '<br />' . $d['caption']; } $desc .= "<br /><br />" . sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true)); // is enclosure/length .. is this even relevant..? $this->feedData[] = array('title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])) . Lang::main('colon') . htmlentities($row['subject'])], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id']], 'description' => [true, [], $desc], 'pubDate' => [false, [], date(DATE_RSS, time() - $row['elapsed'])], 'enclosure' => [false, ['url' => '//i3.ytimg.com/vi/' . $d['videoId'] . '/default.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null], 'guid' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$d['type']] . '=' . $d['typeId'] . '#videos:id=' . $d['id']]); } } else { $this->lvTabs[] = ['video', ['data' => $data]]; } break; case 'latest-articles': // rss $this->lvTabs = []; break; case 'latest-additions': // rss $extraText = ''; break; case 'unrated-comments': $this->lvTabs[] = ['commentpreview', ['data' => []]]; break; case 'missing-screenshots': // limit to 200 entries each (it generates faster, consumes less memory and should be enough options) $cnd = [[['cuFlags', CUSTOM_HAS_SCREENSHOT, '&'], 0], 200]; if (!User::isInGroup(U_GROUP_EMPLOYEE)) { $cnd[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; } foreach (Util::$typeClasses as $classStr) { if (!$classStr) { continue; } $typeObj = new $classStr($cnd); if (!$typeObj->error) { $this->extendGlobalData($typeObj->getJSGlobals(GLOBALINFO_ANY)); $this->lvTabs[] = [$typeObj::$brickFile, ['data' => array_values($typeObj->getListviewData())]]; } } break; case 'most-comments': // rss if ($this->category && !in_array($this->category[0], [1, 7, 30])) { header('Location: ?most-comments=1' . ($this->rss ? '&rss' : null), true, 302); } $tabBase = array('extraCols' => ["\$Listview.funcBox.createSimpleCol('ncomments', 'tab_comments', '10%', 'ncomments')"], 'sort' => ['-ncomments']); foreach (Util::$typeClasses as $type => $classStr) { if (!$classStr) { continue; } $comments = DB::Aowow()->selectCol(' SELECT `typeId` AS ARRAY_KEY, count(1) FROM ?_comments WHERE `replyTo` = 0 AND (`flags` & ?d) = 0 AND `type`= ?d AND `date` > (UNIX_TIMESTAMP() - ?d) GROUP BY `type`, `typeId` LIMIT 100', CC_FLAG_DELETED, $type, (isset($this->category[0]) ? $this->category[0] : 1) * DAY); if (!$comments) { continue; } $typeClass = new $classStr(array(['id', array_keys($comments)])); if (!$typeClass->error) { $data = $typeClass->getListviewData(); if ($this->rss) { foreach ($data as $typeId => &$d) { $this->feedData[] = array('title' => [true, [], htmlentities(Util::$typeStrings[$type] == 'item' ? mb_substr($d['name'], 1) : $d['name'])], 'type' => [false, [], Util::$typeStrings[$type]], 'link' => [false, [], HOST_URL . '/?' . Util::$typeStrings[$type] . '=' . $d['id']], 'ncomments' => [false, [], $comments[$typeId]]); } } else { foreach ($data as $typeId => &$d) { $d['ncomments'] = $comments[$typeId]; } $this->extendGlobalData($typeClass->getJSGlobals(GLOBALINFO_ANY)); $this->lvTabs[] = [$typeClass::$brickFile, array_merge($tabBase, ['data' => array_values($data)])]; } } } break; } // found nothing => set empty content // tpl: commentpreview - anything, doesn't matter what if (!$this->lvTabs && !$this->rss) { $this->lvTabs[] = ['commentpreview', ['data' => []]]; } }
protected function generateContent() { /***********/ /* Infobox */ /***********/ $infobox = $contrib = $groups = []; foreach (Lang::account('groups') as $idx => $key) { if ($idx >= 0 && $this->user['userGroups'] & 1 << $idx) { $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null) . Lang::account('groups', $idx); } } $infobox[] = Lang::user('joinDate') . Lang::main('colon') . '[tooltip name=joinDate]' . date('l, G:i:s', $this->user['joinDate']) . '[/tooltip][span class=tip tooltip=joinDate]' . date(Lang::main('dateFmtShort'), $this->user['joinDate']) . '[/span]'; $infobox[] = Lang::user('lastLogin') . Lang::main('colon') . '[tooltip name=lastLogin]' . date('l, G:i:s', $this->user['prevLogin']) . '[/tooltip][span class=tip tooltip=lastLogin]' . date(Lang::main('dateFmtShort'), $this->user['prevLogin']) . '[/span]'; $infobox[] = Lang::user('userGroups') . Lang::main('colon') . ($groups ? implode(', ', $groups) : Lang::account('groups', -1)); $infobox[] = Lang::user('consecVisits') . Lang::main('colon') . $this->user['consecutiveVisits']; $infobox[] = Util::ucFirst(Lang::main('siteRep')) . Lang::main('colon') . number_format($this->user['sumRep']); // contrib -> [url=http://www.wowhead.com/client]Data uploads: n [small]([tooltip=tooltip_totaldatauploads]xx.y MB[/tooltip])[/small][/url] $co = DB::Aowow()->selectRow('SELECT COUNT(DISTINCT c.id) AS sum, COUNT(cr.commentId) AS nRates FROM ?_comments c LEFT JOIN ?_comments_rates cr ON cr.commentId = c.id WHERE c.replyTo = 0 AND c.userId = ?d', $this->user['id']); if ($co['sum']) { $contrib[] = Lang::user('comments') . Lang::main('colon') . $co['sum'] . ' [small]([tooltip=tooltip_totalratings]' . $co['nRates'] . '[/tooltip])[/small]'; } $ss = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) as nSticky FROM ?_screenshots WHERE userIdOwner = ?d AND status & ?d AND (status & ?d) = 0', CC_FLAG_STICKY, $this->user['id'], CC_FLAG_APPROVED, CC_FLAG_DELETED); if ($ss['sum']) { $contrib[] = Lang::user('screenshots') . Lang::main('colon') . $ss['sum'] . ' [small]([tooltip=tooltip_normal]' . ($ss['sum'] - $ss['nSticky']) . '[/tooltip] + [tooltip=tooltip_sticky]' . $ss['nSticky'] . '[/tooltip])[/small]'; } $vi = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) as nSticky FROM ?_videos WHERE userIdOwner = ?d AND status & ?d AND (status & ?d) = 0', CC_FLAG_STICKY, $this->user['id'], CC_FLAG_APPROVED, CC_FLAG_DELETED); if ($vi['sum']) { $contrib[] = Lang::user('videos') . Lang::main('colon') . $vi['sum'] . ' [small]([tooltip=tooltip_normal]' . ($vi['sum'] - $vi['nSticky']) . '[/tooltip] + [tooltip=tooltip_sticky]' . $vi['nSticky'] . '[/tooltip])[/small]'; } // contrib -> Forum posts: 5769 [small]([tooltip=topics]579[/tooltip] + [tooltip=replies]5190[/tooltip])[/small] $this->infobox = '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]'; if ($contrib) { $this->contributions = '[ul][li]' . implode('[/li][li]', $contrib) . '[/li][/ul]'; } /****************/ /* Main Content */ /****************/ $this->name = $this->user['title'] ? $this->user['displayName'] . ' <' . $this->user['title'] . '>' : sprintf(Lang::user('profileTitle'), $this->user['displayName']); /**************/ /* Extra Tabs */ /**************/ $this->lvTabs = []; $this->forceTabs = true; // [unused] Site Achievements // Reputation changelog (params only for comment-events) if ($repData = DB::Aowow()->select('SELECT action, amount, date AS \'when\', IF(action IN (3, 4, 5), sourceA, 0) AS param FROM ?_account_reputation WHERE userId = ?d', $this->user['id'])) { foreach ($repData as &$r) { $r['when'] = date(Util::$dateFormatInternal, $r['when']); } $this->lvTabs[] = array('file' => 'reputationhistory', 'data' => $repData, 'params' => []); } // Comments if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => false], $nFound)) { $lvData = array('file' => 'commentpreview', 'data' => $_, 'params' => array('hiddenCols' => "\$['author']", 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound)); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $lvData['params']['name'] = '$LANG.tab_latestcomments'; $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, ' . $nFound . ')'; } $this->lvTabs[] = $lvData; } // Comment Replies if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => true], $nFound)) { $lvData = array('file' => 'replypreview', 'data' => $_, 'params' => array('hiddenCols' => "\$['author']", 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', '_totalCount' => $nFound)); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $lvData['params']['name'] = '$LANG.tab_latestreplies'; $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, ' . $nFound . ')'; } $this->lvTabs[] = $lvData; } // Screenshots if ($_ = CommunityContent::getScreenshots(-$this->user['id'], 0, $nFound)) { $lvData = array('file' => 'screenshot', 'data' => $_, 'params' => array('_totalCount' => $nFound)); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $lvData['params']['name'] = '$LANG.tab_latestscreenshots'; $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, ' . $nFound . ')'; } $this->lvTabs[] = $lvData; } // Videos if ($_ = CommunityContent::getVideos(-$this->user['id'], 0, $nFound)) { $lvData = array('file' => 'video', 'data' => $_, 'params' => array('_totalCount' => $nFound)); if ($nFound > CFG_SQL_LIMIT_DEFAULT) { $lvData['params']['name'] = '$LANG.tab_latestvideos'; $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, ' . $nFound . ')'; } $this->lvTabs[] = $lvData; } // forum -> latest topics [unused] // forum -> latest replies [unused] // Characters [todo] $this->user['characterData'] = []; // Profiles [todo] $this->user['profileData'] = []; }