Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code style #27

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ vendor
*.log
docker/certs
docker/logs
.php-cs-fixer.cache
40 changes: 40 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/admin/controllers',
__DIR__ . '/admin/models',
__DIR__ . '/admin/views',
__DIR__ . '/content',
])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
29 changes: 20 additions & 9 deletions 404.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<?php
require_once('lib/model.php');

/**
* @var string $aboutUrl
* @var string $contactUrl
*/

$title = 'Error 404 Not Found - Quán Chị Kòi';
require('content/views/shared/header.php'); ?>
require('content/views/shared/header.php');
?>
<div role="main" class="main">
<section class="page-top">
<div class="container">
<div class="row">
<div class="col-md-12">
<ul class="breadcrumb">
<li><a href="<?= PATH_URL; ?>home">Home</a></li>
<li><a href="<?= PATH_URL; ?>">Home</a></li>
<li class="active">404</li>
</ul>
</div>
Expand All @@ -26,27 +32,32 @@
<div class="col-md-6 col-md-offset-1">
<div class="page-not-found-main">
<h2>404 <i class="fa fa-file"></i></h2>
<p>We're sorry, but the page you were looking for doesn't exist. <br> Chúng tôi xin lỗi, nhưng trang bạn đang tìm kiếm không tồn tại.</p>
<p>We're sorry, but the page you were looking for
doesn't exist. <br> Chúng tôi xin lỗi, nhưng trang
bạn đang tìm kiếm không tồn tại.</p>
</div>
</div>
<div class="col-md-4">
<h4>Dưới đây là một số liên kết hữu ích</h4>
<ul class="nav nav-list primary">
<li><a href="<?= PATH_URL; ?>home">Trang chủ</a></li>
<li><a href="<?= $link_about ?>">Về chúng tôi</a></li>
<li><a href="<?= $link_contact ?>">Liên hệ</a></li>
<li><a href="<?= $aboutUrl ?>">Về chúng tôi</a></li>
<li><a href="<?= $contactUrl ?>">Liên hệ</a></li>
</ul>
</div>
</div>
</section>
<form action="<?= PATH_URL; ?>search/" method="get">
<div class="input-group input-group-lg">
<input class="form-control" placeholder="Search..." name="keyword" id="s" type="text">
<input class="form-control" placeholder="Search..."
name="keyword" id="s" type="text">
<span class="input-group-btn">
<button type="submit" class="btn btn-primary btn-lg"><i class="fa fa-search"></i></button>
<button type="submit" class="btn btn-primary btn-lg"><i
class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<?php require('content/views/shared/footer.php'); ?>
<?php
require('content/views/shared/footer.php'); ?>
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if (file_exists($file)) {
require($file);
} else {
show_404();
show404NotFound();
}


Expand Down
2 changes: 1 addition & 1 deletion admin/controllers/backupdb/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
delete_file_backup($_POST['linkFile']);
header('location:admin.php?controller=backupdb&action=list');
} else {
show_404();
show404NotFound();
}
8 changes: 4 additions & 4 deletions admin/controllers/category/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
updateSubCategory();
}

$categories = get_all('categories', array(
$categories = getAll('categories', [
'select' => 'id,category_name',
'order_by' => 'id'
));
'order_by' => 'id',
]);

if (isset($_GET['sub_cate_id'])) {
$subCateId = intval($_GET['sub_cate_id']);
Expand All @@ -22,6 +22,6 @@

$title = $subCateId === 0 ? 'Thêm danh mục con' : 'Sửa danh mục con';
$navCategory = 'class="active open"';
$subcategory = get_a_record('subcategory', $subCateId);
$subcategory = getRecord('subcategory', $subCateId);

require('admin/views/category/edit.php');
8 changes: 4 additions & 4 deletions admin/controllers/category/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

require_once('admin/models/category.php');

$options = array(
'order_by' => 'id'
);
$options = [
'order_by' => 'id',
];
$title = 'Danh mục sản phẩm';
$subcategories = get_all('subcategory', $options);
$subcategories = getAll('subcategory', $options);
$navCategory = 'class="active open"';

require('admin/views/category/index.php');
8 changes: 4 additions & 4 deletions admin/controllers/comment/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
}

