<?php

defined('WikyBlog') or die("Not an entry point...");

if( empty($_SESSION['textareaY']) ){
	$_SESSION['textareaY'] = 20;
}


function mysqlSetToArray($string){
	$array = array();
	
	$string = wbStr_replace('set(','',$string);
	$string = wbStr_replace(')','',$string);
	$string = wbStr_replace('\'','',$string);
	
	$temp = array();
	$temp = wbExplode(',',$string);
	
	foreach($temp as $value){
		$array[$value] = $value;
	}
	
	return $array;	
}


function toEditArea(&$text,$toolbar=false,$textarea=false){
	$temp = '<div class="WBeditArea1">';
		if( $toolbar && $textarea ){
			$temp .= getToolbar($textarea);
		}	
	
		$temp .= '<div class="WBeditArea2">';
		if($textarea){
			
			$temp .= '<textarea class="WBtextarea" onscroll="setScroll(this)" rows="'.$_SESSION['textareaY'].'" name="'.$textarea.'" cols="80" onchange="WBe.set(true)"  >';
			$temp .= wbHtmlspecialchars($text);
			$temp .= '</textarea>';
			
		}else{
			$temp .= $text;
		}
		$temp .= '</div>';
	$temp .= '</div>';
	return $temp;
}

function getToolbar($textarea,$imgs=true,$smiles=true){
	global $page,$pageOwner,$langA,$jsNum;
	
	$page->scripts[] = '/include/js/editing.js?'.$jsNum;
	
	$text = '<div class="WBeditToolbar scriptOnly">';
	
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\\\'\\\'\\\'\', \'\\\'\\\'\\\'\', \''.$langA['bold_text'].'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_bold.gif').'" alt="'.$langA['bold_text'].'" title="'.$langA['bold_text'].'" width="18" height="18" /></a>';
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\\\'\\\'\', \'\\\'\\\'\', \''.$langA['italic_text'].'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_italic.gif').'" alt="'.$langA['italic_text'].'" title="'.$langA['italic_text'].'" width="18" height="18" /></a>';
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\n== \', \' ==\n\', \''.$langA['headline_text'].'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_header.gif').'" alt="'.$langA['headline_text'].'" title="'.$langA['headline_text'].'" width="20" height="18" /></a>';
	
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\n*\', \'\', \''.$langA['unordered_list'].'\');return false;"><img src="'.wbLinks::getDir('/imgs/icons/text_list_bullets.gif').'" alt="'.$langA['headline_text'].'" title="'.$langA['headline_text'].'" width="20" height="18" /></a>';
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\n#\', \'\', \''.$langA['ordered_list'].'\');return false;"><img src="'.wbLinks::getDir('/imgs/icons/text_list_numbers.gif').'" alt="'.$langA['headline_text'].'" title="'.$langA['headline_text'].'" width="20" height="18" /></a>';
	
	
	$text .= '<img src="'.wbLinks::getDir('/imgs/button_spacer.gif').'" alt="" />';
	$link = '/'.$pageOwner['username'].'/'.$langA['page'].'|'.$langA['title'];
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'[[\', \']]\', \''.$link.'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_link.gif').'" alt="'.$langA['link'].'" title="'.$langA['internal_link'].'" width="20" height="18" /></a>';
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'[\', \']\', \'http://www.wikyblog.com link title\');return false;"><img src="'.wbLinks::getDir('/imgs/button_extlink.gif').'" alt="'.$langA['external_link'].'" title="'.$langA['external_link'].'" width="25" height="18" /></a>';
	
	$text .= '<img src="'.wbLinks::getDir('/imgs/button_spacer.gif').'" alt="" />';
	
	//$text .= '<img src="'.wbLinks::getDir('/imgs/button_spacer.gif').'" alt="" />';
	//$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\n----\n\', \'\', \'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_hr.gif').'" alt="Line" title="Horizontal Line" width="18" height="18" /></a>';
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'&lt;nowiki&gt;\', \'&lt;/nowiki&gt;\', \''.$langA['NOWIKI_TEXT'].'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_nowiki.gif').'" alt="'.$langA['nowiki'].'" title="'.$langA['NOWIKI_TEXT'].'" height="18" width="50" /></a>';
	$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\', \'\', \'~~~\');return false;"><img src="'.wbLinks::getDir('/imgs/button_sig.gif').'" alt="'.$langA['signature'].'" title="'.$langA['SIGNATURE_TEXT'].'" height="18" width="20" /></a>';
	

	//$text .= '<a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\\t\', \'\', \'\');return false;"><img src="'.wbLinks::getDir('/imgs/button_tab.gif').'" alt="Tab" title="Insert Tab" height="18" width="50" /></a>';
	
	//$text .= '<img src="'.wbLinks::getDir('/imgs/button_spacer.gif').'" alt="" />';
	
		
	///// images
		if( $imgs ){
			$text .= ' &nbsp; ';
			$text .= '<a href="javascript:void(0)" onclick="WB.DS(this.parentNode.lastChild);return false;" class="wbCompat">';
			$text .= '<img src="'.wbLinks::getDir('/imgs/button_image.gif').'" alt="'.$langA['image'].'" title="'.$langA['embed_image'].'" width="22" height="18" />';
			$text .= '</a>';
// 			$text .= '<span onmouseover="WB.SI(this)" onmouseout="WB.HI(this)" style="position:relative">';
// 				$text .= '<img onclick="WB.SI(this.parentNode.parentNode)" src="'.wbLinks::getDir('/imgs/button_image.gif').'" alt="'.$langA['image'].'" title="'.$langA['embed_image'].'" width="22" height="18" />';
// 				$text .= '<span onclick="WB.HI(this.parentNode);" style="z-index:10;display:none;position:absolute;background-color:#F1F1F1;border:1px solid #ccc;" class="sm">';
// 					
// 					$text .= '<select onchange="insertWiki(\''.$textarea.'\',\'\',\'\',this.value);" multiple="multiple" size="13" name="wbImgs" title="'.$langA['embed_image'].'">';
// 					$text .= '<optgroup label="&nbsp; '.$langA['embed_image'].'" title="&nbsp; '.$langA['embed_image'].'">';
// 					
// 					if( isset($pageOwner['imgs']) && is_array($pageOwner['imgs']) ){
// 						foreach($pageOwner['imgs'] as $file => $size){
// 							if( $size ){
// 								$text .= '<option value="[[Image:'.wbHtmlspecialchars($file).']]" >'.wbHtmlspecialchars($file).'</option>';
// 							}
// 						}
// 					}else{
// 						$text .= '<option value="">'.$langA['NO_IMAGES'].'</option>';
// 					}
// 					$text .= '<option value=""></option>';
// 					$text .= '</optgroup>';
// 					$text .= '</select>';				
// 				$text .= '</span>';
// 			$text .= '</span>';
		}	
		
		
	///// smiles
		if( $smiles ){
			$smiles = array ( ':D' => 'icon_biggrin.gif', ':)' => 'icon_smile.gif', ':(' => 'icon_sad.gif', ':o' => 'icon_surprised.gif', ':shock:' => 'icon_eek.gif', ':?' => 'icon_confused.gif', '8)' => 'icon_cool.gif', ':lol:' => 'icon_lol.gif', ':x' => 'icon_mad.gif', ':P' => 'icon_razz.gif', ':oops:' => 'icon_redface.gif', ':cry:' => 'icon_cry.gif', ':evil:' => 'icon_evil.gif', ':twisted:' => 'icon_twisted.gif', ':roll:' => 'icon_rolleyes.gif', ':wink:' => 'icon_wink.gif', ':!:' => 'icon_exclaim.gif', ':?:' => 'icon_question.gif', ':idea:' => 'icon_idea.gif', ':arrow:' => 'icon_arrow.gif', ':|' => 'icon_neutral.gif', ':mrgreen:' => 'icon_mrgreen.gif' );
			$text .= ' &nbsp; ';
			$text .= '<span onclick="WB.SI(this)" onmouseover="WB.SI(this)" onmouseout="WB.HI(this)" style="position:relative" >';
				$text .= '<img onclick="WB.SI(this.parentNode)" src="'.wbLinks::getDir('/imgs/smiles/icon_biggrin.gif').'" alt="'.$langA['insert_emoticons'].'" title="'.$langA['insert_emoticons'].'" width="15" height="15" /> ';
				$text .= '<span onclick="WB.HI(this.parentNode);" style="z-index:10;display:none;position:absolute;width:105px;background-color:#F1F1F1;border:1px solid #ccc;padding:7px;">';
				foreach($langA['smiles'] as $markup => $txt){
					$text .= ' <a href="javascript:void(0)" onclick="insertWiki(\''.$textarea.'\', \'\', \'\', \' '.$markup.' \');return false;" >';
					$text .= '<img src="'.wbLinks::getDir('/imgs/smiles/'.$smiles[$markup]).'" alt="'.$txt.'" title="'.$txt.'" width="15" height="15" />';
					$text .= '</a> ';
				}
				$text .= '</span>';
			$text .= '</span>';
		}
		
	///// Sections
		$text .= ' &nbsp; ';
		//using onclick for testing
		$text .= '<span style="position:relative" >';
		$text .= '<select onfocus="WBe.GS(\''.$textarea.'\',this)" onchange="WBe.ES(\''.$textarea.'\',this)" style="width:10em"><option value="">All Sections</option><option value="">--------------------</option></select>';
		$text .= '</span>';
		

		
	//more
		$text .= ' &nbsp; ';
		$text .= '<img src="'.wbLinks::getDir('/imgs/button_spacer.gif').'" alt="" />';
		$text .= ' &nbsp; ';
		$text .= '<span class="sm">'.wbLinks::help('Text_Formatting?en=Text_Formatting','more').'</span>';
	
	//Find Images Form	
		$text .= '<div class="WBeditArea1 loadHide" style="margin-top:7px;" >';
		//$text .= '<b>'.$langA['embed_image'].': </b><br/>';
		
		// $text .= '<a href="javascript:void(0)" onclick="WB.DS(this.parentNode,\'none\');return false;" style="position:relative;float:right">';
		// $text .= 'X';
		// $text .= '</a>';
		
		$text .= '<input type="text" name="wb_img_search" value="" />';
		
		$url = '/include/tool/FileSearch.php?o='.toStorage($pageOwner['username']).'&l='.$GLOBALS['userLanguage'].'&t='.$textarea;
		$url = wbLinks::getDir($url);
		$text .= '<input type="hidden" name="wb_img_url" value="'.$url.'" />';
		
		if(  isset($GLOBALS['wbConfig']['thumbs']) && ($GLOBALS['wbConfig']['thumbs'] == 'On') ){
			$text .= '<input type="hidden" name="wb_img_thumb" value="yes" />';
		}else{
			$text .= '<input type="hidden" name="wb_img_thumb" value="no" />';
		}
		
		$text .= ' &nbsp; <input type="button" onclick="WB.IS();return false;" value="'.$langA['find_images'].'" />';
		
		
		$text .= ' &nbsp; ';
		$text .= wbLinks::local('/Attach/'.$pageOwner['username'],'upload');
				
		$text .= ' &nbsp; <a href="javascript:void(0)" onclick="WB.DS(this.parentNode,\'none\');return false;" >';
		$text .= $langA['close'];
		$text .= '</a>';
				
			//where images will be shown
			$text .= '<div style="text-align:left;padding:.5em" class="sm">';
			$text .= '</div>';
		$text .= '</div>';
	
	$text .= '</div>';
	return $text;
}


