mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
6ccb1bb5df
Found that old 1.0 blog author names were not being migrated over to the new 2.0 AuthorNames (noted that there is now also a relationship between Member and BlogPost). The old 1.0 did not have this relationship so when migrating no authors are brought across from BlogEntry into BlogPost during the MigrationTask.
101 lines
1.8 KiB
PHP
101 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @deprecated since version 2.0
|
|
*
|
|
* @property int $ParentID
|
|
* @property string $Date
|
|
* @property string $PublishDate
|
|
* @property string $Tags
|
|
*/
|
|
class BlogEntry extends BlogPost implements MigratableObject {
|
|
/**
|
|
* @var string
|
|
*/
|
|
private static $hide_ancestor = 'BlogEntry';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private static $db = array(
|
|
'Date' => 'SS_Datetime',
|
|
'Author' => 'Text',
|
|
'Tags' => 'Text',
|
|
);
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function canCreate($member = null) {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function up() {
|
|
foreach($this->TagNames() as $tag) {
|
|
if($this->Tags()->filter('Title', $tag)->count()) {
|
|
continue;
|
|
}
|
|
|
|
$tagObject = new BlogTag();
|
|
$tagObject->Title = $tag;
|
|
$tagObject->BlogID = $this->ParentID;
|
|
|
|
$tagObject->write();
|
|
|
|
$this->Tags()->add($tagObject);
|
|
}
|
|
|
|
$this->PublishDate = $this->Date;
|
|
$this->AuthorNames = $this->Author;
|
|
|
|
// If a user has subclassed BlogEntry, it should not be turned into a BlogPost.
|
|
if($this->ClassName === 'BlogEntry') {
|
|
$this->ClassName = 'BlogPost';
|
|
$this->RecordClassName = 'BlogPost';
|
|
}
|
|
|
|
$this->write();
|
|
}
|
|
|
|
/**
|
|
* Safely split and parse all distinct tags assigned to this BlogEntry.
|
|
*
|
|
* @deprecated since version 2.0
|
|
*
|
|
* @return array
|
|
*/
|
|
public function TagNames() {
|
|
$tags = preg_split('/\s*,\s*/', trim($this->Tags));
|
|
|
|
$results = array();
|
|
|
|
foreach($tags as $tag) {
|
|
if($tag) $results[mb_strtolower($tag)] = $tag;
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function requireDefaultRecords() {
|
|
parent::requireDefaultRecords();
|
|
|
|
if(BlogMigrationTask::config()->run_during_dev_build) {
|
|
$task = new BlogMigrationTask();
|
|
$task->up();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @deprecated since version 2.0
|
|
*/
|
|
class BlogEntry_Controller extends BlogPost_Controller {
|
|
|
|
}
|