49 lines
1.9 KiB
PHP
49 lines
1.9 KiB
PHP
<?php
|
|
If (!defined("INBCWE")) {
|
|
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
|
|
}
|
|
class plugins_mybbnews{
|
|
|
|
function register_plugins(& $plugin){
|
|
$plugin->use_hook('frontpage_news',array($this,"newsview"));
|
|
$plugin->use_hook('navigation_mainmodule',array($this,"frontpage_nav"));
|
|
}
|
|
|
|
function newsview(){
|
|
global $db, $config;
|
|
$this->tpl= new Smarty();
|
|
$parser=new textparser(true);
|
|
$root = $_SERVER['DOCUMENT_ROOT'] . $config["path"];
|
|
$this->tpl->compile_dir = $root . '/core/template/templates_c';
|
|
$this->tpl->cache_dir = $root . '/core/template/cache';
|
|
$this->tpl->config_dir = $root . '/core/template/config';
|
|
$this->tpl->caching = $config["caching"];
|
|
$this->tpl->assign("path",$config["path"]."/");
|
|
if(isset($config["theme"]) && is_dir($root . '/modules/news/templates/'.$config["theme"])){
|
|
$this->tpl-> template_dir = $root . '/modules/news/templates/'.$config["theme"];
|
|
}else{
|
|
$this->tpl-> template_dir = $root . '/modules/news/templates/default';
|
|
}
|
|
$result=$db->query("SELECT u.`username`, n.`title`, n.`date`, n.`text`, c.`name`,c.`picture` FROM `" . $config["prefix"] . "news` n LEFT JOIN `" . $config["prefix"] . "news_category` c ON n.`category`=c.`id` LEFT JOIN `" . $config["prefix"] . "users` u ON u.`uid`=n.`author` WHERE n.`active`='true' ORDER BY n.`date` DESC LIMIT 10");
|
|
while($row=$db->fetch_array($result)){
|
|
$row["year"]=date("Y",$row["dateline"]);
|
|
$row["month"]=date("M",$row["dateline"]);
|
|
$row["day"]=date("d",$row["dateline"]);
|
|
$row["time"]=date("h:i",$row["dateline"]);
|
|
$row["date"]=date("d.m.Y",$row["dateline"]);
|
|
$row["text"]=$parser->parse($row["message"]);
|
|
$news[]=$row;
|
|
}
|
|
$this->tpl->assign('news', $news);
|
|
return $this->tpl->fetch('news.tpl',"news");
|
|
}
|
|
|
|
function frontpage_nav($mainmodule){
|
|
global $db, $config,$mainmodule;
|
|
$mainmodule.="<div id=\"frontpage_mybbnews\" class=\"lineitem\">News</div>";
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
?>
|