mirror of
https://github.com/typemill/typemill.git
synced 2025-08-06 06:07:31 +02:00
Version 1.4.0
This commit is contained in:
@@ -977,7 +977,7 @@ class ArticleApiController extends ContentController
|
||||
}
|
||||
|
||||
# parse markdown-content-array to content-string
|
||||
$content[$key] = ['id' => $key, 'html' => $parsedown->markup($contentArray, $relurl)];
|
||||
$content[$key] = ['id' => $key, 'html' => $parsedown->markup($contentArray)];
|
||||
}
|
||||
|
||||
if($toc)
|
||||
|
@@ -116,6 +116,13 @@ class AuthController extends Controller
|
||||
|
||||
if($userdata && password_verify($params['password'], $userdata['password']))
|
||||
{
|
||||
# check if user has confirmed the account
|
||||
if(isset($userdata['optintoken']) && $userdata['optintoken'])
|
||||
{
|
||||
$this->c->flash->addMessage('error', 'Your registration is not confirmed yet. Please check your e-mails and use the confirmation link.');
|
||||
return $response->withRedirect($this->c->router->pathFor('auth.show'));
|
||||
}
|
||||
|
||||
$user->login($userdata['username']);
|
||||
|
||||
/* clear the user login attemps */
|
||||
|
@@ -143,7 +143,7 @@ class BlockApiController extends ContentController
|
||||
else
|
||||
{
|
||||
# parse markdown-content-array to content-string
|
||||
$blockHTML = $parsedown->markup($blockArray, $relurl);
|
||||
$blockHTML = $parsedown->markup($blockArray);
|
||||
|
||||
# if it is a headline
|
||||
if($blockMarkdown[0] == '#')
|
||||
@@ -195,7 +195,7 @@ class BlockApiController extends ContentController
|
||||
}
|
||||
|
||||
# parse markdown-content-array to content-string
|
||||
$content[$key] = ['id' => $key, 'html' => $parsedown->markup($contentArray, $relurl)];
|
||||
$content[$key] = ['id' => $key, 'html' => $parsedown->markup($contentArray)];
|
||||
}
|
||||
|
||||
# if page has a table of content
|
||||
@@ -353,7 +353,7 @@ class BlockApiController extends ContentController
|
||||
else
|
||||
{
|
||||
# parse markdown-content-array to content-string
|
||||
$blockHTML = $parsedown->markup($blockArray, $relurl);
|
||||
$blockHTML = $parsedown->markup($blockArray);
|
||||
|
||||
# if it is a headline
|
||||
if($blockMarkdown[0] == '#')
|
||||
|
@@ -157,7 +157,7 @@ class ContentBackendController extends ContentController
|
||||
$contentArray = $parsedown->text($block);
|
||||
|
||||
/* parse markdown-content-array to content-string */
|
||||
$content[$key] = $parsedown->markup($contentArray, $relurl);
|
||||
$content[$key] = $parsedown->markup($contentArray);
|
||||
}
|
||||
|
||||
# extract title and delete from content array, array will start at 1 after that.
|
||||
|
@@ -206,15 +206,15 @@ class PageController extends Controller
|
||||
$parsedown->setSafeMode(true);
|
||||
|
||||
/* parse markdown-file to content-array */
|
||||
$contentArray = $parsedown->text($contentMD, $itemUrl);
|
||||
$contentArray = $parsedown->text($contentMD);
|
||||
$contentArray = $this->c->dispatcher->dispatch('onContentArrayLoaded', new OnContentArrayLoaded($contentArray))->getData();
|
||||
|
||||
/* parse markdown-content-array to content-string */
|
||||
$contentHTML = $parsedown->markup($contentArray, $itemUrl);
|
||||
$contentHTML = $parsedown->markup($contentArray);
|
||||
$contentHTML = $this->c->dispatcher->dispatch('onHtmlLoaded', new OnHtmlLoaded($contentHTML))->getData();
|
||||
|
||||
/* extract the h1 headline*/
|
||||
$contentParts = explode("</h1>", $contentHTML);
|
||||
$contentParts = explode("</h1>", $contentHTML, 2);
|
||||
$title = isset($contentParts[0]) ? strip_tags($contentParts[0]) : $settings['title'];
|
||||
|
||||
$contentHTML = isset($contentParts[1]) ? $contentParts[1] : $contentHTML;
|
||||
@@ -240,9 +240,19 @@ class PageController extends Controller
|
||||
$img_alt = isset($img_alt_result[1]) ? $img_alt_result[1] : false;
|
||||
}
|
||||
}
|
||||
elseif($logo)
|
||||
{
|
||||
$img_url = $logo;
|
||||
$pathinfo = pathinfo($settings['logo']);
|
||||
$img_alt = $pathinfo['filename'];
|
||||
}
|
||||
}
|
||||
|
||||
$firstImage = array('img_url' => $base_url . '/' . $img_url, 'img_alt' => $img_alt);
|
||||
$firstImage = false;
|
||||
if($img_url)
|
||||
{
|
||||
$firstImage = array('img_url' => $base_url . '/' . $img_url, 'img_alt' => $img_alt);
|
||||
}
|
||||
|
||||
$route = empty($args) && isset($settings['themes'][$theme]['cover']) ? '/cover.twig' : '/index.twig';
|
||||
|
||||
|
@@ -65,7 +65,7 @@ class SettingsController extends Controller
|
||||
'locale' => $locale,
|
||||
'formats' => $defaultSettings['formats'],
|
||||
'access' => $options,
|
||||
'route' => $route->getName()
|
||||
'route' => $route->getName()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -83,18 +83,24 @@ class SettingsController extends Controller
|
||||
|
||||
if($newSettings)
|
||||
{
|
||||
/* make sure only allowed fields are stored */
|
||||
# check for image settings
|
||||
$imgwidth = isset($newSettings['images']['live']['width']) ? $newSettings['images']['live']['width'] : false;
|
||||
$imgheight = isset($newSettings['images']['live']['height']) ? $newSettings['images']['live']['height'] : false;
|
||||
|
||||
# make sure only allowed fields are stored
|
||||
$newSettings = array(
|
||||
'title' => $newSettings['title'],
|
||||
'author' => $newSettings['author'],
|
||||
'copyright' => $newSettings['copyright'],
|
||||
'year' => $newSettings['year'],
|
||||
'language' => $newSettings['language'],
|
||||
'langattr' => $newSettings['langattr'],
|
||||
'editor' => $newSettings['editor'],
|
||||
'access' => $newSettings['access'],
|
||||
'formats' => $newSettings['formats'],
|
||||
'headlineanchors' => isset($newSettings['headlineanchors']) ? $newSettings['headlineanchors'] : null,
|
||||
'title' => $newSettings['title'],
|
||||
'author' => $newSettings['author'],
|
||||
'copyright' => $newSettings['copyright'],
|
||||
'year' => $newSettings['year'],
|
||||
'language' => $newSettings['language'],
|
||||
'langattr' => $newSettings['langattr'],
|
||||
'editor' => $newSettings['editor'],
|
||||
'access' => $newSettings['access'],
|
||||
'formats' => $newSettings['formats'],
|
||||
'headlineanchors' => isset($newSettings['headlineanchors']) ? $newSettings['headlineanchors'] : null,
|
||||
'displayErrorDetails' => isset($newSettings['displayErrorDetails']) ? true : null,
|
||||
'twigcache' => isset($newSettings['twigcache']) ? true : null
|
||||
);
|
||||
|
||||
# https://www.slimframework.com/docs/v3/cookbook/uploading-files.html;
|
||||
@@ -102,6 +108,17 @@ class SettingsController extends Controller
|
||||
$copyright = $this->getCopyright();
|
||||
|
||||
$validate->settings($newSettings, $copyright, $defaultSettings['formats'], 'settings');
|
||||
|
||||
# use custom image settings
|
||||
if( $imgwidth && ctype_digit($imgwidth) && (strlen($imgwidth) < 5) )
|
||||
{
|
||||
$newSettings['images']['live']['width'] = $imgwidth;
|
||||
}
|
||||
if( $imgheight && ctype_digit($imgheight) && (strlen($imgheight) < 5) )
|
||||
{
|
||||
$newSettings['images']['live']['height'] = $imgheight;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -733,7 +750,9 @@ class SettingsController extends Controller
|
||||
{
|
||||
# set image size
|
||||
$settings = $this->c->get('settings');
|
||||
$settings->replace(['images' => ['live' => ['width' => 500, 'height' => 500]]]);
|
||||
$imageSizes = $settings['images'];
|
||||
$imageSizes['live'] = ['width' => 500, 'height' => 500];
|
||||
$settings->replace(['images' => $imageSizes]);
|
||||
$imageresult = $this->saveImages($imageFields, $userdata, $settings, $images['user']);
|
||||
|
||||
if(isset($_SESSION['slimFlash']['error']))
|
||||
@@ -818,6 +837,42 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function clearCache($request, $response, $args)
|
||||
{
|
||||
$settings = $this->c->get('settings');
|
||||
$dir = $settings['basePath'] . 'cache';
|
||||
$iterator = new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$files = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);
|
||||
|
||||
$error = false;
|
||||
|
||||
foreach($files as $file)
|
||||
{
|
||||
if ($file->isDir())
|
||||
{
|
||||
if(!rmdir($file->getRealPath()))
|
||||
{
|
||||
$error = 'Could not delete some folders.';
|
||||
}
|
||||
}
|
||||
elseif($file->getExtension() !== 'css')
|
||||
{
|
||||
if(!unlink($file->getRealPath()) )
|
||||
{
|
||||
$error = 'Could not delete some files.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($error)
|
||||
{
|
||||
return $response->withJson(['errors' => $error], 500);
|
||||
}
|
||||
|
||||
return $response->withJson(array('errors' => false));
|
||||
|
||||
}
|
||||
|
||||
private function getUserFields($role)
|
||||
{
|
||||
$fields = [];
|
||||
@@ -996,7 +1051,6 @@ class SettingsController extends Controller
|
||||
|
||||
protected function saveImages($imageFields, $userInput, $userSettings, $files)
|
||||
{
|
||||
|
||||
# initiate image processor with standard image sizes
|
||||
$processImages = new ProcessImage($userSettings['images']);
|
||||
|
||||
@@ -1029,5 +1083,6 @@ class SettingsController extends Controller
|
||||
}
|
||||
}
|
||||
return $userInput;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user