From dc0fb9445e8a3ede8bc33d6779fadd89b7ea6893 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 3 Oct 2009 10:30:17 -0400 Subject: Created Theme Switcher Also rewrote the way layouts work. Now, each layout requires a "layout.tpl" file (which contains the header and footer for the layout) and a "style.php" file (which contains and can include other files that contain the CSS for the layout). Each layout has it's own folder in theme/layouts and you can switch between them using a combo box in the Hatbar. Layouts 6.2 and 4.5 have been modified to work with new Layout 7 features such as AJAX, and they should be relatively free of bugs. Layout 3 has not yet been transferred because since it is pre-The New Four Island, it will be very difficult to do so. This changeset requires manual external code changes: * The line below must be added above the functions.php include in The Fourm's funnctions.php require('/svr/www/hatkirby/fourisland/main/includes/session.php'); * The block of Four Island code in The Fourm's page_header() function should be replaced with: global $fi_pagetitle; $fi_pagetitle = $page_title; ob_start(); * The block of Four Island code in The Fourm's page_footer() function should be replaced with: global $fi_pagetitle; $content = ob_get_contents(); ob_end_clean(); $noRightbar = 1; $onFourm = 1; $pageCategory = 'fourm'; if ($fi_pagetitle == 'Index page') { $title = 'The Fourm'; } else if (strpos($fi_pagetitle, 'View topic') !== FALSE) { $title = str_replace('View topic - ', 'Topic: ', $fi_pagetitle) . ' - The Fourm'; } else if (strpos($fi_pagetitle, 'View forum') !== FALSE) { $title = str_replace('View forum - ', 'Fourm: ', $fi_pagetitle) . ' - The Fourm'; } else if (strpos($fi_pagetitle, 'Viewing profile') !== FALSE) { $title = str_replace('Viewing profile - ', 'Member: ', $fi_pagetitle) . ' - The Fourm'; } else { $title = $fi_pagetitle . ' - The Fourm'; } if ($_GET['view'] != 'print') { include('/svr/www/hatkirby/fourisland/main/includes/layout.php'); } else { echo $content; } Closes #117 --- includes/footer.php | 180 ----------------------------- includes/functions.php | 60 ++++++++++ includes/header.php | 96 ---------------- includes/layout.php | 300 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 360 insertions(+), 276 deletions(-) delete mode 100755 includes/footer.php delete mode 100755 includes/header.php create mode 100644 includes/layout.php (limited to 'includes') diff --git a/includes/footer.php b/includes/footer.php deleted file mode 100755 index d1f9668..0000000 --- a/includes/footer.php +++ /dev/null @@ -1,180 +0,0 @@ - adds_block('ONFOURM',array('exi'=>1)); -} - -$getcomments = "SELECT * FROM comments ORDER BY id DESC LIMIT 0,5"; -$getcomments2 = mysql_query($getcomments); -$i=0; -while ($getcomments3[$i] = mysql_fetch_array($getcomments2)) -{ - if ($getcomments3[$i]['is_anon'] == 0) - { - $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getcomments3[$i]['user_id']; - $getuser2 = mysql_query($getuser); - $getuser3 = mysql_fetch_array($getuser2); - - $username = $getuser3['username']; - $website = $getuser3['user_website']; - } else if ($getcomments3[$i]['is_anon'] == 1) - { - $getanon = "SELECT * FROM anon_commenters WHERE id = " . $getcomments3[$i]['user_id']; - $getanon2 = mysql_query($getanon); - $getanon3 = mysql_fetch_array($getanon2); - - if ($getanon3['id'] == $getcomments3[$i]['user_id']) - { - $username = $getanon3['username'] . ' (Guest)'; - $website = $getanon3['website']; - } - } - - if (strpos($getcomments3[$i]['page_id'], 'updates') !== FALSE) - { - $getpost = "SELECT * FROM updates WHERE id = " . substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); - $getpost2 = mysql_query($getpost); - $getpost3 = mysql_fetch_array($getpost2); - - $template->adds_block('COMMENTS', array( 'ID' => $getcomments3[$i]['id'], - 'AREA' => 'blog', - 'CODED' => $getpost3['slug'], - 'ENDING' => '/', - 'TITLE' => stripslashes(htmlentities($getpost3['title'])), - 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); - $i++; - } else if (strpos($getcomments3[$i]['page_id'], 'quote') !== FALSE) - { - $num = substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); - - $template->adds_block('COMMENTS', array( 'ID' => $getcomments3[$i]['id'], - 'AREA' => 'quotes', - 'CODED' => $num, - 'ENDING' => '.php', - 'TITLE' => 'Quote #' . $num, - 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); - $i++; - } else if (strpos($getcomments3[$i]['page_id'], 'polloftheweek') !== FALSE) - { - $getpotw = "SELECT * FROM polloftheweek WHERE id = " . substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); - $getpotw2 = mysql_query($getpotw); - $getpotw3 = mysql_fetch_array($getpotw2); - - $template->adds_block('COMMENTS', array( 'ID' => $getcomments3[$i]['id'], - 'AREA' => 'poll', - 'CODED' => $getpotw3['id'], - 'ENDING' => '.php', - 'TITLE' => 'Poll "' . htmlentities($getpotw3['question']) . '"', - 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); - $i++; - } -} - -$users = array(); -$getusers = "SELECT DISTINCT user_id FROM comments WHERE is_anon = 0"; -$getusers2 = mysql_query($getusers); -$i=0; -while ($getusers3[$i] = mysql_fetch_array($getusers2)) -{ - $getcount = "SELECT COUNT(*) FROM comments WHERE user_id = " . $getusers3[$i]['user_id']; - $getcount2 = mysql_query($getcount); - $getcount3 = mysql_fetch_array($getcount2); - - $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getusers3[$i]['user_id']; - $getuser2 = mysql_query($getuser); - $getuser3 = mysql_fetch_array($getuser2); - - $username = $getuser3['username']; - $website = $getuser3['user_website']; - - $name = (($website != '') ? '' . $username . '' : $username); - $users[] = array('name' => $name, 'count' => $getcount3['COUNT(*)']); - - $i++; -} - -function count_sort($a, $b) -{ - $a = $a['count']; - $b = $b['count']; - - if ($a > $b) - { - return -1; - } else if ($a < $b) - { - return 1; - } else { - return 0; - } -} - -usort($users, 'count_sort'); -$i=0; -foreach ($users as $value) -{ - if ($i == 5) - { - break; - } - - $template->adds_block('TOP', array( 'USERNAME' => $value['name'], - 'COUNT' => $value['count'])); - $i++; -} - -$getpost = "SELECT * FROM phpbb_posts ORDER BY post_id DESC LIMIT 0,5"; -$getpost2 = mysql_query($getpost) or die($getpost); -$i=0; -while ($getpost3[$i] = mysql_fetch_array($getpost2)) -{ - $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getpost3[$i]['poster_id']; - $getuser2 = mysql_query($getuser) or die($getuser); - $getuser3 = mysql_fetch_array($getuser2); - - $template->adds_block('FOURM', array( 'SUBJECT' => $getpost3[$i]['post_subject'], - 'TOPIC' => $getpost3[$i]['topic_id'], - 'POST' => $getpost3[$i]['post_id'], - 'USERNAME' => $getuser3['username'])); -} - -$getpopular = "SELECT * FROM updates ORDER BY popularity DESC LIMIT 0,5"; -$getpopular2 = mysql_query($getpopular); -$i=0; -while ($getpopular3[$i] = mysql_fetch_array($getpopular2)) -{ - $template->adds_block('POPULAR', array( 'CODED' => $getpopular3[$i]['slug'], - 'TITLE' => stripslashes(htmlentities($getpopular3[$i]['title'])))); - $i++; -} - -$template->add('REVISION', exec('hg -R "' . $_SERVER['DOCUMENT_ROOT'] . '" tip --template {rev}')); - -$template->display(); - -?> diff --git a/includes/functions.php b/includes/functions.php index 6b5d8e9..bc839df 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -376,4 +376,64 @@ function getTagColor($i) } } +function getLayout() +{ + if (!isset($_COOKIE['layout'])) + { + return '7'; + } else { + return $_COOKIE['layout']; + } +} + +function getRewriteURL() +{ + if (!isset($_GET['area'])) + { + return '/'; + } else { + if ($_GET['area'] == 'blog') + { + if (isset($_GET['author'])) + { + return '/blog/author/' . $_GET['author'] . '.php'; + } else if (isset($_GET['tag'])) + { + return '/blog/tag/' . $_GET['tag'] . '.php'; + } else if (isset($_GET['post'])) + { + return '/blog/' . $_GET['post'] . '/'; + } else { + return '/blog/'; + } + } else if ($_GET['area'] == 'poll') + { + if (isset($_GET['id'])) + { + return '/poll/' . $_GET['id'] . '.php'; + } else { + return '/poll/'; + } + } else if ($_GET['area'] == 'quotes') + { + if (isset($_GET['act'])) + { + return '/quotes/' . $_GET['act'] . '.php'; + } else { + return '/quotes/'; + } + } else if ($_GET['area'] == 'error') + { + if (isset($_GET['id'])) + { + return '/error/' . $_GET['id'] . '.php'; + } else { + return '/error/'; + } + } else { + return '/' . $_GET['area'] . '/'; + } + } +} + ?> diff --git a/includes/header.php b/includes/header.php deleted file mode 100755 index 003e002..0000000 --- a/includes/header.php +++ /dev/null @@ -1,96 +0,0 @@ -add('CATEGORY',(isset($pageCategory)) ? $pageCategory : 'none'); -$headerTemp->add('AID',(isset($pageAID)) ? $pageAID : 'none'); -$headerTemp->add('EXTRATITLE',isset($title) ? ($title . ' - ') : ''); -$headerTemp->add(strtoupper($pageCategory) . 'ACTIVE', ' class="active"'); - -if (($pageCategory != 'fourm') && ($pageCategory != 'wiki')) -{ - $headerTemp->add('REDIRPAGE',rawurlencode($_SERVER['REQUEST_URI'])); - $headerTemp->add('LOGDATA',echoLogData()); - $headerTemp->add('SID',getSessionID()); - $headerTemp->adds_block('MEMBERS',array('exi' => 1)); - - if (isAdmin()) - { - $headerTemp->adds_block('ADMIN',array('exi' => 1)); - } -} - -if (isset($hatNav) && is_array($hatNav)) -{ - $headerTemp->adds_block('CREATE_HATNAV', array('exi'=>1)); - - foreach ($hatNav as $item) - { - $headerTemp->adds_block('HATNAV',array('TITLE' => $item['title'], 'URL' => $item['url'], 'ICON' => $item['icon'])); - } -} - -$headerTemp->add('POTW', getPollOfTheWeek()); - -$gethits = "SELECT * FROM config WHERE name = \"hits\""; -$gethits2 = mysql_query($gethits); -$gethits3 = mysql_fetch_array($gethits2); -$headerTemp->add('HITS', $gethits3['value']); - -$gethits = "SELECT * FROM config WHERE name = \"todayHits\""; -$gethits2 = mysql_query($gethits); -$gethits3 = mysql_fetch_array($gethits2); -$headerTemp->add('TODAY', $gethits3['value']); - -$headerTemp->add('DATEFINDER', sd_dateFinder()); - -if ($usingIE) -{ - $headerTemp->add('FLASH', 'It appears you are using Internet Explorer. Four Island is not likely to work properly in IE due to a huge bug in it. There are better browsers out there, why not try one?'); -} - -$getaffs = "SELECT * FROM links WHERE type = \"affiliates\" ORDER BY id ASC"; -$getaffs2 = mysql_query($getaffs); -$i=0; -while ($getaffs3 = mysql_fetch_array($getaffs2)) -{ - $headerTemp->adds_block('AFFILIATES', array( 'COLOR' => getTagColor($i++), - 'TITLE' => htmlentities($getaffs3['title']), - 'URL' => $getaffs3['url'])); -} - -$getwebps = "SELECT * FROM links WHERE type = \"webprojs\" ORDER BY id ASC"; -$getwebps2 = mysql_query($getwebps); -$i=0; -while ($getwebps3 = mysql_fetch_array($getwebps2)) -{ - $headerTemp->adds_block('WEBPROJS', array( 'COLOR' => getTagColor($i++), - 'TITLE' => htmlentities($getwebps3['title']), - 'URL' => $getwebps3['url'])); -} - -$headerTemp->display(); - -?> diff --git a/includes/layout.php b/includes/layout.php new file mode 100644 index 0000000..8e92256 --- /dev/null +++ b/includes/layout.php @@ -0,0 +1,300 @@ +add('CATEGORY',(isset($pageCategory)) ? $pageCategory : 'none'); +$template->add('AID',(isset($pageAID)) ? $pageAID : 'none'); +$template->add('EXTRATITLE',isset($title) ? ($title . ' - ') : ''); +$template->add(strtoupper($pageCategory) . 'ACTIVE', ' class="active"'); + +if (($pageCategory != 'fourm') && ($pageCategory != 'wiki')) +{ + $template->add('REDIRPAGE',rawurlencode($_SERVER['REQUEST_URI'])); + $template->add('LOGDATA',echoLogData()); + $template->add('LOWERLOGDATA','log' . strtolower(echoLogData())); + $template->add('SID',getSessionID()); + $template->adds_block('MEMBERS',array('exi' => 1)); + + if (isAdmin()) + { + $template->adds_block('ADMIN',array('exi' => 1)); + } +} + +if (isset($hatNav) && is_array($hatNav)) +{ + $template->adds_block('CREATE_HATNAV', array('exi'=>1)); + + foreach ($hatNav as $item) + { + $template->adds_block('HATNAV',array('TITLE' => $item['title'], 'URL' => $item['url'], 'ICON' => $item['icon'])); + } +} + +$template->add('POTW', getPollOfTheWeek()); + +$gethits = "SELECT * FROM config WHERE name = \"hits\""; +$gethits2 = mysql_query($gethits); +$gethits3 = mysql_fetch_array($gethits2); +$template->add('HITS', $gethits3['value']); + +$gethits = "SELECT * FROM config WHERE name = \"todayHits\""; +$gethits2 = mysql_query($gethits); +$gethits3 = mysql_fetch_array($gethits2); +$template->add('TODAY', $gethits3['value']); + +$template->add('DATEFINDER', sd_dateFinder()); + +if ($usingIE) +{ + $template->add('FLASH', 'It appears you are using Internet Explorer. Four Island is not likely to work properly in IE due to a huge bug in it. There are better browsers out there, why not try one?'); +} + +$getaffs = "SELECT * FROM links WHERE type = \"affiliates\" ORDER BY id ASC"; +$getaffs2 = mysql_query($getaffs); +$i=0; +while ($getaffs3 = mysql_fetch_array($getaffs2)) +{ + $template->adds_block('AFFILIATES', array( 'COLOR' => getTagColor($i++), + 'TITLE' => htmlentities($getaffs3['title']), + 'URL' => $getaffs3['url'])); +} + +$getwebps = "SELECT * FROM links WHERE type = \"webprojs\" ORDER BY id ASC"; +$getwebps2 = mysql_query($getwebps); +$i=0; +while ($getwebps3 = mysql_fetch_array($getwebps2)) +{ + $template->adds_block('WEBPROJS', array( 'COLOR' => getTagColor($i++), + 'TITLE' => htmlentities($getwebps3['title']), + 'URL' => $getwebps3['url'])); +} + +if (isset($onFourm)) +{ + $template->adds_block('ONFOURM',array('exi'=>1)); +} + +$getcomments = "SELECT * FROM comments ORDER BY id DESC LIMIT 0,5"; +$getcomments2 = mysql_query($getcomments); +$i=0; +while ($getcomments3[$i] = mysql_fetch_array($getcomments2)) +{ + if ($getcomments3[$i]['is_anon'] == 0) + { + $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getcomments3[$i]['user_id']; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + $username = $getuser3['username']; + $website = $getuser3['user_website']; + } else if ($getcomments3[$i]['is_anon'] == 1) + { + $getanon = "SELECT * FROM anon_commenters WHERE id = " . $getcomments3[$i]['user_id']; + $getanon2 = mysql_query($getanon); + $getanon3 = mysql_fetch_array($getanon2); + + if ($getanon3['id'] == $getcomments3[$i]['user_id']) + { + $username = $getanon3['username'] . ' (Guest)'; + $website = $getanon3['website']; + } + } + + if (strpos($getcomments3[$i]['page_id'], 'updates') !== FALSE) + { + $getpost = "SELECT * FROM updates WHERE id = " . substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); + $getpost2 = mysql_query($getpost); + $getpost3 = mysql_fetch_array($getpost2); + + $template->adds_block('COMMENTS', array( 'ID' => $getcomments3[$i]['id'], + 'AREA' => 'blog', + 'CODED' => $getpost3['slug'], + 'ENDING' => '/', + 'TITLE' => stripslashes(htmlentities($getpost3['title'])), + 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); + $i++; + } else if (strpos($getcomments3[$i]['page_id'], 'quote') !== FALSE) + { + $num = substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); + + $template->adds_block('COMMENTS', array( 'ID' => $getcomments3[$i]['id'], + 'AREA' => 'quotes', + 'CODED' => $num, + 'ENDING' => '.php', + 'TITLE' => 'Quote #' . $num, + 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); + $i++; + } else if (strpos($getcomments3[$i]['page_id'], 'polloftheweek') !== FALSE) + { + $getpotw = "SELECT * FROM polloftheweek WHERE id = " . substr($getcomments3[$i]['page_id'],strpos($getcomments3[$i]['page_id'],'-')+1); + $getpotw2 = mysql_query($getpotw); + $getpotw3 = mysql_fetch_array($getpotw2); + + $template->adds_block('COMMENTS', array( 'ID' => $getcomments3[$i]['id'], + 'AREA' => 'poll', + 'CODED' => $getpotw3['id'], + 'ENDING' => '.php', + 'TITLE' => 'Poll "' . htmlentities($getpotw3['question']) . '"', + 'AUTHOR' => (($website != '') ? '' . $username . '' : $username))); + $i++; + } +} + +$users = array(); +$getusers = "SELECT DISTINCT user_id FROM comments WHERE is_anon = 0"; +$getusers2 = mysql_query($getusers); +$i=0; +while ($getusers3[$i] = mysql_fetch_array($getusers2)) +{ + $getcount = "SELECT COUNT(*) FROM comments WHERE user_id = " . $getusers3[$i]['user_id']; + $getcount2 = mysql_query($getcount); + $getcount3 = mysql_fetch_array($getcount2); + + $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getusers3[$i]['user_id']; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + $username = $getuser3['username']; + $website = $getuser3['user_website']; + + $name = (($website != '') ? '' . $username . '' : $username); + $users[] = array('name' => $name, 'count' => $getcount3['COUNT(*)']); + + $i++; +} + +function count_sort($a, $b) +{ + $a = $a['count']; + $b = $b['count']; + + if ($a > $b) + { + return -1; + } else if ($a < $b) + { + return 1; + } else { + return 0; + } +} + +usort($users, 'count_sort'); +$i=0; +foreach ($users as $value) +{ + if ($i == 5) + { + break; + } + + $template->adds_block('TOP', array( 'USERNAME' => $value['name'], + 'COUNT' => $value['count'])); + $i++; +} + +$getpost = "SELECT * FROM phpbb_posts ORDER BY post_id DESC LIMIT 0,5"; +$getpost2 = mysql_query($getpost) or die($getpost); +$i=0; +while ($getpost3[$i] = mysql_fetch_array($getpost2)) +{ + $getuser = "SELECT * FROM phpbb_users WHERE user_id = " . $getpost3[$i]['poster_id']; + $getuser2 = mysql_query($getuser) or die($getuser); + $getuser3 = mysql_fetch_array($getuser2); + + $template->adds_block('FOURM', array( 'SUBJECT' => $getpost3[$i]['post_subject'], + 'TOPIC' => $getpost3[$i]['topic_id'], + 'POST' => $getpost3[$i]['post_id'], + 'USERNAME' => $getuser3['username'])); +} + +$getpopular = "SELECT * FROM updates ORDER BY popularity DESC LIMIT 0,5"; +$getpopular2 = mysql_query($getpopular); +$i=0; +while ($getpopular3[$i] = mysql_fetch_array($getpopular2)) +{ + $template->adds_block('POPULAR', array( 'CODED' => $getpopular3[$i]['slug'], + 'TITLE' => stripslashes(htmlentities($getpopular3[$i]['title'])))); + $i++; +} + +$template->add('REVISION', exec('hg -R "' . $_SERVER['DOCUMENT_ROOT'] . '" tip --template {rev}')); + +$gettags = "SELECT DISTINCT tag FROM tags WHERE post_type = \"published\""; +$gettags2 = mysql_query($gettags); +$i=0; +while ($gettags3[$i] = mysql_fetch_array($gettags2)) +{ + $cnttag = "SELECT COUNT(*) FROM tags WHERE tag = \"" . $gettags3[$i]['tag'] . "\" AND post_type = \"published\""; + $cnttag2 = mysql_query($cnttag); + $cnttag3 = mysql_fetch_array($cnttag2); + + $counts[$gettags3[$i]['tag']] = $cnttag3[0]; + + $i++; +} + +$min_count = min($counts); +$spread = max($counts) - $min_count; +$spread = ($spread <= 0) ? 1 : $spread; +$font_step = 8 / $spread; +foreach ($counts as $tag => $count) +{ + if ($count != $min_count) + { + $template->adds_block('TAGCLOUD', array( 'TAG' => $tag, + 'SIZE' => (8 + (($count - $min_count) * $font_step)), + 'COUNT' => $count)); + } +} + +if (!isset($noRightbar)) +{ + $template->adds_block('RIGHTBAR', array('exi'=>1)); +} + +$template->add('ME', getRewriteURL()); + +$template->add('CONTENT', stripslashes($content)); + +$template->display(); + +?> -- cgit 1.4.1