<?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['EditorRightsJournalEdit'])) loginError($sxLang['LoginRequired']);
if($date_ampm == 'pm')
$date_hour_24 = $date_hour + 12;
elseif($date_hour == 12)
$date_hour_24 = 0;
else
$date_hour_24 = $date_hour;
$date_month = substr($date, 5, 2);
$date_day = substr($date, 8, 2);
$date_year = substr($date, 0, 4);
$timestamp = mktime($date_hour_24, $date_minute, 0, $date_month, $date_day, $date_year);
if($Submit)
{
$query = "UPDATE $DB_Journal SET title='$title', entry='$content', timestamp='$timestamp', month='$date_month', day='$date_day', year='$date_year' WHERE id='$entryid'";
$result = mysql_query($query, $Link) or queryError("21", mysql_error());
writeRSSXML();
header("Location: ../journal.php?sxEntryID=$entryid&message=".str_replace(" ","_",$sxLang['MessageJournalEdited']));
die();
//$message = $sxLang['MessageJournalEdited'];
}
$query = "SELECT * FROM $DB_Journal WHERE id='$entryid'";
$result = mysql_query($query, $Link) or queryError("21", 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",
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.sxFormJournalEdit.content.value;
window.document.sxFormJournalEdit.content.value = content + '---FILE'+fileid+'---';
window.document.sxFormJournalEdit.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.sxFormJournalEdit.content.value;
window.document.sxFormJournalEdit.content.value = content + '---PAGE'+pageid+'---';
window.document.sxFormJournalEdit.content.focus();
}
}
}
//-->
</script>
<?PHP } // end if(htmlarea) ?>
<div class="bodyWrapper">
<h1 class="sxAdminHeading"><?PHP echo $sxLang['GeneralHeadingEdit'].' '.getComponentName("1").' '.$sxLang['GeneralHeadingEntry']; ?></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> > <a href="journal_manager.php"><?PHP echo getComponentName("1").' '.$sxLang['GeneralHeadingEntry'].' '.$sxLang['GeneralHeadingManager']; ?></a> > <?PHP echo $sxLang['GeneralHeadingEdit'].' '.getComponentName("1").' '.$sxLang['GeneralHeadingEntry']; ?></div>
<?PHP echoMessage($message); ?>
<form name="sxFormJournalEdit" method="post" action="<?PHP echo $PHP_SELF; ?>">
<table border="0" cellspacing="0" cellpadding="5">
<?PHP if($Preview){ ?>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['Preview']; ?></td>
<td><p><strong><span class="journalDate"><?PHP echo fetchDate($timestamp, 1, 1); ?></span>
<?PHP if($title) echo '<br />' . stripslashes($title); ?></strong></p>
<p><?PHP echo stripslashes($content); ?></p></td>
<tr>
<td colspan="2"><hr size="1" noshade="noshade" /></td>
</tr>
</tr>
<?PHP } ?>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemTitle']; ?></td>
<td><input type="text" style="width:500px;" name="title" value="<?PHP if($Preview) echo htmlspecialchars(stripslashes($title)); else echo htmlspecialchars($ROW->title); ?>" /></td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemDate']; ?></td>
<td><div id="calendarForForm"><input type="text" name="date" id="date" readonly="readonly" value="<?PHP if($Preview) echo date("Y-m-d", $timestamp); else echo date("Y-m-d", $ROW->timestamp); ?>" />
<script type="text/javascript" src="../includes/datepicker/dhtmlSuite-config.js"></script>
<script type="text/javascript" src="../includes/datepicker/dhtmlSuite-common.js"></script>
<script type="text/javascript" src="../includes/datepicker/dhtmlSuite-calendar.js"></script>
<script type="text/javascript" src="../includes/datepicker/dhtmlSuite-dragDropSimple.js"></script>
<script type="text/javascript">
var calendarObjForForm = new DHTMLSuite.calendar({minuteDropDownInterval:1,numberOfRowsInHourDropDown:5,callbackFunctionOnDayClick:'getDateFromCalendar',isDragable:true,displayTimeBar:false});
function pickDate(buttonObj,inputObject)
{
calendarObjForForm.setCalendarPositionByHTMLElement(inputObject,0,inputObject.offsetHeight+2); // Position the calendar right below the form input
calendarObjForForm.setInitialDateFromInput(inputObject,'yyyy-mm-dd'); // Specify that the calendar should set it's initial date from the value of the input field.
calendarObjForForm.addHtmlElementReference('myDate',inputObject); // Adding a reference to this element so that I can pick it up in the getDateFromCalendar below(myInput is a unique key)
if(calendarObjForForm.isVisible()){
calendarObjForForm.hide();
}else{
calendarObjForForm.resetViewDisplayedMonth(); // This line resets the view back to the inital display, i.e. it displays the inital month and not the month it displayed the last time it was open.
calendarObjForForm.display();
}
}
function getDateFromCalendar(inputArray)
{
var references = calendarObjForForm.getHtmlElementReferences(); // Get back reference to form field.
references.myDate.value = inputArray.year + '-' + inputArray.month + '-' + inputArray.day;
calendarObjForForm.hide();
}
</script>
<img alt="<?PHP echo $sxLang['GeneralTooltipPickDate']; ?>" title="<?PHP echo $sxLang['GeneralTooltipPickDate']; ?>" style="cursor:Pointer;cursor:hand;" src="../images/calendar.gif" onclick="pickDate(this,document.sxFormJournalEdit.date);" align="absmiddle" />
</select> @
<select name="date_hour">
<?PHP
for($i = 1; $i <= 12; $i++){
if(($i == date("g", $ROW->timestamp))AND(!$Preview)) $selected = ' selected';
elseif(($Preview)AND($date_hour == $i)) $selected = ' selected';
else $selected = '';
echo '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
?>
</select>:<select name="date_minute">
<?PHP
for($i = 0; $i <= 59; $i++){
if($i < 10) $i = '0'.$i;
if(($i == date("i", $ROW->timestamp))AND(!$Preview)) $selected = ' selected';
elseif(($Preview)AND($date_minute == $i)) $selected = ' selected';
else $selected = '';
echo '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
}
?>
</select> <select name="date_ampm">
<option value="am"<?PHP if((($Preview)AND($date_ampm == 'am'))OR((!$Preview)AND(date("a", $ROW->timestamp) == 'am'))) echo ' selected'; ?>>AM</option>
<option value="pm"<?PHP if((($Preview)AND($date_ampm == 'pm'))OR((!$Preview)AND(date("a", $ROW->timestamp) == 'pm'))) echo ' selected'; ?>>PM</option>
</select><br /><span class="sxSmallText">(<?PHP echo $sxLang['DateFormatYYYYMMDD']; ?>)</span></div>
</td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemEntry']; ?></td>
<td>
<div style="text-align:center;background:#EFEFDE;padding:5px;width:490px;color:#000000;">
<strong><?PHP echo $sxLang['Autolink']; ?></strong>
<select name="insert_file" style="width:150px;" 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("21", mysql_error());
while($ROWF = mysql_fetch_object($resultF)){
echo '<option value="' . $ROWF->id . '">[' . $ROWF->id . '] ' . $ROWF->name . '</option>'."\n";
}
?>
</select>
<select name="insert_page" style="width:150px;" 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("21", 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%">';
if($Preview) echo stripslashes($content);
else echo stripslashes($ROW->entry);
echo '</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 = '500' ;
$oFCKeditor->Height = '400' ;
if($Preview) $oFCKeditor->Value = stripslashes($content);
else $oFCKeditor->Value = stripslashes($ROW->entry);
$oFCKeditor->Create() ;
}
if($sxSetup['WYSIWYG'] == 'htmlarea') {
?>
<textarea name="content" id="content" style="width:575px;height:500px;"><?PHP
if($Preview) echo stripslashes($content);
else echo stripslashes($ROW->entry);
?>
</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 } ?>
</td>
</tr>
<tr>
<td> </td>
<td align="center">
<input type="hidden" name="entryid" value="<?PHP echo $entryid; ?>" />
<input style="width:120px;" type="submit" name="Preview" value="<?PHP echo $sxLang['ButtonPreview']; ?>" class="sxButton" />
<input style="width:120px;" type="submit" name="Submit" value="<?PHP echo $sxLang['JournalButtonEdit']; ?>" class="sxButton" />
</td>
</tr>
</table>
</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();
?>