return ($id) ? $this->_getAttachmentById($id) : false;
}
- private function _handleMediaFile(
- $file,
- $file_title,
- $caption = '',
- $post_id = 0,
- $baseUrl = null
- ) {
+ private function _handleMediaFile( $file, $file_title, $caption = '', $post_id = 0, $baseUrl = null)
+ {
$id = array_search($file, $this->_files);
if ($id === false) {
set_time_limit(120);
$filename = wp_unique_filename($path, $file);
$fp = fopen($path . '/' . $filename, 'w+');
- $fileUrl = ($baseUrl) ? $baseUrl . '/' . $file : $this->_options['toolbox_image_url'] . $file;
+ $fileUrl = ($baseUrl) ? $baseUrl . '/' . rawurlencode($file) : $this->_options['toolbox_image_url'] . $file;
$ch = curl_init($fileUrl);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
}
}
- function _handleAccents($content)
+ private function _handleAccents($content)
{
// from: http://www.php.net/manual/en/domdocument.loadhtml.php#91513
if ( !empty( $content ) && function_exists( 'mb_convert_encoding' ) ) {
$fileBaseName = $fileInfo['filename'];
//echo '<pre>File Info: ' . print_r($fileInfo, true) . '</pre>';
//echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
+ //echo '<pre>$fileBaseName: ' . print_r( $fileBaseName, true ) . '</pre>';
$path = str_replace($fileName, '', $srcMatch[1]);
$path = $fileInfo['dirname'];
+ //echo '<pre>$path: ' . print_r( $path, true ) . '</pre>';
//echo '<pre>'.var_dump($path).'</pre>';
$imagesKey = $this->_getAttachmentByName($fileBaseName);
}
echo '<pre>Second: '.htmlspecialchars($content).'</pre>';
echo '</div>';
+ //exit;
$updatePost = array(
'ID' => $post->ID,
'post_content' => $content
$stmt = $this->_dbh->query($sql);
while ($row = $stmt->fetch()) {
echo '<pre>' . print_r($row, true) . '</pre>';
- $fileName = $row['filename'];
+ $filePath = (isset($this->_options['site_uses_ht_images']) && $this->_options['site_uses_ht_images'])
+ ? $this->_options['toolbox_files_url']
+ : $this->_options['toolbox_image_url'] . '/_ORIGINAL_/';
+ echo '<pre>$filePath: ' . print_r( $filePath, true ) . '</pre>';
+ $fileName = $row['filename'];
$fileTitle = ($row['urltext']) ? $row['urltext'] : $fileName;
- $wpImage = $this->_handleMediaFile(
+ $wpImage = $this->_handleMediaFile(
$fileName,
$fileTitle,
'',
0,
- $this->_options['toolbox_image_url'] . '/_ORIGINAL_/'
+ $filePath
);
echo '<pre>' . print_r($wpImage, true) . '</pre>';
$this->_files[$wpImage] = $fileName;
switch($step) {
case 0:
$this->_greet();
+ echo '<pre>$this->_options: ' . print_r( $this->_options, true ) . '</pre>';
echo '<p><a href="admin.php?import=toolbox&step=1">Begin Import</a></p>';
$currentPostArray = get_option(GLM_WP_IMPORT_POST_OPTION, array());
echo '<pre>' . print_r($currentPostArray, true) . '</pre>';
$imageLimit = 100;
echo '<p>Done</p>';
echo '<p>Now processing the images from old database tables</p>';
- if (isset($_REQUEST['start'])) {
- echo '<p>Second Part of the images</p>';
- $totalImages = $this->_getCkImageCount();
- echo '<p>Number of images in ckimage ' . $totalImages . '</p>';
- $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT );
- if ($start > $totalImages ) {
- echo '<p>Done</p>';
- echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
- } else {
- $this->_getCkImages( $imageLimit, $start );
- $start += $imageLimit;
- $endCount = $start + $imageLimit;
- echo '<p><a href="admin.php?import=toolbox&step=2&start=' . $start . '">
- Step Two [' . $start . ' - ' . $endCount . ']</a></p>';
- }
+ if ( isset($this->_options['site_uses_ht_images']) && $this->_options['site_uses_ht_images'] ) {
+ echo '<p>Site does not use ckimages</p>';
+ echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
} else {
- $start = 0;
- $this->_images = array();
- $this->_storeImages();
- if ($this->_options['toolbox_page_table'] == 'pages') {
- $this->_getParagraphImages();
- echo '<p>Done with Paragraph images</p>';
- $endCount = $start + $imageLimit;
- echo '<p><a href="admin.php?import=toolbox&step=2&start=' . $start . '">
- Step Two [' . $start . ' - ' . $endCount . ']</a></p>';
+ if (isset($_REQUEST['start'])) {
+ echo '<p>Second Part of the images</p>';
+ $totalImages = $this->_getCkImageCount();
+ echo '<p>Number of images in ckimage ' . $totalImages . '</p>';
+ $start = filter_var( $_REQUEST['start'], FILTER_VALIDATE_INT );
+ if ($start > $totalImages ) {
+ echo '<p>Done</p>';
+ echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
+ } else {
+ $this->_getCkImages( $imageLimit, $start );
+ $start += $imageLimit;
+ $endCount = $start + $imageLimit;
+ echo '<p><a href="admin.php?import=toolbox&step=2&start=' . $start . '">
+ Step Two [' . $start . ' - ' . $endCount . ']</a></p>';
+ }
} else {
- $this->_getBusCategoryImages();
- $this->_getBusImages();
- echo '<p>No import from images</p>';
- echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
+ $start = 0;
+ $this->_images = array();
+ $this->_storeImages();
+ if ($this->_options['toolbox_page_table'] == 'pages') {
+ $this->_getParagraphImages();
+ echo '<p>Done with Paragraph images</p>';
+ $endCount = $start + $imageLimit;
+ echo '<p><a href="admin.php?import=toolbox&step=2&start=' . $start . '">
+ Step Two [' . $start . ' - ' . $endCount . ']</a></p>';
+ } else {
+ $this->_getBusCategoryImages();
+ $this->_getBusImages();
+ echo '<p>No import from images</p>';
+ echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
+ }
}
}
+
break;
case 3:
echo '<p>Done</p>';
echo '<p>Now processing the files from old database tables</p>';
$this->_files = array();
$this->_storeFiles();
- if ($this->_options['toolbox_page_table'] == 'pages') {
+ if ( $this->_options['toolbox_files_table'] ) {
$this->_getToolboxFiles();
echo '<p>Done</p>';
} else {
- echo '<p>No import from images</p>';
+ echo '<p>No import from files</p>';
}
echo '<p><a href="admin.php?import=toolbox&step=4">Step Four (Updating Image Ref)</a></p>';
break;