function saveBar($keywords=true,$prev=true,$save=true,$reset=true,$changes=true){
	global $page, $pageOwner, $dbObject, $localHost, $langA, $dbObject;
	
	
	if( empty($_SESSION['shortK']) || is_numeric($_SESSION['shortK']) ){
		$_SESSION['shortK'] = 'alt';
	}
	
	ob_start();
	
	if( (strpos($dbObject->flags,'captcha') !== false)
		&& ($dbObject->editable === 1)
		){
			fileEdit::captchaHTML();
	}
	
	echo '<!--[if lt IE 6]><style>.WBtoolbar{width:auto !important}</style><![endif]-->';
	echo '<table class="WBtoolbar"><tr>';
	//	Save
	if( $save ){
		echo '<td rowspan="2">';
		if( is_string($save) ){
			echo $save;
		}else{
			echo '<input name="cmd" value="'.$langA['save'].'" class="WBbutton" type="submit" accesskey="s" title="'.wbLang::text('SAVE_TEXT',$_SESSION['shortK']).'" onclick="WBe.set(false)" />';
			//echo '<input name="cmd" value="Save" class="WBbutton" type="submit" accesskey="s" title="Save your changes [alt-s]" />';
		}
		echo '</td>';
	}
	
	
	
	//	Preview
	if( $prev ){
		echo '<td rowspan="2">';
		if(is_string($prev)){
			echo $prev;
		}else{
			echo '<input name="cmd" value="'.$langA['preview'].'" class="WBbutton" type="submit" accesskey="p" title="'.wbLang::text('PREVIEW_TEXT',$_SESSION['shortK']).'" />';
			//echo '<input name="cmd" value="'.$langA['preview'].'" class="WBbutton" type="submit" accesskey="p" title="'.$langA['PREVIEW_TEXT'].'" />';
		}
		echo '</td>';
	}
	
	//	changes
	if( $changes ){
		echo '<td rowspan="2">';
		if( is_string($changes) ){
			echo $changes;
		}else{
			echo '<input type="submit" name="cmd" value="'.$langA['changes'].'" class="WBbutton" accesskey="d" title="'.wbLang::text('CHANGES_TEXT',$_SESSION['shortK']).'"  />';
		}
		echo '</td>';
	}
	
	//	Reset
	if( $reset ){
		echo '<td rowspan="2">';
		if( is_string($reset) ){
			echo $reset;
		}else{
			echo '<input type="reset" name="cmd" value="'.$langA['reset'].'" class="WBbutton" accesskey="c" title="'.wbLang::text('RESET_TEXT',$_SESSION['shortK']).'"  onclick="WBe.set(false)" />';
		}
		echo '</td>';
	}
	
	
	
	////	KEYWORDS
	//		$keyword because of Events which has a different way of defining keywords
	//
	//		changing keywords changes the $pageOwner variable
	if( $keywords ){	
		//default message
		if(empty( $dbObject->keywords ) ){
			$temp = '('.wbHtmlspecialchars($langA['DEFAULT_KEYWORD_FIELD']).')';
		}else{
			$temp = wbStr_replace(',',', ',$dbObject->keywords).',';//put a comma on the end for the javascript
		}
		
		//auto-complete keywords
		$keyArray = array();
		if( !empty($pageOwner['keywords']) ){
			foreach($pageOwner['keywords'] as $key => $num){
				$keyArray[] = $key;
			}
		}

		echo '<td style="text-align:right;white-space:nowrap;" class="sm">';
		echo $langA['tags'];
		echo ' :';
		echo '</td><td style="text-align:left;overflow:hidden;">';
			echo '<input type="hidden" name="keyList" value="'.str_replace(array('<','>'),array('&lt;','&gt;'),implode(',',$keyArray)).'" />';
			echo '<input onfocus="WBe.create(this,\''.wbHtmlspecialchars($pageOwner['username']).'\')" onkeyup="WBe.show()" onblur="WBe.blur()" type="text" size="50" title="('.wbHtmlspecialchars($langA['DEFAULT_KEYWORD_FIELD']).')" class="WBinputText" maxlength="200" name="keywords" value="'.$temp.'" />';
		echo '</td></tr><tr>';
	}
	
	if(isset($_POST['summary'])){
		$summary =& $_POST['summary'];
	}else{ 
		$summary = '';
	}
	echo '<td style="text-align:right;white-space:nowrap;" class="sm">';
	echo $langA['edit_summary'];
	echo ' :';
	echo '</td><td style="text-align:left;overflow:hidden;">';
	echo '<input type="text" size="50" class="WBinputText" maxlength="200" name="summary" value="'. wbHtmlspecialchars($summary) .'" />';
	echo '</td>';	
	
	
	echo '</tr></table>';
	
	

	//	I'd  like to show the editor when an include is being used..
	//		but the parser is not run for editing so the includes array is not populated...
	//	
	
	return wb::get_clean();
}



