Skip to content

Commit 33a0469

Browse files
committed
Merge branch 'master' into release
2 parents b70a5c0 + a602cdf commit 33a0469

40 files changed

Lines changed: 441 additions & 236 deletions

app/Auth/User.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ public function getProfileUrl()
216216
*/
217217
public function getShortName($chars = 8)
218218
{
219-
if (strlen($this->name) <= $chars) {
219+
if (mb_strlen($this->name) <= $chars) {
220220
return $this->name;
221221
}
222222

223223
$splitName = explode(' ', $this->name);
224-
if (strlen($splitName[0]) <= $chars) {
224+
if (mb_strlen($splitName[0]) <= $chars) {
225225
return $splitName[0];
226226
}
227227

app/Console/Commands/CreateAdmin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function handle()
4949
if (empty($email)) {
5050
$email = $this->ask('Please specify an email address for the new admin user');
5151
}
52-
if (strlen($email) < 5 || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
52+
if (mb_strlen($email) < 5 || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
5353
return $this->error('Invalid email address provided');
5454
}
5555

@@ -61,15 +61,15 @@ public function handle()
6161
if (empty($name)) {
6262
$name = $this->ask('Please specify an name for the new admin user');
6363
}
64-
if (strlen($name) < 2) {
64+
if (mb_strlen($name) < 2) {
6565
return $this->error('Invalid name provided');
6666
}
6767

6868
$password = trim($this->option('password'));
6969
if (empty($password)) {
7070
$password = $this->secret('Please specify a password for the new admin user');
7171
}
72-
if (strlen($password) < 5) {
72+
if (mb_strlen($password) < 5) {
7373
return $this->error('Invalid password provided, Must be at least 5 characters');
7474
}
7575

app/Entities/Book.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function shelves()
104104
public function getExcerpt(int $length = 100)
105105
{
106106
$description = $this->description;
107-
return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description;
107+
return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description;
108108
}
109109

110110
/**

app/Entities/Bookshelf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function cover()
8383
public function getExcerpt(int $length = 100)
8484
{
8585
$description = $this->description;
86-
return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description;
86+
return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description;
8787
}
8888

8989
/**

app/Entities/Chapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getUrl($path = false)
5656
public function getExcerpt(int $length = 100)
5757
{
5858
$description = $this->text ?? $this->description;
59-
return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description;
59+
return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description;
6060
}
6161

6262
/**

app/Entities/Repos/EntityRepo.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,13 @@ public function destroyChapter(Chapter $chapter)
852852
*/
853853
public function destroyPage(Page $page)
854854
{
855-
// Check if set as custom homepage
855+
// Check if set as custom homepage & remove setting if not used or throw error if active
856856
$customHome = setting('app-homepage', '0:');
857857
if (intval($page->id) === intval(explode(':', $customHome)[0])) {
858-
throw new NotifyException(trans('errors.page_custom_home_deletion'), $page->getUrl());
858+
if (setting('app-homepage-type') === 'page') {
859+
throw new NotifyException(trans('errors.page_custom_home_deletion'), $page->getUrl());
860+
}
861+
setting()->remove('app-homepage');
859862
}
860863

861864
$this->destroyEntityCommonRelations($page);

app/Entities/Repos/PageRepo.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ protected function setUniqueId($element, array &$idMap)
192192
// Create an unique id for the element
193193
// Uses the content as a basis to ensure output is the same every time
194194
// the same content is passed through.
195-
$contentId = 'bkmrk-' . substr(strtolower(preg_replace('/\s+/', '-', trim($element->nodeValue))), 0, 20);
195+
$contentId = 'bkmrk-' . mb_substr(strtolower(preg_replace('/\s+/', '-', trim($element->nodeValue))), 0, 20);
196196
$newId = urlencode($contentId);
197197
$loopIndex = 0;
198198

@@ -422,25 +422,29 @@ public function getPageNav(string $pageContent)
422422
return [];
423423
}
424424

425-
$tree = collect([]);
426-
foreach ($headers as $header) {
427-
$text = $header->nodeValue;
428-
$tree->push([
425+
$tree = collect($headers)->map(function($header) {
426+
$text = trim(str_replace("\xc2\xa0", '', $header->nodeValue));
427+
if (mb_strlen($text) > 30) {
428+
$text = mb_substr($text, 0, 27) . '...';
429+
}
430+
431+
return [
429432
'nodeName' => strtolower($header->nodeName),
430433
'level' => intval(str_replace('h', '', $header->nodeName)),
431434
'link' => '#' . $header->getAttribute('id'),
432-
'text' => strlen($text) > 30 ? substr($text, 0, 27) . '...' : $text
433-
]);
434-
}
435+
'text' => $text,
436+
];
437+
})->filter(function($header) {
438+
return mb_strlen($header['text']) > 0;
439+
});
435440

436441
// Normalise headers if only smaller headers have been used
437-
if (count($tree) > 0) {
438-
$minLevel = $tree->pluck('level')->min();
439-
$tree = $tree->map(function ($header) use ($minLevel) {
440-
$header['level'] -= ($minLevel - 2);
441-
return $header;
442-
});
443-
}
442+
$minLevel = $tree->pluck('level')->min();
443+
$tree = $tree->map(function ($header) use ($minLevel) {
444+
$header['level'] -= ($minLevel - 2);
445+
return $header;
446+
});
447+
444448
return $tree->toArray();
445449
}
446450

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function registerUser(array $userData, $socialAccount = false, $emailV
142142

143143
if ($registrationRestrict) {
144144
$restrictedEmailDomains = explode(',', str_replace(' ', '', $registrationRestrict));
145-
$userEmailDomain = $domain = substr(strrchr($userData['email'], "@"), 1);
145+
$userEmailDomain = $domain = mb_substr(mb_strrchr($userData['email'], "@"), 1);
146146
if (!in_array($userEmailDomain, $restrictedEmailDomains)) {
147147
throw new UserRegistrationException(trans('auth.registration_email_domain_invalid'), '/register');
148148
}

app/Uploads/ImageRepo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ protected function loadThumbs(Image $image)
230230
{
231231
$image->thumbs = [
232232
'gallery' => $this->getThumbnail($image, 150, 150, false),
233-
'display' => $this->getThumbnail($image, 840, null, true)
233+
'display' => $this->getThumbnail($image, 1680, null, true)
234234
];
235235
}
236236

app/helpers.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,19 @@ function baseUrl($path, $forceAppDomain = false)
123123
// Remove non-specified domain if forced and we have a domain
124124
if ($isFullUrl && $forceAppDomain) {
125125
if (!empty($base) && strpos($path, $base) === 0) {
126-
$path = trim(substr($path, strlen($base) - 1));
126+
$path = mb_substr($path, mb_strlen($base));
127+
} else {
128+
$explodedPath = explode('/', $path);
129+
$path = implode('/', array_splice($explodedPath, 3));
127130
}
128-
$explodedPath = explode('/', $path);
129-
$path = implode('/', array_splice($explodedPath, 3));
130131
}
131132

132133
// Return normal url path if not specified in config
133134
if (config('app.url') === '') {
134135
return url($path);
135136
}
136137

137-
return $base . '/' . $path;
138+
return $base . '/' . ltrim($path, '/');
138139
}
139140

140141
/**

0 commit comments

Comments
 (0)