11<?php
22/**
33 * Venustheme
4- *
4+ *
55 * NOTICE OF LICENSE
6- *
6+ *
77 * This source file is subject to the Venustheme.com license that is
88 * available through the world-wide-web at this URL:
99 * http://www.venustheme.com/license-agreement.html
10- *
10+ *
1111 * DISCLAIMER
12- *
12+ *
1313 * Do not edit or add to this file if you wish to upgrade this extension to newer
1414 * version in the future.
15- *
15+ *
1616 * @category Venustheme
1717 * @package Ves_Blog
1818 * @copyright Copyright (c) 2016 Venustheme (http://www.venustheme.com/)
@@ -25,6 +25,9 @@ class Wordpress extends AbstractImport
2525 protected $ _oldCategories = [];
2626 protected $ _catCount = 0 ;
2727
28+ /**
29+ * @inheritdoc
30+ */
2831 public function execute ()
2932 {
3033 $ importPosts = $ this ->getData ('import_posts ' );
@@ -65,7 +68,7 @@ public function execute()
6568 $ data [$ i ]['name ' ] = $ cat ['name ' ];
6669 $ data [$ i ]['parent_id ' ] = $ cat ['parent ' ];
6770 $ data [$ i ]['stores ' ] = [$ this ->_storeManager ->getDefaultStoreView ()->getStoreId ()];
68- $ i ++;
71+ $ i ++;
6972 }
7073 }
7174 if ($ data ){
@@ -79,7 +82,7 @@ public function execute()
7982 $ _cat ['category_id ' ] = $ category ->getId ();
8083 $ _cat ['image ' ] = $ _cat ['layout_type ' ] = $ _cat ['orderby ' ] = $ _cat ['comments ' ] = $ _cat ['item_per_page ' ] = $ _cat ['lg_column_item ' ] = $ _cat ['md_column_item ' ] = $ _cat ['sm_column_item ' ] = $ _cat ['xs_column_item ' ] = $ _cat ['page_layout ' ] = $ _cat ['page_title ' ] = $ _cat ['canonical_url ' ] = $ _cat ['layout_update_xml ' ] = $ _cat ['meta_keywords ' ] = $ _cat ['meta_description ' ] = $ _cat ['posts_style ' ] = $ _cat ['posts_template ' ] = $ _cat ['post_template ' ] = '' ;
8184 }
82- $ _cat ['importing ' ] = true ;
85+ $ _cat ['importing ' ] = true ;
8386 $ category ->setData ($ _cat )->save ();
8487 $ cats [] = $ this ->drawItems ($ data , $ _cat , 0 , $ category ->getId ());
8588 $ oldCategories = $ this ->_oldCategories ;
@@ -126,12 +129,12 @@ public function execute()
126129 // Image
127130 $ image = '' ;
128131 $ real_image_url = '' ;
129- $ sql = "SELECT ( SELECT guid FROM " . $ prefix . "posts WHERE id = m.meta_value ) AS url
132+ $ sql = "SELECT ( SELECT guid FROM " . $ prefix . "posts WHERE id = m.meta_value ) AS url
130133 FROM " . $ prefix . "posts p, " . $ prefix . "postmeta m
131134 WHERE p.post_type = 'post'
132135 AND p.post_status = 'publish'
133136 AND p.id = m.post_id
134- AND m.meta_key = '_thumbnail_id'
137+ AND m.meta_key = '_thumbnail_id'
135138 AND p.id = ' " . $ data ['ID ' ] . "' " ;
136139 $ result3 = $ this ->_mysqliQuery ($ sql );
137140 if ($ result3 ){
@@ -146,8 +149,8 @@ public function execute()
146149 }
147150 }
148151 }
149-
150-
152+
153+
151154 // Tags
152155 $ postTags = [];
153156 if ($ importTags ){
@@ -257,7 +260,11 @@ public function execute()
257260 }
258261 }
259262
260- public function decodeImg ($ str ){
263+ public function decodeImg ($ str )
264+ {
265+ if (!$ str ) {
266+ return $ str ;
267+ }
261268 $ count = substr_count ($ str , "<img " );
262269 $ tmpImg = '' ;
263270 for ($ i =0 ; $ i < $ count ; $ i ++) {
@@ -276,12 +283,14 @@ public function decodeImg($str){
276283 return $ str ;
277284 }
278285
279- public function getCategory ($ cat_id = 0 ){
286+ public function getCategory ($ cat_id = 0 )
287+ {
280288 $ category = $ this ->_categoryFactory ->create ();
281289 return $ category ->load ((int )$ cat_id );
282290 }
283291
284- public function drawItems ($ collection , $ cat , $ level = 0 , $ parentId = '' ){
292+ public function drawItems ($ collection , $ cat , $ level = 0 , $ parentId = '' )
293+ {
285294 $ overwrite = $ this ->getData ('overwrite ' );
286295 $ oldCategories = $ this ->_oldCategories ;
287296 foreach ($ collection as $ _cat ) {
@@ -312,4 +321,4 @@ public function drawItems($collection, $cat, $level = 0, $parentId = ''){
312321
313322 return $ cat ;
314323 }
315- }
324+ }
0 commit comments