Update for the files
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 28 Dec 2015 20:34:50 +0000 (15:34 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 28 Dec 2015 20:34:50 +0000 (15:34 -0500)
When pulling files really need to know which url for the files.
Creating a new option for file URL. Which will be used for the
file uploads.

controllers/Admin.php
controllers/ToolboxImport.php

index db0824d..194b4fc 100644 (file)
@@ -137,6 +137,11 @@ class GlmWPImporter_Admin_Controller
                 'label' => 'Toolbox Files Table',
                 'type'  => 'text'
             ),
+            array(
+                'name'  => 'toolbox_files_url',
+                'label' => 'Toolbox Files URL',
+                'type'  => 'text'
+            ),
             array(
                 'name'  => 'ckeditor_schema',
                 'label' => 'CKEditor Schema',
index 2d5581f..10a4df9 100644 (file)
             if (!$this->_options['toolbox_files_table']) {
                 $errors[] = 'Toolbox Files Table';
             }
+            if (!$this->_options['toolbox_files_url']) {
+                $errors[] = 'Toolbox Files URL';
+            }
             return $errors;
         }
 
                 //return false;
             //}
             //$fileUrl = wp_get_attachment_url($file_id);
-            $fileUrl =$this->_options['toolbox_image_url'] . '/original/' . $data['filename'];
+            $fileUrl =$this->_options['toolbox_files_url'] . '/' . $data['filename'];
             $fileName = ($data['urltext']) ? $data['urltext'] : $data['filename'];
             return "\n".'<a href="'.$fileUrl.'">'.$fileName.'</a>';
         }
             $sql = "
             SELECT *
               FROM {$wpdb->prefix}posts
-             WHERE post_content LIKE '%http://is0.gaslightmedia.com%'
+             WHERE post_content LIKE '%{$this->_options['toolbox_files_url']}%'
                AND post_type = 'page'";
             $sql .= " AND ID IN (" . implode(',', $currentPostArray) . ")";
             $results = $wpdb->get_results($sql, OBJECT);
                 foreach ($results as $post) {
                     $content = $post->post_content;
                     echo '<div style="border: 1px solid green; padding: 9px; margin: 10px;">';
-                    $urlPattern = '%<a href="(' . $this->_options['toolbox_image_url'] . '/[^">]*)" ?[^>]*>([^>]+)</a>%s';
+                    $urlPattern = '%<a href="(' . $this->_options['toolbox_files_url'] . '/[^">]*)" ?[^>]*>([^>]+)</a>%s';
                     if (preg_match_all($urlPattern, $content, $isMatch)) {
                         $isMatchCount = count($isMatch[0]);
                         echo '<p>Matches is0 ' . $isMatchCount . '</p>';
                                     $fileTitle,
                                     '',
                                     $post->ID,
-                                    $this->_options['site_url'] . '/uploads/'
+                                    $this->_options['toolbox_files_url'] . '/'
                                 );
                             }
                             if ($key !== false) {