Skip to content

Commit

Permalink
refactor: naming aligned and corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Oct 13, 2024
1 parent 6460773 commit 22be681
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 251 deletions.
6 changes: 3 additions & 3 deletions phpmyfaq/admin/faqs.editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
];
}

$faq->getRecord($id, null, true);
$faq->getFaq($id, null, true);
$faqData = $faq->faqRecord;
if (!is_null($translateTo)) {
$faqData['lang'] = $translateTo; // once again
Expand All @@ -163,7 +163,7 @@
$faqData['lang'] = Filter::filterInput(INPUT_GET, 'lang', FILTER_SANITIZE_SPECIAL_CHARS);
$categories = $categoryRelation->getCategories($faqData['id'], $faqData['lang']);

$faq->getRecord($faqData['id'], null, true);
$faq->getFaq($faqData['id'], null, true);

$faqData = $faq->faqRecord;
$faqData['tags'] = implode(', ', $tagging->getAllTagsById($faqData['id']));
Expand Down Expand Up @@ -284,7 +284,7 @@
$revisions = $faqRevision->get($faqData['id'], $faqData['lang'], $faqData['author']);

if (isset($selectedRevisionId) && isset($faqData['revision_id']) && $selectedRevisionId !== $faqData['revision_id']) {
$faq->getRecord($faqData['id'], $selectedRevisionId, true);
$faq->getFaq($faqData['id'], $selectedRevisionId, true);
$faqData = $faq->faqRecord;
$faqData['tags'] = implode(', ', $tagging->getAllTagsById($faqData['id']));
$faqData['revision_id'] = $selectedRevisionId;
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/admin/stickyfaqs.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
$template = $twig->loadTemplate('./admin/content/stickyfaqs.twig');

$faq = new Faq($faqConfig);
$stickyData = $faq->getStickyRecordsData();
$stickyData = $faq->getStickyFaqsData();

$templateVars = [
'stickyFAQsHeader' => Translation::get('stickyRecordsHeader'),
Expand Down
4 changes: 2 additions & 2 deletions phpmyfaq/faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@

// Get all data from the FAQ record
if (0 === (int)$solutionId) {
$faq->getRecord($faqId);
$faq->getFaq($faqId);
} else {
$faq->getRecordBySolutionId($solutionId);
$faq->getFaqBySolutionId($solutionId);
}

if (isset($faq->faqRecord['id'])) {
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
//
$id = Filter::filterVar($request->query->get('id'), FILTER_VALIDATE_INT, 0);
if ($id !== 0) {
$faq->getRecord($id);
$faq->getFaq($id);

$seoEntity
->setType(SeoType::FAQ)
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
exit();
}

$faq->getRecord($id);
$faq->getFaq($id);
$faq->faqRecord['category_id'] = $currentCategory;

$filename = 'FAQ-' . $id . '-' . $lang . '.pdf';
Expand Down
15 changes: 5 additions & 10 deletions phpmyfaq/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
$faq->setUser($currentUser);
$faq->setGroups($currentGroups);

$category = new Category($faqConfig);

$plurals = new Plurals();

// Get possible user input
Expand Down Expand Up @@ -78,12 +80,7 @@
$languages = '';
}

// HACK: (re)evaluate the Entity object w/o passing the user language
// so the result set of a Search will have the Entity Path
// for any of the multi-language faq records and the Entity list
// on the left pane will not be affected
if ($allLanguages) {
$category = new Category($faqConfig);
$category->transform(0);
}

Expand Down Expand Up @@ -126,7 +123,7 @@
$resultTags = $tagging->getAllTagsById($recordId);
foreach (array_keys($resultTags) as $resultTagId) {
if (isset($tags[$resultTagId])) {
// if the given tag is in the search term we don't want to list it
// if the given tag is in the search term, we don't want to list it
continue;
}

Expand All @@ -148,7 +145,7 @@
}
}

$searchResult = $faq->renderRecordsByFaqIds($recordIds);
$searchResult = $faq->renderFaqsByFaqIds($recordIds);
}
} else {
$searchResult = '';
Expand Down Expand Up @@ -179,7 +176,7 @@
}

foreach ($searchResults as $faqKey => $faqValue) {
$checkedFaq = $faq->getRecordResult($faqValue->id, $faqValue->lang);
$checkedFaq = $faq->getFaqResult($faqValue->id, $faqValue->lang);
if (0 === $faqConfig->getDb()->numRows($checkedFaq)) {
unset($searchResults[$faqKey]);
}
Expand All @@ -193,8 +190,6 @@
} catch (Exception $exception) {
$faqConfig->getLogger()->debug($exception->getMessage());
}
} else {
$inputSearchTerm = '';
}

