Can I put my own website here, is that cheating? Maybe, but I think this site counts as the most important thing I've personally created. I've only used my own libraries and frameworks to create this website, so it kind of works as a live demonstration of many of my web projects bundled together.
@@ -69,7 +104,7 @@
vlw/php-mysql
-
Yet another abstraction library for the php-mysql extension. For this library, I was willing to sacrifice most of MySQL's flexibility that comes with string interpolation in favor of method chaining that adheres to an SQL-like syntax. For simple DML operations I think it's pretty intuitive.
Together with copy written by the amazing team at iCellate, and a new brand new appearance for the company, I helped design a new website and underlying systems for their GeneMate product.
+
= $work->get_summary("icellate/genemate") ?>
diff --git a/public/work/timeline.php b/public/work/timeline.php
index cd96585..cbb8d87 100644
--- a/public/work/timeline.php
+++ b/public/work/timeline.php
@@ -19,154 +19,158 @@
require_once VV::root("api/src/databases/models/Work/WorkTags.php");
require_once VV::root("api/src/databases/models/Work/WorkActions.php");
- // Connect to VLW API
- $api = new API();
+ $work = new class extends API {
+ private readonly Response $resp;
+ private readonly Response $tags;
+ private readonly Response $actions;
- // Retreive rows from work endpoints
- $resp_work = $api->call(Endpoints::WORK->value)->params($_GET)->get();
+ public function __construct() {
+ parent::__construct();
- // Resolve tags and actions if we got work results
- if ($resp_work->ok) {
- $work_tags = $api->call(Endpoints::WORK_TAGS->value)->get()->json();
- $work_actions = $api->call(Endpoints::WORK_ACTIONS->value)->get()->json();
- }
+ $this->resp = $this->call(Endpoints::WORK->value)->params([
+ WorkModel::IS_LISTED->value => true
+ ])->get();
-?>
-
-
-ok): ?>
- resp->ok) {
+ $this->tags = $this->call(Endpoints::WORK_TAGS->value)->get();
+ $this->actions = $this->call(Endpoints::WORK_ACTIONS->value)->get();
+ }
+ }
/*
Order response from endpoint into a multi-dimensional array.
For example, a single item created at 14th of February 2024 would be ordered like this
[2024 => [[02 => [14 => []]]]]
*/
-
- $rows = [];
- // Create array of arrays ordered by decending year, month, day, items
- foreach ($resp_work->json() as $row) {
- // Create array for current year if it doesn't exist
- if (!array_key_exists($row[WorkModel::DATE_YEAR->value], $rows)) {
- $rows[$row[WorkModel::DATE_YEAR->value]] = [];
+ public function get_timeline(): array {
+ if (!$this->resp->ok) {
+ return [];
}
- // Create array for current month if it doesn't exist
- if (!array_key_exists($row[WorkModel::DATE_MONTH->value], $rows[$row[WorkModel::DATE_YEAR->value]])) {
- $rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]] = [];
+ $timeline = [];
+
+ // Create array of arrays ordered by decending year, month, day, items
+ foreach ($this->resp->json() as $row) {
+ // Create array for current year if it doesn't exist
+ if (!array_key_exists($row[WorkModel::DATE_YEAR->value], $timeline)) {
+ $timeline[$row[WorkModel::DATE_YEAR->value]] = [];
+ }
+
+ // Create array for current month if it doesn't exist
+ if (!array_key_exists($row[WorkModel::DATE_MONTH->value], $timeline[$row[WorkModel::DATE_YEAR->value]])) {
+ $timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]] = [];
+ }
+
+ // Create array for current day if it doesn't exist
+ if (!array_key_exists($row[WorkModel::DATE_DAY->value], $timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]])) {
+ $timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]] = [];
+ }
+
+ // Append item to ordered array
+ $timeline[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]][] = $row;
}
- // Create array for current day if it doesn't exist
- if (!array_key_exists($row[WorkModel::DATE_DAY->value], $rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]])) {
- $rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]] = [];
- }
-
- // Append item to ordered array
- $rows[$row[WorkModel::DATE_YEAR->value]][$row[WorkModel::DATE_MONTH->value]][$row[WorkModel::DATE_DAY->value]][] = $row;
+ return $timeline;
}
- ?>
+ public function get_tags(string $key): array {
+ if (!$this->resp->ok) {
+ return [];
+ }
-
-
- $months): ?>
-
-
- value]
- // Bind VV Interactions for local links
- ? "vv='work' vv-call='navigate'"
- // Open external links in a new tab
- : "target='_blank'";
-
- $link_href = $action[WorkActionsModel::HREF->value] === null
- // Navigate to work details page if no href is defined
- ? "/work/{$item[WorkModel::ID->value]}"
- // Href is defined so use it directly
- : $action[WorkActionsModel::HREF->value];
- ?>
-
- >
-
-