Skip to content

Commit

Permalink
added support to save keywords to resource_data; last commit was bad
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmaturen committed May 22, 2012
1 parent b75153a commit f5ae465
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion inline_keywords.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 19 additions & 4 deletions pages/add_keywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')");
}
}
}
?>
?>

0 comments on commit f5ae465

Please sign in to comment.