i18n::translate('GEDCOM News'),
'type'=>'gedcom',
'descr'=>i18n::translate('The GEDCOM News block shows the visitor news releases or articles posted by an admin user.
The News block is a good place to announce a significant database update, a family reunion, or the birth of a child.'),
'canconfig'=>true,
'config'=>array(
'cache'=>7,
'limit'=>'nolimit',
'flag'=>0
)
);
/**
* Prints a gedcom news/journal
*
* @todo Add an allowed HTML translation
*/
function print_gedcom_news($block = true, $config='', $side, $index)
{
global $WT_IMAGE_DIR, $WT_IMAGES, $TEXT_DIRECTION, $ctype, $WT_BLOCKS;
if(empty($config)) {
$config = $WT_BLOCKS['print_gedcom_news']['config'];
}
if ($config['flag'] == 0) {
$config['limit'] = 'nolimit';
}
if (isset($_REQUEST['gedcom_news_archive'])) {
$config['limit'] = 'nolimit';
$config['flag'] = 0;
}
$usernews = getUserNews(WT_GEDCOM);
$id = "gedcom_news";
$title = "";
if ($WT_BLOCKS['print_gedcom_news']['canconfig']) {
if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=="user" && WT_USER_ID) {
if ($ctype=="gedcom") {
$name = WT_GEDCOM;
} else {
$name = WT_USER_NAME;
}
$title .= ""
."\n"
;
}
}
$title .= i18n::translate('News');
if(WT_USER_GEDCOM_ADMIN) {
$title .= help_link('index_gedcom_news_adm');
} else {
$title .= help_link('index_gedcom_news');
}
$content = "";
if(count($usernews) == 0)
{
$content .= i18n::translate('No News articles have been submitted.').' ';
}
$c = 0;
$td = time();
foreach($usernews as $news)
{
if ($config['limit'] == 'count') {
if ($c >= $config['flag']) {
break;
}
$c++;
}
if ($config['limit'] == 'date') {
if (floor(($td - $news['date']) / 86400) > $config['flag']) {
break;
}
}
// print "
\n";
$content .= "
\n";
// Look for $GLOBALS substitutions in the News title
$newsTitle = embed_globals($news['title']);
$content .= "".PrintReady($newsTitle)." \n";
$content .= "".format_timestamp($news['date'])."
\n";
// Look for $GLOBALS substitutions in the News text
$newsText = embed_globals($news['text']);
$trans = get_html_translation_table(HTML_SPECIALCHARS);
$trans = array_flip($trans);
$newsText = strtr($newsText, $trans);
$newsText = nl2br($newsText);
$content .= PrintReady($newsText)." \n";
// Print Admin options for this News item
if(WT_USER_GEDCOM_ADMIN) {
$content .= ""
."".i18n::translate('Edit')." | "
."".i18n::translate('Delete')." ";
}
$content .= "
\n";
}
$printedAddLink = false;
if (WT_USER_GEDCOM_ADMIN) {
$content .= "".i18n::translate('Add a News article')."";
$printedAddLink = true;
}
if ($config['limit'] == 'date' || $config['limit'] == 'count') {
if ($printedAddLink) $content .= " | ";
$content .= "".i18n::translate('View archive')."";
$content .= help_link('gedcom_news_archive').' ';
}
global $THEME_DIR;
if ($block) {
require $THEME_DIR.'templates/block_small_temp.php';
} else {
require $THEME_DIR.'templates/block_main_temp.php';
}
}
function print_gedcom_news_config($config)
{
global $ctype, $WT_BLOCKS;
if (empty ($config)) $config = $WT_BLOCKS["print_gedcom_news"]["config"];
if (!isset ($config["limit"])) $config["limit"] = "nolimit";
if (!isset ($config["flag"])) $config["flag"] = 0;
if (!isset($config["cache"])) $config["cache"] = $WT_BLOCKS["print_gedcom_news"]["config"]["cache"];
// Limit Type
echo
'