This file contains hidden or 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
<?php | |
/** | |
* Extend this class to create a customised one record editor | |
* for your model - within the framework of the | |
* Silverstripe CMS. | |
* | |
* In the model class you identify the preferred CMS Editor Class. | |
* | |
* In the class below, you can set up custom CMS fields, actions (buttons) |
This file contains hidden or 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
<?php | |
class Foo extends Bar { | |
function removePagesThatAreMoreThanOneYearOld(){ | |
set_time_limit(600); | |
$dataClasses = array("SiteTree"); | |
$allClasses = ClassInfo::subclassesFor("SiteTree"); | |
foreach($allClasses as $class) { | |
$dataClasses += ClassInfo::dataClassesFor($class); |
This file contains hidden or 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
/** | |
* usage: | |
* PHP: | |
* Requirements::javascript("mymodules/javascript/MyJSFx.js"); | |
* Requirements::customScript(" | |
* var MyObject = new MyJSFx('MyForm') | |
* .setVar('mySelector', '.foo') | |
* .setVar('myMethod', function(){return "custom foo"};) | |
* .init();", | |
* "MyObjectCustomScript" |
This file contains hidden or 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
<?php | |
$ip = false; | |
if(!Session::get("MyIPAddress") || isset($_GET["ipfortestingonly"])) { | |
if(isset($_GET["ipfortestingonly"])) { | |
$ip = $_GET["ipfortestingonly"]; | |
} | |
elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} |
This file contains hidden or 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
<?php | |
class Foo { | |
/** | |
* Redirect users if found on incorrect domain | |
* Detects if $_GET['session'] is present, sets session | |
* and redirects back to "clean URL" | |
* Both _SECURE_URL and _STANDARD_URL must be defined, | |
* and include protocol (http(s)://mydomain.com) with no trailing slash | |
* @return null |
This file contains hidden or 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
<?php | |
function getIsValid() { | |
//we go through all the options that would make it invalid... | |
if(! $this->NumberOfTimesCouponCanBeUsed) { | |
return false; | |
} | |
if($this->getUseCount() > $this->NumberOfTimesCouponCanBeUsed) { | |
return false; | |
} | |
$now = strtotime("now"); |
This file contains hidden or 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
/** | |
* Resizes page header font-size for the text to fit. | |
* basically we add a hidden span into the header, | |
* put the text into it and then keep reducing the super large font-size | |
* for as long as the height of the span exceeds the super | |
* tall line-height set for the test (indicating there is more than one line needed | |
* to show the text). | |
*/ | |
setPageHeaderFontSize: function() { |
This file contains hidden or 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
<?php | |
class MyFancyPage extends Page { | |
private static $singular_name = "My Fancy Page"; | |
function i18n_singular_name() { return self::$singular_name;} | |
private static $plural_name = "My Fancy Pages"; | |
function i18n_plural_name() { return self::$plural_name;} | |
} |
This file contains hidden or 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
<?php | |
class ReplacementData { | |
//... | |
private function getData($to) { | |
//... | |
$array = array(); |
This file contains hidden or 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
<?php | |
class MyObject extends DataObject { | |
/** | |
* finds or creates a MyObject based the value for MyObject.SomethingElse | |
* | |
* @param string $code | |
* @return MyObject | |
*/ |
OlderNewer