class fileEdit{
	
// 	function keywordField( &$object ){
// 		global $pageOwner;
// 		
// 		if(empty( $object->keywords ) ){
// 			$temp = '('.wbHtmlspecialchars($langA['DEFAULT_KEYWORD_FIELD']).')';
// 		}else{
// 			$temp = wbStr_replace(',',', ',$object->keywords).',';//put a comma on the end for the javascript
// 		}			
// 		$keyArray = array();
// 		if( !empty($pageOwner['keywords']) ){
// 			foreach($pageOwner['keywords'] as $key => $num){
// 				$keyArray[] = $key;
// 			}
// 		}		
// 		echo '<td style="text-align:left;overflow:hidden;">';
// 			echo '<input type="hidden" name="keyList" value="'.str_replace(array('<','>'),array('&lt;','&gt;'),implode(',',$keyArray)).'" />';
// 			echo '<input onfocus="WBe.create(this,\''.wbHtmlspecialchars($pageOwner['username']).'\')" onkeyup="WBe.show()" onblur="WBe.blur()" type="text" size="50" title="('.wbHtmlspecialchars($langA['DEFAULT_KEYWORD_FIELD']).')" class="WBinputText" maxlength="200" name="keywords" value="'.$temp.'" />';
// 		echo '</td>';
// 	}
	
	
	
