From 5fe1a21b8e43e75f66ccc09a56187339628408d3 Mon Sep 17 00:00:00 2001 From: Cody Cook Date: Mon, 29 Apr 2024 21:16:49 -0700 Subject: [PATCH] Add locale, en_US, DJ and Database functions. --- classes/DJ.php | 128 ++++++++++++++++++++ classes/Database.php | 2 +- dj.php | 246 ++++++++++++++++++++++++++++++++++++++ functions/i18n.php | 2 + index.php | 27 ++++- locale/en_US/messages.php | 15 ++- navbar.php | 28 +++++ 7 files changed, 440 insertions(+), 8 deletions(-) create mode 100644 classes/DJ.php create mode 100644 dj.php create mode 100644 navbar.php diff --git a/classes/DJ.php b/classes/DJ.php new file mode 100644 index 0000000..4aed297 --- /dev/null +++ b/classes/DJ.php @@ -0,0 +1,128 @@ +slug = $slug; + $this->db = $db; + if (!$this->load_from_slug()) { + return false; + } else { + return true; + } + } + + private function load_from_slug(): bool + { + $dj = $this->get_dj_by_slug($this->slug); + if ($dj) { + if (isset($dj['id'])) { + $this->id = $dj['id']; + } + if (isset($dj['name'])) { + $this->name = $dj['name']; + } + if (isset($dj['bio'])) { + $this->bio = $dj['bio']; + } + if (isset($dj['img'])) { + $this->img = $dj['img']; + } + if (isset($dj['email'])) { + $this->email = $dj['email']; + } + if (isset($dj['socials'])) { + $this->socials = json_decode($dj['socials'], true) ?? []; + } + if (isset($dj['created'])) { + $this->created = $dj['created']; + } + if (isset($dj['updated'])) { + $this->updated = $dj['updated']; + } + + return true; + } else { + return false; + } + } + + private function get_dj_by_slug($slug) + { + $stmt = $this->db->prepare("SELECT * FROM djs WHERE slug = ?"); + $stmt->bind_param("s", $slug); + $stmt->execute(); + $result = $stmt->get_result(); + $dj = $result->fetch_assoc(); + $stmt->close(); + return $dj; + } + + public function get_slug(): string + { + return $this->slug; + } + + public function get_id(): int + { + return $this->id; + } + + public function get_name(): string + { + return $this->name; + } + + public function get_bio(): string + { + return $this->bio; + } + + public function get_img(): string + { + return $this->img; + } + + public function get_active(): bool + { + return $this->active; + } + + public function get_email(): string + { + return $this->email; + } + + public function get_socials(): array + { + return $this->socials; + } + + public function get_created(): string + { + return $this->created; + } + + public function get_updated(): string + { + return $this->updated; + } + + +} \ No newline at end of file diff --git a/classes/Database.php b/classes/Database.php index fc77824..5b90b83 100644 --- a/classes/Database.php +++ b/classes/Database.php @@ -7,6 +7,6 @@ class Database extends mysqli public function __construct($config) { // call the parent constructor with the config file - parent::__construct($config['database']['host'], $config['database']['username'], $config['database']['password'], $config['database']['database'], $config['database']['port'] ?? 3306); + parent::__construct($config['database']['host'], $config['database']['user'], $config['database']['pass'], $config['database']['db'], $config['database']['port'] ?? 3306); } } \ No newline at end of file diff --git a/dj.php b/dj.php new file mode 100644 index 0000000..77f6690 --- /dev/null +++ b/dj.php @@ -0,0 +1,246 @@ +get_name() != "") { + $djFound = true; + } +} + + +?> + + + + + + <?php echo $config['app']['name']; ?> + + + + + +
+
+
+
+ +
+
+ + +
+
+
+
+ avatar +
get_name(); ?>
+

$desc1

+

$location1

+
+ + +
+
+
+
+
+
    +
  • + +

    https://mdbootstrap.com

    +
  • +
  • + +

    mdbootstrap

    +
  • +
  • + +

    @mdbootstrap

    +
  • +
  • + +

    mdbootstrap

    +
  • +
  • + +

    mdbootstrap

    +
  • +
+
+
+
+
+
+
+
+
+

Full Name

+
+
+

Johnatan Smith

+
+
+
+
+
+

Email

+
+
+

example@example.com

+
+
+
+
+
+

Phone

+
+
+

(097) 234-5678

+
+
+
+
+
+

Mobile

+
+
+

(098) 765-4321

+
+
+
+
+
+

Address

+
+
+

Bay Area, San Francisco, CA

+
+
+
+
+
+
+
+
+

assigment Project + Status +

+

Web Design

+
+
+
+

Website Markup

+
+
+
+

One Page

+
+
+
+

Mobile Template

+
+
+
+

Backend API

+
+
+
+
+
+
+
+
+
+

assigment Project + Status +

+

Web Design

+
+
+
+

Website Markup

+
+
+
+

One Page

+
+
+
+

Mobile Template

+
+
+
+

Backend API

+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+ + +
+
+ + \ No newline at end of file diff --git a/functions/i18n.php b/functions/i18n.php index 0882dc3..04cee52 100644 --- a/functions/i18n.php +++ b/functions/i18n.php @@ -8,4 +8,6 @@ function loadLocale($lang = 'en_US') { // Fallback to English if the specified language file does not exist return require __DIR__ . '/../locale/en_US/messages.php'; } + + } diff --git a/index.php b/index.php index fe9d90e..a864314 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,29 @@ + + + + + + <?php echo $config['app']['name']; ?> + + + + + + + + + \ No newline at end of file diff --git a/locale/en_US/messages.php b/locale/en_US/messages.php index c7caa2a..427acd8 100644 --- a/locale/en_US/messages.php +++ b/locale/en_US/messages.php @@ -1,5 +1,18 @@ 'Welcome to our Website!', - 'description' => 'This is a description in English.' + 'description' => 'This is a description in English.', + 'userProfile' => "User Profile", + 'user' => 'User', + 'home' => 'Home', + 'djName' => 'DJ Name', + 'email' => 'Email', + 'location' => 'Location', + 'bio' => 'Bio', + 'submit' => 'Submit', + 'login' => 'Login', + 'message' => 'Message', + 'follow' => 'Follow', + 'djs' => 'DJs', + "djNotFound" => "Could not load DJ; either the DJ wasn't found or this DJ is private.", ]; \ No newline at end of file diff --git a/navbar.php b/navbar.php new file mode 100644 index 0000000..0734251 --- /dev/null +++ b/navbar.php @@ -0,0 +1,28 @@ + \ No newline at end of file