|
@@ -10,6 +10,36 @@ use App\Models\AppSession;
|
|
|
//require_once './class.Diff.php';
|
|
|
use Soundasleep\Html2Text as Html2Text;
|
|
|
|
|
|
+if(!function_exists('queryLineExcept')) {
|
|
|
+ function queryLineExcept($except = []) {
|
|
|
+ $params = request()->all();
|
|
|
+ $final = [];
|
|
|
+ foreach ($params as $k => $v) {
|
|
|
+ if(in_array($k, $except) === FALSE) {
|
|
|
+ $final[] = "$k=" . urlencode($v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return implode('&', $final);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+if(!function_exists('sortColumnHead')) {
|
|
|
+ function sortColumnHead($url, $label, $sortKey, $defaultDirection = 'ASC') {
|
|
|
+ $currentSortKey = request()->input('sort');
|
|
|
+ $currentDir = request()->input('dir');
|
|
|
+ $targetDir = $currentDir ? ($currentDir === 'ASC' ? 'DESC' : 'ASC') : $defaultDirection;
|
|
|
+ echo '<a href="' . $url . '?sort=' . $sortKey . '&dir=' . $targetDir . '&' . queryLineExcept(['sort', 'dir']) . '">' . $label . '</a>';
|
|
|
+ if($currentSortKey === $sortKey) {
|
|
|
+ if($currentDir === 'ASC') {
|
|
|
+ echo " ↑";
|
|
|
+ }
|
|
|
+ elseif($currentDir === 'DESC') {
|
|
|
+ echo " ↓";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
if(!function_exists('html2Text')) {
|
|
|
function html2Text($old, $new){
|
|
|
|