Minor improvements to BlogMemberExtension

This commit is contained in:
David Craig 2015-03-25 12:06:02 +13:00
parent 49bee390a3
commit 7b88435b7e

View File

@ -10,7 +10,7 @@
class BlogMemberExtension extends DataExtension {
private static $db = array(
'URLSegment' => 'Varchar',
'URLSegment' => 'Varchar(50)',
'BlogProfileSummary' => 'Text'
);
@ -47,8 +47,7 @@ class BlogMemberExtension extends DataExtension {
*/
public function generateURLSegment() {
$filter = URLSegmentFilter::create();
$name = $this->owner->FirstName . ' ' . $this->owner->Surname;
$urlSegment = $filter->filter($name);
$urlSegment = $filter->filter($this->owner->getName());
// Fallback to generic profile name if path is empty (= no valid, convertable characters)
if(!$urlSegment || $urlSegment == '-' || $urlSegment == '-1') $urlSegment = "profile-$this->ID";
@ -70,7 +69,7 @@ class BlogMemberExtension extends DataExtension {
$conflict = $conflict->exclude('ID', $this->owner->ID);
}
return $conflict->count() == 0;
return !$conflict->exists();
}
}