From: Steve Sutton Date: Tue, 18 Aug 2015 16:27:47 +0000 (-0400) Subject: updates for mountpleasant X-Git-Tag: v0.0.2^2~6 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=8d662a547eceffac45ee34a2426282f68cd3a638;p=WP-Plugins%2Fglm-wp-importer.git updates for mountpleasant --- diff --git a/NOTES.md b/NOTES.md index ec8e4fb..473d5bb 100644 --- a/NOTES.md +++ b/NOTES.md @@ -77,5 +77,8 @@ Step 2 I have all media being imported. Step 3 Updates all media src tags and caption tags Step 4 update keywords , site urls links inside, and update file refs -## For 08/11/2015 ## +### For 08/11/2015 ### Need to check the image references against the database and not the files array + +### For 08/18/2015 ### +May need to check for any links to old member profile pages? Or this may be for something the member import has to do. diff --git a/controllers/Import.php b/controllers/Import.php index a9833c8..43a77fb 100644 --- a/controllers/Import.php +++ b/controllers/Import.php @@ -1015,9 +1015,12 @@ echo '
Caption Text: ' . print_r($cMatch[2][$index], true)  . '
'; if (preg_match('%src="([^"]+)"%', $cMatch[1][$index], $srcMatch)) { echo '
Sub Src Match: ' . print_r($srcMatch[1], true)  . '
'; + $fileInfo = pathinfo($srcMatch[1]); $fileName = basename($srcMatch[1]); + $fileName = $fileInfo['filename']; echo '
File Name: ' . print_r($fileName, true)  . '
'; $path = str_replace($fileName, '', $srcMatch[1]); + $path = $filInfo['dirname']; $imagesKey = $this->_getAttachmentByName($fileName); var_dump($imagesKey); if (!$imagesKey) { @@ -1047,17 +1050,28 @@ } } } + // In this next part Have to remember the $content is already processed. + // Don't edit src if they alrea,dy have an ID if (preg_match_all('%]+)>%', $content, $matches)) { $imageCount = count($matches[0]); for ($index = 0; $index < $imageCount; ++$index) { echo '
Image Match: ' . $imageCount  . '
'; echo '
'.htmlspecialchars($matches[0][$index]).'
'; + if (!(($uploads = wp_upload_dir()) && false === $uploads['error'])) { + return new WP_Error('upload_error', $uploads['error']); + } + echo '
Uploads Url: ' . print_r($uploads['url'], true)  . '
'; + if (preg_match('%src="' . $uploads['url'] . '[^"]+"%', $matches[1][$index], $pMatch)) { + continue; + } if (preg_match('%src="([^"]+)"%', $matches[1][$index], $srcMatch)) { echo '
Sub Src Match: ' . print_r($srcMatch[1], true)  . '
'; - $fileName = basename($srcMatch[1]); + $fileInfo = pathinfo($srcMatch[1]); + echo '
' . print_r($fileInfo, true) . '
'; + $fileName = $fileInfo['filename']; echo '
File Url: ' . print_r($srcMatch[1], true)  . '
'; echo '
File Name: ' . print_r($fileName, true)  . '
'; - $path = str_replace($fileName, '', $srcMatch[1]); + $path = $filInfo['dirname']; echo '
File Path: ' . print_r($path, true)  . '
'; $imagesKey = $this->_getAttachmentByName($fileName); var_dump($imagesKey); @@ -1104,7 +1118,7 @@ SELECT * FROM {$wpdb->prefix}posts WHERE post_type = 'attachment' - AND (post_name = '{$name}' OR post_title = '{$name}')"; + AND (post_name like '{$name}%' OR post_title like '{$name}%')"; $results = $wpdb->get_results($sql, OBJECT); return (!empty($results)) ? $results[0]->ID : false; //return (!empty($results)) ? $results[0] : false; @@ -1154,7 +1168,7 @@ echo '
' . print_r($filename, true) . '
'; echo '
' . print_r($rootUrl, true) . '
'; $img_id = $this->_handleMediaFile( - basename($parsed['path']), + $filename, '', $post->ID, $rootUrl . '/' @@ -1332,6 +1346,7 @@ $this->_updateFilesHref(); echo '

Done

'; echo '

Step Five (Updating Url\'s and keywords)

'; + break; case 5: echo '

Phase Five

'; echo '

Site Url

';