findById((int)$_GET['id']); header('Content-Type: application/json; charset=utf-8'); echo json_encode([ 'id' => $t->id, 'author' => $t->author, 'date' => $t->date, 'testimonial'=> $t->testimonial, 'rating' => $t->rating, 'is_active' => $t->is_active ], JSON_UNESCAPED_UNICODE); exit; } // 4) load model require __DIR__ . '/includes/cms/Testimonial.php'; $model = new Testimonial($conn); // 5) delete review if (isset($_GET['del'])) { $id = (int)$_GET['del']; if ($id) { $model->findById($id)->delete(); } header('Location: reviews.php'); exit; } // 6) create/update review if ($_SERVER['REQUEST_METHOD'] === 'POST') { $id = !empty($_POST['id']) ? (int)$_POST['id'] : null; $t = $id ? $model->findById($id) : new Testimonial($conn); if (!$t) { $t = new Testimonial($conn); } $t->author = trim($_POST['author']); $t->date = $_POST['date']; $t->testimonial = $_POST['testimonial']; $t->rating = (int)$_POST['rating']; $t->is_active = !empty($_POST['is_active']); $t->save(); header('Location: reviews.php'); exit; } // 7) fetch all reviews $all = $model->findAll(); ?>
| מחבר | תאריך | ביקורת | דירוג | פעיל | עריכה | מחק |
|---|---|---|---|---|---|---|
| =htmlspecialchars($r->author)?> | =htmlspecialchars($r->date)?> | =mb_strimwidth(strip_tags($r->testimonial),0,50,'...')?> | =str_repeat('★',$r->rating).str_repeat('☆',5-$r->rating)?> | =$r->is_active?'כן':'לא'?> | מחק |