From 55ee9a1c72554d41aa5005e0d1a2c3d1f622a20a Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Wed, 10 Jan 2018 11:46:05 -0500 Subject: [PATCH] Move files to src Move files.php and create Term class --- include/files.php | 55 ---------------------------------- src/Model/Term.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 55 deletions(-) delete mode 100644 include/files.php create mode 100644 src/Model/Term.php diff --git a/include/files.php b/include/files.php deleted file mode 100644 index 64fe6a3109..0000000000 --- a/include/files.php +++ /dev/null @@ -1,55 +0,0 @@ -/ism", $message["file"], $files)) { - foreach ($files[1] as $file) { - q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')", - intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), dbesc($file)); - } - } -} - -function create_files_from_itemuri($itemuri, $uid) -{ - $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid)); - - if (count($messages)) { - foreach ($messages as $message) - create_files_from_item($message["id"]); - } -} - -function update_files_for_items() -{ - $messages = q("SELECT `id` FROM `item` where file !=''"); - - foreach ($messages as $message) { - echo $message["id"] . "\n"; - create_files_from_item($message["id"]); - } -} diff --git a/src/Model/Term.php b/src/Model/Term.php new file mode 100644 index 0000000000..3b327b582c --- /dev/null +++ b/src/Model/Term.php @@ -0,0 +1,74 @@ +/ism", $message["file"], $files)) { + foreach ($files[1] as $file) { + q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`) VALUES (%d, %d, %d, %d, '%s')", + intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), dbesc($file)); + } + } + } + + /** + * @param string $itemuri item uri + * @param integer $uid uid + * @return void + */ + function create_files_from_itemuri($itemuri, $uid) + { + $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid)); + + if (count($messages)) { + foreach ($messages as $message) + create_files_from_item($message["id"]); + } + } + + /** + * @return void + */ + function update_files_for_items() + { + $messages = q("SELECT `id` FROM `item` where file !=''"); + + foreach ($messages as $message) { + echo $message["id"] . "\n"; + create_files_from_item($message["id"]); + } + } +} \ No newline at end of file -- 2.39.5