$title = $commentId === 0 ? '' : 'Sửa phần bình luận của khách hàng';
$comment = get_a_record('comments', $commentId);
$comment = getRecord('comments', $commentId);

if ($comment['post_id'] <> 0) {
$post = get_a_record('posts', $comment['post_id']);
$post = getRecord('posts', $comment['post_id']);
}

if ($comment['page_id'] <> 0) {
$page = get_a_record('posts', $comment['page_id']);
$page = getRecord('posts', $comment['page_id']);
}

if ($comment['product_id'] <> 0) {
$product = get_a_record('products', $comment['product_id']);
$product = getRecord('products', $comment['product_id']);
}

$navComment = 'class="active open"';
Expand Down
8 changes: 4 additions & 4 deletions admin/controllers/comment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

$title = 'Tổng Danh Sách Bình luận';
$navComment = 'class="active open"';
$option = array(
$option = [
'order_by' => 'id desc',
'where' => 'status<>3 and status<>2'
);
$comments = get_all('comments', $option);
'where' => 'status<>3 and status<>2',
];
$comments = getAll('comments', $option);

require('admin/views/comment/index.php');
2 changes: 1 addition & 1 deletion admin/controllers/comment/spam.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
$title = 'Bình luận Spam';
$navComment = 'class="active open"';

require('admin/views/comment/spam.php');
require('admin/views/comment/spam.php');
2 changes: 1 addition & 1 deletion admin/controllers/comment/trash.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
$title = 'Thùng rác';
$navComment = 'class="active open"';

require('admin/views/comment/trash.php');
require('admin/views/comment/trash.php');
13 changes: 8 additions & 5 deletions admin/controllers/feedback/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

if (!empty($_POST)) {
addFeedbackOrder();
echo "<div style='padding-top: 200px' class='container'><div style='text-align: center;' class='alert alert-success'><strong>Done!</strong> Thư phản hồi của bạn đã được gửi đến hệ thống của quán Chị Kòi. Cảm ơn bạn đã gửi lại phản hồi về quán. <br><br>Hãy đến <a href='admin.php'>Dashboard</a></div></div>";
require('content/views/feedback/result.php');
exit;
}

if (isset($_GET['order_id'])) {
Expand All @@ -13,19 +16,19 @@
$orderId = 0;
}

$order = get_a_record('orders', $orderId);
$order = getRecord('orders', $orderId);
$orderDetail = orderDetail($orderId);

if (isset($userNav)) {
$user_action = get_a_record('users', $userNav);
$user_action = getRecord('users', $userNav);
}

$status = array(
$status = [
0 => 'Đã xác nhận',
1 => 'Đã xử lý',
2 => 'Đang xử lý',
3 => 'Đã bị hủy'
);
3 => 'Đã bị hủy',
];
$title = 'Gửi phản hồi của bạn đến Chị Kòi Quán';
$navFeedback = 'class="active open"';

Expand Down
12 changes: 6 additions & 6 deletions admin/controllers/feedback/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@

$title = $feedbackId === 0 ? '' : 'Sửa phần phản hồi của khách hàng';
$navFeedback = 'class="active open"';
$feedback = get_a_record('feedbacks', $feedbackId);
$feedback = getRecord('feedbacks', $feedbackId);

if ($feedback['order_id'] <> 0) {
$orderDetail = orderDetail($feedback['order_id']);
$order = get_a_record('orders', $feedback['order_id']);
$order = getRecord('orders', $feedback['order_id']);
}
if ($feedback['product_id'] <> 0) {
$product = get_a_record('products', $feedback['product_id']);
$product = getRecord('products', $feedback['product_id']);
}

$status = array(
$status = [
0 => 'Đã xác nhận',
1 => 'Đã xử lý - Done',
2 => 'Đang xử lý - giao hàng',
3 => 'Đã bị hủy'
);
3 => 'Đã bị hủy',
];
require('admin/views/feedback/edit.php');
2 changes: 1 addition & 1 deletion admin/controllers/feedback/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
$title = 'Tổng Danh Sách Các Phản Hồi';
$navFeedback = 'class="active open"';

