<?php
/* Include Files ***************************/
require_once('../db-config.php');
require_once('../inc/lib-compat-class.php');
require_once('../inc/lib-db-class.php');
require_once('../inc/lib-layout-class.php');
require_once('../inc/lib-login-class.php');
/*******************************************/
global $rSdb;

$user	= new userManagement();
if(  !$user->_logged_in  )
	die('|||'.__('Access denied.','recipeshelf'));

if( ! check_ajax_referer('layout-recipe', false) )
	die('|||'.__('Security Alert: Direct access not permitted!','recipeshelf'));

$n 	= "\n";
$id = (int)$_POST['recipe-id'];

$r = new recipeLayout($id,$_POST['pluginURL'],dirname(__FILE__).'/../css/default-layout.css');

$elLayArr = isset($_COOKIE['rSlayout']) ?  explode(',', $_COOKIE['rSlayout']) : array('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1');

function rsCTRL($i){
	global $r, $elLayArr;
	$c = ($elLayArr[$i]=='0')||($i==8||$i==9) ? ' rsl-layout-disabled':'';
    echo '<img id="rsl-el'.$i.'" class="rsl-layout-enable'.$c.'" src="'.$r->pluginURL.'/img/1pixel.gif" title="'.__('On/Off','recipeshelf').'" alt=""/>';
}

function rsCTRLcolor($i){
	global $elLayArr;
	echo ($elLayArr[$i]=='0')||($i==8||$i==9) ? ' style="color:#ddd"':'';
}

function OnOff(){
	echo ' title="'.__('On/Off','recipeshelf').'"';
}

echo $r->addCSS();

### Grab Options
$useroptions	= $rSdb->get_option( $user->_user_name."_options" );
$rS_default_img	= $useroptions['rS_default_img'];
if( is_array($useroptions['rS_default_img']) && array_key_exists ( $id,$useroptions['rS_default_img'] ) )
	$defimg = $useroptions['rS_default_img'][$id];

?>
|||<div class="rsl-layout">
	<div class="rsCtrl rsl-title-photo"<?php OnOff();?>><?php rsCTRL(0);?>
    	<?php echo $r->addPhoto($defimg) ?>
    </div>
	<div class="rsl-head">
	    <div class="rsCtrl rsl-title"<?php rsCTRLcolor(1);OnOff(); ?>><?php rsCTRL(1);?>
	    	<?php echo $r->addName() ?>
        </div>
		<div class="rsCtrl rsl-desc"<?php rsCTRLcolor(2);OnOff();?>><?php rsCTRL(2); ?><?php echo $r->addDescription() ?></div>
		<div class="rsCtrl rsl-tags"<?php rsCTRLcolor(3);OnOff();?>><?php rsCTRL(3); ?><?php echo $r->addCats() ?></div>
	</div>
    <div class="rsCtrl rsl-cookingtime"<?php rsCTRLcolor(4);OnOff(); ?>><?php rsCTRL(4);?>
        <table>
            <tr>
				<td><?php _e('Active','recipeshelf')?>:</td><td class="t-a"><?php echo $r->addCookingTime('active')  ?></td>
            </tr>
            <tr>
		    	<td><?php _e('Passive','recipeshelf')?>:</td><td class="t-p"><?php echo $r->addCookingTime('passive') ?></td>
            </tr>
            <tr>
		    	<td><?php _e('Overall','recipeshelf')?>:</td><td class="t-t"><?php echo $r->addCookingTime('overall') ?></td>
            </tr>
            <tr>
		    	<td><?php _e('Yield','recipeshelf') ?>:</td><td class="yield"><?php echo $r->addYield() ?></td>
            </tr>
            <tr>
		    	<td><?php _e('Kcal','recipeshelf'); ?>:</td><td class="kcal"><?php echo $r->addKcal() ?></td>
            </tr>
        </table>
    </div>
	<div class="rsCtrl rsl-ingredients"<?php rsCTRLcolor(5);OnOff(); ?>><?php rsCTRL(5); echo $r->addIngredients(true) ?></div>
	<div class="rsCtrl rsl-steps"<?php rsCTRLcolor(6);OnOff(); ?>><?php rsCTRL(6);?><strong class="hl"><?php echo __('Steps','recipeshelf')?></strong><div><?php echo $r->addSteps() ?></div></div>
	<div class="rsl-clear"></div>
	<div class="rsCtrl rsl-notes"<?php rsCTRLcolor(7);OnOff(); ?>><?php rsCTRL(7);?><strong class="hl"><?php echo __('Notes','recipeshelf') ?></strong><?php echo $r->addNotes() ?></div>
	<div class="rsCtrl rsl-cookedfor"<?php rsCTRLcolor(8);OnOff(); ?>><?php rsCTRL(8);?><strong class="hl"><?php echo __('Cooked for','recipeshelf')?> </strong><?php echo $r->addCookedFor() ?></div>
	<div class="rsCtrl rsl-urls"<?php rsCTRLcolor(9);OnOff(); ?>><?php rsCTRL(9);?><strong class="hl"><?php echo __('References','recipeshelf')?> </strong><?php echo $r->addURLs() ?></div>
</div>
<div class="rsl-clear"></div>