From 9630777ec6413e9054f217519b12c8caa6661c7e Mon Sep 17 00:00:00 2001 From: Maxime St-Pierre Date: Thu, 26 Apr 2018 18:18:14 -0400 Subject: [PATCH] Add sorting and array_filter for job listing --- controller/action/ContentActions.class.php | 17 ++++++++++------- view/template/content/_job.php | 2 +- view/template/content/join-us.php | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/controller/action/ContentActions.class.php b/controller/action/ContentActions.class.php index d202c8da..66be2eab 100644 --- a/controller/action/ContentActions.class.php +++ b/controller/action/ContentActions.class.php @@ -398,15 +398,18 @@ class ContentActions extends Actions $jobs = array(); - foreach(glob(static::VIEW_FOLDER_JOBS . '/*') as $job){ - + $jobs = array_filter(glob(static::VIEW_FOLDER_JOBS . '/*'), function($job){ list($metadata, $jobHTML) = View::parseMarkdown($job); + + return $metadata['status'] != 'closed'; + }); + + usort($jobs, function($job1, $job2){ + list($metadataA, $jobHTMLA) = View::parseMarkdown($job1); + list($metadataB, $jobHTMLB) = View::parseMarkdown($job2); + return $metadataA['order'] <=> $metadataB['order']; + }); - if($metadata['status'] != 'closed') - { - array_push($jobs, $job); - } - } return ['content/join-us', ['jobs' => $jobs]]; } diff --git a/view/template/content/_job.php b/view/template/content/_job.php index fd744b79..a711697e 100644 --- a/view/template/content/_job.php +++ b/view/template/content/_job.php @@ -1,5 +1,5 @@

-">

+ ">
diff --git a/view/template/content/join-us.php b/view/template/content/join-us.php index 8b5c9442..c040d428 100644 --- a/view/template/content/join-us.php +++ b/view/template/content/join-us.php @@ -74,7 +74,7 @@
$job]) ?> - +

Applying

How To Apply