	// SESSION Editing Array
	//	- makes sure users don't overwrite simultaneous edits
	function init(){
		global $page,$dbObject,$pageOwner;
		
		if( !isset($_SESSION['editPage']) ){
			$_SESSION['editPage'] = array();
		}
		
		//	$_SESSION['editPage'] tells toolSavePage if the user is editing the current version or not
		//	truncate length of list to 6
		while( count($_SESSION['editPage']) > 6){
			$time = array_shift($_SESSION['editPage']);
		}
		
		//unset first so that when it's reset, it's at the top of the stack
		unset($_SESSION['editPage'][$dbObject->uniqStorage]);
		
		// add current page... array length of 7
		//message('This is the modified time '.$dbObject->modified);
		$_SESSION['editPage'][$dbObject->uniqStorage] = $dbObject->modified;
		
		if( $dbObject->checkOwner ){
			fileEdit::checkOwner();
		}
	}
	
	//check account owner agains session username
	function checkOwner($link=false){
		global $dbObject, $pageOwner, $wbConfig;
		
		
		if( $dbObject->exists ){
			return;
		}
		
		if( isset($wbConfig['allUsers']) && $wbConfig['allUsers'] == 'Off'){
			return;
		}
		
		if( empty($_SESSION['username']) ){
			return;
		}
		
		if( wbStrcasecmp($_SESSION['username'],$pageOwner['username']) ){
			return;
		}
		
		
		if( $link === false){
			$link = $dbObject->uniqLink;
		}
		
		$queryString = '';
		$pos = strpos($link,'?');
		if( $pos > 0 ){
			$queryString = substr($link,$pos);
			$link = substr($link,0,$pos);
		}
		
		$lowerLinks = wbStrtolower($link);
		$lowerPieces = explode('/',$lowerLinks);
		$key = array_search(wbStrtolower($pageOwner['username']), $lowerPieces);
		
		$pieces = explode('/',$link);
		
		
		if( !is_null($key) && ($key !== false) ){
			$pieces[$key] = $_SESSION['username'];
			$newLink = implode('/', $pieces).$queryString;
			$mess = '<img src="'.wbLinks::getDir('/imgs/icons/bullet_error.gif').'" border="0" width="16" height="16" style="vertical-align:middle" alt="" /> ';
			$mess .= wbLang::text('OTHER_ACCOUNT', wbLinks::local($newLink,$_SESSION['username']), wbLinks::user($pageOwner['username']));
			message($mess);
		}
	}
	
	//similar to init(), but deals with 'captcha' instead of 'editPage'
	function captcha(){
		global $dbObject;
		
		if( isset($_SESSION['captcha']) ){
			while( count($_SESSION['captcha']) > 6){
				array_shift($_SESSION['captcha']);
			}
		}else{
			$_SESSION['captcha'] = array();
		}
		$rand = rand(0,10000);
		unset($_SESSION['captcha'][$dbObject->uniqStorage]);
		$_SESSION['captcha'][$dbObject->uniqStorage] = $rand;
		return $rand;
	}
	
	function captchaHTML(){
		$r = fileEdit::captcha();
		echo '<table style="margin: 0 auto 0 auto">';
		echo '<tr><td>';
		//echo '<a href="javascript:void(0)" onclick="WBe.RI(this);return false;">';
		$path = wbLinks::getDir('/include/tool/captcha.php?r='.$r);
		echo '<img src="'.$path.'" alt="captcha" />';
		//echo '</a>';
		echo '</td>';
		echo '<td style="vertical-align:middle">';
		echo '<input type="text" name="captcha" value="" />';
		echo '</td>';
		echo '</tr>';
		echo '</table>';
	}
	
	function addIncluded($uri){
		global $page,$dbObject,$wbTables,$pageOwner;
		
		if( !isset($page->contentB[$uri]) || !$dbObject->file_id ){
			return;
		}
		
		$query = 'SELECT `incl_title` ';
		$query .= ' FROM '.$wbTables['all_included'];
		$query .= ' WHERE ';
		$query .= '`file_id` = "'.$dbObject->file_id.'" ';
		$result = wbDB::runQuery($query);
		if( mysql_num_rows($result) == 0){
			return;
		}
		
		$text = '<div class="WBsearchFooter">';
		$text .= '<ul>';
		while( $row = mysql_fetch_assoc($result) ){
			$text .= '<li>'.wbLinks::local('/'.$pageOwner['username'].'/'.$row['incl_title'],$row['incl_title']).'</li>';
		}
		$text .= '</ul>';
		$text .= '</div>';
		$page->contentB[$uri] .= $text;
	}

}
	
	


