<?php

require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php' ;
require_once XOOPS_ROOT_PATH.'/class/xoopsform/formelement.php' ;
require_once dirname(dirname(__FILE__)).'/class/formselecttime.php' ;

if( $storyid > 0 ){
	if( $story->isActiveUser() ){
		$xoopsTpl->assign('poster', $story->getUname());
	}else{
		$xoopsTpl->assign('poster', $story->getUname().'&nbsp;('.$story->getVar('hostname').')');
	}
}else{
	$xoopsTpl->assign('poster', icms_member_user_Object::getUnameFromId($my_uid));
}
$xoopsTpl->assign('title', $story->getVar('title', 'e'));
$xoopsTpl->assign('title_raw', $story->getVar('title', 'n'));
$xoopsTpl->assign('text', $story->getVar('text', 'e'));
$xoopsTpl->assign('text_raw', $story->getVar('text', 'n'));
$xoopsTpl->assign('d3news_post_tray_row', $d3news_post_tray_row);
$xoopsTpl->assign('d3news_post_tray_col', $d3news_post_tray_col);

$bt = new D3newsTopic( $mydirname ) ; // GIJ
$xoopsTpl->assign('topic_selbox', $bt->makeTopicSelBox( false , $story->getVar('topicid') , 'topicid' ));
$xoopsTpl->assign('topicimg', $story->getVar('topicimg'));


// ckeditor
$xoopsTpl->assign( 'use_ckeditor' , ! empty( $xoopsModuleConfig['use_ckeditor'] ) && $gperm->group_perm(4) ) ;


// if user has right to set date.
if( $can_use_date = $gperm->group_perm(3) ){
	// autodate
	$xoopsTpl->assign('autodate', $story->getVar('autodate'));
	$post_date_xf = new icms_form_select_time('', 'auto', $auto, _MD_DATE_FORMAT);
	$xoopsTpl->assign('post_date_selector', $post_date_xf->render());
	// auto expire
	$xoopsTpl->assign('autoexpdate', $story->getVar('autoexpdate'));
	$expire_date_xf = new icms_form_select_time('', 'autoexp', $autoexp, _MD_DATE_FORMAT);
	$xoopsTpl->assign('expire_date_selector', $expire_date_xf->render());
}
$xoopsTpl->assign('can_use_date', $can_use_date);

// relation
if( $use_relation = $gperm->group_perm(7) && $d3news_use_relations ){
	foreach( $relations as $key => $relation ){
		$relations[$key]['title'] = $story->getRelatedTitle($relation['linkedid'], $relation['dirname']);
	}
	$xoopsTpl->assign('relations', $relations);
}
$xoopsTpl->assign('use_relation', $use_relation);

// options
// event notifaction (if mode is edit, not display.)
if ($use_notify = ($icms_member_user_Object && $storyid == 0 && !$gperm->group_perm(2))) {
	$xoopsTpl->assign('notifypub', $story->getVar('notifypub'));
}
$xoopsTpl->assign('use_notify', $use_notify);

// If the user has a right to use HTML
if( $use_html = $gperm->group_perm(4) ){
	$xoopsTpl->assign('html', $story->getVar('html'));
}
$xoopsTpl->assign('use_html', $use_html);

// br (GIJ)
$xoopsTpl->assign('br', $story->getVar('br'));
$xoopsTpl->assign('smiley', $story->getVar('smiley'));
$xoopsTpl->assign('xcode', $story->getVar('xcode'));
$xoopsTpl->assign('block', $story->getVar('block'));
$xoopsTpl->assign('ihome', $story->getVar('ihome'));
$xoopsTpl->assign('html', $story->getVar('html'));
if( $use_approve = $gperm->group_perm(2) ){
	$approve_value = isset($_POST['approve']) ? $story->getVar('approve') : $story->getVar('type');
	$xoopsTpl->assign('approve', $approve_value);
}
$xoopsTpl->assign('use_approve', $use_approve);

// for edit
if( $storyid > 0){
	$xoopsTpl->assign('storyid', $storyid);
}

$xoopsTpl->assign('return', empty( $return ) ? 0 : 1 ) ;
$xoopsTpl->assign('gticket', $xoopsGTicket->getTicketHtml( __LINE__ ));

$xoopsTpl->assign('xoops_module_header', '<script type="text/javascript" src="'.$mydirurl.'/index.php?page=javascript"></script>' . $xoopsTpl->get_template_vars( "xoops_module_header" ));

?>
