-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add switch for commited/remote js and security section to readme
- Loading branch information
1 parent
6cad3d8
commit b718f05
Showing
5 changed files
with
49 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,47 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* Class WomensRefugeShieldControllerExtension | ||
* | ||
* @property ContentController $owner | ||
*/ | ||
class WomensRefugeShieldControllerExtension extends Extension | ||
{ | ||
/** | ||
* @var bool | ||
* @config | ||
*/ | ||
private static $use_remote_js = false; | ||
|
||
private $jsDir = SS_WOMENS_REFUGE_DIR . DIRECTORY_SEPARATOR . 'javascript' . DIRECTORY_SEPARATOR; | ||
|
||
public function onAfterInit() | ||
{ | ||
$config = SiteConfig::current_site_config(); | ||
$jsDir = SS_WOMENS_REFUGE_DIR . DIRECTORY_SEPARATOR . 'javascript' . DIRECTORY_SEPARATOR; | ||
switch ($config->ShieldCode) { | ||
case 1: | ||
Requirements::javascript('https://d3f5l8ze0o4j2m.cloudfront.net/m87/k33spt.js'); | ||
Requirements::javascript($jsDir.'large_tab.js'); | ||
$this->requireCoreJS(); | ||
Requirements::javascript($this->jsDir . 'large_tab.js'); | ||
break; | ||
case 2: | ||
Requirements::javascript('https://d3f5l8ze0o4j2m.cloudfront.net/m87/k33spt.js'); | ||
Requirements::javascript($jsDir.'small_tab.js'); | ||
$this->requireCoreJS(); | ||
Requirements::javascript($this->jsDir . 'small_tab.js'); | ||
break; | ||
} | ||
} | ||
|
||
public function getWomensRefugeShieldButton() | ||
{ | ||
$this->requireCoreJS(); | ||
return $this->owner->renderWith('WomensRefugeShieldButton'); | ||
} | ||
|
||
protected function requireCoreJS() | ||
{ | ||
if (Config::inst()->get(self::class, 'use_remote_js')) { | ||
Requirements::javascript('https://d3f5l8ze0o4j2m.cloudfront.net/m87/k33spt.js'); | ||
} else { | ||
Requirements::javascript($this->jsDir . 'k33spt.min.js'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters