- some important changes to our theme API which can be summerized as:

abstract() + article() = story()

  abstract() and article() have been merged into a new function story()
  which looks like:

  function story($story_object, $reply) {
    if (!reply) {
       // full story
    }
    else {
       // main page version / abstract
    }
  }

  This should allow you to "compress" your theme as abstract() and
  article() tended to be 98% identical.

  => I didn't really merge your themes so I leave it up to *you* to
     improved the code!!! Do it ASAP as we release drupal 2.00 in 7
     days.

  In future we'll have similar functions for other content types as
  for example:

     review($review, $reply);
     enquete($enquete, $reply);
     ...
3-00
Dries Buytaert 2001-03-08 08:16:23 +00:00
parent f516626a29
commit 3958a714cd
9 changed files with 127 additions and 125 deletions

View File

@ -59,7 +59,7 @@ function comment_reply($pid, $id) {
$pid = 0;
if ($link == "story") {
$item = db_fetch_object(db_query("SELECT stories.*, users.userid FROM stories LEFT JOIN users ON stories.author = users.id WHERE stories.status != 0 AND stories.id = '$id'"));
$theme->article($item, "");
$theme->story($item, "");
}
}

View File

@ -11,7 +11,7 @@ $result = db_query("SELECT stories.*, users.userid, COUNT(comments.lid) AS comme
// Display stories:
$theme->header();
while ($story = db_fetch_object($result)) $theme->abstract($story);
while ($story = db_fetch_object($result)) $theme->story($story);
$theme->footer();
?>

View File

@ -247,7 +247,7 @@ function documentation() {
$theme->header();
// displays the header of a page
for each $article to be displayed {
$theme->article($article);
$theme->story($story);
// displays a themed article or story
}
$theme->footer();

View File

@ -101,7 +101,7 @@ function submission_display_item($id) {
$output .= "</FORM>\n";
$theme->header();
$theme->article($submission, "[ <A HREF=\"module.php?mod=submission\"><FONT COLOR=\"$theme->link\">back</FONT></A> ]");
$theme->story($submission, "[ <A HREF=\"module.php?mod=submission\"><FONT COLOR=\"$theme->link\">back</FONT></A> ]");
$theme->box(t("Moderate story"), $output);
$theme->footer();
}

View File

@ -9,7 +9,7 @@ function story_render($id, $cid) {
$story = db_fetch_object(db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = '$id'"));
if (story_visible($story)) {
$theme->article($story, "[ <A HREF=\"story.php?op=reply&id=$id&pid=0\">". t("reply to this story") ."</A> ]");
$theme->story($story, "[ <A HREF=\"story.php?op=reply&id=$id&pid=0\">". t("reply to this story") ."</A> ]");
comment_render($id, $cid);
}
else {

View File

@ -87,7 +87,7 @@ function submit_preview($subject, $abstract, $article, $section) {
$output .= "</FORM>\n";
$theme->header();
$theme->article(new Story($user->userid, $subject, $abstract, $article, $section, time()));
$theme->story(new Story($user->userid, $subject, $abstract, $article, $section, time()));
$theme->box(t("Submit a story"), $output);
$theme->footer();
}

View File

@ -19,7 +19,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE><?PHP echo $site_name; ?> - Tears of technology</TITLE>
<STYLE type="text/css">
@ -29,7 +29,7 @@
-->
</STYLE>
</HEAD>
<BODY TEXT="#202020" BGCOLOR="#FEFEFE" BACKGROUND="themes/jeroen/images/background.gif" ALINK="#000000" LINK="#000000" VLINK="#000000">
<TABLE WIDTH="100%" ALIGN="left" CELLPADDING="0" CELLSPACING="6" BORDER="0">
<TR>
@ -38,7 +38,7 @@
<IMG SRC="themes/jeroen/images/<?PHP echo $img; ?>" ALT=""><BR><BR>
</TD>
<TD WIDTH="20%">
<?PHP
$this->box("Drop where?", "<TR>
@ -73,8 +73,9 @@
} // close header function
function abstract($story) {
$timestamp = format_date($story->timestamp);
function story($story, $reply = 0) {
if (!$reply) {
$timestamp = format_date($story->timestamp);
?>
@ -123,7 +124,7 @@
<TD COLSPAN="2" VALIGN="top" WIDTH="100%">
<?PHP
if ($story->updates)
echo "<P><FONT COLOR=\"#E09226\">". t("Editor's note") .":</FONT>". check_output($story->updates, 1) ."</P>";
if ($story->abstract)
@ -147,11 +148,10 @@
<BR>
<?PHP
}
else {
} // close abstract function
function article($story, $reply) {
$timestamp = format_date($story->timestamp);
$timestamp = format_date($story->timestamp);
?>
@ -213,7 +213,7 @@
if ($story->updates)
echo "<P>check_output($story->abstract, 1)</P><P><FONT COLOR=\"#E09226\">Editor's note by <A HREF=\"account.php?op=userinfo&uname=$story->editor\">$story->editor</A>:</FONT>$story->updates</P>";
else
else
echo check_output($story->abstract, 1);
if ($story->article)
echo "<P>". check_output($story->article, 1) ."</P>";
@ -237,8 +237,8 @@
<BR>
<?PHP
} // close article function
}
} // close story function
function controls() {
echo comment_controls();
@ -258,7 +258,7 @@
echo " <TR>";
echo " <TD>";
echo " <TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" WIDTH=\"100%\">";
// Subject:
echo " <TR>";
echo " <TD ALIGN=\"right\" WIDTH=\"5%\">";

View File

@ -36,47 +36,48 @@
<?
}
function abstract($story) {
print "\n<!-- story: \"$story->subject\" -->\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($story->subject) ."</B></TD></TR>\n";
print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
print " <TR>\n";
print " <TD>\n";
print " <FONT COLOR=\"#7C7C7C\"><SMALL>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?><? if ($story->department) print "<BR>from the $story->department dept."; ?><? print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL><A HREF=\"?section=". urlencode($story->section) ."\"><FONT COLOR=\"#83997A\">$story->section</FONT></A></SMALL>\n";
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR>\n";
print " <TD COLSPAN=\"2\">\n";
if ($story->abstract) print "<P>". check_output($story->abstract, 1) ."</P>\n";
if ($story->updates) print "<P><FONT COLOR=\"#666699\">". t("Editor's note") .":</FONT> ". check_output($story->updates, 1) ."</P>\n";
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR><TD COLSPAN=\"2\">". theme_morelink($this, $story) ."</TD></TR>\n";
print "</TABLE>\n";
print "<BR><BR>\n\n";
}
function article($story, $reply = "") {
print "\n<!-- story: \"$story->subject\" -->\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($story->subject) ."</B></TD></TR>\n";
print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
print " <TR><TD><FONT COLOR=\"#7C7C7C\"><SMALL>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?><? if ($story->department) print "<BR>from the $story->department dept."; ?><? print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL><A HREF=\"index.php?section=". urlencode($story->section) ."\"><FONT COLOR=\"#83997A\">$story->section</FONT></A></SMALL></TD></TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR>\n";
print " <TD COLSPAN=\"2\">\n";
if ($story->abstract) print " <P>". check_output($story->abstract, 1) ."</P>\n";
if ($story->updates) print " <P><FONT COLOR=\"#666699\">". t("Editor's note") .":</FONT>". check_output($story->updates, 1) ."</P>\n";
if ($story->article) print " <P>". check_output($story->article, 1) ."</P>\n";
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR><TD ALIGN=\"right\" COLSPAN=\"2\">". $reply ."</TD></TR>\n";
print "</TABLE>\n";
print "<BR><BR>\n\n";
function story($story, $reply = 0) {
if (!$reply) {
print "\n<!-- story: \"$story->subject\" -->\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($story->subject) ."</B></TD></TR>\n";
print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
print " <TR>\n";
print " <TD>\n";
print " <FONT COLOR=\"#7C7C7C\"><SMALL>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?><? if ($story->department) print "<BR>from the $story->department dept."; ?><? print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL><A HREF=\"?section=". urlencode($story->section) ."\"><FONT COLOR=\"#83997A\">$story->section</FONT></A></SMALL>\n";
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR>\n";
print " <TD COLSPAN=\"2\">\n";
if ($story->abstract) print "<P>". check_output($story->abstract, 1) ."</P>\n";
if ($story->updates) print "<P><FONT COLOR=\"#666699\">". t("Editor's note") .":</FONT> ". check_output($story->updates, 1) ."</P>\n";
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR><TD COLSPAN=\"2\">". theme_morelink($this, $story) ."</TD></TR>\n";
print "</TABLE>\n";
print "<BR><BR>\n\n";
}
else {
print "\n<!-- story: \"$story->subject\" -->\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($story->subject) ."</B></TD></TR>\n";
print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
print " <TR><TD><FONT COLOR=\"#7C7C7C\"><SMALL>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?><? if ($story->department) print "<BR>from the $story->department dept."; ?><? print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL><A HREF=\"index.php?section=". urlencode($story->section) ."\"><FONT COLOR=\"#83997A\">$story->section</FONT></A></SMALL></TD></TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR>\n";
print " <TD COLSPAN=\"2\">\n";
if ($story->abstract) print " <P>". check_output($story->abstract, 1) ."</P>\n";
if ($story->updates) print " <P><FONT COLOR=\"#666699\">". t("Editor's note") .":</FONT>". check_output($story->updates, 1) ."</P>\n";
if ($story->article) print " <P>". check_output($story->article, 1) ."</P>\n";
print " </TD>\n";
print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
print " <TR><TD ALIGN=\"right\" COLSPAN=\"2\">". $reply ."</TD></TR>\n";
print "</TABLE>\n";
print "<BR><BR>\n\n";
}
}
function controls() {

View File

@ -69,74 +69,75 @@
<?
}
function abstract($story) {
$timestamp = format_date($story->timestamp);
function story($story, $reply = 0) {
if (!$reply) {
$timestamp = format_date($story->timestamp);
print "\n<!-- story: \"$story->subject\" -->\n";
?>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="<? echo $this->brcolor1; ?>" WIDTH="100%">
<TR><TD>
<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" WIDTH="100%">
<TR><TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor1; ?>" WIDTH="100%"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><FONT COLOR="<? echo $this->fgcolor1; ?>"><B><? echo "". check_output($story->subject, 1) .""; ?></B></FONT></td><td valign="middle" align="center"><IMG SRC="themes/<? print $this->themename; ?>/images/icon.gif" valign="middle"></td></tr></table></TD></TR>
<TR BGCOLOR="<? echo $this->bgcolor2; ?>">
<?
if ($story->section) { print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\">"; }
else { print "<TD COLSPAN=\"2\" BGCOLOR=\"$this->bgcolor2\">"; }
if ($story->userid) { print "<SMALL>Posted by " . format_username($story->userid) . " on $timestamp"; }
else { print "<SMALL>Posted by $anonymous on $timestamp"; }
if ($story->department) { print " - from the $story->department dept."; }
print "</SMALL>";
if ($story->section) { print "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\"><B><A HREF=\"index.php?section=" . urlencode($story->section) . "\"><FONT COLOR=\"$this->sectioncolor\">$story->section</FONT></A></B>"; }
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor2; ?>">
<TD BGCOLOR="<? echo $this->bgcolor2 ?>" COLSPAN="2">
<?
echo "<P>" . check_output($story->abstract, 1) ."</P>";
if ($story->updates) {
echo "<P><FONT COLOR=\"$this->fgcolor3\">Editor's note by " . format_username($editor) . ":</FONT> ". check_output($story->updates, 1) ."</P>";
}
print "\n<!-- story: \"$story->subject\" -->\n";
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor3; ?>"><TD BGCOLOR="<? echo $this->bgcolor3 ?>" ALIGN="right" COLSPAN="2"><? echo theme_morelink($this, $story) ?></TD></TR>
</TABLE></TD></TR></TABLE><BR>
<?
}
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="<? echo $this->brcolor1; ?>" WIDTH="100%">
<TR><TD>
<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" WIDTH="100%">
<TR><TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor1; ?>" WIDTH="100%"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><FONT COLOR="<? echo $this->fgcolor1; ?>"><B><? echo "". check_output($story->subject, 1) .""; ?></B></FONT></td><td valign="middle" align="center"><IMG SRC="themes/<? print $this->themename; ?>/images/icon.gif" valign="middle"></td></tr></table></TD></TR>
<TR BGCOLOR="<? echo $this->bgcolor2; ?>">
<?
if ($story->section) { print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\">"; }
else { print "<TD COLSPAN=\"2\" BGCOLOR=\"$this->bgcolor2\">"; }
if ($story->userid) { print "<SMALL>Posted by " . format_username($story->userid) . " on $timestamp"; }
else { print "<SMALL>Posted by $anonymous on $timestamp"; }
if ($story->department) { print " - from the $story->department dept."; }
print "</SMALL>";
if ($story->section) { print "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\"><B><A HREF=\"index.php?section=" . urlencode($story->section) . "\"><FONT COLOR=\"$this->sectioncolor\">$story->section</FONT></A></B>"; }
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor2; ?>">
<TD BGCOLOR="<? echo $this->bgcolor2 ?>" COLSPAN="2">
<?
echo "<P>" . check_output($story->abstract, 1) ."</P>";
if ($story->updates) {
echo "<P><FONT COLOR=\"$this->fgcolor3\">Editor's note by " . format_username($editor) . ":</FONT> ". check_output($story->updates, 1) ."</P>";
}
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor3; ?>"><TD BGCOLOR="<? echo $this->bgcolor3 ?>" ALIGN="right" COLSPAN="2"><? echo theme_morelink($this, $story) ?></TD></TR>
</TABLE></TD></TR></TABLE><BR>
<?
}
else {
$timestamp = format_date($story->timestamp);
function article($story, $reply = "") {
$timestamp = format_date($story->timestamp);
?>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="<? echo $this->brcolor1; ?>" WIDTH="100%">
<TR><TD>
<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" WIDTH="100%">
<TR><TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor1; ?>"><FONT COLOR="<? echo $this->fgcolor1; ?>"><B><? echo check_output($story->subject, 1); ?></B></FONT></TD></TR>
<TR BGCOLOR="<? echo $this->bgcolor3; ?>">
<?
if ($story->section) { print "<TD BGCOLOR=\"$this->bgcolor3\">"; }
else { print "<TD COLSPAN=\"2\" BGCOLOR=\"$this->bgcolor3\">"; }
if ($story->userid) { print "<SMALL>Posted by " . format_username($story->userid) . " on $timestamp"; }
else { print "<SMALL>Posted by $anonymous on $timestamp"; }
if ($story->department) { print " - from the $story->department dept."; }
print "</SMALL>";
if ($story->section) { print "</TD><TD BGCOLOR=\"$this->bgcolor3\" ALIGN=\"center\"><B><A HREF=\"index.php?section=" . urlencode($story->section) . "\"><FONT COLOR=\"$this->sectioncolor\">$story->section</FONT></A></B>"; }
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor2; ?>">
<TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor2 ?>" >
<?
if ($story->abstract) print "<P>". check_output($story->abstract, 1) ."</P>\n";
if ($story->updates) print "<P><FONT COLOR=\"$this->bgcolor2\">Editor's note:</FONT> ". check_output($story->updates, 1) ."</P>\n";
if ($story->article) print "<P>". check_output($story->article, 1) ."</P>\n";
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor3; ?>"><TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor3 ?>" ALIGN="right"><? echo "$reply"; ?></TD></TR>
</TABLE></TD></TR></TABLE><BR>
<?
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="<? echo $this->brcolor1; ?>" WIDTH="100%">
<TR><TD>
<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" WIDTH="100%">
<TR><TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor1; ?>"><FONT COLOR="<? echo $this->fgcolor1; ?>"><B><? echo check_output($story->subject, 1); ?></B></FONT></TD></TR>
<TR BGCOLOR="<? echo $this->bgcolor3; ?>">
<?
if ($story->section) { print "<TD BGCOLOR=\"$this->bgcolor3\">"; }
else { print "<TD COLSPAN=\"2\" BGCOLOR=\"$this->bgcolor3\">"; }
if ($story->userid) { print "<SMALL>Posted by " . format_username($story->userid) . " on $timestamp"; }
else { print "<SMALL>Posted by $anonymous on $timestamp"; }
if ($story->department) { print " - from the $story->department dept."; }
print "</SMALL>";
if ($story->section) { print "</TD><TD BGCOLOR=\"$this->bgcolor3\" ALIGN=\"center\"><B><A HREF=\"index.php?section=" . urlencode($story->section) . "\"><FONT COLOR=\"$this->sectioncolor\">$story->section</FONT></A></B>"; }
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor2; ?>">
<TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor2 ?>" >
<?
if ($story->abstract) print "<P>". check_output($story->abstract, 1) ."</P>\n";
if ($story->updates) print "<P><FONT COLOR=\"$this->bgcolor2\">Editor's note:</FONT> ". check_output($story->updates, 1) ."</P>\n";
if ($story->article) print "<P>". check_output($story->article, 1) ."</P>\n";
?>
</TD>
</TR>
<TR BGCOLOR="<? echo $this->bgcolor3; ?>"><TD COLSPAN="2" BGCOLOR="<? echo $this->bgcolor3 ?>" ALIGN="right"><? echo "$reply"; ?></TD></TR>
</TABLE></TD></TR></TABLE><BR>
<?
}
}
function controls() {