<?php
/*

# CloudFW Skin Engine Layouts Functions
# Author: Orkun Gürsel - contact@orkungursel.com - support@cloudfw.net

*/

/*
 *	Get All Skins Array
 *
 *	@since 1.0
**/
function cloudfw_admin_get_all_skins_array($data, $args){
	
	$tab = $_GET['tab'];
	$id = $_GET['id'];
	$this_page = CLOUD_PAGE;
	if ($tab) $this_page_only_tab = $this_page .= '&tab='.$tab ;
	if ($id) $this_page .= '&id='.$id ;
	
	$custom_skins_array = (array) cloudfw_get_all_skins();		
	
	krsort($custom_skins_array);
						
	foreach ((array)$custom_skins_array  as $skin_id) {
		
			if (!$skin_custom = cloudfw_get_a_skin($skin_id)) continue;
			
			$custom_skins[] =  array(
			"item_value"	=> $skin_id,
			"item_class"	=> "",
			"item_html" 	=> '<span class="skin-thumb">
			<span>
				<span class="colour" style="'.cloudfw_skin_engine_make_attribute(NULL,'background-color',_isso($skin_custom["data"]["body"]["background-color"], $skin_custom["data"]["body"]["background-color"], 'ffffff')).'"></span>
				<span class="colour" style="'.cloudfw_skin_engine_make_attribute(NULL,'background-color',_isso(!empty($skin_custom["data"]["a"]["color"]), $skin_custom["data"]["a"]["color"], '2F2F2F')).'"></span>
				<span class="colour" style="'.cloudfw_skin_engine_make_attribute(NULL,'background-color',$skin_custom["data"]["sub_navigation_background"]["background-color"][0]).'"></span>
			</span>
			<strong class="highlight"></strong>
				
			</span><span class="skin-name"><span title="'.esc_attr($skin_custom["name"]).'" class="">'.cloudfw_less_text($skin_custom["name"], 30).'</span></span>',
			"item_before" 	=> '<span class="edit_remove_skin_container">',
			"item_after"	=> '<span class="edit_remove_skin"><a class="remove tooltip theThisConfirm" title="'.__('Delete','cloudfw').'" href="'.$this_page_only_tab.'&amp;q=1&amp;deleteSkin=true&amp;id='.$skin_id.'"><span>'.__('Delete','cloudfw').'</span></a><a class="duplicate tooltip" title="'.__('Duplicate','cloudfw').'" href="'.$this_page_only_tab.'&amp;q=1&amp;duplicateSkin=true&amp;id='.$skin_id.'"><span>'.__('Duplicate','cloudfw').'</span></a><a class="edit tooltip" title="'.__('Edit','cloudfw').'" href="'.$this_page_only_tab.'&amp;jump=1&amp;id='.$skin_id.'"><span>'.__('Edit','cloudfw').'</span></a></span></span>'
			);
						
	}
	
	return $custom_skins;
	
}

/*
 *	Get Default Skins Array
 *
 *	@since 1.0
**/
function cloudfw_admin_get_default_skins_array(){


	global $theme_skins;
					
	foreach ($theme_skins as $skin_id => $skin) {
		
		$skin_version_echo =  ($skin["version"]) ? '<span class="skin-version">with version '.$skin["version"].'</span>':NULL;
		
		$skins[] =  array(
		"item_value"	=> $skin_id,
		"item_class"	=> "",
		"item_html" 	=> '<span class="skin-thumb" style="background: url('.$skin["thumbnail"].') no-repeat scroll 0 0 transparent;"></span><span class="skin-name">'.$skin["name"].''.$skin_version_echo.'</span>',
		"item_before" 	=> '<span class="edit_remove_skin_container">',
		"item_after"	=> _isso(!empty($skin["css"]),'<span class="edit_remove_skin"><a class="find tooltip" title="'.__('CSS Location:','cloudfw').SKINS_DIR.$skin["css"].'" href="#"><span>'.__('Css','cloudfw').'</span></a></span>').'</span>'
		);
						
	}
	
	return $skins;
	
}


