Created
April 25, 2023 18:58
-
-
Save novia713/ab2ef74b7542dac03d7ace7e74dbe7da to your computer and use it in GitHub Desktop.
libr/util/table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function sortString($a, $b) { | |
return strcmp($a, $b); | |
} | |
function sortNumber($a, $b) { | |
return r_num_get(NULL, $a) - r_num_get(NULL, $b); | |
} | |
class RTableColumnType { | |
public $name; | |
public $sort_function; | |
function __construct($name, $sort_function) { | |
$this->name = $name; | |
$this->sort_function = $sort_function; | |
} | |
} | |
$r_table_type_string = new RTableColumnType("string", "sortString"); | |
$r_table_type_number = new RTableColumnType("number", "sortNumber"); | |
$r_table_type_bool = new RTableColumnType("bool", "sortNumber"); | |
function r_table_type($name) { | |
if (strpos($name, "bool") === 0) { | |
return $GLOBALS['r_table_type_bool']; | |
} | |
if ($name === "string") { | |
return $GLOBALS['r_table_type_string']; | |
} | |
if ($name === "number") { | |
return $GLOBALS['r_table_type_number']; | |
} | |
return null; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment