feedTitles for RSS feeds. private $veryTopCode; // code that will be outputted to the very top of the page (above the logo & nav options) inside the wrapper. private $columns; // an array of all of the columns main portion of the page private $useDefaultColumns;// if false, then the normal Pedlr-style columns will be used (with widths based on percentages). If true, the static-width default colset is used. private $tabs; // an array of the tabs to be displayed about the main page content private $leftTextTabs; // array of left aligned text only tabs private $rightTextTabs; // array of right aligned text only tabs private $headMessages; // html code that should appear at the top of the content below the menu/tabs. private $headCallbacks; // functions to call inside the tag. private $toolTips; // array of tool-tip bubbles. private $cacheKey; private $cacheResults; private $minAge; // the minumum age that the user should be in order to see the main content of the page. This can be rolled into the authentication later, but for now is just used to know if we should serve AdSense. private $codePath; // for setting a path to which all styles and js sit in... primarily used for setting different domain names (ie: LyricWiki uses "http://pedlr.com"). private $logoURL; // for overloading only (used by LyricWiki). private $logoLink; private $logoTitle; private $extraHeadStart; private $extraHeadEnd; // Extra-Head info is extra text to be printed out in the header tags. 'Start goes at the very top and 'End goes at the very end of the tag contents. private $useModules; // if true, then the module css will be included & passed the color string private $colors; private $bgImage; private $bgImageSettings; public function Page($title='', $columnWidths = array( 100 ), $mainBgColor = 'ffffff'){ profiler_beginSection(__METHOD__); $this->colors = array(); $this->title = $title; $this->metaDescription = ""; $this->metaKeywords = ""; $this->styles = array(); $this->scripts = array(); $this->rssFeeds = array(); $this->veryTopCode = ""; $this->tabs = array(); $this->leftTextTabs = array(); $this->rightTextTabs = array(); $this->colors['bgcolor'] = '000000'; // background of the page, to the sides, behind the tabs, etc. $this->colors['mainbg'] = $mainBgColor; // backround of the area where the main content will go (as opposed to bg of the page). $this->minAge = -1; // by default, pages have no age restriction $this->bgImage = ""; $this->bgImageSettings = 3; $this->headMessages = ""; $this->toolTips = array(); $this->addScript("jquery/jquery.js"); $this->addScript("doItLater.js" ); //$this->addScript("feedbackTools.js" ); // TODO: Decide whether to use FeedbackTools, then either port it or delete the whole thing (there is a .css include and an include_once in this file also). $user = getUser(); if($user->isLoggedIn()){ sendQuery("UPDATE userStats SET pageViews=pageViews+1 WHERE user_id=".$user->getId()); } $this->cacheKey = ""; $this->cacheResults = false; $this->codePath = getCodePath(); $this->logoURL = ""; $this->logoLink = ""; $this->logoTitle = ""; $this->extraHeadStart = $this->extraHeadEnd = ""; $this->headCallbacks = array(); $this->addRSS("rss.php", "doItLater Recent Updates"); // Set up the default menu tabs. NON-PORTABLE: This should be moved out to some config file or something. $user = getUser(); if($user->isLoggedIn()){ $this->addTab("Home", "home.php"); } $this->addTab("Pictures", "pictures.php"); $this->addTab("Videos", "movies.php"); $this->addTab("Games", "games.php"); $this->addTab("Flash", "flash.php"); $this->addTab("Recent", "recent.php"); //$this->addTab("About", "about.php"); // TODO: IMPLEMENT THE PAGE AND UNCOMMENT THIS LINE $this->addTab("Upload", "submit.php"); // Use the default 3-column (static-width columns) layout unless overridden. $this->columns = array(new Column(25), new Column(55), new Column(20)); // the default three-column layout - NOTE: The widths aren't actually used in this special case. See note at top of file. $this->useDefaultColumns = true; if(count($columnWidths) > 1){ $this->setColumns($columnWidths); } profiler_endSection(__METHOD__); } public function getTitle(){ return $this->title; } public function setTitle($title){$this->title = $title;} public function setMetaTags($metaDescription, $metaKeywords){ $this->metaDescription = $metaDescription; $this->metaKeywords = $metaKeywords; } public function getMinAge(){return $this->minAge;} public function setMinAge($min){$this->minAge = $min;} public function getColor( $colorName ){ return getVal($this->colors, $colorName);} public function setColor( $colorName, $color ){ return $this->colors[$colorName] = $color; } public function getBgColor(){ return $this->getColor("bgColor"); } public function setBgColor($color){ $this->setColor( "bgColor", $color ); } public function setColors( $colors ){ $this->colors = $colors; } public function getBgImage(){ return $this->bgImage; } public function setBgImage( $bgImage ){ $this->bgImage = $bgImage; } public function getBgImageSettings(){ return $this->bgImageSettings; } public function setBgImageSettings( $bgImageSettings ){ $this->bgImageSettings = $bgImageSettings; } public function addMessage($msg){$this->headMessages .= "\n$msg";} public function addTopCode($code){$this->veryTopCode .= "\n$code";} public function setTopCode($code){$this->veryTopCode = $code;} public function addHeaderCallback($callbackFunc){$this->headCallbacks[] = $callbackFunc;} public function useModules($useModules=true){$this->useModules = $useModules;} public function getCodePath(){return $this->codePath;} public function useDefaultColumns($useThem){ $this->useDefaultColumns = $useThem; if(!$useThem){ $this->colors['mainbg'] = '000000'; } } public function addToolTip($id, $title, $caption){ include_once "toolTipTools.php"; $this->toolTips[] = array( TT_ID => $id, TT_TITLE => $title, TT_CAPTION => $caption ); } public function addToolTips($toolTips){ $this->toolTips = array_merge($this->toolTips, $toolTips); } public function setPath($codePath){$this->codePath = $codePath;} public function setLogo($logoURL, $logoTitle="", $logoLink=""){ $this->logoURL = $logoURL; if($logoTitle != ""){$this->logoTitle = $logoTitle;} if($logoLink != ""){$this->logoLink = $logoLink;} } public function addHeadCode($headCode, $start=true){ if($start){ $this->extraHeadStart .= $headCode; } else { $this->extraHeadEnd .= $headCode; } } //// // Sets the column widths for all columns. Does error-checking on passed parameters. // Overwrites any previous values. //// public function setColumns($columnWidths=array(100)){ profiler_beginSection(__METHOD__); include_once 'columns.php'; $this->useDefaultColumns(false); while(count($columnWidths) < 4){ $columnWidths[] = 0; } $lastColumnFound = false; $this->columns = array(); // clears out the previuos columns for( $i = 0; $i < 4; ++$i ){ if( $columnWidths[ $i ] > 0 && !$lastColumnFound ){ $this->columns[ $i ] = new Column( $columnWidths[ $i ] ); }else if( $columnWidths[ $i ] > 0 && $lastColumnFound ){ throw new Exception( "Columns cannot be specifed after a column with 0 width." ); }else{ $lastColumnFound = true; } } if( count( $this->columns ) == 0 ){ throw new Exception( "No columns specified for this page." ); }else if( count( $this->columns ) == 1 ){ $this->columns[0]->setClass( "highlander" ); }else{ for( $i = 0; $i < count( $this->columns ); ++$i ){ if( $i == 0 ){ $this->columns[ $i ]->setClass( "left" ); }else if( $i == count( $this->columns ) - 1 ){ $this->columns[ $i ]->setClass( "right" ); }else{ $this->columns[ $i ]->setClass( "center" ); } } } profiler_endSection(__METHOD__); } public function getColumns(){return $this->columns;} //// // This differs from just calling requireLogin directly because it passes this page // into the function, so that when something else is displayed, this page's current // settings (title, tabs, etc.) are used. //// public function requireLogin($failed=false){ profiler_beginSection(__METHOD__); if(!getUser()->isLoggedIn()){ ob_start(); print "
\n"; dispMsg("This page requires you to log in. If you are not a member yet, please sign up with the form below."); // STRINGTABLES print "
\n"; $this->addMessage(ob_get_clean()); } requireLogin($failed, '', '', '', '', $this); profiler_endSection(__METHOD__); } //// // Adds a stylesheet to the page. If unshift is true, then this value will be put onto the top of the list // in the display order when the HTML is outputted (so that it can be overridden by later includes). //// public function addStyle( $style, $unshift = false ){ if(is_array($style)){ foreach( $style as $sheet ){ $this->addStyle( $sheet ); } } else if($unshift && ($style != "")){ array_unshift($this->styles, $style); } else if($style != ""){ $this->styles[ $style ] = $style; } } public function addScript( $scripts, $unshift = false ){ if(!is_array($scripts)){ $scripts = array($scripts); } foreach($scripts as $currScript){ $currScript = str_replace( 'jquery/', JQUERY_DIR, $currScript ); if(!isset($this->scripts[$currScript])){ // prevents duplicates if($unshift){ array_unshift($this->scripts, $currScript); // won't be associative, so it allows duplicates in this rare case. } else { $this->scripts[$currScript] = $currScript; } } } } public function addRSS($feedUrl, $feedTitle="RSS"){ if(!isset($this->rssFeeds[$feedUrl])){ $this->rssFeeds[$feedUrl] = $feedTitle; } } public function addModule( $module, $position = 0 ){ if($this->columns[ $position ]){ $this->columns[ $position ]->addModule( $module ); $this->addStyle( $module->getStylesheet() ); $this->addScript($module->getScripts()); } else { throw new Exception( "Adding module to column index ".$position." which does not exist." ); } } protected function clearModules(){ foreach( $this->columns as $column ){ $column->clear(); } } public function addTab( $name, $href, $style = '' ){ if( $style == 'leftText' ){ $this->leftTextTabs[ $name ] = $href; }else if( $style =='rightText' ){ $this->rightTextTabs[ $name ] = $href; }else{ $this->tabs[ $name ] = $href; } } //// // This method of display will show the whole page all at once. After doing the header // it will go through each column and use the registered modules for that column and display // them, then it will move on to the footer. //// public function display(){ profiler_beginSection(__METHOD__); $this->header(); if($this->useDefaultColumns){ if($this->columns[COLUMN_CENTER]->numModules() > 0){ $column = $this->columns[COLUMN_CENTER]; print $column->getContentOnly(); } } else { $this->displayColumns(); } $this->bottom(); profiler_endSection(__METHOD__); } //// // Displays the top of the page to allow free-form content // when not using modules. //// public function header(){ profiler_beginSection(__METHOD__); // Processing that needs to be done before the header (to change any includes or data in the header such as the cart balance), // but has output which should be held until the header is done being displayed. ob_start(); $messages = ob_get_clean(); // Processing that belongs in the head messages. ob_start(); // NOTE: This is where some extra pre-processing can be done (adding favorites, etc.). $this->headMessages .= ob_get_clean(); $colorString = ""; foreach( $this->colors as $colorName => $colorValue ){ $colorString .= ($colorString==""?"":"&"); // puts an ampersand only if needed $colorString .= "$colorName=$colorValue"; } $colorString = strtolower($colorString); if( $this->bgImage != "" ){ $colorString .= "&bgImage=".$this->bgImage."&bgImageSettings=".$this->bgImageSettings; } // Adds the dynamic css to the page. $this->addStyle( "globalcss.php?$colorString" ); if($this->useModules || (! $this->useDefaultColumns)){ $this->addStyle( "modulecss.php?$colorString", true ); } //$this->addStyle( "feedbackTools.css" ); // TODO: Decide whether or not to pull in the feedback tools. $this->displayHeader(); $this->displayTabs(); print "\n\n"; print $messages; if($this->headMessages != ""){ if($this->useDefaultColumns){ print "\n"; } print "
\n"; print $this->headMessages; print "
\n"; if($this->useDefaultColumns){ print "\n"; } } if($this->useDefaultColumns){ $this->displayLeftColumn(); } profiler_endSection(__METHOD__); } //// // Displays the start of the page from the doc-type through at least the head tag. If headOnly is false, then the // start of the page structure (the top menu, left side, etc.) will also be displayed. //// public function displayHeader($headOnly=false){ profiler_beginSection(__METHOD__); echo "\n"; echo "\n"; echo " \n"; echo ($this->extraHeadStart==""?"":$this->extraHeadStart."\n"); echo " \n"; // If the code has registered any callbacks that need to be called inside of the head-tags, process them here. if(is_array($this->headCallbacks) && (count($this->headCallbacks) > 0)){ foreach($this->headCallbacks as $funcName){ if(function_exists($funcName)){ call_user_func_array($funcName,array()); } } } // Display the page TITLE (with reasonable defaults if it wasn't set). if($this->title == ""){ $PHP_SELF = $_SERVER['PHP_SELF']; $this->title = substr($PHP_SELF, (strrpos($PHP_SELF,"/")+1)); $this->title = substr($this->title, 0, strrpos($this->title,".")); $this->title = ucfirst($this->title); } $suffix = ""; if(false === strpos($this->title, getSite(false))){ $suffix = (($this->title == "")?"":" - ").getSite(false); } echo " ".$this->title.$suffix."\n"; // Handle the META-tags (in case any search engines are still listening). if($this->metaDescription == ""){ $this->metaDescription = $this->title." on ".getSite(false); } if($this->metaKeywords == ""){ $this->metaKeywords = $this->title." ".getSite(false)." picture pics pic videos vid vids"; } print " metaKeywords\" />\n"; print " metaDescription\" />\n"; // Include the favicon (without this code it would only be detected when the app is in the document-root directory of the webserver). print " getCodePath()."/favicon.ico\" type=\"image/vnd.microsoft.icon\" />\n"; // If using an animated GIF, uncomment this line (leave the one above also), but only set the .gif here. //print " getCodePath()."/favicon.ico\"/>\n"; // NOTE: This needs to be included even if there are no ->toolTips or EXTRA_TOOL_TIPS since a page may call displayHeader(), then add a toolTip later. $this->addStyle("toolTips.css"); $this->addScript("toolTips.js"); foreach( $this->styles as $name => $style ){ echo " \n"; } //echo " \n"; // TODO: Decide if this should be ported from Pedlr. foreach( $this->scripts as $name => $script ){ echo " \n"; } foreach($this->rssFeeds as $feedUrl => $feedTitle){ echo " \n"; } echo ($this->extraHeadEnd==""?"":$this->extraHeadEnd."\n"); // extra data to be put inside the head-tags echo " \n"; echo " \n"; // Reloads the page if it is a login to avoid the repost form data prompt - TODO: Port the login from Pedlr. $user = getUser(); if( getPost('formName') == 'dil_login' && $user->isLoggedIn() ){ print ""; } // headOnly allows for all the normal css/js includes and session initialization without any display. if(!$headOnly){ echo "
\n"; echo $this->veryTopCode; // SWC 20070116 - Used for making extra nav menus (ex: random.php uses it to control where you can go). echo "
\n"; // Help avoid confusion during development by changing the logos drastically. if($this->logoURL == ""){ $this->logoURL = $this->getCodePath()."/images/logo.png"; } $this->logoLink = ($this->logoLink==""?$this->getCodePath()."/index.php":$this->logoLink); $this->logoTitle = ($this->logoTitle==""?getSite(false):$this->logoTitle); // Main logo on the top-left of the page. echo " \n"; // Builds the main nav menu. $usersHome = $user->isLoggedIn() ? $user->getUsername()."'s Home" : "Home"; $menuOpts = array( $this->getCodePath()."/home.php" => $usersHome, $this->getCodePath()."/about.php" => "About", //$this->getCodePath()."/press.php" => "Press", //$this->getCodePath()."/contact.php" => "Contact" ); if( !$user->isLoggedIn() ){ $menuOpts[$this->getCodePath()."/register.php"] = "Sign Up"; } if($user->isLoggedIn()){ //$menuOpts[$this->getCodePath()."/promote.php?station=invite"] = "Invite"; $menuOpts[$this->getCodePath()."/index.php?logout=true"] = "Logout"; } if($user->isLoggedIn()){ // Display the menu based on the array. print "\n"; } else { print "Why do it now when you can doItLater?\n"; } echo "
\n"; echo "
\n"; if($user->isAdmin()){ include_once 'adminTools.php'; } if($this->useDefaultColumns){ print "\n"; } // TODO: Figure out where to put this feedback widget //include_once "feedbackTools.php"; //feedbackWidget($this->getCodePath()); } profiler_endSection(__METHOD__); } // end displayHeader() private function displayTabs(){ profiler_beginSection(__METHOD__); if($this->useDefaultColumns){ print "\n"; } profiler_endSection(__METHOD__); } //// // Displays the left-most column as well as the markup that goes around it (like starting the row that will hold all of the main content). // // This "left column" is ONLY used if useDefaultColumns is true. Otherwise, the percentage-width Pedlr-style columns are used. //// public function displayLeftColumn(){ profiler_beginSection(__METHOD__); if($this->useDefaultColumns){ // Left side-bar print ""; print ""; print ""; print "
\n"; } if(count($this->tabs) > 0){ echo "\t
    \n"; foreach( $this->tabs as $name => $href ){ if(endsWith(strtolower($_SERVER['PHP_SELF']), "/pedlrpage.php")){ // TODO: REFACTOR THIS WHEN USING dil USER PAGES // Request URI is weird with PedlrPages (especially if additional GET params are used). $currentHref = strtolower(getVal($_GET, "uname")."/".PEDLR_PAGENAME); } else { $currentHref = strtolower( $_SERVER['REQUEST_URI'] ); if( endsWith( $currentHref, "/" ) ){ $currentHref = substr($currentHref, 0, -1); } } $tabHref = $href; // tabHref is just for comparison to currentHref used to find the active tab. $tabHref = strtolower( $tabHref ); if( startsWith( $tabHref, "/" ) ){ $tabHref = substr( $tabHref, 1 ); } if( endsWith( $href, "/" ) ){ $tabHref = substr( $tabHref, 0, strlen( $tabHref ) - 1 ); } $tabHref = strtolower($this->getCodePath()."/$tabHref"); print "\t$t
  • \n"; echo" \n"; echo"  \n"; echo"  \n"; echo" \n"; echo" ".$name."\n"; echo" \n"; echo"  \n"; echo"  \n"; echo" \n"; echo"
  • \n"; } foreach( $this->leftTextTabs as $name => $href ){ $class = strtolower( str_replace(' ', '', $name) ); echo"
  • $name
  • "; } foreach( $this->rightTextTabs as $name => $href ){ $class = strtolower( str_replace(' ', '', $name) ); echo"
  • $name
  • "; } echo "
\n"; echo "
\n"; echo "
 
\n"; echo "
 
\n"; echo "
 
\n"; echo "
\n"; print "
\n"; // makes the body wrap down below the tabs } if($this->useDefaultColumns){ print "
\n"; if($this->columns[COLUMN_LEFT]->numModules() > 0){ $column = $this->columns[COLUMN_LEFT]; print $column->getContentOnly(); } else { $user = getUser(); if($user->isAdmin()){ defconBox(); } if($user->isAdmin()){ print "\n"; print "\n"; if($user->isAdmin()){ $numMovies = simpleQuery("SELECT COUNT(*) FROM movies"); $numPictures = simpleQuery("SELECT COUNT(*) FROM pictures"); $numGames = simpleQuery("SELECT COUNT(*) FROM games"); $numFlash = simpleQuery("SELECT COUNT(*) FROM flash"); $sum = $numMovies + $numPictures + $numGames + $numFlash; print "\n"; } print "
Site Stats
$numMovies videos
$numPictures pictures
$numGames games
"; print "$numFlash flash movies
-----
$sum

\n"; } //print "place_holder\n"; // make sure pictures fit on the left as expected // SWC 20060817 - AdSense Code. // SWC 20090322 - Due to an automated message that complained that we were showing Google ads next to overly mature content, added this restriction. if($this->getMinAge() < 13){ print "\n"; ?> \n"; // Main body. print "
\n"; print "\n\n\t\n"; } profiler_endSection(__METHOD__); } // end displayLeftColumn() //// // Displays the right-most column as well as the markup that goes around it. // // This "right column" is ONLY used if useDefaultColumns is true. Otherwise, the percentage-width Pedlr-style columns are used. //// public function displayRightColumn(){ profiler_beginSection(__METHOD__); if($this->useDefaultColumns){ if($this->columns[COLUMN_RIGHT]->numModules() > 0){ $column = $this->columns[COLUMN_RIGHT]; print $column->getContentOnly(); } else { // This is the code that was formerly in the rightSideBar() function popularTagBar(); print "place_holder\n"; // make sure pictures fit on the right as expected print "

\n"; print "
\n"; print "Sites we love:
\n"; // TODO: Consider rotating in a bunch of Motive Force sites and tweaking the ratios based on what we want to promote at any given time. // TODO: NON-PORTABLE. print ""; print "Song lyrics from LyricWiki.org\n"; print "\n"; print "
\n"; } } profiler_endSection(__METHOD__); } // end displayRightColumn() protected function displayColumns(){ profiler_beginSection(__METHOD__); foreach( $this->columns as $column ){ $column->setBgColor($this->colors['bgColor']); // used by AdModules to determine best colors for embedded Ads. echo $column->getHTML(); } $extraEmpties = 4 - count( $this->columns ); $hiddenColumn = new Column(0); $hiddenColumn->setClass( "hidden" ); for( $i = 0; $i < $extraEmpties; $i++ ){ echo $hiddenColumn->getHTML(); } profiler_endSection(__METHOD__); } //// // Takes care of the bottom of the page by displaying the footer and allowing // the caching to run. //// public function bottom(){ profiler_beginSection(__METHOD__); $this->footer(); $this->cache(); profiler_endSection(__METHOD__); } //// // Displays the bottom of the page (closing any open tags). // // If the page is not going to be using the normal layout (menus, columns, etc.), then // just use displayFooter(true) instead of footer(). //// public function footer(){ profiler_beginSection(__METHOD__); print "\n\t\n\n\n"; if($this->useDefaultColumns){ print "
\n"; $this->displayRightColumn(); print "
"; } else { print "
\n"; } else { print "
\n"; } // If the custom error handler has been called and the error was hidden in comments, this displays a thin red line red block. GLOBAL $HAD_HIDDEN_ERROR; if($HAD_HIDDEN_ERROR){ print "\n"; } echo "\n\n"; // TODO: REFACTOR IT SO THAT THE FOOTER IS ABOVE AND THE displayFooter FUNCTION IS called something that makes mroe sense (like "closeRemainingTags" or something). /* echo "\n"; */ $this->displayFooter(); profiler_endSection(__METHOD__); } //// // footOnly can be used when you just want a blank page with Pedlr's header data and bubble system, etc. but not the // normal page layout. //// public function displayFooter($footOnly=false){ profiler_beginSection(__METHOD__); $this->dispToolTips(); if($footOnly === false){ print " \n"; } if((WHICH_SERVER == SERVER_RELEASE) || (WHICH_SERVER == SERVER_BETA)){ // SWC 20061016 Google Analytics code // NON-PORTABLE: This is specific to doItLater.com and should be changed by any other sites using the system. print "\n"; print "\n"; } print " \n"; print "\n"; profiler_endSection(__METHOD__); } //// // Displays the code for the content of the tool tips. //// private function dispToolTips(){ profiler_beginSection(__METHOD__); include_once "toolTipTools.php"; GLOBAL $EXTRA_TOOL_TIPS; if(count($EXTRA_TOOL_TIPS) > 0){ $this->toolTips = array_merge($this->toolTips, $EXTRA_TOOL_TIPS); $EXTRA_TOOL_TIPS = array(); } tt_dumpData($this->toolTips); profiler_endSection(__METHOD__); } // end dispBubbles() // CACHING FUNCTIONS //// // Includes the caching files. This is helpful if the user wants to use one of the defines // in their call to enableCaching. //// public function includeCaching(){ profiler_beginSection(__METHOD__); include_once "cacheTools.php"; profiler_endSection(__METHOD__); } //// // Enables caching for the current page for a certain duration (in mySQL INTERVAL syntax) and // either a given or automatically generated keyName. If the cache result is found, then the // cached data is outputted and execution will stop. //// public function enableCache($keyName='', $duration="10 MINUTE"){ profiler_beginSection(__METHOD__); $this->includeCaching(); if($keyName == ''){ $keyName = "AUTO_".$_SERVER['REQUEST_URI']; } // Will print the data and exit if it is still valid checkCache($keyName, $duration); $this->cacheKey = $keyName; $this->cacheResults = true; ob_start(); profiler_endSection(__METHOD__); } // end enableCaching //// // If caching is enabled for this page, stores the result. // By default, also prints this code when done unless quelchOutput is false. //// public function cache($quelchOutput=false){ profiler_beginSection(__METHOD__); if($this->cacheResults){ $pageData = ob_get_clean(); cachePage($this->cacheKey, $pageData); print $pageData; } profiler_endSection(__METHOD__); } // end cache() } // end class Page ?>