/**
  * main class constructor
  * @param $module
  */
 public function __construct($module = null)
 {
     parent::__construct();
     if ($module instanceof HW_Module) {
         $this->module = $module;
     }
     $this->posts = new HWIE_Posts_Group($this);
     //posts
     $this->options = new HWIE_Options_Group($this);
     //options
     $this->skins = new HWIE_Skins_Group($this);
     //skins mananger
     $this->widgets = new HWIE_Widgets_Group($this);
     //widgets data
 }
 /**
  * @param string $item
  * @return array|string
  */
 public function parse_skin_values($item = '')
 {
     $simplexml_parser = HW_WXR_Parser::get_instance()->simplexml_parser;
     $skin = $this->get_skin(0);
     //->cloneNode(true);
     $xml = self::dom_to_simplexml($skin);
     //standalone element must assign namespaces
     $simplexml_parser->gather_skins_data($this->skins_data);
     $data = $simplexml_parser->build_skin_data($xml);
     return $data ? isset($data[$item]) ? $data[$item] : '' : $data;
 }
 /**
  * parse config data for command
  * @param $cmd_name
  * @param $item
  * @return array|WP_Error
  */
 public function parse_wxr_data($cmd_name, $item = '')
 {
     if (empty($this->xml)) {
         return;
     }
     $cmd_data = array();
     if (isset($this->xml->{$cmd_name})) {
         //$parser = new HW_WXR_Parser_SimpleXML ;
         $parser = new HW_WXR_Parser();
         $cmd_data = $parser->parse($this->xml->{$cmd_name});
         /*foreach($this->xml->$cmd_name as $item) {
               //$cmd_data = $parser->parse( $item->children() );
           }*/
     }
     return $item ? isset($cmd_data[$item]) ? $cmd_data[$item] : '' : $cmd_data;
 }
 /**
  * fetch modules from repositories
  * @return array
  */
 function get_modules_repositories()
 {
     //$parser = new HW_WXR_Parser ;
     $this->packages = HW_WXR_Parser::read_simplexml_object(HW_HOANGWEB_PLUGINS . '/modules-package.xml');
     /*if(!empty($result->xml->module))
             foreach($result->xml->module as $module) {
     
             }*/
     return !empty($this->packages->xml->module) ? $this->packages->xml->module : array();
 }
 /**
  * add import result
  * @param $type
  * @param $name
  * @param $value
  */
 public function add_import($type, $name, $value)
 {
     global $wpdb;
     if (is_array($name)) {
         $name = HW_WXR_Parser::get_import_id($name);
     }
     if (!trim($name)) {
         return;
     }
     if (!is_string($value) && !is_numeric($value)) {
         $value = base64_encode(maybe_serialize($value));
     }
     $row = array('_type' => $type, 'name' => $name, 'value' => $value);
     $count = $wpdb->get_var("SELECT COUNT(*) FROM " . self::TRACKING_SQL_TABLE . " where name='{$name}' and _type='{$type}'");
     if ($count == 0) {
         $wpdb->insert(self::TRACKING_SQL_TABLE, $row);
         /*$wpdb->replace(self::TRACKING_SQL_TABLE,
               $row,
               array(
                   '%s',
                   '%s',
                   '%s',
               )
           );*/
     } else {
         $wpdb->update(self::TRACKING_SQL_TABLE, $row, array('name' => $name, '_type' => $type));
     }
     if ($type == 'post') {
         $this->importer->hw_processed_posts[$name] = $value;
     } elseif ($type == 'term') {
         $this->importer->processed_terms[$name] = $value;
     } elseif ($type == 'menu_item') {
         $this->importer->processed_menu_items[$name] = $value;
     }
 }