require('admin/views/feedback/index.php');
require('admin/views/feedback/index.php');
8 changes: 4 additions & 4 deletions admin/controllers/feedback/myfeedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
$navFeedback = $yourFeedback = 'class="active open"';
global $userNav;

$option = array(
$option = [
'order_by' => 'id desc',
'where' => 'user_id=' . $userNav
);
$feedbacks = get_all('feedbacks', $option);
'where' => 'user_id=' . $userNav,
];
$feedbacks = getAll('feedbacks', $option);

require('admin/views/feedback/myfeedback.php');
2 changes: 1 addition & 1 deletion admin/controllers/feedback/reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

$title = $feedbackId === 0 ? '' : 'Trả lời cho phản hồi của khách hàng';
$feedback = get_a_record('feedbacks', $feedbackId);
$feedback = getRecord('feedbacks', $feedbackId);
$navFeedback = 'class="active open"';

require('admin/views/feedback/reply.php');
2 changes: 1 addition & 1 deletion admin/controllers/feedback/result.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
header('javascript: history.go(-1)');
header('javascript: history.go(-1)');
14 changes: 7 additions & 7 deletions admin/controllers/feedback/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
}

$title = $feedbackId === 0 ? '' : 'Xem chi tiết phản hồi của khách hàng';
$feedback = get_a_record('feedbacks', $feedbackId);
$feedback = getRecord('feedbacks', $feedbackId);

if ($feedback['order_id'] <> 0) {
$orderDetail = orderDetail($feedback['order_id']);
$order = get_a_record('orders', $feedback['order_id']);
$order = getRecord('orders', $feedback['order_id']);
}

if ($feedback['product_id'] <> 0) {
$product = get_a_record('products', $feedback['product_id']);
$product = getRecord('products', $feedback['product_id']);
}

$status = array(
$status = [
0 => 'Đã xác nhận',
1 => 'Đã xử lý - Done',
2 => 'Đang xử lý - giao hàng',
3 => 'Đã bị hủy'
);
3 => 'Đã bị hủy',
];
$navFeedback = 'class="active open"';

require('admin/views/feedback/view.php');
require('admin/views/feedback/view.php');
2 changes: 1 addition & 1 deletion admin/controllers/header-footer/editMenuFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

$title = 'Sửa menu link footer website';
$navHF = 'class="active open"';
$menuFooter = get_a_record('menu_footers', $menuFooterId);
$menuFooter = getRecord('menu_footers', $menuFooterId);

require('admin/views/header-footer/editMenuFooter.php');
2 changes: 1 addition & 1 deletion admin/controllers/header-footer/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

$title = 'Sửa header footer website';
$navHF = 'class="active open"';
$contact = get_a_record('contacts', 1);
$contact = getRecord('contacts', 1);

require('admin/views/header-footer/index.php');
16 changes: 8 additions & 8 deletions admin/controllers/header-footer/listMenuFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
permission_user();
permission_moderator();

$linkOptions = array(
$linkOptions = [
'order_by' => 'id ASC',
'where' => 'parent=0'
);
'where' => 'parent=0',
];
$title = 'Danh sách link Footer';
$navHF = 'class="active open"';
$menuFooterLinks = get_all('menu_footers', $linkOptions);
$titleOptions = array(
$menuFooterLinks = getAll('menu_footers', $linkOptions);
$titleOptions = [
'order_by' => 'id ASC',
'where' => 'parent=1'
);
$titleFooterLinks = get_all('menu_footers', $titleOptions);
'where' => 'parent=1',
];
$titleFooterLinks = getAll('menu_footers', $titleOptions);

require('admin/views/header-footer/listMenuFooter.php');
2 changes: 1 addition & 1 deletion admin/controllers/home/logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

global $userNav;

$user_login = get_a_record('users', $userNav);
$user_login = getRecord('users', $userNav);

unset($_SESSION['user']);
cartDestroy();
Expand Down
Loading