/*
 *	CloudFw Background Set
 *
 *	@since 1.0
**/

function cloudfw_SEL_background_set($atts = array()){
	extract($atts);
	global $array_patterns, $array_image_repeat, $array_image_attachment, $array_image_positions;
?>

			<div class="microtabWrap">
                <ul class="microtab">
                    <li><a class="microTabIcons pDefined" href="#<?php echo $sectionModule_;?>_pdefined"><?php _e('Predefined Styles','cloudfw'); ?></a>
                        <div id="<?php echo $sectionModule_;?>_pdefined" class="microTabContent">
                            <div class="sub-title"><?php _e('Pattern','cloudfw'); ?>:</div>
                            <?php
                            
                            admin_create_gf_menu (array(
                                'id'		=> cloudfw_PV_make_form_name(_isso($sectionModule_pattern, $sectionModule_pattern, $sectionModule),'pattern'),
                                'value'		=> $data[_isso($sectionModule_pattern, $sectionModule_pattern, $sectionModule)]["pattern"],
                                'content'	=> $array_patterns,
                                'width'		=> '260',
								'class'		=> '',
								'acc'		=> TRUE
                                )
                            );
                            
                            ?>
                         <div class="clear"></div>
                        </div><!--/Tab-->
                    </li>
                        
                    <li><a class="microTabIcons cImage" href="#<?php echo $sectionModule_;?>_cimage"><?php _e('Custom Image','cloudfw'); ?></a>
                        <div id="<?php echo $sectionModule_;?>_cimage" class="microTabContent">
                        <div class="sub-title"><?php _e('Image URL','cloudfw'); ?>:</div>
                        <?php
						admin_create_upload_button_v2(array(
					        'id' => cloudfw_PV_make_form_name($sectionModule,'background-image'),
					        'value' => $data[$sectionModule]["background-image"],
					        'preview' => FALSE,
					        'thumb_path' => $data['thumbnail'],
					        'upload_button_value' => __('Upload','cloudfw'),
					        'class' => 'input_230',
					        'wrapClass' => 'minimal-upload',
					    ));
						
						?>
                        <div class="grid oneof2">
                        <div class="sub-title"><?php _e('Image-Repeat','cloudfw'); ?>:</div>
                            <?php
                            admin_create_gf_menu (array(
                                'id'		=> cloudfw_PV_make_form_name($sectionModule,'background-repeat'),
                                'value'		=> $data[$sectionModule]["background-repeat"],
                                'content'	=> $array_image_repeat,
                                'width'		=> '145',
								'class'		=> '',
								'acc'		=> TRUE
                                )
                            );
                            
                            ?>
                         <div class="clear"></div>
                      	</div><!--/oneof2-->
                      <div class="grid oneof2 last">
                        <div class="sub-title"><?php _e('Image-Position','cloudfw'); ?>:</div>
                            <?php
                            admin_create_gf_menu (array(
                                'id'		=> cloudfw_PV_make_form_name($sectionModule,'background-position'),
                                'value'		=> $data[$sectionModule]["background-position"],
                                'content'	=> $array_image_positions,
                                'width'		=> '145',
								'class'		=> ''
                                )
                            );
                            
                            ?>
                         <div class="clear"></div>
                      	</div><!--/oneof2-->
                      <?php if ($array_image_attachment && $attachment):?>
                      <div class="grid">
                        
                        <div class="sub-title"><?php _e('Image-Attachment','cloudfw'); ?>:</div>
                            <?php
                            admin_create_gf_menu (array(
                                'id'		=> cloudfw_PV_make_form_name($sectionModule,'background-attachment'),
                                'value'		=> $data[$sectionModule]["background-attachment"],
                                'content'	=> $array_image_attachment,
                                'width'		=> '205',
								'class'		=> ''
                                )
                            );
                            
                            ?>
                         <div class="clear"></div>
                         
                      	</div><!--/grid-->
                      <?php endif;?>
                      
                        </div><!--/Tab-->
                    </li>
                </ul>
                
            </div>


<?php
};


?>