Got keywords from text using rake-php-plus and then stored in the DB, then used it to append the keywords to the meta tag.
🚀 Deploy website on push / 🎉 Deploy (push) Successful in 20s

Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
2023-11-18 13:06:27 +00:00
parent f27a5113b1
commit 5b063afad3
11 changed files with 161 additions and 27 deletions
+15 -7
View File
@@ -7,10 +7,12 @@ use api\utils\imgUtils;
use DOMDocument;
use PDO;
use Psr\Http\Message\UploadedFileInterface;
use DonatelloZa\RakePlus\RakePlus;
use function DI\string;
use const api\utils\feedGenerator\ATOM;
use const api\utils\feedGenerator\RSS2;
require_once __DIR__ . "/../utils/config.php";
require_once __DIR__ . "/../utils/imgUtils.php";
require_once __DIR__ . "/../utils/feedGenerator/FeedWriter.php";
@@ -30,7 +32,7 @@ class blogData
$conn = dbConn();
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
headerImg, body, bodyText, categories, folderID FROM blog ORDER BY featured DESC,
headerImg, body, bodyText, categories, keywords, folderID FROM blog ORDER BY featured DESC,
dateCreated DESC;");
$stmt->execute();
@@ -55,7 +57,7 @@ class blogData
$conn = dbConn();
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
headerImg, body, bodyText, categories, folderID FROM blog WHERE
headerImg, body, bodyText, categories, keywords, folderID FROM blog WHERE
title = :title;");
$stmt->bindParam(":title", $title);
$stmt->execute();
@@ -80,7 +82,7 @@ class blogData
$conn = dbConn();
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
headerImg, body, bodyText, categories, folderID FROM blog ORDER BY
headerImg, body, bodyText, categories, keywords, folderID FROM blog ORDER BY
dateCreated DESC LIMIT 1;");
$stmt->execute();
@@ -104,7 +106,7 @@ class blogData
$conn = dbConn();
$stmt = $conn->prepare("SELECT ID, title, DATE_FORMAT(dateCreated, '%Y-%m-%dT%TZ') AS dateCreated,
DATE_FORMAT(dateModified, '%Y-%m-%dT%TZ') AS dateModified, featured, abstract,
headerImg, body, bodyText, categories, folderID FROM blog WHERE featured = 1;");
headerImg, body, bodyText, categories, keywords, folderID FROM blog WHERE featured = 1;");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -225,7 +227,9 @@ class blogData
$from = "../blog/imgs/tmp/";
$newBody = $this->changeHTMLSrc($body, $to, $from);
$stmt = $conn->prepare("UPDATE blog SET title = :title, featured = :featured, abstract = :abstract, body = :body, bodyText = :bodyText, dateModified = :dateModified, categories = :categories WHERE ID = :ID;");
$keywords = implode(", ", RakePlus::create($bodyText)->keywords());
$stmt = $conn->prepare("UPDATE blog SET title = :title, featured = :featured, abstract = :abstract, body = :body, bodyText = :bodyText, dateModified = :dateModified, categories = :categories, keywords = :keywords WHERE ID = :ID;");
$stmt->bindParam(":ID", $ID);
$stmt->bindParam(":title", $title);
$stmt->bindParam(":featured", $featured);
@@ -234,6 +238,7 @@ class blogData
$stmt->bindParam(":bodyText", $bodyText);
$stmt->bindParam(":dateModified", $dateModified);
$stmt->bindParam(":categories", $categories);
$stmt->bindParam(":keywords", $keywords);
return $stmt->execute();
}
@@ -282,8 +287,10 @@ class blogData
$stmtMainProject->execute();
}
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, abstract, body, bodyText, categories, folderID)
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :abstract, :body, :bodyText, :categories, :folderID);");
$keywords = implode(", ", RakePlus::create($bodyText)->keywords());
$stmt = $conn->prepare("INSERT INTO blog (title, dateCreated, dateModified, featured, headerImg, abstract, body, bodyText, categories, keywords, folderID)
VALUES (:title, :dateCreated, :dateModified, :featured, :headerImg, :abstract, :body, :bodyText, :categories, :keywords, :folderID);");
$stmt->bindParam(":title", $title);
$stmt->bindParam(":dateCreated", $dateCreated);
$stmt->bindParam(":dateModified", $dateCreated);
@@ -294,6 +301,7 @@ class blogData
$stmt->bindParam(":body", $newBody);
$stmt->bindParam(":bodyText", $bodyText);
$stmt->bindParam(":categories", $categories);
$stmt->bindParam(":keywords", $keywords);
$stmt->bindParam(":folderID", $folderID);
if ($stmt->execute())
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long