Location: PHPKode > projects > SiteX > admin/page_edit.php
<?PHP
ob_start();
session_start();

include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsPagesEdit']))  loginError($sxLang['LoginRequired']);

if($Submit)
{
	$query = "SELECT * FROM $DB_Pages WHERE id='$pageid'";
	$result = mysql_query($query, $Link) or queryError("22", mysql_error());
	$ROW = mysql_fetch_object($result);
	$old_page_name = $ROW->name;
	
	$query = "SELECT * FROM $DB_Navigation";
	$result = mysql_query($query, $Link) or queryError("22", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		if($ROW->url == 'page.php?page='.str_replace(' ', '_', $old_page_name))
		{
			$new_url = 'page.php?page='.str_replace(' ', '_', $name);
			$query2 = "UPDATE $DB_Navigation SET url='$new_url' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or queryError("26", mysql_error());
		}
	}
	
	$query = "UPDATE $DB_Pages
	          SET name='$name', 
			       content='$content', 
				  lastupdated='$NOW', 
				  formatted='0', 
				  meta_description='$page_meta_description',
				  meta_keywords='$page_meta_keywords',
				  meta_title_ext='$page_meta_title_ext'
			  WHERE id='$pageid'";
	$result = mysql_query($query, $Link) or queryError("38", mysql_error());
	
	$query = "DELETE FROM $DB_Pages_Private WHERE pageid='$pageid'";
	$result = mysql_query($query, $Link) or queryError("38", mysql_error());
	
	if($private)
	{
		foreach ($user_types as $k => $v)
		{
			$query = "INSERT INTO $DB_Pages_Private (pageid, typeid) VALUES ('$pageid', '$k')";
			$result = mysql_query($query, $Link) or queryError("38", mysql_error());
		}
	}

	header("Location: ../page.php?pageid=$pageid&message=".str_replace(" ","_",$sxLang['MessagePageEdited']));
	die();
}

$query = "SELECT * FROM $DB_Pages WHERE id='$pageid'";
$result = mysql_query($query, $Link) or queryError("25", mysql_error());
$ROW = mysql_fetch_object($result);

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");

?>

<?PHP
// ============================== 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.sxFormPageEdit.content.value; 
			window.document.sxFormPageEdit.content.value = content + '---FILE'+fileid+'---'; 
			window.document.sxFormPageEdit.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.sxFormPageEdit.content.value; 
			window.document.sxFormPageEdit.content.value = content + '---PAGE'+pageid+'---'; 
			window.document.sxFormPageEdit.content.focus();
		}
	}
}
//-->
</script> 
<?PHP } // end if(htmlarea) ?>

