<?php

// editor.php
// -----------------------------------------------------------------------------
// The XComponents 'server compatibility subsite' homepage
// This page tests the PHP version, and whether the PHP cURL module is installed
// 
// Project    > A16-dmABS-1.5-Feb09
// Copyright  > (C) Digital Mail Limited (2005/2006)
// Author     > RAK for DML
// -----------------------------------------------------------------------------

// Let XComponents know they are running inside dmABS
$dmx_options['abs'] = TRUE;

// Call in the XComponents engine and options file
define('MOD_PHP', substr(PHP_SAPI, 0, 3) != 'cgi'); // Are we running as mod_php?
define('DOCROOT', 
	MOD_PHP && isset($_SERVER['DOCUMENT_ROOT']) ? 
		$_SERVER['DOCUMENT_ROOT'] : 
		(
			MOD_PHP && isset($_SERVER['SCRIPT_FILENAME']) ? 
				substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])) : 
				(
					substr(str_repeat('../', count(explode('/', preg_replace('_/+_', '/', $_SERVER['PHP_SELF'])))-2), 0, -1) != '' ?
						substr(str_repeat('../', count(explode('/', preg_replace('_/+_', '/', $_SERVER['PHP_SELF'])))-2), 0, -1) :
						'.'
				)
		)
	);
include(DOCROOT . '/dmx/dmx_options.php');
include(DOCROOT . '/dmx/core/php/dmx_shop_handler.php');
include(DOCROOT . '/dmx/core/php/dmx_shop_components.php');

$abs_debug = new debug(0);

$abs_root = '';
@include(DOCROOT . '/abs_version_control.php');
include(DOCROOT . $abs_root . '/common/authenticate.php');

// Set overall mode of site operation
// Valid values are 'AFFILIATE', 'ADAPTED'
$abs_sitemode = 'ADAPTED';

// Get site options
$abs_opt = abs_get_site_options($abs_sitemode);

// Is the user an authorised site administrator?
$abs_authorised = ABS_AUTH_METHOD == 'PHP-SESSION'
				&& isset($_SESSION['ABS_AUTH']['status'])
				&& $_SESSION['ABS_AUTH']['status']
				&& abs_get_ip() == $_SESSION['ABS_AUTH']['ip'];

// Resolve version (so we know which panels directory to use).
$abs_content = abs_resolve_version();

// Include panel class, and initialise it
require_once(DOCROOT . '/dmx/core/php/class/panel.class.php');
$panel = new Panel(
	DOCROOT . $abs_root . '/_CONTENT',
	$abs_content['version'],
	$abs_content['default'],
	$abs_content['today']
);
$panel->pan_globals  = array('abs_root', 'abs_opt', 'dmx_glib', 'abs_subject'); // Place these variables in scope of panel renderer
$panel->js_interface = 'abs_editable'; // Push panel names into 'abs_editable' javascript object

$dmx_glib = $abs_root . '/themes/' . $abs_opt['theme'] . '/gen_images/sgm/';

