<?php 
//+-----------------------------------------------------+//
//+ Copyright Floopo.com
//+ helper.pages.php
//+ Page editor admin helper
//+-----------------------------------------------------+//

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

//____DEFAULT TEMPLATE_____________________________
$inner_template = ADMIN_TEMPLATES.'tpl_page_editor.htm';


//____Check for any Post_____________________
if(isset($_POST['update'])) {

    $page_name1 = Sanatize(mysql_real_escape_string($_POST['page_name1']));
    $page_name2 = Sanatize(mysql_real_escape_string($_POST['page_name2']));
    $page_content1 = $_POST['page_content1'];
    $page_content2 = $_POST['page_content2'];

    //__upate the db
    $dbase->UpdateRecord("UPDATE web_pages
                      		SET
					  		page_name= '$page_name1',
					  		page_content= '$page_content1'
					  		WHERE page_ref = 1");

    $dbase->UpdateRecord("UPDATE web_pages
                      		SET
					  		page_name= '$page_name2',
					  		page_content= '$page_content2'
					  		WHERE page_ref = 2");
					  		
					  		
        //________write to settings file______________________
        include_once (BASEPATH.'/com/com_admin/configbuilder.php');
        $myFile = BASEPATH.'/config/settings.php';
        //@unlink($myFile);
        $fh = @fopen($myFile,'wb');
        @fwrite($fh,$config_line) or $error = true;
        @fclose($fh);

        //writing notification
        if($error) {
            $notification = $lang['settings_writing_error'];

        }
        else {

            //general notification
            $notification = (($dbase->obj_status) ? $lang['request_completed'] : $lang['generic_error']);
        }

}


//____Lets get current settings_____________________
$page1 = $dbase->SelectRecord("SELECT *
                                  FROM web_pages
								  WHERE page_ref = 1");

$page2 = $dbase->SelectRecord("SELECT *
                                  FROM web_pages
								  WHERE page_ref = 2");


//___Set live data________________________________
if(isset($_POST['update'])){
$page_name1 = stripslashes($_POST['page_name1']);
$page_name2 = stripslashes($_POST['page_name2']);
$page_content1 = stripslashes($_POST['page_content1']);
$page_content2 = stripslashes($_POST['page_content2']);
}else{
$page_name1 = stripslashes($page1['page_name']);
$page_name2 = stripslashes($page2['page_name']);
$page_content1 = stripslashes($page1['page_content']);
$page_content2 = stripslashes($page2['page_content']);
}


//___FCK Editors________________________________________________________
include (FCK_EDITOR);
$sBasePath = BASEURL.'/thirdparty/fckeditor/';
$oFCKeditor = new FCKeditor('page_content1');
$oFCKeditor->BasePath = $sBasePath;
$oFCKeditor->CustomConfigurationsPath = "fckconfig.js";
$oFCKeditor->ToolbarSet = 'BasicPlus';//OR manually set to 'Basic', 'BasicPlus' or 'Advanced'
$oFCKeditor->SkinPath = $sBasePath + 'editor/skins/silver/';
$oFCKeditor->Value = $page_content1;
$oFCKeditor->Width = '800';
$oFCKeditor->Height = '500';
$FCKeditor1 = $oFCKeditor->CreateHtml();
$fck_page_content1 = $FCKeditor1;

$oFCKeditor2 = new FCKeditor('page_content2');
$oFCKeditor2->BasePath = $sBasePath;
$oFCKeditor2->CustomConfigurationsPath = "fckconfig.js";
$oFCKeditor2->ToolbarSet = 'BasicPlus';//OR manually set to 'Basic', 'BasicPlus' or 'Advanced'
$oFCKeditor2->SkinPath = $sBasePath + 'editor/skins/silver/';
$oFCKeditor2->Value = $page_content2;
$oFCKeditor2->Width = '800';
$oFCKeditor2->Height = '500';
$FCKeditor2 = $oFCKeditor2->CreateHtml();
$fck_page_content2 = $FCKeditor2;


?>