set_filenames(array('NewsOnIndex' => NBC_NEWS_PATH.'template/NewsOnIndex.tpl')); $conf_nbc_News = explode(";" ,$conf['nbc_News']); $conf['nb_news_homepage'] = $conf_nbc_News[0]; $conf['nb_news_page'] = $conf_nbc_News[1]; $conf['nb_news_page_option'] = explode("," ,$conf_nbc_News[2]); $user['forbidden_news'] = calculate_news_permissions($user['id']); $query = ' SELECT n.id AS new_id , n.date , n.author FROM '.NEWS_TABLE.' AS n WHERE n.id NOT IN ('.$user['forbidden_news'].') ORDER BY date DESC LIMIT '.$conf['nb_news_homepage'].' ;'; $result = pwg_query($query); $start=0; while ($row = mysql_fetch_array($result)) { if ($start == 0) $template->assign('news', array( 'U_NEWS' => NBC_NEWS_PATH.'news.php' )); $new_id = $row['new_id']; //get the news translation $query = ' SELECT id AS news_translation_id,language,title,content FROM '.NEWS_TRANSLATION_TABLE.' WHERE new_id = '.$new_id.' '; $no_news_translation=false; $subresult = pwg_query($query.'AND language = \''.$user['language'].'\';'); $subrow = mysql_fetch_array($subresult); //there is a no translation for the user language if (empty($subrow)) { $no_news_translation=true; $research = pwg_query('SELECT language FROM '.USER_INFOS_TABLE.' WHERE user_id = '.$conf['guest_id'].';'); $defaultlanguage = mysql_fetch_array($research); //get the default translation $subresult = pwg_query($query.'AND language = \''.$defaultlanguage['language'].'\';'); $subrow = mysql_fetch_array($subresult); //there is no translation for the default language if (empty($subrow)) { //get the first translation $subresult = pwg_query($query.'LIMIT 1;'); $subrow = mysql_fetch_array($subresult); } } $message=$subrow['content']; $read_more=(strlen($message)!=strlen($subrow['content'])); $template->assign( 'news.a_news', array( 'NEWS_AUTHOR'=>$row['author'], 'NEWS_DATE'=>format_date($row['date'],'mysql_datetime',true), 'TITLE'=>$subrow['title'], 'CONTENT'=>$message )); //there is no tranlstation for this news if ($no_news_translation) { $template->assign('news.a_news.no_news_translation', array()); } //news has been cuted if ($read_more) { $template->assign( 'news.a_news.read_more', array( 'URL' => add_url_params(__FILE__, array( 'nb_news_page' => '1', 'start' => $start, )), ) ); } $start++; } if (isset($im_priority)) { $insert_before = $im_priority['NewsOnIndex'] < $im_priority['Categories'] ? '
' : '
'; } else { $insert_before = $conf_nbc_News[0] == 'on' ? '
' : '
'; } //$template->loadfile('index'); $template->uncompiled_code['index'] = str_replace($insert_before, '{NEWSONINDEX_CONTENT}' . $insert_before, $template->uncompiled_code['index']); $template->assign_var_from_handle('NEWSONINDEX_CONTENT', 'NewsOnIndex'); ?>