| 1 |
[- |
| 2 |
$r = shift ; |
| 3 |
$config = $r -> {config} ; |
| 4 |
$dberr = '' ; |
| 5 |
|
| 6 |
eval { require DBIx::Recordset ; } ; |
| 7 |
|
| 8 |
$dberr = "DBI and DBIx::Recordset must be installed: $@" if ($@) ; |
| 9 |
|
| 10 |
if (!$dberr) |
| 11 |
{ |
| 12 |
eval { |
| 13 |
*set = DBIx::Recordset -> Search ({'!DataSource' => $config -> {dbdsn}, |
| 14 |
'!Username' => $config -> {dbuser}, |
| 15 |
'!Password' => $config -> {dbpassword}, |
| 16 |
'!DBIAttr' => { RaiseError => 1, PrintError => 1, LongReadLen => 32765, LongTruncOk => 0, }, |
| 17 |
'!Table' => 'item, itemtext', |
| 18 |
'!TabRelation' => 'item_id = item.id', |
| 19 |
'!Order' => 'creationtime desc', |
| 20 |
'language_id' => $r -> param -> language, |
| 21 |
'category_id' => 1, |
| 22 |
'state' => 1, |
| 23 |
'$max' => 8}) ; |
| 24 |
} ; |
| 25 |
$dberr = "Error accessing $config->{dbdsn}: " . DBIx::Recordset -> LastError . $@ if (DBIx::Recordset -> LastError || $@) ; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
-] |
| 31 |
|
| 32 |
<table width="252" border="0" cellspacing="0" cellpadding="0"> |
| 33 |
<tr> |
| 34 |
<td><img src="[+ $r -> {imageuri} +]h_news.gif" width="152" height="19"/></td> |
| 35 |
</tr> |
| 36 |
<tr> |
| 37 |
<td> </td> |
| 38 |
</tr> |
| 39 |
<tr> |
| 40 |
<td> |
| 41 |
|
| 42 |
[$if !$dberr $] |
| 43 |
[$while ($rec = $set -> Next)$] |
| 44 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
| 45 |
<tr> |
| 46 |
<td bgcolor="#327EA7"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> |
| 47 |
<font color="#FFFFFF"> |
| 48 |
[- |
| 49 |
$date = $rec -> {modtime} ; |
| 50 |
$date =~ /^(\d+)-(\d+)-(\d+)/ ; |
| 51 |
$date = $r -> param -> language eq 'de'?"$3.$2.$1":"$2/$3/$1" ; |
| 52 |
-] |
| 53 |
[+ $date +] |
| 54 |
</font></b></font></td> |
| 55 |
</tr> |
| 56 |
<tr> |
| 57 |
<td bgcolor="#C2D9E5"><img src="[+ $r -> {imageuri} +]linie-news.gif" width="152" height="4"/></td> |
| 58 |
</tr> |
| 59 |
<tr> |
| 60 |
<td bgcolor="#D2E9F5"> |
| 61 |
<table width="100%" border="0" cellspacing="0" cellpadding="3"> |
| 62 |
<tr> |
| 63 |
<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> |
| 64 |
[- |
| 65 |
$txt = $rec -> {description} ; |
| 66 |
$txt =~ s#<#<#g ; |
| 67 |
$txt =~ s#>#>#g ; |
| 68 |
$txt =~ s#B<(.*?)>#<B>$1</B>#g ; |
| 69 |
$txt =~ s#(http://[-a-zA-Z./0-9]+)#<A HREF="$1">$1</A>#g if (!($txt =~ s#L<\"(.*?)\"\|(.*?)>#<A HREF="$2">$1</A>#g)) ; |
| 70 |
-] |
| 71 |
[+ do { local $escmode = 0 ; $txt } +] |
| 72 |
</font></td> |
| 73 |
</tr> |
| 74 |
</table> |
| 75 |
</td> |
| 76 |
</tr> |
| 77 |
</table> |
| 78 |
[$endwhile $] |
| 79 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
| 80 |
<tr> |
| 81 |
<td bgcolor="#327EA7"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> |
| 82 |
<a href="db/news/news.htm"><b><font color="#FFFFFF"> [= more_news =]</font></b></a></font> |
| 83 |
</td> |
| 84 |
</tr> |
| 85 |
<tr> |
| 86 |
<td bgcolor="#C2D9E5"><img src="[+ $r -> {imageuri} +]linie-news.gif" width="152" height="4"/></td> |
| 87 |
</tr> |
| 88 |
<tr> |
| 89 |
<td bgcolor="#327EA7"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> |
| 90 |
<a href="db/add.-category_id-1-.epl"><b><font color="#FFFFFF"> [= add_news =]</font></b></a></font> |
| 91 |
</td> |
| 92 |
</tr> |
| 93 |
<tr> |
| 94 |
<td bgcolor="#C2D9E5"><img src="[+ $r -> {imageuri} +]linie-news.gif" width="152" height="4"/></td> |
| 95 |
</tr> |
| 96 |
</table> |
| 97 |
[$else$] |
| 98 |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
| 99 |
<tr> |
| 100 |
<td bgcolor="#327EA7" align=center><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><b> |
| 101 |
<font color="#FFFFFF"> |
| 102 |
News not available because database is not correctly set up |
| 103 |
</font></b></font></td> |
| 104 |
</tr> |
| 105 |
<tr> |
| 106 |
<td bgcolor="#C2D9E5"><img src="[+ $r -> {imageuri} +]linie-news.gif" width="152" height="4"/></td> |
| 107 |
</tr> |
| 108 |
<tr> |
| 109 |
<td bgcolor="#D2E9F5"> |
| 110 |
<table width="100%" border="0" cellspacing="0" cellpadding="3"> |
| 111 |
<tr> |
| 112 |
<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> |
| 113 |
[+ $dberr +]<br> |
| 114 |
<b>To get the database related parts working, install |
| 115 |
DBI and DBIx::Recordset, setup a database for Embperl, create tables by |
| 116 |
running eg/webutil/setupdb.pl (make sure to edit the DSN inside the |
| 117 |
script first) and enter the correct DSN in eg/web/config.pl.</b> |
| 118 |
</font></td> |
| 119 |
</tr> |
| 120 |
</table> |
| 121 |
</td> |
| 122 |
</tr> |
| 123 |
</table> |
| 124 |
|
| 125 |
[$endif$] |
| 126 |
</td> |
| 127 |
</tr> |
| 128 |
</table> |