Skip to content
Open
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
98 changes: 0 additions & 98 deletions includes/ui-helpers.php

This file was deleted.

72 changes: 63 additions & 9 deletions universities.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
require_once 'includes/db.php';
require_once 'includes/require_user_details.php';
require_once 'includes/ui-helpers.php';

$pageTitle = 'Universities';
$pageStyles = ['css/pages/universities.css'];
Expand Down Expand Up @@ -68,6 +67,30 @@
return $item['id'];
}, array_slice($universities, 0, 2));

$universityImageMap = [
'University of Colombo' => 'images/universities/colombo.jpg',
'University of Peradeniya' => 'images/universities/universityofperadeniya.jfif',
'University of Sri Jayewardenepura' => 'images/universities/universityofsrijayewardenepura.jpg',
'University of Kelaniya' => 'images/universities/universityofkelaniya.webp',
'University of Moratuwa' => 'images/universities/universityofmoratuwa.jpg',
'University of Jaffna' => 'images/universities/universityofjaffna.jpg',
'Eastern University' => 'images/universities/easternuniversityofmoratuwa.jpg',
'South Eastern University of Sri Lanka' => 'images/universities/seusl.jpg',
'Rajarata University of Sri Lanka' => 'images/universities/rajaratauniversity.jpg',
'Wayamba University of Sri Lanka' => 'images/universities/WayambaUniversity.jpg',
'Sabaragamuwa University of Sri Lanka' => 'images/universities/sabaragamuwa.jpg',
'Uva Wellassa University' => 'images/universities/uwawellassa.jpg',
'University of Ruhuna' => 'images/universities/universityofruhuna.jpg',
'University of Vavuniya, Sri Lanka' => 'images/universities/University_of_Vavuniya.png',
'University of Vavuniya' => 'images/universities/University_of_Vavuniya.png',
'Gampaha Wickramarachchi University of Indigenous Medicine, Sri Lanka' => 'images/universities/Gampaha Wickramarachchi University of Indigenous Medicine, Sri Lanka.JPG',
'Gampaha Wickramarachchi University of Indigenous Medicine' => 'images/universities/Gampaha Wickramarachchi University of Indigenous Medicine, Sri Lanka.JPG',
'University of Trincomalee' => 'images/universities/university_of_trincomalee.jpg',
'Trincomalee Campus, Eastern University, Sri Lanka' => 'images/universities/university_of_trincomalee.jpg',
'Swami Vipulananda Institute of Aesthetic Studies' => 'images/universities/Swami_Vipulananda_Institut_of_Aesthetic_Studies.jpg',
'Swami Vipulananda Institute of Aesthetic Studies, Eastern University, Sri Lanka' => 'images/universities/Swami_Vipulananda_Institut_of_Aesthetic_Studies.jpg',
];

include 'includes/header.php';
?>
<style>
Expand Down Expand Up @@ -112,16 +135,47 @@ class="search-input"
<?php if ($universities): ?>
<div class="university-grid">
<?php foreach ($universities as $university): ?>
<?php $image = getUniversityImagePath($university); ?>
<?php
$image = 'images/universities/placeholder.jpg';
$rawImage = trim((string) ($university['image_url'] ?? $university['image'] ?? ''));
$candidates = [];

if ($rawImage !== '') {
$rawImage = str_replace('\\', '/', $rawImage);
$candidates[] = $rawImage;

$baseName = basename($rawImage);
if ($baseName !== '') {
$candidates[] = 'images/universities/' . $baseName;
$candidates[] = 'images/' . $baseName;
}
}

if (!empty($university['name']) && isset($universityImageMap[$university['name']])) {
$candidates[] = $universityImageMap[$university['name']];
}

foreach (array_unique($candidates) as $candidate) {
if ($candidate !== '' && file_exists($candidate)) {
$image = $candidate;
break;
}
}

$location = !empty($university['location']) ? $university['location'] : 'Sri Lanka';

$description = !empty($university['description'])
? $university['description']
: 'Discover programs and opportunities at this institution.';
if (strlen($description) > 200) {
$description = substr($description, 0, 200) . '...';
}
?>
<article class="university-card reveal-on-scroll" data-streams="<?php echo htmlspecialchars($university['stream_list']); ?>">
<div class="university-image">
<?php if ($image): ?>
<img src="<?php echo htmlspecialchars($image, ENT_QUOTES, 'UTF-8'); ?>" loading="lazy" alt="<?php echo htmlspecialchars($university['name']); ?>">
<?php else: ?>
<div class="university-image university-image--placeholder"></div>
<?php endif; ?>
<img src="<?php echo htmlspecialchars($image, ENT_QUOTES, 'UTF-8'); ?>" loading="lazy" alt="<?php echo htmlspecialchars($university['name']); ?>">
<div class="image-overlay">
<div class="location-tag"><i class="fa-solid fa-location-dot" aria-hidden="true"></i> <?php echo htmlspecialchars(getUniversityLocation($university)); ?></div>
<div class="location-tag"><i class="fa-solid fa-location-dot" aria-hidden="true"></i> <?php echo htmlspecialchars($location); ?></div>
<?php if (!empty($university['type'])): ?>
<span class="type-badge type-<?php echo strtolower($university['type']); ?>"><?php echo htmlspecialchars($university['type']); ?></span>
<?php else: ?>
Expand All @@ -131,7 +185,7 @@ class="search-input"
</div>
</div>
<div class="university-content">
<p><?php echo htmlspecialchars(getUniversityDescription($university)); ?></p>
<p><?php echo htmlspecialchars($description); ?></p>
<div class="pills">
<span class="pill degree-pill"><?php echo $university['degree_count']; ?> Degrees</span>
<?php if (!empty($university['stream_list']) && $university['stream_list'] !== 'All'): ?>
Expand Down
13 changes: 11 additions & 2 deletions university.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
require_once 'includes/db.php';
require_once 'includes/ui-helpers.php';

$pageStyles = ['css/pages/universities.css'];

Expand Down Expand Up @@ -89,14 +88,24 @@
}
}

$heroDescription = '';
if ($university) {
$heroDescription = !empty($university['description'])
? $university['description']
: 'Discover programs and opportunities at this institution.';
if (strlen($heroDescription) > 320) {
$heroDescription = substr($heroDescription, 0, 320) . '...';
}
}

include 'includes/header.php';
?>
<?php if ($university): ?>
<section class="page-hero reveal-on-scroll detail-hero">
<div class="container">
<div class="hero-text">
<h1><?php echo htmlspecialchars($university['name']); ?></h1>
<p class="page-hero-meta"><?php echo htmlspecialchars(getUniversityDescription($university, 320)); ?></p>
<p class="page-hero-meta"><?php echo htmlspecialchars($heroDescription); ?></p>
</div>
</div>
</section>
Expand Down