// Change a little the $searchCategory value;
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$faqSession->userTracking('show_category', $selectedCategoryId);

$categoryData = $category->getCategoryData($selectedCategoryId);
$records = $faq->renderRecordsByCategoryId(
$records = $faq->renderFaqsByCategoryId(
$selectedCategoryId,
$faqConfig->get('records.orderby'),
$faqConfig->get('records.sortby')
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getBookmarkList(): array
$list = [];

foreach ($bookmarks as $bookmark) {
$faq->getRecord((int) $bookmark->faqid);
$faq->getFaq((int) $bookmark->faqid);
$faqData = $faq->faqRecord;

$url = sprintf(
Expand Down
6 changes: 3 additions & 3 deletions phpmyfaq/src/phpMyFAQ/Configuration/DatabaseConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

private string $password;

private string $db;
private string $database;

private string $prefix;

Expand All @@ -51,7 +51,7 @@ public function __construct(string $filename)
$this->port = $DB['port'] === '' ? null : (int) $DB['port'];
$this->user = $DB['user'];
$this->password = $DB['password'];
$this->db = $DB['db'];
$this->database = $DB['db'];
$this->prefix = $DB['prefix'];
$this->type = $DB['type'];
}
Expand All @@ -78,7 +78,7 @@ public function getPassword(): string

public function getDatabase(): string
{
return $this->db;
return $this->database;
}

public function getPrefix(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function import(): JsonResponse

$elasticsearch = new Elasticsearch($this->configuration);
$faq = new Faq($this->configuration);
$faq->getAllRecords();
$faq->getAllFaqs();

$bulkIndexResult = $elasticsearch->bulkIndex($faq->faqRecords);
if (isset($bulkIndexResult['success'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public function delete(Request $request): JsonResponse
$adminLog->log($user, 'Deleted FAQ ID ' . $faqId);

try {
$faq->deleteRecord($faqId, $faqLanguage);
$faq->delete($faqId, $faqLanguage);
} catch (FileException | AttachmentException $e) {
return $this->json(['error' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
}
Expand Down
8 changes: 4 additions & 4 deletions phpmyfaq/src/phpMyFAQ/Controller/Api/FaqController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function getById(Request $request): JsonResponse

$faqId = Filter::filterVar($request->get('faqId'), FILTER_VALIDATE_INT);

$faq->getRecord($faqId);
$faq->getFaq($faqId);
$result = $faq->faqRecord;

if ((is_countable($result) ? count($result) : 0) === 0 || $result['solution_id'] === 42) {
Expand Down Expand Up @@ -248,7 +248,7 @@ public function getByTagId(Request $request): JsonResponse
$recordIds = $tags->getFaqsByTagId($tagId);

try {
$result = $faq->getRecordsByIds($recordIds);
$result = $faq->getFaqsByIds($recordIds);
return $this->json($result, Response::HTTP_OK);
} catch (Exception $e) {
return $this->json(['error' => $e->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR);
Expand Down Expand Up @@ -455,7 +455,7 @@ public function getSticky(): JsonResponse
$faq->setUser($currentUser);
$faq->setGroups($currentGroups);

$result = array_values($faq->getStickyRecordsData());
$result = array_values($faq->getStickyFaqsData());

if ((is_countable($result) ? count($result) : 0) === 0) {
return $this->json($result, Response::HTTP_NOT_FOUND);
Expand Down Expand Up @@ -517,7 +517,7 @@ public function list(): JsonResponse
$faq = new Faq($this->configuration);
$faq->setUser($currentUser);
$faq->setGroups($currentGroups);
$faq->getAllRecords(
$faq->getAllFaqs(
FAQ_SORTING_TYPE_CATID_FAQID,
['lang' => $this->configuration->getLanguage()->getLanguage()]
);
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/Controller/Api/PdfController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getById(Request $request): JsonResponse
$categoryId = Filter::filterVar($request->get('categoryId'), FILTER_VALIDATE_INT);
$faqId = Filter::filterVar($request->get('faqId'), FILTER_VALIDATE_INT);

$faq->getRecord($faqId);
$faq->getFaq($faqId);
$result = $faq->faqRecord;

if ((is_countable($result) ? count($result) : 0) === 0 || $result['solution_id'] === 42) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function create(Request $request): JsonResponse
if ($comment->create($commentEntity)) {
$notification = new Notification($this->configuration);
if ('faq' == $type) {
$faq->getRecord($id);
$faq->getFaq($id);
$notification->sendFaqCommentNotification($faq, $commentEntity);
} else {
$news = new News($this->configuration);
Expand Down
Loading

0 comments on commit 22be681

Please sign in to comment.