1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-13 00:24:15 +02:00

Flextype Slim Integration - next round of integration

This commit is contained in:
Awilum
2019-04-16 00:46:36 +03:00
parent aec81ecf78
commit 4499bb2eae

View File

@@ -3,76 +3,63 @@
namespace Flextype;
use Flextype\Component\Registry\Registry;
use function Flextype\Component\I18n\__;
use Slim\Http\Request;
use Slim\Http\Response;
use Psr\Container\ContainerInterface;
$app->get('/admin/information', function (Request $request, Response $response, array $args) {
$app->get('/admin/information', InformationController::class . ':index')->setName('admin.information');
if (function_exists('apache_get_modules')) {
if (!in_array('mod_rewrite', apache_get_modules())) {
$apache_mod_rewrite_installed = false;
class InformationController {
protected $container;
// constructor receives container instance
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function index()
{
if (function_exists('apache_get_modules')) {
if (!in_array('mod_rewrite', apache_get_modules())) {
$apache_mod_rewrite_installed = false;
} else {
$apache_mod_rewrite_installed = true;
}
} else {
$apache_mod_rewrite_installed = true;
}
} else {
$apache_mod_rewrite_installed = true;
}
if (!function_exists('password_hash')) {
$password_hash_installed = false;
} else {
$password_hash_installed = true;
}
if (!function_exists('password_verify')) {
$password_verify_installed = false;
} else {
$password_verify_installed = true;
}
return $this->view->render($response,
'plugins/admin/views/templates/system/information/index.html', [
'menu_item' => 'information',
'php_uname' => php_uname(),
'webserver' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : @getenv('SERVER_SOFTWARE'),
'php_sapi_name' => php_sapi_name(),
'apache_mod_rewrite_installed' => $apache_mod_rewrite_installed,
'password_verify_installed' => $password_verify_installed,
'password_hash_installed' => $password_hash_installed
]);
})->setName('information');
class InformationManager
{
public static function getInformationManager()
{
Registry::set('sidebar_menu_item', 'infomation');
Themes::view('admin/views/templates/system/information/list')->display();
}
/**
* Tests whether a file is writable for anyone.
*
* @param string $file File to check
* @return bool
*/
public static function isFileWritable(string $file) : bool
{
// Is file exists ?
if (! file_exists($file)) {
throw new RuntimeException(vsprintf("%s(): The file '{$file}' doesn't exist", array(__METHOD__)));
if (!function_exists('password_hash')) {
$password_hash_installed = false;
} else {
$password_hash_installed = true;
}
// Gets file permissions
$perms = fileperms($file);
// Is writable ?
if (is_writable($file) || ($perms & 0x0080) || ($perms & 0x0010) || ($perms & 0x0002)) {
return true;
if (!function_exists('password_verify')) {
$password_verify_installed = false;
} else {
$password_verify_installed = true;
}
return $this->view->render($response,
'plugins/admin/views/templates/system/information/index.html', [
'menu_item' => 'information',
'php_uname' => php_uname(),
'webserver' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : @getenv('SERVER_SOFTWARE'),
'php_sapi_name' => php_sapi_name(),
'apache_mod_rewrite_installed' => $apache_mod_rewrite_installed,
'password_verify_installed' => $password_verify_installed,
'password_hash_installed' => $password_hash_installed,
'links' => [
'information' => [
'link' => '/admin/information',
'title' => __('admin_information'),
'attributes' => ['class' => 'navbar-item active']
],
]
]);
}
}