#[BOFN]###############################################################################
#
#
#Pagenews - a free script to publish news on websites
#Copyright (C) 2004,2005,2006,2007,2008 Philipp Kindt
#
#This file is part of Pagenews.
#
# 	 This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#[EOFN]###############################################################################


#this package provides a view of the templates that inserts "edit-me" links
# more specific, it cares bout the edit-boxes when we are in template editor view.


package dntempeditor_chooser;
require dnhtml_injector;

########################################################################
#makes editor view of template html $_[0], returns suitable code
#needs template name in $_[1]
sub modify_html_for_edit_view{

	my $injector = dnhtml_injector->new();

	#temporarily switch of editor mode view flag to avoid endless looping
	my $emode_flag = $donparser::editor_mode;
	$donparser::editor_mode = "false";
	
	my $parser = donparser->new(dntemplatemanager::determine_path("internal"));

	$parser->open("dnadmin_tempeditor_chooser_prefix");
	$parser->add_handler("DNTEMPEDITOR_CHOOSER_TEMPLATE_NAME",$_[1]);
	
	$parser->parse();
	my $prefix = $parser->get_text();
	$parser->reset();
	$parser->open("dnadmin_tempeditor_chooser_suffix");
	$parser->add_handler("DNTEMPEDITOR_CHOOSER_TEMPLATE_NAME",$_[1]);

	$parser->parse();
	my $suffix =$parser->get_text();

	$injector->set_prefix($prefix);
	$injector->set_suffix($suffix);	
	my $rv = $injector->inject_html($_[0]);	
	#restore editor mode flag
	$donparser::editor_mode = $emode_flag;
	
	return $rv;
}
;

