PageRenderTime 103ms CodeModel.GetById 60ms app.highlight 6ms RepoModel.GetById 34ms app.codeStats 0ms

/wp-content/themes/mymaxiskirt/framework/php/wordpress-importer/avia-export-class.php

https://bitbucket.org/sanders_nick/my-maxi-skirt
PHP | 127 lines | 80 code | 27 blank | 20 comment | 16 complexity | a4184cd8e0da1ce7c7c107c54ae37623 MD5 | raw file
  1<?php  if ( ! defined('AVIA_FW')) exit('No direct script access allowed');
  2/**
  3 * This file holds the class that creates the options export file for the wordpress importer
  4 *
  5 *
  6 * @author		Christian "Kriesi" Budschedl
  7 * @copyright	Copyright (c) Christian Budschedl
  8 * @link		http://kriesi.at
  9 * @link		http://aviathemes.com
 10 * @since		Version 1.1
 11 * @package 	AviaFramework
 12 */
 13
 14/**
 15 *
 16 */
 17if( !class_exists( 'avia_wp_export' ) )
 18{
 19	class avia_wp_export 
 20	{
 21		function avia_wp_export($avia_superobject)
 22		{
 23			if(!isset($_GET['avia_export'])) return;
 24		
 25			$this->avia_superobject = $avia_superobject;
 26			$this->subpages = $avia_superobject->subpages;
 27			$this->options  = $avia_superobject->options;
 28			$this->db_prefix = $avia_superobject->option_prefix;
 29			
 30			add_action('admin_init',array(&$this, 'initiate'),200);
 31		}
 32		
 33		function initiate()
 34		{
 35
 36			//get the first subkey of the saved options array
 37			foreach($this->subpages as $subpage_key => $subpage)
 38			{
 39				$export[$subpage_key] = $this->export_array_generator($this->avia_superobject->option_page_data, $this->options[$subpage_key], $subpage);
 40			}
 41			
 42			//export of options
 43			$export = base64_encode(serialize($export));
 44			
 45			//export of dynamic pages
 46			$export_dynamic_pages = get_option($this->db_prefix.'_dynamic_pages');
 47			if($export_dynamic_pages) $export_dynamic_pages = base64_encode(serialize($export_dynamic_pages));
 48			
 49			//export of dynamic elements
 50			$export_dynamic_elements = get_option($this->db_prefix.'_dynamic_elements');
 51			if($export_dynamic_elements) $export_dynamic_elements = base64_encode(serialize($export_dynamic_elements));
 52			
 53			echo '<pre>&#60?php '."\n\n";
 54			echo '/*this is a base64 encoded option set for the default dummy data. If you choose to import the dummy.xml file with the help of the framework importer this options will also be imported*/'."\n\n";
 55			echo '$options = "';
 56			print_r($export);
 57			echo '";</pre>'."\n\n";
 58			
 59			echo '<pre>'."\n";
 60			echo '$dynamic_pages = "';
 61			print_r($export_dynamic_pages);
 62			echo '";</pre>';
 63			
 64			echo '<pre>'."\n";
 65			echo '$dynamic_elements = "';
 66			print_r($export_dynamic_elements);
 67			echo '";</pre>';
 68
 69			exit();
 70		}
 71		
 72		
 73		
 74		function export_array_generator($elements, $options, $subpage, $grouped = false)
 75		{	
 76
 77			$export = array();
 78			//iterate over all option page elements
 79			foreach($elements as $element)
 80			{
 81				if((in_array($element['slug'], $subpage) || $grouped) && isset($element['id']) && isset($options[$element['id']]))
 82				{
 83					if($element['type'] != 'group')
 84					{
 85						if(isset($element['subtype']) && !is_array($element['subtype']))
 86						{
 87							//pass id-value and subtype
 88							$taxonomy = false;
 89							if(isset($element['taxonomy'])) $taxonomy = $element['taxonomy'];
 90							
 91							$value = avia_backend_get_post_page_cat_name_by_id($options[$element['id']] , $element['subtype'], $taxonomy);
 92						}
 93						else
 94						{
 95							
 96							$value = $options[$element['id']];
 97						}
 98						
 99						if(isset($value))
100						{
101							$element['std'] = $value;
102							$export[$element['id']] = $element;
103						}
104					}
105					else
106					{
107						$iterations = count($options[$element['id']]);
108						$export[$element['id']] = $element;
109						for($i = 0; $i < $iterations; $i++)
110						{
111							$export[$element['id']]['std'][$i] = $this->export_array_generator($element['subelements'], $options[$element['id']][$i], $subpage, true);
112						}
113					}
114				}
115			}
116			
117			return $export;
118			
119		}
120		
121		
122
123		
124	}
125}
126
127