optionsframework_machine($options); $this->Inputs = $return[0]; $this->Menu = $return[1]; $this->Defaults = $return[2]; } /** * Process options data and build option fields * * @uses get_option() * * @access public * @since 1.0.0 * * @return array */ public static function optionsframework_machine($options) { $data = get_option(OPTIONS); $defaults = array(); $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; //create array of defaults if ($value['type'] == 'multicheck'){ if (is_array($value['std'])){ foreach($value['std'] as $i=>$key){ $defaults[$value['id']][$key] = true; } } else { $defaults[$value['id']][$value['std']] = true; } } else { if (isset($value['id'])) $defaults[$value['id']] = $value['std']; } //Start Heading if ( $value['type'] != "heading" ) { $class = ''; if(isset( $value['class'] )) { $class = $value['class']; } //hide items in checkbox group $fold=''; if (array_key_exists("fold",$value)) { if ($data[$value['fold']]) { $fold="f_".$value['fold']." "; } else { $fold="f_".$value['fold']." temphide "; } } $output .= '
'."\n"; //only show header if 'name' value exists if($value['name']) $output .= '

'. $value['name'] .'

'."\n"; $output .= '
'."\n" . '
'."\n"; } //End Heading //switch statement to handle various options type switch ( $value['type'] ) { //text input case 'text': $t_value = ''; $t_value = stripslashes($data[$value['id']]); $mini =''; if(!isset($value['mod'])) $value['mod'] = ''; if($value['mod'] == 'mini') { $mini = 'mini';} $output .= ''; break; //select option case 'select': $mini =''; if(!isset($value['mod'])) $value['mod'] = ''; if($value['mod'] == 'mini') { $mini = 'mini';} $output .= '
'; $output .= '
'; break; //textarea option case 'textarea': $cols = '8'; $ta_value = ''; if(isset($value['options'])){ $ta_options = $value['options']; if(isset($ta_options['cols'])){ $cols = $ta_options['cols']; } } $ta_value = stripslashes($data[$value['id']]); $output .= ''; break; //radiobox option case "radio": foreach($value['options'] as $option=>$name) { $output .= ''; } break; //checkbox option case 'checkbox': if (!isset($data[$value['id']])) { $data[$value['id']] = 0; } $fold = ''; if (array_key_exists("folds",$value)) $fold="fld "; $output .= ''; $output .= ''; break; //multiple checkbox option case 'multicheck': $multi_stored = $data[$value['id']]; foreach ($value['options'] as $key => $option) { if (!isset($multi_stored[$key])) {$multi_stored[$key] = '';} $of_key_string = $value['id'] . '_' . $key; $output .= '
'; } break; //multiple checkbox option case 'sidebar': break; //ajax image upload option case 'upload': if(!isset($value['mod'])) $value['mod'] = ''; $output .= Options_Machine::optionsframework_uploader_function($value['id'],$value['std'],$value['mod']); break; // native media library uploader - @uses optionsframework_media_uploader_function() case 'media': $_id = strip_tags( strtolower($value['id']) ); $int = ''; $int = optionsframework_mlu_get_silentpost( $_id ); if(!isset($value['mod'])) $value['mod'] = ''; $output .= bresponZive_themepacific_Options_Machine::optionsframework_media_uploader_function( $value['id'], $value['std'], $int, $value['mod'] ); // New AJAX Uploader using Media Library break; //colorpicker option case 'color': $output .= '
'; $output .= ''; break; //typography option case 'typography': $typography_stored = isset($data[$value['id']]) ? $data[$value['id']] : $value['std']; /* Font Size */ if(isset($typography_stored['size'])) { $output .= '
'; $output .= '
'; } /* Line Height */ if(isset($typography_stored['height'])) { $output .= '
'; $output .= '
'; } /* Font Face */ if(isset($typography_stored['face'])) { $output .= '
'; $output .= '
'; } /* Font Weight */ if(isset($typography_stored['style'])) { $output .= '
'; $output .= '
'; } /* Font Color */ if(isset($typography_stored['color'])) { $output .= '
'; $output .= ''; } break; //border option case 'border': /* Border Width */ $border_stored = $data[$value['id']]; $output .= '
'; $output .= '
'; /* Border Style */ $output .= '
'; $output .= '
'; /* Border Color */ $output .= '
'; $output .= ''; break; //images checkbox - use image as checkboxes case 'images': $i = 0; $select_value = $data[$value['id']]; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if(NULL!=checked($select_value, $key, false)) { $checked = checked($select_value, $key, false); $selected = 'of-radio-img-selected'; } $output .= ''; $output .= ''; $output .= '
'. $key .'
'; $output .= ''; $output .= '
'; } break; //info (for small intro box etc) case "info": $info_text = $value['std']; $output .= '
'.$info_text.'
'; break; //display a single image case "image": $src = $value['std']; $output .= ''; break; //tab heading case 'heading': if($counter >= 2){ $output .= '
'."\n"; } $header_class = str_replace(' ','',strtolower($value['name'])); $jquery_click_hook = str_replace(' ', '', strtolower($value['name']) ); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '
  • '. $value['name'] .'
  • '; $output .= '

    '.$value['name'].'

    '."\n"; break; //drag & drop slide manager case 'slider': $_id = strip_tags( strtolower($value['id']) ); $int = ''; $int = optionsframework_mlu_get_silentpost( $_id ); $output .= '
      '; $slides = $data[$value['id']]; $count = count($slides); if ($count < 2) { $oldorder = 1; $order = 1; $output .= bresponZive_themepacific_Options_Machine::optionsframework_slider_function($value['id'],$value['std'],$oldorder,$order,$int); } else { $i = 0; foreach ($slides as $slide) { $oldorder = $slide['order']; $i++; $order = $i; $output .= bresponZive_themepacific_Options_Machine::optionsframework_slider_function($value['id'],$value['std'],$oldorder,$order,$int); } } $output .= '
    '; $output .= 'Add New Slide
    '; break; //drag & drop block manager case 'sorter': $sortlists = isset($data[$value['id']]) && !empty($data[$value['id']]) ? $data[$value['id']] : $value['std']; $output .= '
    '; if ($sortlists) { foreach ($sortlists as $group=>$sortlist) { $output .= '
      '; $output .= '

      '.$group.'

      '; foreach ($sortlist as $key => $list) { $output .= ''; if ($key != "placebo") { $output .= '
    • '; $output .= ''; $output .= $list; $output .= '
    • '; } } $output .= '
    '; } } $output .= '
    '; break; //background images option case 'tiles': $i = 0; $select_value = isset($data[$value['id']]) && !empty($data[$value['id']]) ? $data[$value['id']] : ''; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if(NULL!=checked($select_value, $option, false)) { $checked = checked($select_value, $option, false); $selected = 'of-radio-tile-selected'; } $output .= ''; $output .= ''; $output .= '
    '; $output .= '
    '; } break; //backup and restore options data case 'backup': $instructions = $value['desc']; $backup = get_option(BACKUPS); if(!isset($backup['backup_log'])) { $log = 'No backups yet'; } else { $log = $backup['backup_log']; } $output .= '
    '; $output .= '
    '.$instructions."\n"; $output .= '

    '. __('Last Backup : ','ThemePacific').''.$log.'

    '."\n"; $output .= 'Backup Options'; $output .= 'Restore Options'; $output .= '
    '; break; //export or import data between different installs case 'transfer': $instructions = $value['desc']; $output .= ''."\n"; $output .= 'Import Options'; break; } //description of each option if ( $value['type'] != 'heading' ) { if(!isset($value['desc'])){ $explain_value = ''; } else{ $explain_value = '
    '. $value['desc'] .'
    '."\n"; } $output .= '
    '.$explain_value."\n"; $output .= '
    '."\n"; } } $output .= ''; return array($output,$menu,$defaults); } /** * Ajax image uploader - supports various types of image types * * @uses get_option() * * @access public * @since 1.0.0 * * @return string */ public static function optionsframework_uploader_function($id,$std,$mod){ $data =get_option(OPTIONS); $uploader = ''; $upload = $data[$id]; $hide = ''; if ($mod == "min") {$hide ='hide';} if ( $upload != "") { $val = $upload; } else {$val = $std;} $uploader .= ''; $uploader .= '
    '.__('Upload','ThemePacific').''; if(!empty($upload)) {$hide = '';} else { $hide = 'hide';} $uploader .= 'Remove'; $uploader .='
    ' . "\n"; $uploader .= '
    ' . "\n"; if(!empty($upload)){ $uploader .= '
    '; $uploader .= ''; $uploader .= ''; $uploader .= ''; $uploader .= '
    '; } $uploader .= '
    ' . "\n"; return $uploader; } /** * Native media library uploader * * @uses get_option() * * @access public * @since 1.0.0 * * @return string */ public static function optionsframework_media_uploader_function($id,$std,$int,$mod){ $data =get_option(OPTIONS); $uploader = ''; $upload = $data[$id]; $hide = ''; if ($mod == "min") {$hide ='hide';} if ( $upload != "") { $val = $upload; } else {$val = $std;} $uploader .= ''; $uploader .= '
    Upload'; if(!empty($upload)) {$hide = '';} else { $hide = 'hide';} $uploader .= 'Remove'; $uploader .='
    ' . "\n"; $uploader .= '
    '; if(!empty($upload)){ $uploader .= ''; $uploader .= ''; $uploader .= ''; } $uploader .= '
    '; $uploader .= '
    ' . "\n"; return $uploader; } /** * Drag and drop slides manager * * @uses get_option() * * @access public * @since 1.0.0 * * @return string */ public static function optionsframework_slider_function($id,$std,$oldorder,$order,$int){ $data = get_option(OPTIONS); $slider = ''; $slide = array(); $slide = $data[$id]; if (isset($slide[$oldorder])) { $val = $slide[$oldorder]; } else {$val = $std;} //initialize all vars $slidevars = array('title','url','link','description'); foreach ($slidevars as $slidevar) { if (!isset($val[$slidevar])) { $val[$slidevar] = ''; } } //begin slider interface if (!empty($val['title'])) { $slider .= '
  • '.stripslashes($val['title']).''; } else { $slider .= '
  • Slide '.$order.''; } $slider .= ''; $slider .= 'Edit
    '; $slider .= '
    '; $slider .= ''; $slider .= ''; $slider .= ''; $slider .= ''; $slider .= '
    Upload'; if(!empty($val['url'])) {$hide = '';} else { $hide = 'hide';} $slider .= 'Remove'; $slider .='
    ' . "\n"; $slider .= '
    '; if(!empty($val['url'])){ $slider .= ''; $slider .= ''; $slider .= ''; } $slider .= '
    '; $slider .= ''; $slider .= ''; $slider .= ''; $slider .= ''; $slider .= 'Delete'; $slider .= '
    ' . "\n"; $slider .= '
    '; $slider .= '
  • '; return $slider; } }//end Options Machine class ?>