more work on tablelisting
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
47
lib/Froxlor/UI/Callbacks/Domain.php
Normal file
47
lib/Froxlor/UI/Callbacks/Domain.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Froxlor\UI\Callbacks;
|
||||
|
||||
use Froxlor\UI\Panel\UI;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Listing
|
||||
*
|
||||
*/
|
||||
|
||||
class Domain
|
||||
{
|
||||
public static function domainTarget(string $data, array $attributes): mixed
|
||||
{
|
||||
if (empty($attributes['aliasdomain'])) {
|
||||
// path or redirect
|
||||
if (preg_match('/^https?\:\/\//', $attributes['documentroot'])) {
|
||||
return [
|
||||
'type' => 'link',
|
||||
'data' => [
|
||||
'text' => $attributes['documentroot'],
|
||||
'href' => $attributes['documentroot'],
|
||||
'target' => '_blank'
|
||||
]
|
||||
];
|
||||
} else {
|
||||
// show docroot nicely
|
||||
if (strpos($attributes['documentroot'], UI::getCurrentUser()['documentroot']) === 0) {
|
||||
$attributes['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace(UI::getCurrentUser()['documentroot'], "/", $attributes['documentroot']));
|
||||
}
|
||||
return $attributes['documentroot'];
|
||||
}
|
||||
}
|
||||
return UI::getLng('domains.aliasdomain') . ' ' . $attributes['aliasdomain'];
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Froxlor\UI\Callbacks;
|
||||
|
||||
/**
|
||||
@@ -18,22 +19,27 @@ namespace Froxlor\UI\Callbacks;
|
||||
*/
|
||||
class Text
|
||||
{
|
||||
public static function boolean(?string $data): array
|
||||
{
|
||||
return [
|
||||
'type' => 'boolean',
|
||||
'data' => (bool) $data
|
||||
];
|
||||
}
|
||||
public static function boolean(?string $data): array
|
||||
{
|
||||
return [
|
||||
'type' => 'boolean',
|
||||
'data' => (bool) $data
|
||||
];
|
||||
}
|
||||
|
||||
public static function domainWithSan(string $data, array $attributes): array
|
||||
{
|
||||
return [
|
||||
'type' => 'domainWithSan',
|
||||
'data' => [
|
||||
'domain' => $data,
|
||||
'san' => implode(', ', $attributes['san'] ?? []),
|
||||
]
|
||||
];
|
||||
}
|
||||
public static function domainWithSan(string $data, array $attributes): array
|
||||
{
|
||||
return [
|
||||
'type' => 'domainWithSan',
|
||||
'data' => [
|
||||
'domain' => $data,
|
||||
'san' => implode(', ', $attributes['san'] ?? []),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function customerfullname(string $data, array $attributes): string
|
||||
{
|
||||
return \Froxlor\User::getCorrectFullUserDetails($attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,16 +81,23 @@ class Collection
|
||||
public function has(string $column, string $class, string $parentKey = 'id', string $childKey = 'id', array $params = []): Collection
|
||||
{
|
||||
$this->has[] = [
|
||||
'column' => $column,
|
||||
'class' => $class,
|
||||
'parentKey' => $parentKey,
|
||||
'childKey' => $childKey,
|
||||
'params' => $params
|
||||
'column' => $column,
|
||||
'class' => $class,
|
||||
'parentKey' => $parentKey,
|
||||
'childKey' => $childKey,
|
||||
'params' => $params
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addParam(array $keyval): Collection
|
||||
{
|
||||
$this->params = array_merge($this->params, $keyval);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withPagination(array $columns): Collection
|
||||
{
|
||||
// TODO: handle 'sortable' => true in $columns
|
||||
|
||||
@@ -35,6 +35,13 @@ class UI
|
||||
*/
|
||||
private static $linker = null;
|
||||
|
||||
/**
|
||||
* current logged in user
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $userinfo = [];
|
||||
|
||||
/**
|
||||
* default fallback theme
|
||||
*
|
||||
@@ -224,6 +231,16 @@ class UI
|
||||
return self::$linker;
|
||||
}
|
||||
|
||||
public static function setCurrentUser($userinfo = null)
|
||||
{
|
||||
self::$userinfo = $userinfo;
|
||||
}
|
||||
|
||||
public static function getCurrentUser(): array
|
||||
{
|
||||
return self::$userinfo;
|
||||
}
|
||||
|
||||
public static function setLng($lng = array())
|
||||
{
|
||||
self::$lng = $lng;
|
||||
|
||||
@@ -24,7 +24,7 @@ class User
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'];
|
||||
} else {
|
||||
if ($userinfo['name'] != '' && $userinfo['firstname'] != '') {
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . ' | ' . $userinfo['company'];
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . '<br><small>' . $userinfo['company'] . '</small>';
|
||||
} else {
|
||||
$returnval = $userinfo['company'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user