<?php
//+-----------------------------------------------+//
//+ Copyright Floopo.com
//+ Text Helper
//+ Adding and editing new text via browser
//+-----------------------------------------------+//

defined('BASEPATH') or die('You can not directly access this file');//check its within this framework

//____DEPENDENCIES____
include_once (BASEPATH.'/lib/lib_formprocessor/formprocessor.php');

//loggedin_check();

//___START_______________


//__New Submission___
if ($_POST) {

    $_POST['text_message'] = Sanatize(mysql_real_escape_string(($_POST['text_message']))); //TODO some cleaning here
    $process_form = new FormProcessor();
    ($process_form->RequiredFields('text_message')) ? null : $display_notification = $lang['fill_in_all'];

    //all is ok
    if ($process_form->obj_status) {
        $text_message = StringSnip($_POST['text_message']);
        $show_notification = 1;


        //are we doing an edit
        if ($_POST['content_id']) {
            $content_id = $_POST['content_id'];
            $dbase->UpdateRecord("UPDATE content_text 
			                      SET text_message = '$text_message'
								  WHERE content_id = '$content_id'");
        } else {

            //are we adding new content
            $dbase->InsertRecord("INSERT INTO content_text (
			                      text_message, user_name, date_added, date_added_short
								  ) values (
								  '$text_message', '$env_user_name', NOW(),NOW())");
        }

        //did everything go ok
        ($dbase->obj_status) ? $display_notification = $lang['request_completed'] : $display_notification = $lang['generic_error'];
    }
}



///FCK EDITOR________________________________________________________________________
include (FCK_EDITOR);
$sBasePath = BASEURL.'/thirdparty/fckeditor/';
$oFCKeditor = new FCKeditor('text_message');
$oFCKeditor->BasePath = $sBasePath;
$oFCKeditor->CustomConfigurationsPath = "fckconfig.js";
$oFCKeditor->ToolbarSet = $config['fckeditor_toolbar']; //OR manually set to 'Basic', 'BasicPlus' or 'Advanced'
$oFCKeditor->SkinPath = $sBasePath + 'editor/skins/silver/';
$oFCKeditor->Value = "$text_message";
$oFCKeditor->Width = '647';
$oFCKeditor->Height = '175';
$FCKeditor1 = $oFCKeditor->CreateHtml();
$fck_editor = $FCKeditor1;
//____________________________________________________________________________________

?>