1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace rias\contactformextensions\controllers; |
4
|
|
|
|
5
|
|
|
use Craft; |
6
|
|
|
use craft\web\Controller; |
7
|
|
|
use rias\contactformextensions\ContactFormExtensions; |
8
|
|
|
use rias\contactformextensions\elements\ContactFormSubmission; |
9
|
|
|
use rias\contactformextensions\elements\db\ContactFormSubmissionQuery; |
10
|
|
|
use rias\contactformextensions\models\Settings; |
11
|
|
|
|
12
|
|
|
class SubmissionsController extends Controller |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param string|null $submissionId |
16
|
|
|
* @param string|null $siteHandle |
17
|
|
|
* @property Settings $settings |
18
|
|
|
* |
19
|
|
|
* @return \yii\web\Response |
20
|
|
|
*/ |
21
|
|
|
public function actionShowSubmission(string $submissionId = null, string $siteHandle = null) |
22
|
|
|
{ |
23
|
|
|
$query = new ContactFormSubmissionQuery(ContactFormSubmission::class); |
24
|
|
|
$query->id = $submissionId; |
25
|
|
|
|
26
|
|
|
/* @var ContactFormSubmission $submission */ |
27
|
|
|
$submission = $query->one(); |
28
|
|
|
|
29
|
|
|
$volume = Craft::$app->getVolumes()->getVolumeByHandle(ContactFormExtensions::$plugin->settings->attachmentVolumeHandle); |
30
|
|
|
$messageObject = ContactFormExtensions::$plugin->contactFormExtensionsService->utf8AllTheThings((array) json_decode($submission->message)); |
31
|
|
|
$attachments = explode(", ", $submission->attachments); |
32
|
|
|
$variables = [ |
33
|
|
|
'submission' => $submission, |
34
|
|
|
'siteHandle' => $siteHandle, |
35
|
|
|
'messageObject' => $messageObject, |
36
|
|
|
'attachments' => $attachments, |
37
|
|
|
'volumeRoot' => $this->sanitizeUrl($volume->getRootPath()) |
|
|
|
|
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
return $this->renderTemplate('contact-form-extensions/submissions/_show', $variables); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
public function sanitizeUrl($url){ |
45
|
|
|
$url = str_replace(Craft::getAlias('@webroot'), '',$url); |
46
|
|
|
$url = str_replace(Craft::getAlias('@root'), '',$url); |
47
|
|
|
$url = str_replace(Craft::getAlias('@web'), '',$url); |
48
|
|
|
return $url; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.