<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['PageHeadingEdit']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <?PHP echo $sxLang['PageHeadingEdit']; ?></div>
   <?PHP echoMessage($message); ?><noscript ><div class="noscript"><?PHP echo $sxLang['JavascriptDisabled']; ?></div></noscript>
	<form name="sxFormPageEdit" action="<?PHP print $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
		  <p><strong><?PHP echo $sxLang['GeneralItemName']; ?></strong> 
		  <input style="width:350px;" name="name" type="text" id="name" value="<?PHP echo htmlspecialchars($ROW->name); ?>" /></p>
		<div class="sxAutolink">
		<strong><?PHP echo $sxLang['Autolink']; ?></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<select name="insert_file" style="width:198px;" onChange="fileInsert<?PHP
			switch($sxSetup['WYSIWYG'])
			{
				case 'fck' :
					echo 'FCK';
					break;
				case 'htmlarea' :
					echo 'HA';
					break;
				case 'tinymce' :
					echo 'TinyMCE';
					break;
			}
		?>(this)">
		<option><?PHP echo $sxLang['LinkFile']; ?></option>
		<?PHP
		$queryF = "SELECT * FROM $DB_Files ORDER BY filename";
		$resultF = mysql_query($queryF, $Link) or queryError("38", mysql_error());
		while($ROWF = mysql_fetch_object($resultF)){
			echo '<option value="' . $ROWF->id . '">[' . $ROWF->id . '] ' . $ROWF->name . '</option>'."\n";
		}
		?>
		</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<select name="insert_page" style="width:198px;" onChange="pageInsert<?PHP
			switch($sxSetup['WYSIWYG'])
			{
				case 'fck' :
					echo 'FCK';
					break;
				case 'htmlarea' :
					echo 'HA';
					break;
				case 'tinymce' :
					echo 'TinyMCE';
					break;
			}
		?>(this)">
		<option><?PHP echo $sxLang['LinkPage']; ?></option>
		<?PHP
		$queryP = "SELECT * FROM $DB_Pages ORDER BY name";
		$resultP = mysql_query($queryP, $Link) or queryError("38", mysql_error());
		while($ROWP = mysql_fetch_object($resultP)){
			echo '<option value="' . $ROWP->id . '">[' . $ROWP->id . '] ' . $ROWP->name . '</option>'."\n";
		}
		?>
		</select></div>
		<?PHP
		
		// Run TinyMCE
		if($sxSetup['WYSIWYG'] == 'tinymce')
			echo '<textarea id="content" name="content" class="mceEditor" rows="25" cols="80" style="width: 80%">'.$ROW->content.'</textarea>';
		
		// Run FCKeditor
		if($sxSetup['WYSIWYG'] == 'fck')
		{
			$oFCKeditor = new FCKeditor('content') ;
			
			$oFCKeditor->Config['DefaultLanguage'] = $sxSetupFCKLanguage ;
			$oFCKeditor->BasePath = getURLFolder() . '/includes/fck/' ;
			$sxFCKServerPath = getURLFolder() . '/content/fck/';
			
			$sxFCKConnectorPath = $oFCKeditor->BasePath . 'editor/filemanager/browser/default/browser.html?Connector=../../connectors/php/connector.php?ServerPath=' . $sxFCKServerPath;
						
			$oFCKeditor->Config['LinkBrowserURL']  = $sxFCKConnectorPath;
			$oFCKeditor->Config['ImageBrowserURL'] = $sxFCKConnectorPath . '&Type=Image';
			$oFCKeditor->Config['FlashBrowserURL'] = $sxFCKConnectorPath . '&Type=Flash';
			
			$oFCKeditor->Width  = '575' ;
			$oFCKeditor->Height = '500' ;
			
			$oFCKeditor->Value = $ROW->content;
			$oFCKeditor->Create() ;
		}
		
		if($sxSetup['WYSIWYG'] == 'htmlarea') {
		?>
		<textarea name="content" id="content" style="width:575px;height:500px;"><?PHP echo $ROW->content; ?></textarea>
		  <script language="javascript1.2">
			var config = new Object();    // create new config object
			
			config.width = "575px";
			config.height = "400px";
			config.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
			config.debug = 0;
			
			// NOTE:  You can remove any of these blocks and use the default config!
			
			config.toolbar = [
				['fontname'],
				['fontsize'],
				['HorizontalRule','InsertTable','Createlink','InsertImage','htmlmode'],
				['linebreak'],
				['bold','italic','underline','separator'],
				['strikethrough','subscript','superscript','separator'],
				['justifyleft','justifycenter','justifyright','separator'],
				['OrderedList','UnOrderedList','Outdent','Indent','separator'],
				['forecolor','backcolor'],
			];
			
			editor_generate('content',config);
		  </script>
		  <?PHP } ?>
		<table border="0" cellspacing="3" cellpadding="5">
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemMETATitleExt']; ?></td>
		  <td><input name="page_meta_title_ext" style="width:300px;" value="<?PHP echo $ROW->meta_title_ext; ?>"></td>
		</tr>			
		<?PHP if(!$sxSetup['MetaSitewide']){ ?>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralMETADescription']; ?></td>
		  <td><textarea name="page_meta_description" style="width:300px;height:100px;"><?PHP echo $ROW->meta_description; ?></textarea></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralMETAKeywords']; ?></td>
		  <td><textarea name="page_meta_keywords" style="width:300px;height:100px;"><?PHP echo $ROW->meta_keywords; ?></textarea></td>
		</tr>
		<?PHP } ?>
		<tr>
		<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemPrivate']; ?></td>
		<td>
		<?PHP
		$checked = "";
		$query3 = "SELECT * FROM $DB_Pages_Private WHERE pageid='$ROW->id'";
		$result3 = mysql_query($query3, $Link) or queryError("38", mysql_error());
		if(mysql_num_rows($result3)) $checked = " checked";
		?>
		<input type="checkbox" name="private" value="1"<?PHP echo $checked; ?> /> <?PHP echo $sxLang['GeneralMakePrivate']; ?><hr size="1" noshade="noshade" /><?PHP
		$query2 = "SELECT * FROM $DB_Users_Types";
		$result2 = mysql_query($query2, $Link) or queryError("38", mysql_error());
		while($ROW2 = mysql_fetch_object($result2)){
			
			$checked = "";
			$query3 = "SELECT * FROM $DB_Pages_Private WHERE pageid='$ROW->id'";
			$result3 = mysql_query($query3, $Link) or queryError("38", mysql_error());
			while($ROW3 = mysql_fetch_object($result3)){
				if($ROW3->typeid == $ROW2->id) $checked = " checked";
			}
			
			echo '<input name="user_types[' . $ROW2->id . ']" type="checkbox" id="user_types" value="1"' . $checked;
			echo ' />' . $ROW2->name . '<br />';
		}
		?></td>
	  </tr>
	</table>
   <div align="right">
	 <input type="hidden" name="pageid" value="<?PHP echo $pageid; ?>" /> 
	 <input type="submit" name="Submit" value="<?PHP echo $sxLang['PageButtonSave']; ?>" class="sxButton" />
	</div>
   </form>
  </div>
  <!-- background refresh -->
<iframe src ="../includes/session_keepalive.php?interval=<?PHP echo $sxThemeConfig['AdminKeepAlive']; ?>&bgcolor=<?PHP echo urlencode($sxThemeConfig['SiteBaseColor']); ?>" scrolling="no" height="1" marginheight="0" marginwidth="0" frameborder="0" align="right" width="1"></iframe>
  
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX