Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #133 from Dolphiq/feature/Fix-elements-not-having-…
Browse files Browse the repository at this point in the history
…an-edit-link-on-list-view

Feature/fix elements not having an edit link on list view
  • Loading branch information
johanzandstra authored Jan 25, 2023
2 parents ceadd4c + 8d9847b commit d59f2c5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Redirect Changelog

## 2.0.1 - 2023-01-25
### Fixed
- Fix elements not having an edit link on list view
### Changed
- Set redirects template to extend new craft 4 "_layouts/elementindex" layout
- Allow for query parameters to be passed through to successful redirects
- Special thanks to JoshC96

## 2.0.0 - 2022-06-24
### Changed
- Make compatible with Craft 4.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dolphiq/redirect",
"description": "Craft redirect plugin provides an easy way to enter and maintain 301 and 302 redirects and 404 error pages.",
"type": "craft-plugin",
"version": "2.0.0",
"version": "2.0.1",
"keywords": [
"craft",
"cms",
Expand Down
7 changes: 2 additions & 5 deletions src/controllers/RedirectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
namespace dolphiq\redirect\controllers;

use Craft;
use craft\web\Controller;
use craft\helpers\UrlHelper;

use craft\web\Controller;
use dolphiq\redirect\events\RedirectEvent;
use dolphiq\redirect\helpers\UrlRule;
use dolphiq\redirect\RedirectPlugin;

use \dolphiq\redirect\helpers\UrlRule;
use \dolphiq\redirect\records\CatchAllUrl as CatchAllUrlRecord;
use yii\web\NotFoundHttpException;

class RedirectController extends Controller
Expand Down
10 changes: 6 additions & 4 deletions src/elements/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@

use Craft;
use craft\base\Element;
use dolphiq\redirect\elements\db\RedirectQuery;
use craft\elements\db\ElementQueryInterface;
use craft\elements\actions\Edit;
use dolphiq\redirect\elements\actions\DeleteRedirects;
use craft\elements\db\ElementQueryInterface;
use craft\helpers\Html;
use craft\helpers\UrlHelper;
use craft\validators\DateTimeValidator;
use dolphiq\redirect\elements\actions\DeleteRedirects;
use dolphiq\redirect\elements\db\RedirectQuery;
use dolphiq\redirect\records\Redirect as RedirectRecord;
use Throwable;
use craft\elements\User;

class Redirect extends Element
{
Expand Down Expand Up @@ -393,7 +395,7 @@ public function __toString(): string
{
try {
return $this->getName();
} catch (\Throwable $e) {
} catch (Throwable $e) {
ErrorHandler::convertExceptionToError($e);
}
}
Expand Down
13 changes: 2 additions & 11 deletions src/elements/db/RedirectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

use Craft;
use craft\db\QueryAbortedException;
use dolphiq\redirect\elements\Redirect;
use craft\elements\db\ElementQuery;
use craft\helpers\Db;
use yii\db\Connection;
use DateTime;

class RedirectQuery extends ElementQuery
{
Expand Down Expand Up @@ -117,9 +116,6 @@ protected function beforePrepare(): bool
Craft::info('dolphiq/redirect beforePrepare', __METHOD__);
$this->joinElementTable('dolphiq_redirects');


// $this->joinElementTable('elements_sites');

$this->query->select([
'elements_sites.siteId',
'dolphiq_redirects.sourceUrl',
Expand All @@ -129,8 +125,6 @@ protected function beforePrepare(): bool
'dolphiq_redirects.statusCode',
]);

// $this->subQuery->andWhere(Db::parseParam('status', null));

if ($this->sourceUrl) {
$this->subQuery->andWhere(Db::parseParam('dolphiq_redirects.sourceUrl', $this->sourceUrl));
}
Expand All @@ -141,16 +135,13 @@ protected function beforePrepare(): bool
$this->subQuery->andWhere(Db::parseParam('dolphiq_redirects.statusCode', $this->statusCode));
}
if ($this->hitAt && $this->hitAt > 0) {
$inactiveDate = new \DateTime();
$inactiveDate = new DateTime();
$inactiveDate->modify("-60 days");

$this->subQuery->andWhere(Db::parseParam('dolphiq_redirects.hitAt', $inactiveDate->format("Y-m-d H:m:s"), '<'));
$this->subQuery->andWhere(Db::parseParam('dolphiq_redirects.hitAt', ':notempty:'));
}

// $this->subQuery->andWhere(Db::parseParam('elements_sites.siteId', null));
// $this->_applyEditableParam();

return parent::beforePrepare();
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/CatchAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace dolphiq\redirect\services;

use Craft;
use yii\base\Component;
use dolphiq\redirect\records\CatchAllUrl as CatchAllUrlRecord;
use yii\base\Component;

/**
* Class Redirects service.
Expand Down
7 changes: 4 additions & 3 deletions src/services/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
namespace dolphiq\redirect\services;

use Craft;
use craft\helpers\Db;
use dolphiq\redirect\elements\Redirect;
use yii\base\Component;
use craft\helpers\Db;
use yii\db\Expression;

/**
* Class Redirects service.
Expand Down Expand Up @@ -103,8 +104,8 @@ public function registerHitById(int $redirectId, $destinationUrl = ''): bool
->update(
'{{%dolphiq_redirects}}',
[
'hitAt' => new \yii\db\Expression('now()'),
'hitCount' => new \yii\db\Expression('{{hitCount}} + 1'),
'hitAt' => new Expression('now()'),
'hitCount' => new Expression('{{hitCount}} + 1'),
],
['id' => $redirectId]
)
Expand Down

0 comments on commit d59f2c5

Please sign in to comment.