Beispiel #1
0
function LaunchExport()
{
	xoops_cp_header();
	adminmenu(4);
	echo '<br />';
	$story = new nw_NewsStory();
	$topic= new nw_NewsTopic();
	$exportedstories=array();
	$date1=$_POST['date1'];
	$date2=$_POST['date2'];
	$timestamp1=mktime(0,0,0,intval(substr($date1,5,2)), intval(substr($date1,8,2)), intval(substr($date1,0,4)));
	$timestamp2=mktime(23,59,59,intval(substr($date2,5,2)), intval(substr($date2,8,2)), intval(substr($date2,0,4)));
	$topiclist='';
	if(isset($_POST['export_topics'])) {
		$topiclist=implode(',',$_POST['export_topics']);
	}
	$topicsexport=intval($_POST['includetopics']);
	$tbltopics=array();
	$exportedstories=$story->NewsExport($timestamp1, $timestamp2, $topiclist, $topicsexport, $tbltopics);
	if(count($exportedstories)) {
		$xmlfile=XOOPS_ROOT_PATH.'/uploads/nw_stories.xml';
		$fp=fopen($xmlfile,'w');
		if(!$fp) {
			redirect_header('index.php',4,sprintf(_AM_NW_EXPORT_ERROR,$xmlfile));
		}

		fwrite($fp,nw_utf8_encode("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"));
		fwrite($fp,nw_utf8_encode("<nw_stories>\n"));
		if($topicsexport) {
			foreach($tbltopics as $onetopic) {
				$topic->nw_NewsTopic($onetopic);
				$content = "<nw_topic>\n";
				$content .= sprintf("\t<topic_id>%u</topic_id>\n",$topic->topic_id());
				$content .= sprintf("\t<topic_pid>%u</topic_pid>\n",$topic->topic_pid());
				$content .= sprintf("\t<topic_imgurl>%s</topic_imgurl>\n",$topic->topic_imgurl());
				$content .= sprintf("\t<topic_title>%s</topic_title>\n",$topic->topic_title('F'));
				$content .= sprintf("\t<menu>%d</menu>\n",$topic->menu());
				$content .= sprintf("\t<topic_frontpage>%d</topic_frontpage>\n",$topic->topic_frontpage());
				$content .= sprintf("\t<topic_rssurl>%s</topic_rssurl>\n",$topic->topic_rssurl('E'));
				$content .= sprintf("\t<topic_description>%s</topic_description>\n",$topic->topic_description());
				$content .= sprintf("</nw_topic>\n");
				$content = nw_utf8_encode($content);
				fwrite($fp,$content);
			}
		}

		foreach($exportedstories as $onestory) {
			$content = "<xoops_story>\n";
    		$content .= sprintf("\t<storyid>%u</storyid>\n",$onestory->storyid());
    		$content .= sprintf("\t<uid>%u</uid>\n",$onestory->uid());
    		$content .= sprintf("\t<uname>%s</uname>\n",$onestory->uname());
    		$content .= sprintf("\t<title>%s</title>\n",$onestory->title());
    		$content .= sprintf("\t<created>%u</created>\n",$onestory->created());
    		$content .= sprintf("\t<published>%u</published>\n",$onestory->published());
    		$content .= sprintf("\t<expired>%u</expired>\n",$onestory->expired());
    		$content .= sprintf("\t<hostname>%s</hostname>\n",$onestory->hostname());
    		$content .= sprintf("\t<nohtml>%d</nohtml>\n",$onestory->nohtml());
    		$content .= sprintf("\t<nosmiley>%d</nosmiley>\n",$onestory->nosmiley());
    		$content .= sprintf("\t<hometext>%s</hometext>\n",$onestory->hometext());
    		$content .= sprintf("\t<bodytext>%s</bodytext>\n",$onestory->bodytext());
    		$content .= sprintf("\t<description>%s</description>\n",$onestory->description());
    		$content .= sprintf("\t<keywords>%s</keywords>\n",$onestory->keywords());
    		$content .= sprintf("\t<counter>%u</counter>\n",$onestory->counter());
    		$content .= sprintf("\t<topicid>%u</topicid>\n",$onestory->topicid());
    		$content .= sprintf("\t<ihome>%d</ihome>\n",$onestory->ihome());
    		$content .= sprintf("\t<notifypub>%d</notifypub>\n",$onestory->notifypub());
    		$content .= sprintf("\t<story_type>%s</story_type>\n",$onestory->type());
    		$content .= sprintf("\t<topicdisplay>%d</topicdisplay>\n",$onestory->topicdisplay());
    		$content .= sprintf("\t<topicalign>%s</topicalign>\n",$onestory->topicalign());
    		$content .= sprintf("\t<comments>%u</comments>\n",$onestory->comments());
    		$content .= sprintf("\t<rating>%f</rating>\n",$onestory->rating());
	    	$content .= sprintf("\t<votes>%u</votes>\n",$onestory->votes());
    		$content .= sprintf("</xoops_story>\n");
    		$content = nw_utf8_encode($content);
    		fwrite($fp,$content);
		}
		fwrite($fp,nw_utf8_encode("</nw_stories>\n"));
		fclose($fp);
		$xmlfile=XOOPS_URL.'/uploads/nw_stories.xml';
		printf(_AM_NW_EXPORT_READY,$xmlfile,NW_MODULE_URL . '/admin/index.php?op=deletefile&amp;type=xml');
	} else {
		printf(_AM_NW_EXPORT_NOTHING);
	}
}