function fetchSidePanel($p = 'home', $numberItems = 3) { $this->setupLibraries(); if ($p == 'home' and defined('ADS_HOME_SIDEBAR')) { $code .= str_replace("{ad}", '<fb:iframe src="' . URL_CALLBACK . '?p=cache&m=ad&locale=homeSidebar" frameborder="0" scrolling="no" style="width:244px;height:70px;padding:0px;"/>', $this->common['adWrapSidebar']); } else { if (defined('ADS_ANY_SIDEBAR')) { $code .= str_replace("{ad}", '<fb:iframe src="' . URL_CALLBACK . '?p=cache&m=ad&locale=anySidebar" frameborder="0" scrolling="no" style="width:244px;height:70px;padding:0px;"/>', $this->common['adWrapSidebar']); } } // display widgets if ($p == 'home') { require_once PATH_CORE . '/classes/widgets.class.php'; $wt = new FeaturedWidgetsTable($this->db); $code .= $wt->lookupWidget('homeSidebar'); } // using session and page, it builds a side panel switch ($p) { case 'otherProfile': default: if (!defined('ENABLE_SIDE_WIRE')) { if ($this->session->isMember) { $code .= $this->fetchProfileSummaryPanelForHomePage($this->session->fbId, true, true); } else { $code .= $this->fetchTeamIntro(); } } break; case 'myProfile': // do nothing at top break; case 'team': if ($this->session->isMember) { $code .= $this->fetchProfileSummaryPanelForHomePage($this->session->fbId, true, true); } break; case 'appTab': $code .= $this->fetchProfileSummaryPanelForHomePage($this->session->fbId, false, false); $code .= $this->fetchTeamIntro(); break; } // to do: rotate through various cached panels // e.g. Team Leaders, Featured Challenges, Eligible Rewards, Team in Action if ($p == 'otherProfile' or $p == 'myProfile') { $cacheName = 'sideLeaders'; if ($this->templateObj->checkCache($cacheName, 30)) { // still current, get from cache $temp = $this->templateObj->fetchCache($cacheName); } else { $temp = $this->fetchLeaders('alltime', 'inside', 5); $temp .= $this->fetchLeaders('weekly', 'inside', 5); $this->templateObj->cacheContent($cacheName, $temp); } $code .= $temp; } else { /* * if ( is_callable(array($this, $panelOption[$x])) ) { call_user_func_array( array($this, 'page_' . $this->default_page), NULL ); */ // display local blogs if (defined('ENABLE_LOCAL')) { if ($this->session->isLoaded) { $cacheName = 'sideLocal_' . $this->session->userid; } else { $cacheName = 'sideLocal'; } if ($this->templateObj->checkCache($cacheName, 15)) { // still current, get from cache $temp = $this->templateObj->fetchCache($cacheName); } else { $temp = $this->fetchSideWire('local'); $this->templateObj->cacheContent($cacheName, $temp); } $code .= $temp; } // display newswire if (defined('ENABLE_SIDE_WIRE')) { $cacheName = 'sideWire'; if ($this->templateObj->checkCache($cacheName, 15)) { // still current, get from cache $temp = $this->templateObj->fetchCache($cacheName); } else { $temp = $this->fetchSideWire('wire'); $this->templateObj->cacheContent($cacheName, $temp); } $code .= $temp; } // to do: loop thru, pick a random number // pick a panel that hasn't been added to panelspicked before // add it based on the random number // continue until you have $numberItems of panels $panelOption = array(3 => 'fetchChallenges', 4 => 'fetchRewardsRandom', 1 => 'fetchPopularStories', 2 => 'fetchLeaders'); $panelCacheName = array(1 => 'sidePopular', 3 => 'sideChallenges', 4 => 'sideRewards', 2 => 'sideLeaders'); $panelsPicked = array(); $x = 1; while ($x < 5) { $cacheName = $panelCacheName[$x]; if ($x == 4 and $this->session->isMember) { $cacheName .= '_member'; } // for rewards panel with join button if ($this->templateObj->checkCache($cacheName, 30)) { // still current, get from cache $temp = $this->templateObj->fetchCache($cacheName); } else { $temp = call_user_func_array(array($this, $panelOption[$x]), NULL); $this->templateObj->cacheContent($cacheName, $temp); } // only display rewards for anonymous viewer or team viewer, x=4 is a hack for array placement in panelCacheName if (!($x == 4 and (!$this->session->isLoaded or $this->session->u->eligibility != 'team'))) { $code .= $temp; } $x += 1; } } return $code; }