From d0feb76cef0b4a9178fb9920238f1216c91901c7 Mon Sep 17 00:00:00 2001 From: Cameron <e107inc@gmail.com> Date: Wed, 9 Dec 2020 15:12:56 -0800 Subject: [PATCH] Issue #3291 - gSitemap upgrades to save table and table_id info for syncing on changes. (coming soon) --- e107_plugins/download/e_gsitemap.php | 12 ++++--- e107_plugins/forum/e_gsitemap.php | 2 ++ e107_plugins/gsitemap/admin_config.php | 48 ++++++++++++++++++++------ e107_plugins/gsitemap/gsitemap_sql.php | 2 ++ e107_plugins/news/e_gsitemap.php | 4 +++ 5 files changed, 54 insertions(+), 14 deletions(-) diff --git a/e107_plugins/download/e_gsitemap.php b/e107_plugins/download/e_gsitemap.php index dff1dfbec..ea3a3ef10 100644 --- a/e107_plugins/download/e_gsitemap.php +++ b/e107_plugins/download/e_gsitemap.php @@ -31,8 +31,10 @@ class download_gsitemap foreach($data as $row) { $import[] = array( + 'id' => $row['download_category_id'], + 'table' => 'download_category', 'name' => $row['download_category_name'], - 'url' => e107::url('download', 'category', $row, array('mode' => 'full' )), + 'url' => e107::url('download', 'category', $row, array('mode' => 'full' )), 'type' => LAN_PLUGIN_DOWNLOAD_NAME ); } @@ -41,9 +43,11 @@ class download_gsitemap foreach($data as $row) { $import[] = array( - 'name' => $row['download_name'], - 'url' => e107::url('download', 'item', $row, array('mode' => 'full' )), - 'type' => LAN_PLUGIN_DOWNLOAD_NAME + 'id' => $row['download_id'], + 'table' => 'download', + 'name' => $row['download_name'], + 'url' => e107::url('download', 'item', $row, array('mode' => 'full' )), + 'type' => LAN_PLUGIN_DOWNLOAD_NAME ); } diff --git a/e107_plugins/forum/e_gsitemap.php b/e107_plugins/forum/e_gsitemap.php index b82612b63..b5b9c0b6e 100644 --- a/e107_plugins/forum/e_gsitemap.php +++ b/e107_plugins/forum/e_gsitemap.php @@ -26,6 +26,8 @@ class forum_gsitemap // plugin-folder + '_rss' foreach($data as $row) { $import[] = array( + 'id' => $row['forum_id'], + 'table' => 'forum', 'name' => $row['forum_name'], 'url' => e107::url('forum','forum',$row, array('mode'=>'full')), // ('forum/forum/view', $row['forum_id']), 'type' => LAN_PLUGIN_FORUM_NAME diff --git a/e107_plugins/gsitemap/admin_config.php b/e107_plugins/gsitemap/admin_config.php index a9a3200f3..d8de7df10 100644 --- a/e107_plugins/gsitemap/admin_config.php +++ b/e107_plugins/gsitemap/admin_config.php @@ -22,6 +22,8 @@ e107::lan('gsitemap',true); $gsm = new gsitemap; +//todo Use ADMIN-UI + class gsitemap { @@ -397,7 +399,12 @@ class gsitemap { if(!in_array($row['link_name'], $existing)) { - $importArray[] = array('name' => $row['link_name'], 'url' => $row['link_url'], 'type' => GSLAN_1); + $importArray[] = array( + 'table' => 'links', + 'id' => $row['link_id'], + 'name' => $row['link_name'], + 'url' => $row['link_url'], + 'type' => GSLAN_1); } } @@ -415,7 +422,13 @@ class gsitemap { $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"); + $importArray[] = array( + 'table' => 'page', + 'id' => $row['page_id'], + '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" + ); } } @@ -464,7 +477,7 @@ class gsitemap $id = 'gs-'.$k; $text .= " <tr> - <td class='center'><input id='".$id."' type='checkbox' name='importid[]' value='".$ia['name']."^".$ia['url']."^".$ia['type']."' /></td> + <td class='center'><input id='".$id."' type='checkbox' name='importid[]' value='".$ia['name']."^".$ia['url']."^".$ia['type']."^".$ia['table']."^".$ia['id']."' /></td> <td><label for='".$id."'>".$ia['type']."</label></td> <td>".$ia['name']."</td> <td><span class='smalltext'>".str_replace(SITEURL,"",$ia['url'])."</span></td> @@ -519,15 +532,30 @@ class gsitemap $sql = e107::getDb(); $tp = e107::getParser(); $log = e107::getAdminLog(); - + + foreach($_POST['importid'] as $import) { - list($name, $url, $type) = explode("^", $import); - - $name = $tp->toDB($name); - $url = $tp->toDB($url); - - $sql->insert("gsitemap", "0, '$name', '$url', '".time()."', '".$_POST['import_freq']."', '".$_POST['import_priority']."', '$type', '0', '', '0' "); + list($name, $url, $type, $table, $id) = explode("^", $import); + + $insert = array( + 'gsitemap_id' => 0, + 'gsitemap_name' => $tp->toDB($name), + 'gsitemap_url' => $tp->toDB($url), + 'gsitemap_table' => $tp->toDB($id), + 'gsitemap_table_id' => (int) $id, + 'gsitemap_lastmod' => time(), + 'gsitemap_freq' => $_POST['import_freq'], + 'gsitemap_priority' => $_POST['import_priority'], + 'gsitemap_cat' => $type, + 'gsitemap_order' => '0', + 'gsitemap_img' => '', + 'gsitemap_active' => '0', + ); + + $sql->insert("gsitemap", $insert); + + // $sql->insert("gsitemap", "0, '$name', '$url', '".time()."', '".$_POST['import_freq']."', '".$_POST['import_priority']."', '$type', '0', '', '0' "); } $this->message = count($_POST['importid'])." link(s) imported."; diff --git a/e107_plugins/gsitemap/gsitemap_sql.php b/e107_plugins/gsitemap/gsitemap_sql.php index a3308e8be..a2638a7c7 100644 --- a/e107_plugins/gsitemap/gsitemap_sql.php +++ b/e107_plugins/gsitemap/gsitemap_sql.php @@ -2,6 +2,8 @@ CREATE TABLE gsitemap ( gsitemap_id int(11) unsigned NOT NULL auto_increment, gsitemap_name varchar(200) NOT NULL default '', gsitemap_url varchar(200) NOT NULL default '', + gsitemap_table varchar(50) NOT NULL default '', + gsitemap_table_id int(7) NOT NULL default '0', gsitemap_lastmod varchar(15) NOT NULL default '', gsitemap_freq varchar(10) NOT NULL default '', gsitemap_priority char(3) NOT NULL default '', diff --git a/e107_plugins/news/e_gsitemap.php b/e107_plugins/news/e_gsitemap.php index 9e245bceb..5ff04cac1 100644 --- a/e107_plugins/news/e_gsitemap.php +++ b/e107_plugins/news/e_gsitemap.php @@ -32,6 +32,8 @@ class news_gsitemap foreach($data as $row) { $import[] = array( + 'id' => $row['category_id'], + 'table' => 'news_category', 'name' => $row['category_name'], 'url' => e107::getUrl()->create('news/list/category', $row, array('full' => 1)) , 'type' => LAN_NEWS_23 @@ -51,6 +53,8 @@ class news_gsitemap foreach($data as $row) { $import[] = array( + 'id' => $row['news_id'], + 'table' => 'news', 'name' => $row['news_title'], 'url' => e107::getUrl()->create('news/view/item', $row, array('full' => 1)), 'type' => ADLAN_0