1<?php
2/**
3 * DokuWiki Plugin dirpictures (Syntax Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  jerome <jerome_at_reso-nance.org>
7 */
8
9if(!defined('DOKU_INC')) die();
10
11// Very basic sort functions
12class sortPages {
13
14    static function sort(&$files, $type, $order) {
15       if ($type == "date") {
16		   if ($order == "asc") usort($files, "sortPages::_dateAsc");
17		   elseif ($order == "desc") usort($files, "sortPages::_dateDesc");
18	   }
19    }
20
21    // Sort by Date Asc
22    private static function _dateAsc($a, $b) {
23		if ($a['date'] == $b['date']) return 0;
24		return ($a['date'] < $b['date']) ? -1 : 1;
25	}
26
27	// Sort by Date Desc
28	private static function _dateDesc($a, $b) {
29		if ($a['date'] == $b['date']) return 0;
30		return ($a['date'] > $b['date']) ? -1 : 1;
31	}
32}
33
34