/** * fetch skins * @param $skins * @param string $fhash_skin * @param string $fconfig_name * @param array $extra * @param bool $compac_skin */ public function fetch_skins($skins, $fhash_skin = 'hash_skin', $fconfig_name = 'hwskin_config', $extra = array(), $compac_skin = true) { $result = array(); if (!empty($skins)) { foreach ($skins as $skin) { $name = (string) $skin->attributes()->name; $_skin = $skin->children($this->namespaces['skin']); $skin_type = !empty($_skin->skin_type) ? (string) $_skin->skin_type : 'file'; //skin $pskin = new HWIE_Skin_Params($name ? $name : 'skin', (string) $_skin->instance); //skins data for current module $pskin->skins_data = HWIE_Param::dom_to_simplexml($this->skins->documentElement, 'SimpleXMLElement', 'params'); $pskin->add_hash_skin($fhash_skin, array('skin' => (string) $_skin->skin_name, 'file' => (string) $_skin->file, 'source' => (string) $_skin->source, 'group' => (string) $_skin->group, 'skin_type' => $skin_type)); #$pskin->add_skin_config(); $pskin->add_skin_config($fconfig_name, array('group' => (string) $_skin->group)); $extra_params = array('hwskin_condition' => "", 'skin_options' => array('enqueue_css_position' => 'footer', 'enqueue_js_position' => 'footer')); if ($skin_type == 'link') { $pskin->add_skin_file('url', array('file' => (string) $_skin->file)); } if (!empty($_skin->params)) { $skin_params = $this->simplexml_parser->recursive_option_data($_skin->params->children())->option; if (!empty($skin_params)) { $extra_params = array_merge($extra_params, $skin_params); } } if (is_array($extra) && count($extra)) { $extra_params = array_merge($extra_params, $extra); } $pskin->extra_params($extra_params); $result[$name] = $compac_skin ? $pskin->get_skin(false) : $pskin; #$pskin->parse_skin_values(); } } return $result; }
/** * export module data to wxr format (module data mean short data written for module) * @param $xml */ public function export_wxr_data($xml = null) { #$this->test();return; if (empty($xml)) { $xml = $this->xml_data; } $module = $this->get_module()->option('module_name'); foreach ($this->get_posts_xml($xml) as $item) { $item_atts = (array) $item->attributes(); //get xml element attributes $wp = $item->children($this->namespaces['wp']); $hw = $item->children($this->namespaces['hw']); $title = (string) $wp->title; $form = $hw->form_html->children($this->namespaces['hw']); $form_html = (string) $form->html; if (!empty($hw->mail)) { //$mail = self::array_to_xml_params($hw->mail, false); $mail = dom_import_simplexml($hw->mail); } else { $mail = array(); } //form skin $atts = $hw->skin->attributes(); $skin = $hw->skin->children($this->namespaces['skin']); $skin_name = $atts['name'] ? $atts['name'] : 'skin'; /*$skin_instance = !empty($skin->instance)? (string) $skin->instance : 'hw-wpcf7'; $skin_source = !empty($skin->source)? (string) $skin->source : 'plugin'; $pskin = new HWIE_Skin_Params(($atts['name']? $atts['name'] : 'skin'), $skin_instance); $pskin->add_hash_skin('hash_skin', array( 'skin' => (string)$skin->skin_name, 'source' => $skin_source )); $pskin->add_skin_config(); $params = array( 'hwskin_condition' => '', 'skin_options' => array( 'enqueue_css_position' => 'head', 'enqueue_js_position' => 'footer' ) ); if(!empty($skin->params)) { $skin_params = $this->simplexml_parser->recursive_option_data($skin->params)->option; if(!empty($skin_params)) $params = array_merge($params, $skin_params); } $pskin->extra_params($params); */ $skins = $this->fetch_skins($skin, 'hash_skin', 'hwskin_config', 0, false); //google form id if (isset($hw->google_formID)) { $gform_id = (string) $hw->google_formID; } else { $gform_id = '1GzynAtb3hiv6E0mFE0KhxMwARSYGdGSY8oJ5ImGM7m4'; } $this->posts->addItem(array('title' => $title, 'description' => '', 'content' => '', 'excerpt' => '', 'post_type' => 'wpcf7_contact_form', 'post_metas' => array('_wpcf7-form' => $form_html, '_form' => $form_html, '_mail' => $mail, '_mail_2' => array('active' => '0', 'subject' => '', 'sender' => '', 'body' => '', 'recipient' => '', 'additional_headers' => ''), '_messages' => array('mail_sent_ok' => '', 'mail_sent_ng' => '', 'validation_error' => '', 'spam' => '', 'accept_terms' => '', 'invalid_required' => '', 'invalid_too_long' => '', 'invalid_too_short' => ''), '_additional_settings' => 'on_sent_ok: "" on_submit: ""', '_locale' => 'vi', '_hw_wpcf7_use_skin' => 'on', '_hw_wpcf7_skin' => $skins[$skin_name]->get_hash_skin(), '_hw_wpcf7skin_setting' => $skins[$skin_name]->get_skin(), '_hw_custom_css' => '', '_hw_form_template' => 'basic-contact-form', '_hw_gformID' => $gform_id, '_enable_email_by_gapp' => 'on', '_hook_url' => '', '_hwcf_data_hook' => 'google_form', '_hw_sent_ok_redirect_page' => '-1', '_hw_on_sent_ok_js_event' => '', '_hw_on_submit_js_event' => '', '_hw_default_gform' => '', '_hw_form_class_attr' => (string) $form->form_class, '_hw_form_id_attr' => (string) $form->form_id, '_hw_form_name_attr' => (string) $form->form_name, '_hw_form_enctype_attr' => (string) $form->form_enctype)), $item_atts['@attributes']); /*$ele=new HWIE_Param('params:skin_encoded', array('instance'=> $module, 'name' => 'hash_skin')); $ele->add_child('skin:skin', 'skin1'); $ele->add_child('skin:skin_type', 'file');*/ } //set options foreach ($this->get_options_xml($xml) as $item) { $atts = $item->attributes(); $name = !empty($atts['name']) ? (string) $atts['name'] : 'loadingImg'; $hw = $item->children($this->namespaces['hw']); $skin = $hw->skin->children($this->namespaces['skin']); $skin_instance = !empty($skin->instance) ? (string) $skin->instance : 'hwcf7_images'; $skin_source = !empty($skin->source) ? (string) $skin->source : 'plugin'; $group = (string) $skin->group; //wpcf7 loading $skin_image = new HWIE_Skin_Params($name, $skin_instance); $skin_image->add_hash_skin('hash_skin', array('skin' => (string) $skin->skin_name, 'source' => $skin_source, 'skin_type' => (string) $skin->skin_type, 'group' => $group)); $skin_image->add_skin_config('hwskin_config', array('group' => $group)); $skin_image->add_skin_file('url', array('file' => (string) $skin->file)); break; } if (isset($skin_image)) { $this->options->add_option('HW_Wpcf_settings', array('general' => array('enable_wpcf7_css' => '1', 'enable_wpcf7_js' => '1', 'exclude_pages' => array('__all__'), 'loadingImg' => $skin_image->get_skin(false)), 'webhook' => array('webhook_url' => ''))); } //start import $this->do_import(); }