Commit 8e94fe16 authored by Dries's avatar Dries

- structure.inc: added category_name($cid) and topic_name($tid).

  They both return a linked string with the respective category,
  or topic name.  Updated all themes to use these new functions.

- (stripped tabs from emsa files, nevermind)
parent 73ad4c76
...@@ -22,27 +22,37 @@ function category_save($edit) { ...@@ -22,27 +22,37 @@ function category_save($edit) {
foreach ($edit as $key=>$value) db_query("UPDATE category SET $key = '". check_input($value) ."' WHERE cid = '$edit[cid]'"); foreach ($edit as $key=>$value) db_query("UPDATE category SET $key = '". check_input($value) ."' WHERE cid = '$edit[cid]'");
} }
// delete category $cid: // delete category $cid:
function category_del($cid) { function category_del($cid) {
db_query("DELETE FROM category WHERE cid = '". check_input($cid) ."'"); db_query("DELETE FROM category WHERE cid = '". check_input($cid) ."'");
db_query("UPDATE node SET cid = 0 WHERE cid = '". check_input($cid) ."'"); db_query("UPDATE node SET cid = 0 WHERE cid = '". check_input($cid) ."'");
} }
// return post threshold:
function category_post_threshold($cid) { function category_post_threshold($cid) {
$category = db_fetch_object(db_query("SELECT post AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); $category = db_fetch_object(db_query("SELECT post AS threshold FROM category WHERE cid = '". check_input($cid) ."'"));
return $category->threshold; return $category->threshold;
} }
// return dump threshold:
function category_dump_threshold($cid) { function category_dump_threshold($cid) {
$category = db_fetch_object(db_query("SELECT dump AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); $category = db_fetch_object(db_query("SELECT dump AS threshold FROM category WHERE cid = '". check_input($cid) ."'"));
return $category->threshold; return $category->threshold;
} }
// return expiration threshold:
function category_expire_threshold($cid) { function category_expire_threshold($cid) {
$category = db_fetch_object(db_query("SELECT expire AS threshold FROM category WHERE cid = '". check_input($cid) ."'")); $category = db_fetch_object(db_query("SELECT expire AS threshold FROM category WHERE cid = '". check_input($cid) ."'"));
return $category->threshold; return $category->threshold;
} }
// return linked string with name of category $cid:
function category_name($cid) {
$category = category_get_object("cid", $cid);
return ($category) ? "<A HREF=\"index.php?category=$category->cid\">$category->name</A>" : "";
}
function category_form_select($type, $edit = array(), $size = 1) { function category_form_select($type, $edit = array(), $size = 1) {
$result = db_query("SELECT * FROM category WHERE type = '$type'"); $result = db_query("SELECT * FROM category WHERE type = '$type'");
while ($category = db_fetch_object($result)) { while ($category = db_fetch_object($result)) {
...@@ -89,6 +99,13 @@ function topic_del($tid) { ...@@ -89,6 +99,13 @@ function topic_del($tid) {
db_query("UPDATE node SET tid = 0 WHERE tid = '". check_input($tid) ."'"); db_query("UPDATE node SET tid = 0 WHERE tid = '". check_input($tid) ."'");
} }
// return linked string with name of topic $tid:
function topic_name($tid, $name = 0) {
$topic = topic_get_object("tid", $tid);
$name = $name ? "<A HREF=\"index.php?topic=$topic->tid\">$topic->name</A> - $name" : "<A HREF=\"index.php?topic=$topic->tid\">$topic->name</A>";
return ($topic->pid) ? topic_name($topic->pid, $name) : $name;
}
// renders a HTML form to select one or more topics: // renders a HTML form to select one or more topics:
function topic_form_select($edit = array(), $size = 1) { function topic_form_select($edit = array(), $size = 1) {
foreach (topic_tree() as $tid=>$name) { foreach (topic_tree() as $tid=>$name) {
......
...@@ -60,15 +60,13 @@ function story($story, $main = 0) { ...@@ -60,15 +60,13 @@ function story($story, $main = 0) {
<TD> <TD>
<?php <?php
echo strtr(t("by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "small"))); echo strtr(t("by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "small")));
?> ?>
</TD> </TD>
<TD ALIGN="right"> <TD ALIGN="right">
<?php <?php
echo "<A HREF=\"index.php?category=$story->cid\">". check_output($story->category) ."</A> / <A HREF=\"index.php?topic=$story->tid\">". check_output($story->topic) ."</A>"; echo category_name($story->cid) ." / ". topic_name($story->tid);
?> ?>
</TD> </TD>
</TR> </TR>
......
...@@ -117,7 +117,7 @@ function story($story, $main = 0) { ...@@ -117,7 +117,7 @@ function story($story, $main = 0) {
<tr> <tr>
<td class="lgl"><img src="themes/goofy/images/null.gif" alt=""></td> <td class="lgl"><img src="themes/goofy/images/null.gif" alt=""></td>
<td class="lgcnt"><small><?php echo strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?></small></td> <td class="lgcnt"><small><?php echo strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?></small></td>
<td class="lgcnt" nowrap><div align="right"><?php echo "<A HREF=\"index.php?category=$story->cid\">". check_output($story->category) ."</A> / <A HREF=\"index.php?topic=$story->tid\">". check_output($story->topic) ."</A>"; ?></div></td> <td class="lgcnt" nowrap><div align="right"><?php echo category_name($story->cid) ." / ". topic_name($story->tid); ?></div></td>
<td class="lgr"><img src="themes/goofy/images/null.gif" alt=""></td> <td class="lgr"><img src="themes/goofy/images/null.gif" alt=""></td>
</tr> </tr>
<tr> <tr>
......
...@@ -103,9 +103,7 @@ function story($story, $main = 0) { ...@@ -103,9 +103,7 @@ function story($story, $main = 0) {
<tr> <tr>
<td align="left" background="themes/jeroen/images/menutitle.gif" nowrap> <td align="left" background="themes/jeroen/images/menutitle.gif" nowrap>
<FONT COLOR="#FEFEFE"> <FONT COLOR="#FEFEFE">
<?php <?php
switch (rand(0,13)) { switch (rand(0,13)) {
case 0: $how = "Yelled"; break; case 1: $how = "Whispered"; break; case 0: $how = "Yelled"; break; case 1: $how = "Whispered"; break;
case 2: $how = "Reported"; break; case 3: $how = "Posted"; break; case 2: $how = "Reported"; break; case 3: $how = "Posted"; break;
...@@ -116,14 +114,13 @@ function story($story, $main = 0) { ...@@ -116,14 +114,13 @@ function story($story, $main = 0) {
case 12: $how = "Forged"; break; case 12: $how = "Forged"; break;
default: $how = "Sneaked through"; default: $how = "Sneaked through";
} }
echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp), "large")) ."</FONT> echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp), "large")) ."</FONT>";
?>
</FONT> </FONT>
</td> </td>
<td align=\"right\" background=\"themes/jeroen/images/menutitle.gif\" nowrap> <?php
<b><a href=\"index.php?category=$story->cid\">". check_output($story->category) ."</a> / <a href=\"index.php?topic=$story->tid\">". check_output($story->topic) ."</a></b>"; echo "<td align=\"right\" background=\"themes/jeroen/images/menutitle.gif\" nowrap><b>". category_name($story->cid) ." / ". topic_name($story->tid) ."</b>";
?> ?>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -51,7 +51,7 @@ function story($story, $main = 0) { ...@@ -51,7 +51,7 @@ function story($story, $main = 0) {
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 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 " <TR>\n";
print " <TD>\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"))); ?><?php print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL><A HREF=\"index.php?category=$story->cid\"><FONT COLOR=\"#83997A\">". check_output($story->category) ."</FONT></A> / <A HREF=\"index.php?topic=$story->tid\"><FONT COLOR=\"#83997A\">". check_output($story->topic) ."</FONT></A></SMALL>\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"))); ?><?php print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL>". category_name($story->cid) ." / ". topic_name($story->tid) ."</SMALL>\n";
print " </TD>\n"; print " </TD>\n";
print " </TR>\n"; print " </TR>\n";
print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n"; print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
......
...@@ -4,6 +4,14 @@ ALTER TABLE node ADD tid int(10) unsigned DEFAULT '0' NOT NULL; ...@@ -4,6 +4,14 @@ ALTER TABLE node ADD tid int(10) unsigned DEFAULT '0' NOT NULL;
ALTER TABLE story DROP section; ALTER TABLE story DROP section;
ALTER TABLE comments ADD KEY(lid); ALTER TABLE comments ADD KEY(lid);
CREATE TABLE cvs (
user varchar(32) DEFAULT '' NOT NULL,
files text,
status int(2) DEFAULT '0' NOT NULL,
message text,
timestamp int(11) DEFAULT '0' NOT NULL
);
CREATE TABLE category ( CREATE TABLE category (
cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(32) DEFAULT '' NOT NULL, name varchar(32) DEFAULT '' NOT NULL,
......
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