include('editor_support.php');

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Panel Editor</title>

	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<meta name="Copyright" content="Digital Mail Limited 2005-2010">

	<link href="/dmx/core/b0/css/core_dmclub.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/over_dmclub.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/core.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/over.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/print.css" rel="stylesheet" type="text/css" media="Print">
	<!--[if lt IE 7]>
		<link href="/dmx/core/b0/css/ie6.css" rel="stylesheet" type="text/css" media="All" />
	<![endif]-->
	
	<script language="javascript" src="/dmx/core/js/mootools-1.2.4-core-yc.js" type="text/javascript"></script>
	<script language="javascript" src="/dmx/core/js/mootools-1.2.4.2-more.js" type="text/javascript"></script>
	<script language="javascript" src="/dmx/core/b0/js/b0_interface.js" type="text/javascript"></script>

	<script language="javascript">
	
	// Set up page initialisation event handler
	if (window.addEventListener)
	{
		window.addEventListener('load', b0_interface_init, true); // W3C
	}
	else if (window.attachEvent)
	{
		window.attachEvent('onload', b0_interface_init); // IE  - Quirks Mode
	}
	else
	{
		window.onload = b0_interface_init;
	}

	</script>
	
	<!-- TIMYMCE EDITOR -->
	<script language="javascript" type="text/javascript" src="<?=$abs_root;?>/admin/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
	<script language="javascript" type="text/javascript">
	tinyMCE.init({
		theme : 'advanced',
		mode : 'textareas',
		plugins : "safari,table,save,advhr,advimage,advlink,iespell,inlinepopups,zoom,flash,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,xhtmlxtras,-emotions,ibrowser",

		theme_advanced_toolbar_align : 'left',
		theme_advanced_toolbar_location : 'top',
		theme_advanced_statusbar_location : 'bottom',
		theme_advanced_resizing : true,
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace",
		theme_advanced_buttons3_add_before : "tablecontrols",
		theme_advanced_buttons3_add : "iespell,flash,separator,fullscreen",
		theme_advanced_blockformats : 'p,div,h1,h2,h3',
		theme_advanced_styles : 'float_left=float_left;float_left_deep=float_left_deep;float_right=float_right;float_right_deep=float_right_deep;col1i=col1i;col1f=col1f;col2i=col2i;col2f=col2f;divider=divider;infotext=infotext',

		valid_elements : '+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong[class|style],-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style|onmouseover],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],small,-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]',

		remove_linebreaks : false,
		relative_urls : false,
		force_p_newlines : true,
		trim_span_elements : true,
		doctype : '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
		content_css : '<?=$abs_root;?>/themes/<?=$abs_opt["theme"];?>/css/typography_and_colours.css'
	});
	</script>
	
</head>

<body>
<div class="dmb0">

<a name="top"></a>

<!-- ************** -->
<!-- HEADER SECTION -->
<!-- ************** -->

<!-- MAIN HEADER BAR AND BRANDING -->
<div id="header_bar">
	<div class="content" align="center">
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="limit_width_700">
			<tr>
				<td style="width: 99%; vertical-align: middle;" class="title">Panel Editor</td>
				<td><img src="/dmx/core/b0/images/dmclub_header/dmclub_better_biz.gif" alt="better business through  innovative telecoms" width="164" height="71" border="0"></td>
				<td><img src="/dmx/core/b0/images/dmclub_header/dmclub_logo.gif" alt="dmClub logo" width="63" height="71" border="0"></td>
			</tr>
			<tr>
				<td></td>
				<td colspan="2"><img src="/dmx/core/b0/images/dmclub_header/dmclub_highlight.gif" alt="" width="227" height="8" border="0"></td>
			</tr>
		</table>
	</div>
</div>
<!-- END MAIN HEADER BAR AND BRANDING -->

<!-- NAV BAR -->
<div id="nav_bar">
	<div class="content" align="center">
		<div class="limit_width_700">
		 	<div style="float: right">
		 		<!-- RHS NAV BAR CONTENT -->
		 		<!-- END RHS NAV BAR CONTENT -->
		 	</div>
		 	<!-- LHS NAV BAR CONTENT -->
		 	<!-- END LHS NAV BAR CONTENT -->
		 	&nbsp;
		</div>
	</div>
</div>
<!-- END NAV BAR -->

<!-- ERROR MESSAGE BAR -->
<div id="err_msg_bar" style="display: none;">
	<div class="content" align="center">
		<div class="limit_width_700"></div>
	</div>
</div>
<!-- END ERROR MESSAGE BAR -->

<!-- ****************** -->
<!-- END HEADER SECTION -->
<!-- ****************** -->


<!-- ******************* -->
<!-- PAGE BODY CONTAINER -->
<!-- ******************* -->

<div class="content" align="center">
<div class="limit_width_700">

<!-- BODY CONTENT STARTS HERE -->

