Location: PHPKode > projects > SiteX > includes/wysiwyg.php
<?PHP
// - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -
// wysiwyg.php
// Created by: P Mills (May 2008)
// Last updated by: BJ Sintay (5/22/2008)
// SiteX Project
// 0.7 Beta Core
// http://sitex.bjsintay.com
// - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = - = -

// ============================== TinyMCE ==============================
if($sxSetup['WYSIWYG'] == 'tinymce') { ?>
<script type="text/javascript" src="../includes/tinymce/tiny_mce.js"></script>
<script type="text/javascript">
<!--
	tinyMCE.init({
		// General options
		mode : "textareas",
		editor_selector : 'mceEditor',
		language : "<?PHP echo $sxSetupTinyMCELanguage; ?>",
		theme : "advanced",
		relative_urls : false,
		plugins : "safari,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,preview,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",

		// Theme options
		theme_advanced_buttons1 : "fullscreen,|,undo,redo,|,bold,italic,underline,strikethrough,|,forecolor,backcolor,|,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,justifyfull,|,outdent,indent,blockquote,|,link,unlink,anchor,image,cleanup,help,code",
		theme_advanced_buttons3 : "tablecontrols,|,removeformat,visualaid,visualchars,|,sub,sup,|,charmap,iespell,media,advhr,|,emotions",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		//content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "",
			staffid : ""
		}
	});

function fileInsertTinyMCE(selObj)
{
	var fileid = selObj.options[selObj.selectedIndex].value;
	var filename = new Array();
	<?PHP
	$query2 = "SELECT * FROM $DB_Files";
	$result2 = mysql_query($query2, $Link);
	while($ROW2 = mysql_fetch_object($result2))	
		echo "	filename[$ROW2->id] = '" . addslashes($ROW2->name) . "';\n";
	?>
	
	if(fileid)
	{
			tinyMCE.execCommand('mceInsertContent',false,'<a href="<?PHP echo sxPathToRoot()."/"; ?>redirect.php?fileid='+fileid+'">'+filename[fileid]+'</a>');
	}
}
	
function pageInsertTinyMCE(selObj)
{
	var pageid = selObj.options[selObj.selectedIndex].value;
	var pagename = new Array();
	<?PHP
	$query2 = "SELECT * FROM $DB_Pages";
	$result2 = mysql_query($query2, $Link);
	while($ROW2 = mysql_fetch_object($result2))	
		echo "	pagename[$ROW2->id] = '" . addslashes($ROW2->name) . "';\n";
	?>
		
	if(pageid)
	{
		tinyMCE.execCommand('mceInsertContent',false,'<a href="<?PHP echo sxPathToRoot()."/"; ?>page.php?pageid='+pageid+'">'+pagename[pageid]+'</a>');
	}
}

//-->
</script>

<?PHP
} // end if(tinymce)

