```
## Todo
-Need to import all the paragraph images into Media Library and assign them to their page.
-Getting Errors on some of the images
-Also need to fix the file permissions for the fetched images.
-Need to pull all image url’s out of the post_content sections and replace them with images that are imported into the Media Library.
-Need to replace any ‘keywords’ with the correct url’s.
+ac|todo item
+-|-----
+X|Need to import all the paragraph images into Media Library and assign them to their page.
+X|Getting Errors on some of the images
+X|Also need to fix the file permissions for the fetched images.
+X|Need to pull all image url’s out of the post_content sections and replace them with images that are imported into the Media Library.
+ |Need to replace any ‘keywords’ with the correct url’s.
+ |Need to replace any of the old site url's from their name-number/ to the correct wordpress ones.
$sql = "SELECT * FROM toolbox.pages";
$data = $this->_dbh->query($sql)->fetchAll();
printf('<p>Found %d Pages</p>', count($data));
- echo '<a href="admin.php?import=toolbox&step=1">Start the Import Now</a>';
+ echo '<p><a href="admin.php?import=toolbox&step=1">Start the Import Now</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=2">Part 2</a></p>';
}
}
echo '<pre>' . print_r($this->_options, true) . '</pre>';
}
+ /**
+ * _findAndReplace
+ *
+ * Find and Replace all the 'keyword'
+ *
+ * @param mixed $haystack String for replacement
+ *
+ * @access private
+ * @return void
+ */
+ private function _findAndReplace($haystack)
+ {
+ if (strstr($haystack, '{') !== false) {
+ $pattern = '/\{([A-Z0-9\&\-\,\'\" ]*)\}/i';
+ if (preg_match_all($pattern, $haystack, $needle) != 0) {
+ $total = count($needle[0]);
+ for ($iter = 0; $iter < $total; $iter++) {
+ // replace this with the real post
+ $page = $this->_pageGateway->findByKeyword($needle[1][$iter]);
+ if ($page == false) {
+ //return $haystack;
+ } else {
+ // need to get the page url for this from wp
+ $seoUrl = Toolkit_Template_Page::getSeoUrl(
+ $this->_pageGateway,
+ $page['id']
+ );
+ $anchor = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
+ $haystack = str_replace($needle[0][$iter], $anchor, $haystack);
+ }
+ }
+ return $haystack;
+ } else {
+ return $haystack;
+ }
+
+ if (strstr($haystack, '{') !== false) {
+ return $this->_findAndReplace($haystack);
+ }
+ }
+
+ return $haystack;
+ }
+
/**
* _import
*
}
}
+ private function _replaceUrls()
+ {
+ $this->_connect();
+ echo '<p>Replace keywords</p>';
+ $sql = "
+ SELECT id,navigation_name,keyword
+ FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_page_table']}
+ WHERE keyword != ''
+ ORDER BY parent,pos";
+ $stmt = $this->_dbh->query($sql);
+ while ($page = $stmt->fetch()) {
+ echo '<pre>' . print_r($page, true) . '</pre>';
+ }
+ echo '<p>Replace page url\'s</p>';
+ }
+
/**
* dispatch
*
case 1:
$this->_import();
break;
+ case 2:
+ $this->_replaceUrls();
+ break;
}
$this->_footer();