diff --git a/build.sh b/build.sh index 7a0da47..1ed0440 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ git log | grep -m 1 commit commit=`git log | grep -m 1 commit ` commitnick=${commit:7:10} -commitnick='0.3' +commitnick='0.4' echo "updating version information in inline_keywords.yaml with latest git commit $commitnick" sed -ibk "s/version: .*/version: $commitnick/" inline_keywords.yaml rm inline_keywords.yamlbk diff --git a/inline_keywords.yaml b/inline_keywords.yaml index 06313fa..b9865e6 100644 --- a/inline_keywords.yaml +++ b/inline_keywords.yaml @@ -1,6 +1,6 @@ name: inline_keywords author: Aaron T. Maturen -version: 0.3 +version: 0.4 desc: Enable Adding Keywords on Search Result Page info_url: https://github.com/aaronmaturen/rs_inline_keywords config_url: /plugins/inline_keywords/pages/setup.php diff --git a/pages/add_keywords.php b/pages/add_keywords.php index 4413852..195799d 100644 --- a/pages/add_keywords.php +++ b/pages/add_keywords.php @@ -5,11 +5,26 @@ include_once "../../../include/general.php"; include_once "../../../include/resource_functions.php"; +$fields = sql_query("select ref from resource_type_field where title = 'Keywords'"); +$type = ($fields[0]['ref']); + $keywords = explode(' ',str_replace('+',' ',$_REQUEST['keywords'])); $refs = explode(' ',str_replace('+',' ',$_REQUEST['refs'])); -foreach($refs as $ref){ +foreach($refs as $ref) + { foreach($keywords as $keyword){ - add_keyword_mappings($ref, $keyword,8); + add_keyword_mappings($ref, $keyword,$type); + } + $inline_keyword_data = sql_query("SELECT * FROM resource_data WHERE resource_type_field = '$type' AND resource = '$ref'"); + if($inline_keyword_data) + { + $keywordstring = implode(' ',array_unique(array_merge($keywords, explode(' ',$inline_keyword_data[0]['value'])))); + sql_query("UPDATE resource_data SET value = '$keywordstring' WHERE resource_type_field = '$type' AND resource = '$ref'"); + } + else + { + $keywordstring = implode(' ',$keywords); + sql_query("INSERT INTO resource_data(resource, resource_type_field, value) VALUES($ref, $type, '$keywordstring')"); + } } -} -?> \ No newline at end of file +?>