i18n::translate('Advanced HTML'),
'type'=>'both',
'descr'=>i18n::translate('This is an HTML block that you can place on your page to add any sort of message you may want. You can insert references to information from your GEDCOM into the HTML text.'),
'canconfig'=>true,
'config'=>array(
'cache'=>0,
'title'=>'',
'html'=>i18n::translate('
Put your title here
Click the configure button')." ".i18n::translate('to change what is printed here.
'),
'gedcom'=>'__current__',
'compat'=>0,
'ui'=>0
)
);
function print_htmlplus_block($block=true, $config='', $side, $index) {
global $ctype, $GEDCOM, $HTML_BLOCK_COUNT, $WT_BLOCKS, $WT_IMAGE_DIR, $WT_IMAGES, $TEXT_DIRECTION, $MULTI_MEDIA, $SHOW_ID_NUMBERS;
// config sanity check
if (empty($config)){$config = $WT_BLOCKS['print_htmlplus_block']['config'];}else{foreach($WT_BLOCKS['print_htmlplus_block']['config'] as $k=>$v){if (!isset($config[$k])){$config[$k] = $v;}}}
if (!isset($HTML_BLOCK_COUNT)){$HTML_BLOCK_COUNT = 0;}$HTML_BLOCK_COUNT++;
/*
* Select GEDCOM
*/
switch($config['gedcom']) {
case '__current__':
break;
case '':
break;
case '__default__':
$GEDCOM=get_site_setting('DEFAULT_GEDCOM');
if (!$GEDCOM) {
foreach (get_all_gedcoms() as $gedcom) {
$GEDCOM=$gedcom;
break;
}
}
break;
default:
if (get_gedcom_setting(get_gedcom_from_id($config['gedcom']), 'imported')) {
$GEDCOM = $config['gedcom'];
}
break;
}
/*
* Initiate the stats object.
*/
if($config['compat'] == 1)
{
require_once WT_ROOT.'includes/classes/class_stats_compat.php';
$stats = new stats_compat($GEDCOM);
}
elseif($config['ui'] == 1)
{
require_once WT_ROOT.'includes/classes/class_stats_ui.php';
$stats = new stats_ui($GEDCOM);
}
else
{
$stats = new stats($GEDCOM);
}
// Make some values from the GEDCOM's 0 HEAD record visible to the world
global $CREATED_SOFTWARE, $CREATED_VERSION, $CREATED_DATE;
$CREATED_SOFTWARE = $stats->gedcomCreatedSoftware();
$CREATED_VERSION = $stats->gedcomCreatedVersion();
$CREATED_DATE = $stats->gedcomDate();
/*
* First Pass.
* Handle embedded language, fact, global, etc. references
* This needs to be done first because the language variables could themselves
* contain embedded keywords.
*/
// Title
$config['title'] = embed_globals($config['title']);
// Content
$config['html'] = embed_globals($config['html']);
/*
* Second Pass.
*/
list($new_tags, $new_values) = $stats->getTags("{$config['title']} {$config['html']}");
// Title
if (strstr($config['title'], '#')){$config['title'] = str_replace($new_tags, $new_values, $config['title']);}
// Content
$config['html'] = str_replace($new_tags, $new_values, $config['html']);
/*
* Restore Current GEDCOM
*/
$GEDCOM = WT_GEDCOM;
/*
* Start Of Output
*/
$id = "html_block{$HTML_BLOCK_COUNT}";
$title = "";
if ($config['title'] != '') {
if ($WT_BLOCKS['print_htmlplus_block']['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 .= ""
."'
;
}
}
$title .= $config['title'];
}
if (WT_USER_GEDCOM_ADMIN) {
$title .= help_link('index_htmlplus_a');
} else {
$title .= help_link('index_htmlplus');
}
$content = $config['html'];
if ($config['title'] == '' && $WT_BLOCKS['print_htmlplus_block']['canconfig']) {
if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=="user" && WT_USER_ID) {
if ($ctype=="gedcom") {
$name = str_replace("'", "\'", $GEDCOM);
} else {
$name = WT_USER_NAME;
}
$content .= " "
.""
.""
.help_link('index_htmlplus_ahelp');
}
}
global $THEME_DIR;
if ($block) {
require $THEME_DIR.'templates/block_small_temp.php';
} else {
require $THEME_DIR.'templates/block_main_temp.php';
}
}
function print_htmlplus_block_config($config)
{
global $ctype, $WT_BLOCKS, $TEXT_DIRECTION, $GEDCOM;
$useFCK = file_exists(WT_ROOT.'modules/FCKeditor/fckeditor.php');
$templates = array();
$d = dir('blocks/');
while(false !== ($entry = $d->read()))
{
if(strstr($entry, 'block_htmlplus_'))
{
$tpl = file("blocks/{$entry}");
$info = array_shift($tpl);
$bits = explode('|', $info);
if(count($bits) != 2)
{
$bits = array($entry, '');
}
$templates[] = array(
'filename' =>$entry,
'title' =>$bits[0],
'description' =>$bits[1],
'template' =>htmlspecialchars(join('', $tpl),ENT_COMPAT,'UTF-8')
);
}
}
$d->close();
// config sanity check
if(empty($config)){$config = $WT_BLOCKS['print_htmlplus_block']['config'];}else{foreach($WT_BLOCKS['print_htmlplus_block']['config'] as $k=>$v){if (!isset($config[$k])){$config[$k] = $v;}}}
// title
$config['title'] = htmlentities($config['title'], ENT_COMPAT, 'UTF-8');
print "