// ============================== F C K ==============================
if($sxSetup['WYSIWYG'] == 'fck') {
	include("../includes/fck/fckeditor.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function fileInsertFCK(selObj)
{
	var fileid = selObj.options[selObj.selectedIndex].value;
	var filename = new Array();
	<?PHP
	$query2 = "SELECT * FROM $DB_Files";
	$result2 = mysql_query($query2, $Link);
	while($ROW2 = mysql_fetch_object($result2))	
		echo "	filename[$ROW2->id] = '" . addslashes($ROW2->name) . "';\n";
	?>
	
	if((fileid)&&(fileid != 0))
	{
		var oEditor = FCKeditorAPI.GetInstance('content') ;
		oEditor.SetData( oEditor.GetData() +  '<A HREF="redirect.php?fileid='+fileid+'">'+filename[fileid]+'</A>') ;
	}
}

function pageInsertFCK(selObj)
{
	var pageid = selObj.options[selObj.selectedIndex].value;
	var pagename = new Array();
	<?PHP
	$query2 = "SELECT * FROM $DB_Pages";
	$result2 = mysql_query($query2, $Link);
	while($ROW2 = mysql_fetch_object($result2))	
		echo "	pagename[$ROW2->id] = '" . addslashes($ROW2->name) . "';\n";
	?>
		
	if((pageid)&&(pageid != 0))
	{
		var oEditor = FCKeditorAPI.GetInstance('content') ;
		oEditor.SetData( oEditor.GetData() +  '<A HREF="page.php?pageid='+pageid+'">'+pagename[pageid]+'</A>') ;
	}
}
-->
</script>
<?PHP
} // end if(FCK)

// ============================== htmlarea ==============================
if($sxSetup['WYSIWYG'] == 'htmlarea') {
?>
<script language="JavaScript" type="text/JavaScript">
<!--
_editor_url = "../includes/htmlarea/";                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
  document.write(' language="Javascript1.2"></scr' + 'ipt>'); 
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }

function fileInsertHA(selObj)
{
	var fileid = selObj.options[selObj.selectedIndex].value;
	var filename = new Array();
	<?PHP
	$query2 = "SELECT * FROM $DB_Files";
	$result2 = mysql_query($query2, $Link);
	while($ROW2 = mysql_fetch_object($result2))	
		echo "	filename[$ROW2->id] = '" . addslashes($ROW2->name) . "';\n";
	?>
	
	if(fileid)
	{
		if (win_ie_ver >= 5.5)
		{
			editor_insertHTML('content', '<A HREF="redirect.php?fileid='+fileid+'">'+filename[fileid]+'</A>', '', 0);
		}
		else{
			var content = window.document.sxEventAdd.content.value; 
			window.document.sxEventAdd.content.value = content + '---FILE'+fileid+'---'; 
			window.document.sxEventAdd.content.focus();
		}
	}
}

function pageInsertHA(selObj)
{
	var pageid = selObj.options[selObj.selectedIndex].value;
	var pagename = new Array();
	<?PHP
	$query2 = "SELECT * FROM $DB_Pages";
	$result2 = mysql_query($query2, $Link);
	while($ROW2 = mysql_fetch_object($result2))	
		echo "	pagename[$ROW2->id] = '" . addslashes($ROW2->name) . "';\n";
	?>
		
	if(pageid)
	{
		if (win_ie_ver >= 5.5)
		{
			editor_insertHTML('content', '<A HREF="page.php?pageid='+pageid+'">'+pagename[pageid]+'</A>', '', 0);
		}
		else
		{
			var content = window.document.sxEventAdd.content.value; 
			window.document.sxEventAdd.content.value = content + '---PAGE'+pageid+'---'; 
			window.document.sxEventAdd.content.focus();
		}
	}
}
//-->
</script> 
<?PHP } // end if(htmlarea) ?>

<script language="JavaScript" type="text/JavaScript">
<!--
function alldayChange ()
{
	if (document.sxEventAdd.allday.checked == true)

	{
		document.sxEventAdd.start_date_hour.disabled = true;
		document.sxEventAdd.start_date_minute.disabled = true;
		document.sxEventAdd.start_date_ampm.disabled = true;
		document.sxEventAdd.end_date_hour.disabled = true;
		document.sxEventAdd.end_date_minute.disabled = true;
		document.sxEventAdd.end_date_ampm.disabled = true;
	}

	else
	{
		document.sxEventAdd.start_date_hour.disabled = false;
		document.sxEventAdd.start_date_minute.disabled = false;
		document.sxEventAdd.start_date_ampm.disabled = false;
		document.sxEventAdd.end_date_hour.disabled = false;
		document.sxEventAdd.end_date_minute.disabled = false;
		document.sxEventAdd.end_date_ampm.disabled = false;
	}
}
function submitIt (myForm)
{
	var shr; var ehr;
	var start = myForm.start_date_year.value + myForm.start_date_month.value + myForm.start_date_day.value;
	var end   = myForm.end_date_year.value + myForm.end_date_month.value + myForm.end_date_day.value;
	
	if (myForm.allday.checked != true)
	{
		if ((myForm.start_date_ampm.value == 'am')&&(myForm.start_date_hour.value == '12'))
			shr = 0;
			
		else
		{
			if ((myForm.start_date_ampm.value == 'pm')&&(eval(myForm.start_date_hour.value) < 12))
			{
				shr = eval(myForm.start_date_hour.value) + 12;
			}
			else
			{
				shr = myForm.start_date_hour.value;
			}
		}
		
		if ((myForm.end_date_ampm.value == 'am')&&(myForm.end_date_hour.value == '12'))
			ehr = 0;
			
		else
		{
			if ((myForm.end_date_ampm.value == 'pm')&&(eval(myForm.end_date_hour.value) < 12))
			{
				ehr = eval(myForm.end_date_hour.value) + 12;
			}
			else
			{
				ehr = myForm.end_date_hour.value;
			}
		}
		
		start = start + shr;
		end = end + ehr;
	}
	
	if (end < start)
	{	
		alert ("<?PHP echo $sxLang['EventJSImpossibleDates']; ?>");
		return false;
	}
}
//-->
</script>
Return current item: SiteX