silverstripe-blog/code/compat/pages/BlogEntry.php

97 lines
1.6 KiB
PHP
Raw Normal View History

2015-02-08 08:03:55 +01:00
<?php
/**
* @deprecated since version 2.0
2015-05-09 16:33:12 +02:00
*
* @property int $ParentID
* @property string $Date
* @property string $PublishDate
* @property string $Tags
2015-02-08 08:03:55 +01:00
*/
class BlogEntry extends BlogPost implements MigratableObject {
2015-05-09 16:33:12 +02:00
/**
* @var string
*/
2015-02-08 08:03:55 +01:00
private static $hide_ancestor = 'BlogEntry';
2015-05-09 16:33:12 +02:00
/**
* @var array
*/
2015-02-08 08:03:55 +01:00
private static $db = array(
2015-05-09 16:33:12 +02:00
'Date' => 'SS_Datetime',
'Author' => 'Text',
'Tags' => 'Text',
2015-02-08 08:03:55 +01:00
);
/**
2015-05-09 16:33:12 +02:00
* {@inheritdoc}
2015-02-08 08:03:55 +01:00
*/
public function canCreate($member = null) {
return false;
}
2015-05-09 16:33:12 +02:00
/**
* {@inheritdoc}
*/
2015-02-08 08:03:55 +01:00
public function up() {
foreach($this->TagNames() as $tag) {
2015-05-09 16:33:12 +02:00
if($this->Tags()->filter('Title', $tag)->count()) {
continue;
}
2015-02-08 08:03:55 +01:00
$tagObject = new BlogTag();
$tagObject->Title = $tag;
$tagObject->BlogID = $this->ParentID;
2015-05-09 16:33:12 +02:00
2015-02-08 08:03:55 +01:00
$tagObject->write();
2015-05-09 16:33:12 +02:00
2015-02-08 08:03:55 +01:00
$this->Tags()->add($tagObject);
}
$this->PublishDate = $this->Date;
2015-05-09 16:33:12 +02:00
2015-02-08 08:03:55 +01:00
if($this->ClassName === 'BlogEntry') {
$this->ClassName = 'BlogPost';
$this->write();
}
}
2015-05-09 16:33:12 +02:00
/**
* 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}
*/
2015-02-08 08:03:55 +01:00
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 {
2015-05-09 16:33:12 +02:00
2015-02-08 08:03:55 +01:00
}