mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Minor improvements to BlogMemberExtension
This commit is contained in:
parent
49bee390a3
commit
7b88435b7e
@ -10,7 +10,7 @@
|
|||||||
class BlogMemberExtension extends DataExtension {
|
class BlogMemberExtension extends DataExtension {
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'URLSegment' => 'Varchar',
|
'URLSegment' => 'Varchar(50)',
|
||||||
'BlogProfileSummary' => 'Text'
|
'BlogProfileSummary' => 'Text'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -47,8 +47,7 @@ class BlogMemberExtension extends DataExtension {
|
|||||||
*/
|
*/
|
||||||
public function generateURLSegment() {
|
public function generateURLSegment() {
|
||||||
$filter = URLSegmentFilter::create();
|
$filter = URLSegmentFilter::create();
|
||||||
$name = $this->owner->FirstName . ' ' . $this->owner->Surname;
|
$urlSegment = $filter->filter($this->owner->getName());
|
||||||
$urlSegment = $filter->filter($name);
|
|
||||||
|
|
||||||
// Fallback to generic profile name if path is empty (= no valid, convertable characters)
|
// Fallback to generic profile name if path is empty (= no valid, convertable characters)
|
||||||
if(!$urlSegment || $urlSegment == '-' || $urlSegment == '-1') $urlSegment = "profile-$this->ID";
|
if(!$urlSegment || $urlSegment == '-' || $urlSegment == '-1') $urlSegment = "profile-$this->ID";
|
||||||
@ -70,7 +69,7 @@ class BlogMemberExtension extends DataExtension {
|
|||||||
$conflict = $conflict->exclude('ID', $this->owner->ID);
|
$conflict = $conflict->exclude('ID', $this->owner->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conflict->count() == 0;
|
return !$conflict->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user