mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Remove migration related files as this commit is for templates
This commit is contained in:
parent
f4e431da27
commit
f6c19793b7
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogEntry extends BlogPost implements MigratableObject {
|
||||
|
||||
private static $hide_ancestor = 'BlogEntry';
|
||||
|
||||
private static $db = array(
|
||||
"Date" => "SS_Datetime",
|
||||
"Author" => "Text",
|
||||
"Tags" => "Text"
|
||||
);
|
||||
|
||||
/**
|
||||
* Safely split and parse all distinct tags assigned to this BlogEntry
|
||||
*
|
||||
* @return array Associative array of lowercase tag to native case tags
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public function canCreate($member = null) {
|
||||
// Deprecated
|
||||
return false;
|
||||
}
|
||||
|
||||
public function up() {
|
||||
// Migrate tags
|
||||
foreach($this->TagNames() as $tag) {
|
||||
// Skip if tag already assigned
|
||||
if($this->Tags()->filter('Title', $tag)->count()) continue;
|
||||
|
||||
// Create tag
|
||||
$tagObject = new BlogTag();
|
||||
$tagObject->Title = $tag;
|
||||
$tagObject->BlogID = $this->ParentID;
|
||||
$tagObject->write();
|
||||
$this->Tags()->add($tagObject);
|
||||
}
|
||||
|
||||
// Update fields
|
||||
$this->PublishDate = $this->Date;
|
||||
if($this->ClassName === 'BlogEntry') {
|
||||
$this->ClassName = 'BlogPost';
|
||||
$this->write();
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogHolder extends BlogTree implements MigratableObject {
|
||||
|
||||
private static $hide_ancestor = 'BlogHolder';
|
||||
|
||||
private static $db = array(
|
||||
'AllowCustomAuthors' => 'Boolean',
|
||||
'ShowFullEntry' => 'Boolean',
|
||||
);
|
||||
|
||||
private static $has_one = array(
|
||||
'Owner' => 'Member',
|
||||
);
|
||||
|
||||
public function canCreate($member = null) {
|
||||
// Deprecated
|
||||
return false;
|
||||
}
|
||||
|
||||
public function up() {
|
||||
if($this->ClassName === 'BlogHolder') {
|
||||
$this->ClassName = 'Blog';
|
||||
$this->write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogHolder_Controller extends BlogTree_Controller {
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogTree extends Blog implements MigratableObject {
|
||||
|
||||
private static $hide_ancestor = 'BlogTree';
|
||||
|
||||
private static $db = array(
|
||||
'Name' => 'Varchar(255)',
|
||||
'LandingPageFreshness' => 'Varchar',
|
||||
);
|
||||
|
||||
public function canCreate($member = null) {
|
||||
// Deprecated
|
||||
return false;
|
||||
}
|
||||
|
||||
public function up() {
|
||||
if($this->ClassName === 'BlogTree') {
|
||||
$this->ClassName = 'Blog';
|
||||
$this->write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogTree_Controller extends Blog_Controller {
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description of BlogMigrationTask
|
||||
*
|
||||
* @author dmooyman
|
||||
*/
|
||||
class BlogMigrationTask extends MigrationTask {
|
||||
|
||||
/**
|
||||
* Should this task be invoked automatically via dev/build?
|
||||
*
|
||||
* @config
|
||||
* @var boolean
|
||||
*/
|
||||
private static $run_during_dev_build = true;
|
||||
|
||||
protected function message($text) {
|
||||
if(Controller::curr() instanceof DatabaseAdmin) {
|
||||
DB::alteration_message($text, 'obsolete');
|
||||
} else {
|
||||
Debug::message($text);
|
||||
}
|
||||
}
|
||||
|
||||
public function up() {
|
||||
$classes = ClassInfo::implementorsOf('MigratableObject');
|
||||
$this->message('Migrating legacy blog records');
|
||||
|
||||
foreach($classes as $class) {
|
||||
// migrate objects in each stage
|
||||
if(is_subclass_of($class, 'SiteTree')) {
|
||||
foreach(array('Stage', 'Live') as $stage) {
|
||||
$oldMode = Versioned::get_reading_mode();
|
||||
Versioned::reading_stage($stage);
|
||||
$this->upClass($class, $stage);
|
||||
Versioned::set_reading_mode($oldMode);
|
||||
}
|
||||
} else {
|
||||
// Migrate object
|
||||
$this->upClass($class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down() {
|
||||
$this->message('BlogMigrationTask::down() not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate records of a single class
|
||||
*
|
||||
* @param type $class
|
||||
* @param type $stage
|
||||
*/
|
||||
protected function upClass($class, $stage = null) {
|
||||
// Migrate all records
|
||||
$items = $class::get();
|
||||
if($count = $items->count()) {
|
||||
$stageMessage = " in stage {$stage}";
|
||||
$this->message("Migrating {$count} legacy {$class} records{$stageMessage}.");
|
||||
foreach($items as $item) $item->up();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
interface MigratableObject {
|
||||
|
||||
/**
|
||||
* Migrate the object up to the current version
|
||||
*/
|
||||
public function up();
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
if(!class_exists('Widget')) return;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class ArchiveWidget extends BlogArchiveWidget implements MigratableObject {
|
||||
|
||||
private static $db = array(
|
||||
'DisplayMode' => 'Varchar'
|
||||
);
|
||||
|
||||
private static $only_available_in = array('none');
|
||||
|
||||
public function canCreate($member = null) {
|
||||
// Deprecated
|
||||
return false;
|
||||
}
|
||||
|
||||
public function up() {
|
||||
if($this->DisplayMode) {
|
||||
$this->Type = ($this->DisplayMode === 'year') ? 'Yearly' : 'Monthly';
|
||||
}
|
||||
$this->ClassName = 'BlogArchiveWidget';
|
||||
$this->write();
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
if(! class_exists('Widget')) return;
|
||||
|
||||
/**
|
||||
* A list of tags associated with blog posts
|
||||
*
|
||||
* @package blog
|
||||
*/
|
||||
class TagCloudWidget extends BlogTagsWidget implements MigratableObject {
|
||||
|
||||
private static $db = array(
|
||||
"Title" => "Varchar",
|
||||
"Limit" => "Int",
|
||||
"Sortby" => "Varchar"
|
||||
);
|
||||
|
||||
private static $only_available_in = array('none');
|
||||
|
||||
public function canCreate($member = null) {
|
||||
// Deprecated
|
||||
return false;
|
||||
}
|
||||
|
||||
public function up() {
|
||||
$this->ClassName = 'BlogTagsWidget';
|
||||
$this->write();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user