Skip to content
Snippets Groups Projects

WIP: FEATURE: SS4 Upgrade

Open Paul Jayme requested to merge feature/ss4-upgrade into develop
2 unresolved threads
Compare and Show latest version
6 files
+ 89
62
Compare changes
  • Side-by-side
  • Inline
Files
6
<?php
namespace ThunderCats\UserSurveys\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\UserForms\Control\UserDefinedFormController;
class SurveyUserDefinedFormController extends UserDefinedFormController
{
private static $allowed_actions = array(
'index',
'ping',
'Form',
'finished',
);
/**
* Using $SurveyUserDefinedForm in the Content area of the page shows
* where the form should be rendered into. If it does not exist
* then default back to $Form.
*
* @return array
*/
public function index(HTTPRequest $request = null)
{
if ($this->Content && $form = $this->Form()) {
$hasLocation = stristr($this->Content, '$SurveyUserDefinedForm');
if ($hasLocation) {
$content = preg_replace('/(<p[^>]*>)?\\$SurveyUserDefinedForm(<\\/p>)?/i', $form->forTemplate(), $this->Content);
return array(
'Content' => DBField::create_field(DBHTMLText::class, $content),
'Form' => '',
);
}
}
return array(
'Content' => DBField::create_field(DBHTMLText::class, $this->Content),
'Form' => $this->Form(),
);
}
/**
* Get the form for the page. Form can be modified by calling {@link updateForm()}
* on a UserDefinedForm extension.
*
* @return Forms
*/
public function Form()
{
return null;
}
}