protected function getCatsAndSubCats($flag = FALSE) { $condition = ''; $categoryModel = new CategoryTableModel(); $categoryModel->setTable('category'); $categoryModel->readAllRecords(); $subCategoryModel = new SubCategoryTableModel(); $subCategoryModel->setTable('subcategory'); if (!$flag) { $condition .= "WHERE subcategory.category_id = " . end($categoryModel->getAllRecords())['id']; } $subCategoryModel->readAllRecords('*', $condition); return ['cats' => array_reverse($categoryModel->getAllRecords()), 'subcats' => array_reverse($subCategoryModel->getAllRecords())]; }
public function getCategoriesAction() { // Передаем заголовки header('Content-type: text/plain; charset=utf-8'); header('Cache-Control: no-store, no-cache'); header('Expires: ' . date('r')); $model = new CategoryTableModel(); $model->setTable('category'); $model->readAllRecords(); echo json_encode($model->getAllRecords()); }
public function siteConfigAction() { $fc = FrontController::getInstance(); $model = new AdminModel('Настройки сайта'); $siteCng = new SiteConfigurator(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $siteCng->setPostData($_POST); $siteCng->setSiteConfig(); Session::setMsg('Настройки сайта успешно обновлены', 'success'); header('Location: ' . $_SERVER['REQUEST_URI']); exit; } else { $categoryModel = new CategoryTableModel(); $categoryModel->setTable('category'); $categoryModel->readAllRecords(); $model->setData(['siteConfig' => $siteCng->getSiteConfig(), 'siteCategories' => $categoryModel->getAllRecords()]); $output = $model->render('../views/admin/siteconfig/siteconfig.php', 'admin'); $fc->setPage($output); } }