<?php if (!isset($error_flag)) : ?>		

	<br />
	
	<form name="edit_form" action="<?=$_SERVER['PHP_SELF'];?>" method="post">
	<input type="hidden" name="edit_action" value="save">
	<input type="hidden" name="panel_path" value="<?=$panel_path;?>">
	<input type="hidden" name="return_url" value="<?=$return_url;?>">

	<table width="100%" cellpadding="0" cellspacing="3" border="0">
	<tr>
		<td style="width: 70px;">Panel:</td>
		<td><b><?=$panel_id;?>.html</b></td>
		<td style="text-align: right;"><input type="submit" class="form_submit" value="save new version of panel"></td>
	</tr>
	<tr>
		<td>Location:</td>
		<td><b><?php echo(str_replace($panel_id, '', $panel_path)); ?></b></td>
		<td style="text-align: right;"><input type="submit" class="form_submit" value="cancel edit" onclick="document.edit_form.edit_action.value='cancel';"></td>
	</tr>
	</table>
	
	<br />
	
	<textarea name="content" style="width: 100%;" rows="40">
	<?=$panel_html;?>
	</textarea>
	
	<br>
	
	<input type="submit" class="form_submit" value="save new version of panel"> &nbsp;&nbsp;
	<input type="submit" class="form_submit" value="cancel edit" onclick="document.edit_form.edit_action.value='cancel';">
	
	</form>
	
<?php else : ?>

<h1>Your webserver cannot write to the current panels subdirectory</h1>

<p>
<b>Saving the edited content failed.</b><br>
Attempted write path: <?=$attempted_path;?>
</p>

<p>
To set the right permissions, log onto the server using a secure shell client.<br>
(1) Make sure the directory exists<br>
(2) To set permissions to allow write access on the directory and all the panel files it contains:<br>
<strong>chmod -R 777 <?=$panel->panel_file;?></strong>
</p>

<?php endif; ?>

<!-- END BODY CONTENT -->

<!-- HELP AREA -->         
<a name="help"></a>
<div id="help">
	
	<!-- STANDARD HELP HEADER BAR -->
	<div id="help_header_bar">
		<div style="float: right">
			<!-- RHS LINKS IN HELP HEADER BAR -->
			<a href="#" onclick="popup('http://my.dmclub.net/dmnotes', 'dmNotes'); return false;" class="popup infotext">dmNotes<span class="tipcontents">Counult our full user guide for more details</span></a><a href="#" onclick="popup('http://my.dmclub.net/dmSupport_R13S13/dmSupportDetails.cfm', 'dmSupport'); return false;" class="popup infotext">dmSupport<span class="tipcontents">Contact our helpdesk</span></a>			<!-- END RHS LINKS IN HELP HEADER BAR -->
		</div>
		<!-- LHS HELP HEADER BAR CONTENT -->
		<span class="title">Help for this page</span>
		<!-- END LHS HELP HEADER BAR CONTENT -->
	</div>
	<!-- END STANDARD HELP HEADER BAR -->
	
	<div id="help_contents">
	<!-- VARIABLE HELP AREA CONTENT -->


	<!-- END VARIABLE HELP AREA CONTENT -->

	<!-- STANDARD dmNOTES AND dmSUPPORT LINKS -->
	<h1>Further information and assistance</h1>
	<a href="#" onclick="popup('http://my.dmclub.net/dmnotes', 'dmNotes'); return false;" class="popup">dmNotes:</a> Consult our full user guide for more details<br />
	<a href="#" onclick="popup('http://my.dmclub.net/dmSupport_R13S13/dmSupportDetails.cfm', 'dmSupport'); return false;" class="popup">dmSupport:</a> Contact our helpdesk with a technical enquiry, a question or your comments
	<!-- END STANDARD dmNOTES AND dmSUPPORT LINKS -->
	</div>

</div>
<!-- END HELP AREA -->

</div>
</div>

<!-- *********************** -->
<!-- END PAGE BODY CONTAINER -->
<!-- *********************** -->

<!-- ********** -->
<!-- FOOTER BAR -->
<!-- ********** -->

<br style="clear: both;">
<div id="footer_bar">
	<div class="content" align="center">
		<div class="limit_width_700">
		 	<div style="float: right">
		 		<!-- RHS FOOTER CONTENT -->
		 		<!-- Standard back to top link -->
		 		&nbsp;&nbsp;&nbsp;<a href="#top">back to top</a>
		 		<!-- END RHS FOOTER CONTENT -->
		 	</div>
		 	<!-- LHS FOOTER CONTENT -->
			ddmx:server:index.php:S01_C07
		 	<!-- END LHS FOOTER CONTENT -->
		</div>
	</div>
</div>

<!-- ************** -->
<!-- END FOOTER BAR -->
<!-- ************** -->

</div>

</body>
</html>