Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Updating minor class definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Glasl committed Jun 20, 2016
1 parent 6892f18 commit 99740b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [misdirection](https://packagist.org/packages/nglasl/silverstripe-misdirection)

_The current release is **2.2.9**_
_The current release is **2.2.10**_

> A module for SilverStripe which will allow both simple and regular expression link redirections based on customisable mappings, either hooking into a page not found or replacing the default automated URL handling.
Expand Down
51 changes: 40 additions & 11 deletions code/tasks/MisdirectionHistoricalLinkMappingTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ public function run($request) {

protected function getPublishedVersionRecords() {

$query = new SQLSelect('ID, RecordID, ParentID, URLSegment, Version', 'SiteTree_versions', 'WasPublished = 1', 'ID ASC');
$query = new SQLSelect(
'ID, RecordID, ParentID, URLSegment, Version',
'SiteTree_versions',
'WasPublished = 1',
'ID ASC'
);
return $query->execute();
}

Expand Down Expand Up @@ -126,11 +131,13 @@ protected function updateURLs($records) {
protected function addMappingToList($URL, $ID) {

$this->linkMappings[$URL] = $ID;
$query = new SQLUpdate($this->replayTable, array(
'FullURL' => $URL
), array(
'ID' => $ID
));
$query = new SQLUpdate(
$this->replayTable,
array(
'FullURL' => $URL
),
"ID = {$ID}"
);
$query->execute();
}

Expand Down Expand Up @@ -174,7 +181,11 @@ protected function isUpdated($ID, $oldURLSegment, $oldParentID) {

protected function getReplayRecordByID($ID) {

$query = new SQLSelect('*', $this->replayTable, "ID = {$ID}");
$query = new SQLSelect(
'*',
$this->replayTable,
"ID = {$ID}"
);
$records = $query->execute();
return $records->first();
}
Expand All @@ -188,7 +199,11 @@ protected function getReplayRecordByID($ID) {

protected function getChildren($ID) {

$query = new SQLSelect('*', $this->replayTable, 'ParentID = ' . (int)$ID);
$query = new SQLSelect(
'*',
$this->replayTable,
'ParentID = ' . (int)$ID
);
return $query->execute();
}

Expand Down Expand Up @@ -218,7 +233,15 @@ protected function getURLForRecord($record = null, $URL = null) {

// Retrieve the parent element which was most recently published.

$parentQuery = new SQLSelect('ID, ParentID, URLSegment, Version', $this->replayTable, "ID = {$parentID}", null, null, null, 1);
$parentQuery = new SQLSelect(
'ID, ParentID, URLSegment, Version',
$this->replayTable,
"ID = {$parentID}",
null,
null,
null,
1
);
$parent = $parentQuery->execute()->first();
return $this->getURLForRecord($parent, $URL);
}
Expand All @@ -239,7 +262,11 @@ protected function checkAndCreateMappings() {

// Check that the URL is not the current live URL.

$query = new SQLSelect('ID', $this->replayTable, "FullURL = '{$URL}'");
$query = new SQLSelect(
'ID',
$this->replayTable,
"FullURL = '{$URL}'"
);
if($query->count('ID') == 0) {
echo "<div>{$siteTreeID} - {$URL}</div><br>";
if($this->live) {
Expand Down Expand Up @@ -273,7 +300,9 @@ protected function setupStructure() {

// Delete all records from the table.

$query = new SQLDelete(self::$default_table);
$query = new SQLDelete(
self::$default_table
);
$query->execute();
}
}
Expand Down

0 comments on commit 99740b6

Please sign in to comment.