From: Steve Sutton Date: Mon, 23 May 2016 20:07:13 +0000 (-0400) Subject: This update for csrye.org tables X-Git-Tag: v0.1.2^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=f8782313a108aac01eea0c1e91707560e53c3e55;p=WP-Plugins%2Fglm-wp-importer.git This update for csrye.org tables This toolbox had the files in the bus table. They usually are in the files table. --- diff --git a/controllers/ToolboxImport.php b/controllers/ToolboxImport.php index bfae9e3..a643145 100644 --- a/controllers/ToolboxImport.php +++ b/controllers/ToolboxImport.php @@ -127,12 +127,12 @@ if (!$this->_options['toolbox_paragraphs_table']) { $errors[] = 'Toolbox Paragraph Table'; } - if (!$this->_options['toolbox_files_table']) { - $errors[] = 'Toolbox Files Table'; - } - if (!$this->_options['toolbox_files_url']) { - $errors[] = 'Toolbox Files URL'; - } + //if (!$this->_options['toolbox_files_table']) { + // $errors[] = 'Toolbox Files Table'; + //} + //if (!$this->_options['toolbox_files_url']) { + // $errors[] = 'Toolbox Files URL'; + //} return $errors; } @@ -195,26 +195,19 @@ private function _displayFile($data) { - //if ($this->_options['toolbox_paragraphs_table'] == 'pages') { - //$file_id = $this->_handleMediaFile($data['filename']); - //} else { - //$file_id = $this->_handleMediaFile( - //$data['filename'], - //'', - //0, - //$this->_options['site_url'] . 'uploads/' - //); - //} - - //if (!$file_id) { - //return false; - //} - //$fileUrl = wp_get_attachment_url($file_id); $fileUrl =$this->_options['toolbox_files_url'] . '/' . $data['filename']; $fileName = ($data['urltext']) ? $data['urltext'] : $data['filename']; return "\n".''.$fileName.''; } + private function _displayFile2($file, $filename) + { + $fileUrl =$this->_options['site_url'] . 'uploads/' . $file; + $fileName = ($filename) ? $filename : $file; + return "\n".''.$fileName.''; + } + + private function _addMedia($file, $postId) { $fileType = wp_check_filetype(basename($file), null); @@ -375,7 +368,7 @@ FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_page_table']} $WHERE ORDER BY parent,pos"; - $pageSql .= ($limit) ? " LIMIT $limit OFFSET $offset" : ''; + //$pageSql .= ($limit) ? " LIMIT $limit OFFSET $offset" : ''; $pageData = $this->_dbh->query($pageSql)->fetchAll(PDO::FETCH_ASSOC); if ($this->_options['toolbox_page_table'] == 'pages') { $paragraphSql = " @@ -399,11 +392,18 @@ WHERE bcb.catid = :page ORDER BY bcb.pos"; $paraStmt = $this->_dbh->prepare($paragraphSql); - $fileSql = " - SELECT * - FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_files_table']} - WHERE bus_id = :pid - ORDER BY bus_id,pos"; + if ($this->_options['toolbox_files_table'] == 'pages') { + $fileSql = " + SELECT * + FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_files_table']} + WHERE bus_id = :pid + ORDER BY bus_id,pos"; + } else { + $fileSql = " + SELECT file,filename,file2,file2name,file3,file3name + FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_paragraphs_table']} + WHERE id = :pid"; + } $fileStmt = $this->_dbh->prepare($fileSql); } $data = $this->_dbh->query($pageSql)->fetchAll(); @@ -496,27 +496,23 @@ break; } $page['pageContent'] .= $paragraph['description']; - //preg_match_all("/' . print_r($matches, true) . ''; - - /* - for ($i = 0; $i < count($matches[0]); $i++) { - if ($matches[1][$i]) { - $newSrc = $this->_getDescriptionImage($matches[1][$i]); - $parsUrl = parse_url($newSrc); - $imgName = basename($parsUrl['path']); - $page['pageContent'] = str_replace($matches[1][$i], $newSrc, $page['pageContent']); - $page['srcs'][] = $imgName; - } - } - */ - //var_dump($paragraph['id']); $fileStmt->bindParam(':pid', $paragraph['id'], PDO::PARAM_INT); $fileStmt->execute(); while ($file = $fileStmt->fetch()) { - //echo '
Files: ' . print_r($file, true) . '
'; - //$page['files'][] = $file['filename']; - $page['pageContent'] .= $this->_displayFile($file); + echo '
$file: ' . print_r($file, true) . '
'; + if ($this->_options['toolbox_files_table'] == 'pages') { + $page['pageContent'] .= $this->_displayFile($file); + } else { + if ($file['file']) { + $page['pageContent'] .= $this->_displayFile2($file['file'], $file['filename']); + } + if ($file['file2']) { + $page['pageContent'] .= $this->_displayFile2($file['file2'], $file['file2name']); + } + if ($file['file3']) { + $page['pageContent'] .= $this->_displayFile2($file['file3'], $file['file3name']); + } + } } ++$iterator; }