From f92f5714871090fda9591f767e17b782c16d9280 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 28 Jul 2016 08:45:23 -0400 Subject: [PATCH] Update for placing the page title into wp posts title. Adding a checkbox for the glm wp importer settings that will enable the setup to place the page titles into the posts titles. This was needed on Petoskey Area because their design had a separate area for placing the page title. Usually it would be inside the page content. --- controllers/Admin.php | 16 ++++++++++++++++ controllers/ToolboxImport.php | 35 +++++++++++++++++++---------------- views/checkbox.php | 5 +++++ 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 views/checkbox.php diff --git a/controllers/Admin.php b/controllers/Admin.php index 194b4fc..8721dea 100644 --- a/controllers/Admin.php +++ b/controllers/Admin.php @@ -87,6 +87,11 @@ class GlmWPImporter_Admin_Controller ); $fieldNames = array( + array( + 'name' => 'navigation_name_in_content', + 'label' => 'Place the navigation title into page content', + 'type' => 'checkbox' + ), array( 'name' => 'site_url', 'label' => 'Site URL', @@ -189,6 +194,9 @@ class GlmWPImporter_Admin_Controller case 'text': $callback = 'glmwpimporterRenderText'; break; + case 'checkbox': + $callback = 'glmwpimporterRenderCheckbox'; + break; default: return false; break; @@ -212,6 +220,14 @@ class GlmWPImporter_Admin_Controller include $this->path . 'views/text.php'; } + public function glmwpimporterRenderCheckbox($fieldName) { + static $options; + if (!$options) { + $options = get_option(GLM_WP_IMPORT_SETTINGS); + } + include $this->path . 'views/checkbox.php'; + } + public function glmwpimporter_settings_section_callback() { echo __('Database Options', 'wordpress'); diff --git a/controllers/ToolboxImport.php b/controllers/ToolboxImport.php index da836de..9a7b984 100644 --- a/controllers/ToolboxImport.php +++ b/controllers/ToolboxImport.php @@ -202,7 +202,7 @@ private function _displayFile2($file, $filename) { - $fileUrl =$this->_options['site_url'] . 'uploads/' . $file; + $fileUrl =$this->_options['site_url'] . '/uploads/' . $file; $fileName = ($filename) ? $filename : $file; return "\n".''.$fileName.''; } @@ -407,15 +407,11 @@ $fileStmt = $this->_dbh->prepare($fileSql); } $data = $this->_dbh->query($pageSql)->fetchAll(); - //echo '
' . print_r($data, true) . '
'; - //exit; foreach ($data as &$page) { $page['srcs'] = array(); $paraStmt->bindParam(':page', $page['id'], PDO::PARAM_INT); $paraStmt->execute(); $paragraphs = $paraStmt->fetchAll(); - //echo '
' . print_r($paragraphs, true) . '
'; - //exit; $primaryAlign = 'right'; $secondaryAlign = 'right'; $alternateImg = false; @@ -445,10 +441,13 @@ $page['pageContent'] = ''; $iterator = 1; if ($this->_options['toolbox_page_table'] == 'bus_category') { - $page['pageContent'] .= '

'.$page['category'].'

'; + if ( $this->_options['navigation_name_in_content'] ) { + $page['pageContent'] .= '

'.$page['category'].'

'; + } else { + $page['title'] .= $page['category']; + } ++$iterator; if ($page['image']) { - //$page['images'][] = $page['image']; $page['pageContent'] .= $this->_displayImage($page, $primaryAlign); } $page['pageContent'] .= $page['description']; @@ -458,10 +457,13 @@ switch ($iterator) { case 1: if (isset($paragraph['title']) && $paragraph['title']) { - $page['pageContent'] .= '

'.$paragraph['title'].'

'; + if ( $this->_options['navigation_name_in_content'] ) { + $page['pageContent'] .= '

'.$paragraph['title'].'

'; + } else { + $page['title'] = $paragraph['title']; + } } if (isset($paragraph['image']) && $paragraph['image']) { - //$page['images'][] = $paragraph['image']; $page['pageContent'] .= $this->_displayImage($paragraph, $primaryAlign); } break; @@ -473,7 +475,6 @@ $page['pageContent'] .= '

'.$paragraph['title'].'

'; } if (isset($paragraph['image']) && $paragraph['image']) { - //$page['images'][] = $paragraph['image']; $page['pageContent'] .= $this->_displayImage($paragraph, $secondaryAlign); } break; @@ -490,7 +491,6 @@ $align = $secondaryAlign; } if (isset($paragraph['image']) && $paragraph['image']) { - //$page['images'][] = $paragraph['image']; $page['pageContent'] .= $this->_displayImage($paragraph, $align); } break; @@ -516,7 +516,6 @@ } ++$iterator; } - //echo '
Files: ' . print_r($page['files'], true) . '
'; } return $data; } @@ -540,9 +539,13 @@ if ($page['parent']) { } - $pageName = (isset($page['navigation_name'])) - ? $page['navigation_name'] - : $page['category']; + if ( $page['title'] ) { + $pageName = $page['title']; + } else if ( $page['navigation_name'] ) { + $pageName = $page['navigation_name']; + } else { + $pageName = $page['category']; + } // if you don't find the parent page id then use the default given or 0 $parent = isset($this->_post[$page['parent']]) ? $this->_post[$page['parent']] @@ -1214,7 +1217,7 @@ $sql = " SELECT * FROM {$this->_options['ckeditor_schema']}.{$this->_options['ckeditor_images_table']}"; - + $sql .= " LIMIT $limit OFFSET $offset"; $stmt = $this->_dbh->query($sql); diff --git a/views/checkbox.php b/views/checkbox.php new file mode 100644 index 0000000..47336b8 --- /dev/null +++ b/views/checkbox.php @@ -0,0 +1,5 @@ +> -- 2.17.1