theme.class 11.6 KB
Newer Older
Dries's avatar
Dries committed
1
2
<?

Jeroen's avatar
Jeroen committed
3

Dries's avatar
Dries committed
4
5
 class Theme {
   ### color set #1:
Jeroen's avatar
Jeroen committed
6
   var $bgcolor1 = "#9370DB";   // background color
Jeroen's avatar
Jeroen committed
7
   var $fgcolor1 = "#FEFEFE";   // table body color
Jeroen's avatar
Jeroen committed
8
   var $hlcolor1 = "#FF00FF";   // high-light color
Dries's avatar
Dries committed
9
10

   ### color set #2:
Jeroen's avatar
Jeroen committed
11
12
   var $bgcolor2 = "#836FFF";
   var $fgcolor2 = "#FEFEFE";
Dries's avatar
Dries committed
13
14
15
   var $hlcolor2 = "#666699";

   ### color set #3:
Jeroen's avatar
Jeroen committed
16

Jeroen's avatar
Jeroen committed
17
   var $bgcolor3 = "#FEFEFE";
Dries's avatar
Dries committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
   var $fgcolor3 = "yellow";
   var $hlcolor3 = "yellow";

   ######
   # Syntax.......: header($title);
   # Description..: a function to draw the page header.
   function header($title) {
    ?>
     <HTML>
     <HEAD>
      <TITLE><? include "config.inc"; echo $sitename; ?></TITLE>
      <META NAME="description" CONTENT="drop.org">
      <META NAME="keywords" CONTENT="drop, weblog, portal, community, news, article, announcements, stories, story, computer, science, space, hype, cult, geek, nerd, foo, bar">
     </HEAD>
     <STYLE type="text/css"> 
      <!--
       BODY,TD,P,UL,LI,DIV,FORM,EM,BLOCKQUOTE { font-size: 8pt; font-family: verdana,helvetica,arial; }
      -->
     </STYLE>
     <BODY TEXT="#000000" BGCOLOR="#FFFFFF" ALINK="#CCCCCC" LINK="#444444" VLINK="#666666">
      <TABLE BORDER="0" CELLPADDING="2" CELLSPACING="2">
       <TR>
        <TD COLSPAN="3"><IMG SRC="/themes/default/images/logo.gif" ALT="drop.org logo"></TD>
       </TR>
       <TR><TD ALIGN="right" COLSPAN="3"><FONT SIZE="2"><A HREF="">home</A> | <A HREF="/faq.php">faq</A> | <A HREF="/search.php">search</A> | <A HREF="/submit.php">submit news</A> | <A HREF="/account.php">user account</A> | <A HREF="/webboard.php">webboard</A></FONT><HR></TD></TR>
       <TR>
        <TD VALIGN="top" WIDTH="120">
         <?
          dbconnect();

          ### Display admin blocks:
          displayAdminblock($this);

         ### Display referring sites:
         displayReferrals($this);
        ?>
       </TD>
       <TD VALIGN="top" WIDTH="440">
    <?
   }

   ######
   # Syntax.......: abstract(...);
   # Description..: a function to draw an abstract story box, that is the
   #                boxes displayed on the main page.
   function abstract($editor, $informant, $timestamp, $subject, $abstract, $comments, $category, $department, $link) {
     $timestamp = date("l, F d, Y - h:i:s A", $timestamp);

     include "config.inc";
      ?>
       <TABLE BORDER="0" CELLPADDING="4" WIDTH="100%">
        <TR BGCOLOR="<? echo $this->bgcolor1; ?>"><TD COLSPAN="2"><FONT COLOR="<? echo $this->bgcolor2; ?>"><B><? echo $subject; ?></B></FONT></TD></TR>
Jeroen's avatar
Jeroen committed
70
        <TR BGCOLOR="<? echo $this->bgcolor1; ?>">
Dries's avatar
Dries committed
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
         <TD>
         <?
          if ($informant) {
            print "<FONT SIZE=\"-1\">Posted by <A HREF=\"account.php?op=userinfo&uname=$informant\">$informant</A> on $timestamp"; ?><? if ($department) echo "<BR>from the $department dept."; ?><? print "</FONT></TD><TD ALIGN=\"center\" WIDTH=\"80\"><B><A HREF=\"search.php?category=$category\"><FONT COLOR=\"#83997A\">$category</FONT></A></B>";
          }
          else {
            print "<FONT SIZE=\"-1\">Posted by $anonymous on $timestamp"; ?><? if ($department) echo "<BR>from the $department dept."; ?><? print "</FONT></TD><TD ALIGN=\"center\" WIDTH=\"80\"><A HREF=\"search.php?category=$category\">$category</A>";
          }
         ?>
        </TD>
       </TR>
       <TR BGCOLOR="<? echo $this->bgcolor3; ?>">
        <TD COLSPAN="2">
        <?
         if ($comments) {
           echo "<P>$abstract</P><P><FONT COLOR=\"$this->bgcolor1\">Editor's note by <A HREF=\"account.php?op=userinfo&uname=$editor\">$editor</A>:</FONT> $comments</P>";
         }
         else {
           echo $abstract;
         }        
        ?>
        </TD>
       </TR>
      <TR BGCOLOR="<? echo $this->bgcolor2; ?>"><TD ALIGN="right" COLSPAN="2"><? echo $link ?></TD></TR>
     </TABLE><BR>
    <?	
   }

   ######
   # Syntax.......: article(...);
   # Description..: a function to dispay a complete article (without user 
   #                comments).  It's what you get when you followed for
   #                instance one of read-more links on the main page.
   function article($editor, $informant, $timestamp, $subject, $department, $abstract, $comments, $article, $reply) {
     $timestamp = date("l, F d, Y - h:i:s A", $timestamp);

      include "config.inc";
       ?>
      <TABLE BORDER="0" CELLPADDING="4" WIDTH="100%">
       <TR BGCOLOR="<? echo $this->bgcolor1; ?>"><TD><FONT COLOR="<? echo $this->bgcolor2; ?>"><B><? echo $subject; ?></B></FONT></TD></TR>
Jeroen's avatar
Jeroen committed
111
       <TR BGCOLOR="<? echo $this->bgcolor1; ?>">
Dries's avatar
Dries committed
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
        <TD>
         <?
          if ($informant) {
            print "<FONT SIZE=\"-1\">Posted by <A HREF=\"account.php?op=userinfo&uname=$informant\">$informant</A> on $timestamp"; ?><? if ($department) echo "<BR>from the $department dept."; ?><? print "</FONT>";
          }
          else {
            print "<FONT SIZE=\"-1\">Posted by $anonymous on $timestamp"; ?><? if ($department) echo "<BR>from the $department dept."; ?><? print "</FONT>";
          }
         ?>
        </TD>
       </TR>
       <TR BGCOLOR="<? echo $this->bgcolor3; ?>">
        <TD>
         <? 
          if ($abstract) echo "<P>$abstract<P>";
          if ($comments) echo "<P><FONT COLOR=\"$this->bgcolor1\">Editor's note by <A HREF=\"account.php?op=userinfo&uname=$editor\">$editor</A>:</FONT> $comments</P>";
          if ($article) echo "<P>$article</P>";
         ?>
        </TD>
       </TR>
      <TR BGCOLOR="<? echo $this->bgcolor2; ?>"><TD ALIGN="right"><? echo "$reply"; ?></TD></TR>
     </TABLE><BR>
    <? 
   }

   ######
   # Syntax.......: comment(...);
   # Description..: this function is used to theme user comments.
   function comment($poster, $subject, $tid, $date, $url, $email, $score, $reason, $comment, $link, $thread = "") {
     include "config.inc";

     if (!eregi("[a-z0-9]",$poster)) $poster = $anonymous;
     if (!eregi("[a-z0-9]",$subject)) $subject = "[no subject]";
     echo "<A NAME=\"$tid\">";

     ### Create comment header:
     echo "<TABLE BORDER=\"0\" CELLPADDING=\"4\" CELLSPACING=\"2\" WIDTH=\"100%\">";
     echo " <TR BGCOLOR=\"$this->bgcolor2\">";
     echo "  <TD>";
     echo "   <TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\"WIDTH=\"100%\">";

     ### Subject:
     echo "    <TR>";
     echo "     <TD ALIGN=\"right\" WIDTH=\"5%\"><FONT COLOR=\"$this->bgcolor1\"><B>Subject:</B></FONT></TD><TD WIDTH=\"80%\">";
     echo "      <B><FONT COLOR=\"$this->bgcolor1\">$subject</FONT></B>";
     echo " &nbsp; <FONT SIZE=\"2\"> [Score: $score";
     if (isset($reason)) echo ", $comments_meta_reasons[$reason]";
     echo "]</FONT>";
     echo "     </TD>";

     ### Moderation:
     echo "     <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">";
     echo "      <SELECT NAME=\"meta:$tid\">";
     echo "         <OPTION VALUE=\"-1\">Moderate</OPTION>\n";
     for ($i = 0; $i < sizeof($comments_meta_reasons); $i++) {
       echo "       <OPTION VALUE=\"$i\">$comments_meta_reasons[$i]</OPTION>\n";
     }
     echo "      </SELECT>";
     echo "     </TD>";
     echo "    </TR>";

     ### Author:
     echo "    <TR>";
     echo "     <TD ALIGN=\"right\" VALIGN=\"top\">Author:</TD><TD><B>$poster</B> ";
     if ($poster != $anonymous) {
       ### Display extra information line:
       $info .= "<A HREF=\"account.php?op=userinfo&uname=$poster\">user info</A>";
       if ($email) $info .= " | <A HREF=\"mailto:$email\">$email</A>";
       if (eregi("http://",$url)) $info .= " | <A HREF=\"$url\" TARGET=\"_new\">$url</A>";
       echo "<BR><FONT SIZE=\"2\">[ $info ]</FONT>";
     }
     echo "     </TD>";
     echo "    </TR>";

     ### Date
     echo "    <TR><TD ALIGN=\"right\">Date:</TD><TD>". formatTimestamp($date) ."</TD></TR>";

     echo "   </TABLE>";
     echo "  </TD>";
     echo " </TR>";

     ### Print body of comment:
     if ($comment) echo " <TR><TD BGCOLOR=\"$this->bgcolor3\">$comment</TD></TR>";

     ### Print thread (if any):
     if ($thread) echo " <TR><TD BGCOLOR=\"$this->bgcolor2\">$thread</TD></TR>";

     ### Print bottom link(s):
     echo " <TR><TD ALIGN=\"right\" BGCOLOR=\"$this->bgcolor2\">[ $link ]</TD></TR>";
     echo " </TABLE>";
   }

   ######
   # Syntax.......: preview(...);
   # Description..: this function is used to preview a story and is used at
   #                different parts of the homepage: when a visitors sumbits
   #                news, when an editor wants to post news, when people
   #                check the entries in the sumbission queue, etc.
   function preview($editor, $informant, $timestamp, $subject, $department, $abstract, $comments, $article) {
     include "config.inc";
     ?>
      <TABLE BORDER="0" CELLPADDING="4" WIDTH="100%">
       <TR BGCOLOR="<? echo $this->bgcolor1; ?>"><TD><FONT COLOR="<? echo $this->bgcolor2; ?>"><B><? echo $subject; ?></B></FONT></TD></TR>
       <TR BGCOLOR="<? echo $this->bgcolor2; ?>">
        <TD>
         <?
          if ($informant) {
            print "<FONT SIZE=\"-1\">Posted by <A HREF=\"account.php?op=userinfo&uname=$informant\">$informant</A> on $timestamp"; ?><? if ($department) echo "<BR>from the $department dept."; ?><? print "</FONT>";
          }
          else {
            print "<FONT SIZE=\"-1\">Posted by $anonymous on $timestamp"; ?><? if ($department) echo "<BR>from the $department dept."; ?><? print "</FONT>";
          }
         ?>
        </TD>
       </TR>
       <TR BGCOLOR="<? echo $this->bgcolor3; ?>">
        <TD>
         <? 
          if ($abstract) echo "<P>$abstract<P>";
          if ($comments) echo "<P><FONT COLOR=\"$this->bgcolor1\">Editor's note by <A HREF=\"account.php?op=userinfo&uname=$editor\">$editor</A>:</FONT> $comments</P>";
          if ($article) echo "<P>$article</P>";
        ?>
       </TD>
      </TR>
      <TR BGCOLOR="<? echo $this->bgcolor2; ?>"><TD ALIGN="right">&nbsp;</TD></TR>
     </TABLE><BR>
    <?
   }
 
   ######
   # Syntax.......: box($title, $body);
   # Description..: a function to draw a box/block.
   function box($subject, $content) { 
     include "config.inc";
     print "<TABLE BORDER=\"0\" CELLPADDING=\"3\" CELLSPACING=\"3\" WIDTH=\"100%\">";
     print " <TR><TD ALIGN=\"center\" BGCOLOR=\"$this->bgcolor1\" WIDTH=\"100%\"><FONT COLOR=\"$this->fgcolor1\"><B>$subject</B></FONT></TD></TR>";
     print " <TR><TD BGCOLOR=\"$this->bgcolor2\">$content</TD></TR>";
     print "</TABLE><BR>";
   }

   ######
   # Syntax.......: footer();
   # Description..: a function to draw the page footer.
   function footer() {
    ?>
       </TD>
       <TD VALIGN="top" WIDTH="150">
         <?
         global $PHP_SELF;  

         if (strstr($PHP_SELF, "index.php")) {
           global $user;

           ### Display login box:
           displayAccount($this);
 
           ### Display voting poll:
           displayPoll($this);

           ### Display old headlines:
           displayOldHeadlines($this);
         }
         elseif (strstr($PHP_SELF, "account.php")) {
           ### Display account settings:
           displayAccountSettings($this);
         }
         elseif (strstr($PHP_SELF, "article.php")) {
           global $sid; 

           ### Display related links:
           displayRelatedLinks($this, $sid);

           ### Display new headlines:
           displayNewHeadlines($this);
         }
         else {
           ### Display new headlines:
           displayNewHeadlines($this);
         }
        ?>
       </TD>
      </TR>
      <TR>
       <TD ALIGN="center" COLSPAN="3">
        <FONT SIZE="2">[ <A HREF="">home</A> | <A HREF="/faq.php">faq</A> | <A HREF="/search.php">search</A> | <A HREF="/submit.php">submit news</A> | <A HREF="/account.php">user account</A> | <A HREF="/webboard.php">webboard</A> ] </FONT>
       </TD>
      </TR>
     </TABLE>
    </BODY> 
    </HTML>
    <?
   }
 }

?>