2025-06-02 10:01:12 +02:00
< ? php
2025-06-23 20:45:15 +02:00
If ( ! defined ( " INBCWE " )) {
2025-06-02 10:01:12 +02:00
die ( " Dieses Script kann nicht ausserhalb des Frameworks laufen! " );
}
2025-06-02 22:38:25 +02:00
use Smarty\Smarty ;
class plugins_mybbnews {
2025-06-02 10:01:12 +02:00
function register_plugins ( $plugin ){
$plugin -> use_hook ( 'frontpage_mybbnews' , array ( $this , " newsview " ));
$plugin -> use_hook ( 'navigation_mainmodule' , array ( $this , " frontpage_nav " ));
}
function newsview (){
global $db , $config ;
2025-06-19 17:16:19 +02:00
date_default_timezone_set ( $config [ 'timezone' ]);
2025-06-02 10:01:12 +02:00
$this -> tpl = new Smarty ();
$parser = new textparser ( true );
$root = $_SERVER [ 'DOCUMENT_ROOT' ] . $config [ " path " ];
2025-06-02 22:38:25 +02:00
$this -> tpl -> setCompileDir ( $root . '/core/template/templates_c' );
$this -> tpl -> setCacheDir ( $root . '/core/template/cache' );
$this -> tpl -> setConfigDir ( $root . '/core/template/config' );
If ( $config [ " caching " ] == 1 ){
$this -> tpl -> setCaching ( Smarty :: CACHING_LIFETIME_SAVED );
}
2025-06-02 10:01:12 +02:00
$this -> tpl -> assign ( " path " , $config [ " path " ] . " / " );
if ( isset ( $config [ " theme " ]) && is_dir ( $root . '/modules/mybbnews/templates/' . $config [ " theme " ])){
2025-06-02 22:38:25 +02:00
$this -> tpl -> setTemplateDir ( $root . '/modules/mybbnews/templates/' . $config [ " theme " ]);
2025-06-02 10:01:12 +02:00
} else {
2025-06-02 22:38:25 +02:00
$this -> tpl -> setTemplateDir ( $root . '/modules/mybbnews/templates/default' );
2025-06-02 10:01:12 +02:00
}
$result = $db -> query ( " SELECT n.*,t.*,( SELECT COUNT(`pid`) FROM `ab_posts` c WHERE c.`replyto`=n.`pid` AND c.`visible`='1') as count FROM `ab_posts` n LEFT JOIN `ab_threads` t ON t.`tid`=n.`tid` WHERE n.`fid`='2' AND n.`replyto`='0' AND n.`visible`='1' ORDER BY n.`dateline` 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 " ]);
2025-06-19 17:16:19 +02:00
$row [ " time " ] = date ( " H:i " , $row [ " dateline " ]);
2025-06-02 10:01:12 +02:00
$row [ " date " ] = date ( " d.m.Y " , $row [ " dateline " ]);
$row [ " text " ] = $parser -> parse ( nl2br ( $row [ " message " ]));
$row [ " title " ] = $parser -> parse ( nl2br ( $row [ " subject " ]));
2025-06-17 21:55:44 +02:00
$row [ " fuid " ] = $row [ " uid " ];
2025-06-02 10:01:12 +02:00
$row [ " comments " ] = $row [ " count " ];
$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 ;
}
}
?>