Source of file ABTestingConfigExtension.php
Size: 1,476 Bytes - Last Modified: 2021-12-24T06:50:53+00:00
/var/www/docs.ssmods.com/process/src/code/ABTestingConfigExtension.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php /** * Class ABTestingConfigExtension */ class ABTestingConfigExtension extends DataExtension { public static $db = array( 'ABGlobalTest' => 'Boolean', 'ABTestGlobalScript' => 'Text' ); /** * Update the CMS fields on the extended object * * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { $member = Member::currentUser(); // lock down testing for the administrator only if ($member->Email == Email::getAdminEmail()) { $fields->addFieldToTab( 'Root.ABTesting', new CheckboxField('ABGlobalTest', 'This site currently undergoing AB testing.') ); $fields->addFieldToTab( 'Root.ABTesting', new TextareaField('ABTestGlobalScript', 'Inline Script for AB Testing (from Google content experiments)') ); } } /** * Provide a way to get the required script for AB testing into the template engine * * @return mixed */ public function getABTestGlobalScript() { if ($this->owner->getField('ABGlobalTest') != 0) { if (!is_null($this->owner->getField('ABTestGlobalScript'))) { $html = new HTMLText(); $html->setValue($this->owner->getField('ABTestGlobalScript')); return $html; } } return false; } } |