Commit 9e498458 authored by Kjartan's avatar Kjartan

Changes

- created a BaseTheme class in theme.inc.
- added links($links = array(), $status = 0, $node = 0) to BaseTheme.
- modified all themes to extend from BaseTheme.
- modiefied theme_link() to take advantage of $theme->links().
- theme_morelink() does not require a $theme argument.

Todo
- add the other standard variables and functions to BaseTheme.
- some themes could use some more modifications.

Weird
- marvin.theme still has a story() function.
parent 10c96ede
<?php
class BaseTheme {
function links($links = array(), $status = 0, $node = 0) {
if ($status == 1)
$links = array_merge(theme_morelink($node), $links);
foreach ($links as $link) {
$_links[] = count($link) == 2 ? "<A HREF=\"$link[0]\"><FONT COLOR=\"$theme->link\">". t($link[1]) ."</FONT></A>" : t($link[0]);
}
if ($status == 2) return ($_links ? implode(" | ", $_links) : "");
else return ($_links ? "[ ". implode(" | ", $_links) ." ]" : "");
}
}
function theme_init() {
global $user, $themes;
......@@ -12,21 +24,22 @@ function theme_init() {
return new Theme();
}
function theme_link($separator = " | ") {
$links[] = "<A HREF=\"index.php\">". t("home") ."</A>";
$links[] = "<A HREF=\"search.php\">". t("search") ."</A>";
$links[] = "<A HREF=\"submit.php\">". t("submit") ."</A>";
$links[] = "<A HREF=\"account.php\">". t("account") ."</A>";
function theme_link() {
global $theme;
$links[] = array("index.php", t("home"));
$links[] = array("search.php", t("search"));
$links[] = array("submit.php", t("submit"));
$links[] = array("account.php", t("account"));
foreach (module_list() as $name) {
if (module_hook($name, "page")) $links[] = "<A HREF=\"module.php?mod=$name\">".t($name) ."</A>";
if (module_hook($name, "page")) $links[] = array("module.php?mod=$name", t($name));
}
// if (module_exist("forum")) $links[] = "<A HREF=\"module.php?mod=forum\">".t("forum") ."</A>";
// if (module_exist("diary")) $links[] = "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>";
// if (module_exist("book")) $links[] = "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>";
return implode($separator, $links);
return $theme->links($links, 2);
}
......@@ -97,15 +110,15 @@ function theme_blocks($region, $theme) {
}
}
function theme_morelink($theme, $node) {
function theme_morelink(&$node) {
if ($node->body) {
$link[] = "<A HREF=\"node.php?id=$node->nid\"><FONT COLOR=\"$theme->link\">". t("read more") ."</FONT></A>";
$links[] = array("node.php?id=$node->nid", t("read more"));
}
if ($node->comment) {
$link[] = "<A HREF=\"node.php?id=$node->nid\"><FONT COLOR=\"$theme->link\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</FONT></A>";
$links[] = array("node.php?id=$node->nid", format_plural(node_get_comments($node->nid), "comment", "comments"));
}
return ($link ? "[ ". implode(" | ", $link) ." ]" : "");
return $links;
}
function theme_moderation_results($theme, $node) {
......
......@@ -9,7 +9,7 @@
*********************************************************************/
class Theme {
class Theme extends BaseTheme {
// General colorset that can be used for this theme
var $foreground = "#000000";
var $background = "#FFFFFF";
......@@ -30,7 +30,7 @@ function header() {
<TD ALIGN="right" COLSPAN="2">
<?php
print theme_link(" | ");
print theme_link();
?>
</TD>
......@@ -50,7 +50,7 @@ function header() {
} // close header function
function node($node, $main = 0) {
function node($node, $main = 0, $links = 0) {
?>
<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="3" WIDTH="100%">
......@@ -83,8 +83,7 @@ function node($node, $main = 0) {
<TR>
<TD COLSPAN="2">
<?php
if ($main)
echo theme_morelink($this, $node);
if ($main || $links) echo $this->links($links, $main, $node);
?>
</TD>
......
......@@ -10,7 +10,7 @@
*********************************************************************/
class Theme {
class Theme extends BaseTheme {
var $link = "#666699";
// General colorset that can be used for this theme
......@@ -39,7 +39,7 @@ function header() {
<TR>
<TD ALIGN="right" COLSPAN="2">
<?php
print "<SMALL>". theme_link(" | ") ."</SMALL>\n";
print "<SMALL>". theme_link() ."</SMALL>\n";
?>
</TD>
</TR>
......@@ -66,12 +66,12 @@ function story($story, $main = 0) {
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
if ($main) print " <TR><TD COLSPAN=\"2\">". theme_morelink($this, $story) ."</TD></TR>\n";
if ($main || $links) print " <TR><TD COLSPAN=\"2\">". $this->links($links, $main, $node) ."</TD></TR>\n";
print "</TABLE>\n";
print "<BR><BR>\n\n";
}
function node($node, $main = 0) {
function node($node, $main = 0, $links = 0) {
print "\n<!-- node: \"$node->title\" -->\n";
print "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\" WIDTH=\"100%\">\n";
print " <TR><TD COLSPAN=\"2\"><IMG SRC=\"themes/marvin/images/drop.gif\" ALT=\"\"> &nbsp; <B>". check_output($node->title) ."</B></TD></TR>\n";
......@@ -86,7 +86,7 @@ function node($node, $main = 0) {
print " <TD COLSPAN=\"2\"><P>". check_output($node->body, 1) ."</P></TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
if ($main) print " <TR><TD COLSPAN=\"2\">". theme_morelink($this, $node) ."</TD></TR>\n";
if ($main || $links) print " <TR><TD COLSPAN=\"2\">". $this->links($links, $main, $node) ."</TD></TR>\n";
print "</TABLE>\n";
print "<BR><BR>\n\n";
}
......@@ -168,7 +168,7 @@ function footer() {
<TR>
<TD ALIGN="center" COLSPAN="3">
<?php
print "<P><SMALL>[ ". theme_link(" | ") ." ]</SMALL></P><P>". variable_get(site_footer, "") ."</P>\n";
print "<P><SMALL>[ ". theme_link() ." ]</SMALL></P><P>". variable_get(site_footer, "") ."</P>\n";
?>
</TD>
</TR>
......
......@@ -10,7 +10,7 @@
*********************************************************************/
class Theme {
class Theme extends BaseTheme {
var $foreground = "#000000";
var $background = "#FFFFFF";
......@@ -65,7 +65,7 @@ function header() {
</TR>
<TR>
<TD COLSPAN="2" ALIGN="CENTER">
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print theme_link(" | "); ?></BIG></TD></TR></TABLE></TD></TR></TABLE>
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print theme_link(); ?></BIG></TD></TR></TABLE></TD></TR></TABLE>
</TD>
</TR>
<TR><TD COLSPAN="2"><?php
......@@ -81,7 +81,7 @@ function header() {
<?php
}
function node($node, $main = 0) {
function node($node, $main = 0, $links = 0) {
print "\n<!-- node: \"$node->title\" -->\n";
?>
......@@ -103,8 +103,8 @@ function node($node, $main = 0) {
</TD>
</TR>
<?php
if ($main)
echo "<TR BGCOLOR=\"". $this->bgcolor3 ."\"><TD BGCOLOR=\"". $this->bgcolor3 ."\" ALIGN=\"right\" COLSPAN=\"2\">". theme_morelink($this, $node) ."</TD></TR>";
if ($main || $links)
echo "<TR BGCOLOR=\"". $this->bgcolor3 ."\"><TD BGCOLOR=\"". $this->bgcolor3 ."\" ALIGN=\"right\" COLSPAN=\"2\">". $this->links($links, $main, $node) ."</TD></TR>";
?>
</TABLE></TD></TR></TABLE><BR>
<?php
......@@ -204,7 +204,7 @@ function footer() {
?></TD></TR>
<TR>
<TD COLSPAN="2">
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print theme_link(" | "); ?></BIG></TD></TR></TABLE></TD></TR></TABLE>
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BGCOLOR="<?php echo $this->brcolor1; ?>"><TR><TD ALIGN="CENTER"><TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="4"><TR><TD ALIGN="CENTER" BGCOLOR="<?php echo $this->bgcolor2; ?>"><BIG><?php print theme_link(); ?></BIG></TD></TR></TABLE></TD></TR></TABLE>
</TD>
</TR>
</TABLE>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment