mirror of
https://github.com/typemill/typemill.git
synced 2025-08-06 22:26:32 +02:00
Fix deprection errors php 8.2 and other bugs
This commit is contained in:
@@ -10,7 +10,29 @@ use Typemill\Models\StorageWrapper;
|
||||
class Assets
|
||||
{
|
||||
public $baseUrl;
|
||||
|
||||
|
||||
public $JS;
|
||||
|
||||
public $CSS;
|
||||
|
||||
public $inlineJS;
|
||||
|
||||
public $inlineCSS;
|
||||
|
||||
public $editorJS;
|
||||
|
||||
public $editorCSS;
|
||||
|
||||
public $editorInlineJS;
|
||||
|
||||
public $svgSymbols;
|
||||
|
||||
public $meta;
|
||||
|
||||
public $imageUrl;
|
||||
|
||||
public $imageFolder;
|
||||
|
||||
public function __construct($baseUrl)
|
||||
{
|
||||
$this->baseUrl = $baseUrl;
|
||||
@@ -69,7 +91,7 @@ class Assets
|
||||
|
||||
public function activateVue()
|
||||
{
|
||||
$vueUrl = '<script src="' . $this->baseUrl . '/system/author/js/vue.min.js"></script>';
|
||||
$vueUrl = '<script src="' . $this->baseUrl . '/system/author/js/vue.js"></script>';
|
||||
if(!in_array($vueUrl, $this->JS))
|
||||
{
|
||||
$this->JS[] = $vueUrl;
|
||||
@@ -90,6 +112,7 @@ class Assets
|
||||
|
||||
public function activateTachyons()
|
||||
{
|
||||
die('Hi from asset class, Tachyons not available in Typemill v2');
|
||||
$tachyonsUrl = '<link rel="stylesheet" href="' . $this->baseUrl . '/system/author/css/tachyons.min.css" />';
|
||||
if(!in_array($tachyonsUrl, $this->CSS))
|
||||
{
|
||||
|
@@ -99,12 +99,16 @@ class ControllerApiAuthorArticle extends Controller
|
||||
'item' => $item,
|
||||
'metadata' => $metadata
|
||||
];
|
||||
$this->c->get('dispatcher')->dispatch(new OnPagePublished($data), 'onPagePublished');
|
||||
|
||||
$message = $this->c->get('dispatcher')->dispatch(new OnPagePublished($data), 'onPagePublished')->getData();
|
||||
|
||||
# validate message
|
||||
|
||||
$response->getBody()->write(json_encode([
|
||||
'navigation' => $draftNavigation,
|
||||
'item' => $item,
|
||||
'metadata' => $metadata
|
||||
'metadata' => $metadata,
|
||||
'message' => $message
|
||||
]));
|
||||
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
|
@@ -30,19 +30,11 @@ class ControllerApiSystemExtensions extends Controller
|
||||
return $response->withHeader('Content-Type', 'application/json')->withStatus(400);
|
||||
}
|
||||
|
||||
if(!isset($this->settings[$params['type']][$params['name']]))
|
||||
{
|
||||
$response->getBody()->write(json_encode([
|
||||
'message' => Translations::translate('The plugin or themes was not found.'),
|
||||
]));
|
||||
|
||||
return $response->withHeader('Content-Type', 'application/json')->withStatus(404);
|
||||
}
|
||||
|
||||
if($params['checked'] == true)
|
||||
{
|
||||
$extension = new Extension();
|
||||
|
||||
$definitions = false;
|
||||
if($params['type'] == 'plugins')
|
||||
{
|
||||
$definitions = $extension->getPluginDefinition($params['name']);
|
||||
@@ -51,6 +43,14 @@ class ControllerApiSystemExtensions extends Controller
|
||||
{
|
||||
$definitions = $extension->getThemeDefinition($params['name']);
|
||||
}
|
||||
if(!$definitions)
|
||||
{
|
||||
$response->getBody()->write(json_encode([
|
||||
'message' => Translations::translate('The plugin or themes was not found.'),
|
||||
]));
|
||||
|
||||
return $response->withHeader('Content-Type', 'application/json')->withStatus(404);
|
||||
}
|
||||
|
||||
if(isset($definitions['license']) && in_array($definitions['license'], ['MAKER', 'BUSINESS']))
|
||||
{
|
||||
|
@@ -72,7 +72,7 @@ class ControllerWebSystem extends Controller
|
||||
);
|
||||
|
||||
$extension = new Extension();
|
||||
$themeDefinitions = $extension->getThemeDetails();
|
||||
$themeDefinitions = $extension->getThemeDetails($this->settings['theme']);
|
||||
|
||||
# add userroles and other datasets
|
||||
foreach($themeDefinitions as $name => $definitions)
|
||||
@@ -126,7 +126,7 @@ class ControllerWebSystem extends Controller
|
||||
);
|
||||
|
||||
$extension = new Extension();
|
||||
$pluginDefinitions = $extension->getPluginDetails();
|
||||
$pluginDefinitions = $extension->getPluginDetails($this->settings['plugins']);
|
||||
|
||||
# add userroles and other datasets
|
||||
foreach($pluginDefinitions as $name => $definitions)
|
||||
@@ -137,7 +137,8 @@ class ControllerWebSystem extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$pluginSettings = $extension->getPluginSettings($this->settings['plugins']);
|
||||
# $pluginSettings = $extension->getPluginSettings($this->settings['plugins']);
|
||||
$pluginSettings = $this->settings['plugins'];
|
||||
|
||||
$license = [];
|
||||
if(is_array($this->settings['license']))
|
||||
@@ -150,7 +151,7 @@ class ControllerWebSystem extends Controller
|
||||
'darkmode' => $request->getAttribute('c_darkmode'),
|
||||
'mainnavi' => $mainNavigation,
|
||||
'jsdata' => [
|
||||
'systemnavi' => $systemNavigation,
|
||||
'systemnavi' => $systemNavigation,
|
||||
'settings' => $pluginSettings,
|
||||
'definitions' => $pluginDefinitions,
|
||||
'license' => $license,
|
||||
|
@@ -7,6 +7,17 @@ use Typemill\Events\OnShortcodeFound;
|
||||
|
||||
class ParsedownExtension extends \ParsedownExtra
|
||||
{
|
||||
|
||||
private $settings;
|
||||
|
||||
private $dispatcher;
|
||||
|
||||
private $showAnchor;
|
||||
|
||||
private $visualMode;
|
||||
|
||||
private $baseUrl;
|
||||
|
||||
function __construct($baseUrl = '', $settings = NULL, $dispatcher = NULL)
|
||||
{
|
||||
parent::__construct();
|
||||
|
@@ -11,6 +11,13 @@ use Typemill\Static\Translations;
|
||||
|
||||
class ApiAuthorization implements MiddlewareInterface
|
||||
{
|
||||
|
||||
private $acl;
|
||||
|
||||
private $resource;
|
||||
|
||||
private $action;
|
||||
|
||||
public function __construct($acl, string $resource = NULL, string $action = NULL)
|
||||
{
|
||||
$this->acl = $acl;
|
||||
|
@@ -7,7 +7,9 @@ use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
|
||||
use Slim\Flash\Messages;
|
||||
|
||||
class FlashMessages
|
||||
{
|
||||
{
|
||||
private $container;
|
||||
|
||||
public function __construct($container)
|
||||
{
|
||||
$this->container = $container;
|
||||
|
@@ -10,6 +10,15 @@ use Slim\Psr7\Response;
|
||||
|
||||
class WebAuthorization implements MiddlewareInterface
|
||||
{
|
||||
|
||||
private $router;
|
||||
|
||||
private $acl;
|
||||
|
||||
private $resource;
|
||||
|
||||
private $action;
|
||||
|
||||
public function __construct(RouteParser $router, $acl, string $resource = NULL, string $action = NULL)
|
||||
{
|
||||
$this->router = $router;
|
||||
|
@@ -9,7 +9,11 @@ use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
|
||||
use Slim\Psr7\Response;
|
||||
|
||||
class WebRedirectIfAuthenticated implements MiddlewareInterface
|
||||
{
|
||||
{
|
||||
private $router;
|
||||
|
||||
private $settings;
|
||||
|
||||
public function __construct(RouteParser $router, $settings)
|
||||
{
|
||||
$this->router = $router;
|
||||
|
@@ -11,6 +11,8 @@ use Typemill\Models\User;
|
||||
|
||||
class WebRedirectIfUnauthenticated implements MiddlewareInterface
|
||||
{
|
||||
private $router;
|
||||
|
||||
public function __construct(RouteParser $router)
|
||||
{
|
||||
$this->router = $router;
|
||||
|
@@ -9,6 +9,8 @@ class Content
|
||||
{
|
||||
private $storage;
|
||||
|
||||
private $parsedown;
|
||||
|
||||
public function __construct($baseurl = NULL, $settings = NULL, $dispatcher = NULL)
|
||||
{
|
||||
$this->storage = new StorageWrapper('\Typemill\Models\Storage');
|
||||
|
@@ -14,25 +14,46 @@ class Extension
|
||||
$this->storage = new StorageWrapper('\Typemill\Models\Storage');
|
||||
}
|
||||
|
||||
public function getThemeDetails()
|
||||
public function getThemeDetails($activeThemeName = NULL)
|
||||
{
|
||||
$themes = $this->getThemes();
|
||||
|
||||
$themeDetails = [];
|
||||
foreach($themes as $themeName)
|
||||
{
|
||||
$themeDetails[$themeName] = $this->getThemeDefinition($themeName);
|
||||
$details = $this->getThemeDefinition($themeName);
|
||||
if($details && isset($details['name']))
|
||||
{
|
||||
# add to first position if active
|
||||
if($activeThemeName && ($activeThemeName == $themeName))
|
||||
{
|
||||
$themeDetails = array_merge(array($themeName => $details), $themeDetails);
|
||||
}
|
||||
else
|
||||
{
|
||||
$themeDetails[$themeName] = $details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $themeDetails;
|
||||
}
|
||||
|
||||
public function getThemeSettings($themes)
|
||||
public function getThemeSettings($themesInSettings)
|
||||
{
|
||||
# WHAT ABOUT DEFAULT-SETTINGS FROM THEME YAMLs?
|
||||
|
||||
$themes = $this->getThemes();
|
||||
|
||||
$themeSettings = [];
|
||||
foreach($themes as $themename => $themeinputs)
|
||||
foreach($themes as $themename)
|
||||
{
|
||||
if(!is_array($themeinputs)){ $themeinputs = []; }
|
||||
$themeinputs = [];
|
||||
if(isset($themesInSettings[$themename]))
|
||||
{
|
||||
$themeinputs = $themesInSettings[$themename];
|
||||
}
|
||||
|
||||
$themeSettings[$themename] = $themeinputs;
|
||||
$themeSettings[$themename]['customcss'] = $this->storage->getFile('cacheFolder', '', $themename . '-custom.css');
|
||||
}
|
||||
@@ -40,6 +61,7 @@ class Extension
|
||||
return $themeSettings;
|
||||
}
|
||||
|
||||
|
||||
public function getThemes()
|
||||
{
|
||||
$themeFolder = $this->storage->getFolderPath('themesFolder');
|
||||
@@ -71,36 +93,39 @@ class Extension
|
||||
'description' => Translations::translate('You can overwrite the theme-css with your own css here.')
|
||||
];
|
||||
|
||||
# add image preview file
|
||||
$themeSettings['preview'] = '/themes/' . $themeName . '/' . $themeName . '.png';
|
||||
|
||||
return $themeSettings;
|
||||
}
|
||||
|
||||
public function getPluginDetails()
|
||||
public function getPluginDetails($userSettings = NULL)
|
||||
{
|
||||
$plugins = $this->getPlugins();
|
||||
|
||||
$pluginDetails = [];
|
||||
foreach($plugins as $pluginName)
|
||||
{
|
||||
$pluginDetails[$pluginName] = $this->getPluginDefinition($pluginName);
|
||||
$details = $this->getPluginDefinition($pluginName);
|
||||
if($details && $details['name'])
|
||||
{
|
||||
# add active plugins first
|
||||
if(
|
||||
$userSettings
|
||||
&& isset($userSettings[$pluginName])
|
||||
&& ($userSettings[$pluginName]['active'] == true)
|
||||
)
|
||||
{
|
||||
$pluginDetails = array_merge(array($pluginName => $details), $pluginDetails);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pluginDetails[$pluginName] = $details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $pluginDetails;
|
||||
}
|
||||
|
||||
public function getPluginSettings($plugins)
|
||||
{
|
||||
$pluginSettings = [];
|
||||
foreach($plugins as $pluginname => $plugininputs)
|
||||
{
|
||||
$pluginSettings[$pluginname] = $plugininputs;
|
||||
}
|
||||
|
||||
return $pluginSettings;
|
||||
}
|
||||
|
||||
public function getPlugins()
|
||||
{
|
||||
$pluginFolder = $this->storage->getFolderPath('pluginsFolder');
|
||||
|
@@ -41,7 +41,7 @@ class Storage
|
||||
|
||||
protected $isReadable = [];
|
||||
|
||||
protected $isWrtiable = [];
|
||||
protected $isWritable = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -9,6 +9,8 @@ class User
|
||||
{
|
||||
private $userDir;
|
||||
|
||||
private $storage;
|
||||
|
||||
private $yaml;
|
||||
|
||||
private $user = false;
|
||||
|
@@ -16,6 +16,8 @@ abstract class Plugin implements EventSubscriberInterface
|
||||
|
||||
protected $route;
|
||||
|
||||
protected $urlinfo;
|
||||
|
||||
protected $adminroute = false;
|
||||
|
||||
protected $editorroute = false;
|
||||
@@ -26,7 +28,11 @@ abstract class Plugin implements EventSubscriberInterface
|
||||
$this->container = $container;
|
||||
$this->urlinfo = $this->container->get('urlinfo');
|
||||
$this->route = $this->urlinfo['route'];
|
||||
$this->route = ltrim($this->route, '/');
|
||||
|
||||
if($this->route != '/')
|
||||
{
|
||||
$this->route = ltrim($this->route, '/');
|
||||
}
|
||||
|
||||
if(str_starts_with($this->route, 'tm/'))
|
||||
{
|
||||
|
@@ -241,7 +241,7 @@ $container->set('translations', $translations);
|
||||
$container->set('dispatcher', function() use ($dispatcher){ return $dispatcher; });
|
||||
|
||||
# asset function for plugins
|
||||
$assets = new \Typemill\Assets($urlinfo['basepath']);
|
||||
$assets = new \Typemill\Assets($urlinfo['baseurl']);
|
||||
$container->set('assets', function() use ($assets){ return $assets; });
|
||||
|
||||
/****************************
|
||||
@@ -286,6 +286,16 @@ $container->set('view', function() use ($settings, $urlinfo, $translations) {
|
||||
* MIDDLEWARE *
|
||||
****************************/
|
||||
|
||||
foreach($middleware as $pluginMiddleware)
|
||||
{
|
||||
$middlewareClass = $pluginMiddleware['classname'];
|
||||
$middlewareParams = $pluginMiddleware['params'];
|
||||
if(class_exists($middlewareClass))
|
||||
{
|
||||
$app->add(new $middlewareClass($middlewareParams));
|
||||
}
|
||||
}
|
||||
|
||||
$app->add(new AssetMiddleware($assets, $container->get('view')));
|
||||
|
||||
$app->add(new ValidationErrorsMiddleware($container->get('view')));
|
||||
|
Reference in New Issue
Block a user