diff --git a/e107_plugins/gsitemap/admin_config.php b/e107_plugins/gsitemap/admin_config.php index 2a8a949f1..d5ef9f4c8 100644 --- a/e107_plugins/gsitemap/admin_config.php +++ b/e107_plugins/gsitemap/admin_config.php @@ -340,6 +340,13 @@ class gsitemap $frm = e107::getForm(); $mes = e107::getMessage(); + $existing = array(); + $sql -> select("gsitemap", "*"); + while($row = $sql->fetch()) + { + $existing[] = $row['gsitemap_name']; + } + $importArray = array(); @@ -348,20 +355,27 @@ class gsitemap $nfArray = $sql -> db_getList(); foreach($nfArray as $row) { - if(!$sql -> select("gsitemap", "*", "gsitemap_name='".$row['link_name']."' ")) + if(!in_array($row['link_name'], $existing)) { $importArray[] = array('name' => $row['link_name'], 'url' => $row['link_url'], 'type' => GSLAN_1); } } /* custom pages ... */ - $sql -> select("page", "*", "ORDER BY page_datestamp ASC", "no-where"); - $nfArray = $sql -> db_getList(); - foreach($nfArray as $row) + $query = "SELECT p.page_id, p.page_title, p.page_sef, p.page_chapter, ch.chapter_sef as chapter_sef, b.chapter_sef as book_sef FROM #page as p + LEFT JOIN #page_chapters as ch ON p.page_chapter = ch.chapter_id + LEFT JOIN #page_chapters as b ON ch.chapter_parent = b.chapter_id + WHERE page_title !='' ORDER BY page_datestamp ASC"; + + $data = $sql->retrieve($query,true); + + foreach($data as $row) { - if(!$sql -> select("gsitemap", "*", "gsitemap_name='".$row['page_title']."' ")) + if(!in_array($row['page_title'], $existing)) { - $importArray[] = array('name' => $row['page_title'], 'url' => e107::getUrl()->create('page/view', $row, array('allow' => 'page_sef,page_title,page_id')), 'type' => "Custom Page"); + $route = ($row['page_chapter'] == 0) ? "page/view/other" : "page/view/index"; + + $importArray[] = array('name' => $row['page_title'], 'url' => e107::getUrl()->create($route, $row, array('full'=>1, 'allow' => 'page_sef,page_title,page_id, chapter_sef, book_sef')), 'type' => "Page"); } } @@ -374,7 +388,7 @@ class gsitemap $nfArray = $sql -> db_getList(); foreach($nfArray as $row) { - if(!$sql -> select("gsitemap", "*", "gsitemap_name='".$row['forum_name']."' ")) + if(!in_array($row['forum_name'], $existing)) { $importArray[] = array('name' => $row['forum_name'], 'url' => e107::getUrl()->create('forum/forum/view', $row['forum_id']), 'type' => "Forum"); }