PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB`view = new View(); $this->db = Database::getInstance(); } public function index() { $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $perPage = 6; $offset = ($page - 1) * $perPage; // Filtreleme $deviceType = $_GET['device_type'] ?? null; $brand = $_GET['brand'] ?? null; $where = "status = 'published'"; $params = []; if ($deviceType) { $where .= " AND device_type = ?"; $params[] = $deviceType; } if ($brand) { $where .= " AND brand = ?"; $params[] = $brand; } $posts = $this->db->fetchAll( "SELECT * FROM posts WHERE $where ORDER BY created_at DESC LIMIT ? OFFSET ?", array_merge($params, [$perPage, $offset]) ); $total = $this->db->fetchOne("SELECT COUNT(*) as total FROM posts WHERE $where", $params); $totalPages = ceil($total['total'] / $perPage); // Kategoriler ve markalar $deviceTypes = $this->db->fetchAll( "SELECT DISTINCT device_type FROM posts WHERE status = 'published' AND device_type IS NOT NULL ORDER BY device_type" ); $brands = $this->db->fetchAll( "SELECT DISTINCT brand FROM posts WHERE status = 'published' AND brand IS NOT NULL ORDER BY brand" ); // SEO - Çözüm Merkezi Sayfası (Title: 60 karakter, Description: 160 karakter) $latestPosts = $this->getLatestPosts(); $this->view->set('page_title', 'Çözüm Merkezi'); $this->view->set('page_description', 'Ankara beyaz eşya kombi servisi çözüm merkezi. Buzdolabı, çamaşır makinesi, kombi, klima ve televizyon arıza çözümleri, bakım ipuçları ve teknik bilgiler. Uzman tavsiyeleri.'); $this->view->set('page_keywords', 'ankara beyaz eşya servisi çözüm merkezi, kombi arıza çözümleri, beyaz eşya bakım ipuçları, teknik servis bilgileri'); $this->view->set('posts', $posts); $this->view->set('current_page', $page); $this->view->set('total_pages', $totalPages); $this->view->set('device_types', $deviceTypes); $this->view->set('brands', $brands); $this->view->set('current_device_type', $deviceType); $this->view->set('current_brand', $brand); $this->view->set('latest_posts', $latestPosts); $this->view->render('blog/index'); } public function show($slug) { $post = $this->findPostBySlug($slug); if (!$post) { $this->renderNotFound(); return; } $latestPosts = $this->getLatestPosts($post['id']); $deviceTypes = $this->getDeviceTypes(); $brands = $this->getBrands(); $this->renderPost($post, $latestPosts, $deviceTypes, $brands); } public function showByCategory($deviceTypeSlug, $slug) { $post = $this->findPostBySlug($slug); if (!$post) { $this->renderNotFound(); return; } $postDeviceSlug = Helper::slug($post['device_type'] ?? ''); if (!$postDeviceSlug || $postDeviceSlug !== $deviceTypeSlug) { $this->renderNotFound(); return; } $latestPosts = $this->getLatestPosts($post['id']); $deviceTypes = $this->getDeviceTypes(); $brands = $this->getBrands(); $this->renderPost($post, $latestPosts, $deviceTypes, $brands); } public function showByBrand($deviceTypeSlug, $brandSlug, $slug) { $post = $this->findPostBySlug($slug); if (!$post) { $this->renderNotFound(); return; } $postDeviceSlug = Helper::slug($post['device_type'] ?? ''); $postBrandSlug = Helper::slug($post['brand'] ?? ''); if (!$postDeviceSlug || $postDeviceSlug !== $deviceTypeSlug || !$postBrandSlug || $postBrandSlug !== $brandSlug) { $this->renderNotFound(); return; } $latestPosts = $this->getLatestPosts($post['id']); $deviceTypes = $this->getDeviceTypes(); $brands = $this->getBrands(); $this->renderPost($post, $latestPosts, $deviceTypes, $brands); } private function findPostBySlug($slug) { return $this->db->fetchOne( "SELECT * FROM posts WHERE slug = ? AND status = 'published'", [$slug] ); } private function renderPost($post, $latestPosts = [], $deviceTypes = [], $brands = []) { // SEO - Çözüm Merkezi Detay Sayfası (Title: max 60 karakter, Description: 160 karakter) $postTitle = $post['title']; $postExcerpt = Helper::excerpt(strip_tags($post['content']), 120); $seoTitle = $postTitle . ' | Ankara Servis'; if (mb_strlen($seoTitle) > 60) { $seoTitle = mb_substr($postTitle, 0, 40) . '... | Ankara Servis'; } $seoDescription = $postExcerpt . ' - Ankara beyaz eşya kombi servisi Anka Servis çözüm merkezi.'; if (mb_strlen($seoDescription) > 160) { $seoDescription = mb_substr($seoDescription, 0, 157) . '...'; } $this->view->set('page_title', $seoTitle); $this->view->set('page_description', $seoDescription); $this->view->set('page_keywords', 'ankara beyaz eşya servisi, ankara kombi servisi, ' . strtolower($postTitle)); $this->view->set('post', $post); $this->view->set('latest_posts', $latestPosts); $this->view->set('device_types', $deviceTypes); $this->view->set('brands', $brands); $this->view->render('blog/show'); } private function renderNotFound() { http_response_code(404); $this->view->render('errors/404'); } private function getLatestPosts($excludeId = null) { $sql = "SELECT id, title, slug, device_type, brand, created_at FROM posts WHERE status = 'published'"; $params = []; if ($excludeId) { $sql .= " AND id != ?"; $params[] = $excludeId; } $sql .= " ORDER BY created_at DESC LIMIT 6"; return $this->db->fetchAll($sql, $params); } private function getDeviceTypes() { return $this->db->fetchAll( "SELECT DISTINCT device_type FROM posts WHERE status = 'published' AND device_type IS NOT NULL ORDER BY device_type" ); } private function getBrands() { return $this->db->fetchAll( "SELECT DISTINCT brand FROM posts WHERE status = 'published' AND brand IS NOT NULL ORDER BY brand" ); } }