/** * 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; }