//
//					FUNCTIONS
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 					FLOW AND DISPLAY
//

class initEdit{
	
	function init(){
		global $page, $dbObject, $langA, $wbParser, $jsNum;
		
		if( !cookies() ){
			message('COOKIES_REQUIRED');
			return;
		}
		
		
		$xmlHttpOverride = false;
		switch( $page->userCmd ){
		
			case 'preview':
			case wbStrtolower($langA['preview']):
				
				$dbObject->setFromPost();
				$dbObject->checkData(false);
				$field = $dbObject->outputObj();
				$dbObject->addFooter($field);
				
				$mess = wbLang::text('PREVIEW_WARN');
				if( $page->ajaxRequest && $dbObject->validData && !empty($_GET['wb']['u']) ){
					$mess .= '<br/>';
					$url = fromStorageUrl($_GET['wb']['u']);
					if( $url ){
						$url = wbLinks::getUrl($url);
						$mess .= '<a href="javascript:void(0)" onclick="WBt.go(\''.$_GET['wb']['u'].'\',\''.$url.'\')">'.$langA['continue_editing'].'</a>';
						$mess .= ' - ';
					}
					$mess .= '<a href="javascript:void(0)" onclick="WBe.PS(\''.$_GET['wb']['u'].'\');return false;" >'.$langA['save_now'].'</a>';
					$page->scripts[] = '/include/js/editingAll.js?'.$jsNum;
				}
				message($mess);
				
			break;
			
			//toolSavePage.php include this script sometimes..
			//	if it does we don't want the default edit case to happen
			case 'save'://maps don't use $langA['save']
			case wbStrtolower($langA['save']):
				$xmlHttpOverride = true;
			break;
		
			case 'customedit':
				fileEdit::init();
			return;
			
			case 'append':
			case 'appenddata':
				$data = '';
				if( !empty($_POST['appendContent']) ){
					$data = $_POST['appendContent'];
					
				}elseif( !empty($_GET['appendContent']) ){
					$data = $_GET['appendContent'];
				}
				if($dbObject->exists){
					$dbObject->content .= "\n\n". $data;
				}else{
					$dbObject->content = $data;
				}
				
			
			case 'edit':
			default:
				$xmlHttpOverride = true;
				fileEdit::init();
				
				//for editErrors
				if( $dbObject->exists && (strpos($dbObject->flags,'safe') === false) ){
					$dbObject->checkData();	//version 0.10... after a while, should just be able to rely completely on the "safe" flag
										//and not have to checkData() here again..
										//.. except, different data types will have different warnings.. which come from checkData()
				}
				
			break;
		}
	
	//
	//		The Edit Box!
	//
	
		//	3)	Edit Values
		
		if( !isset($_GET['wb']) || $xmlHttpOverride ){
			$page->autoForm = true;
			$uri = $dbObject->editValues();
			// if( $uri ){
			// 	fileEdit::addIncluded($uri);
			// }
		}
	}
}
