Skip to content

Instantly share code, notes, and snippets.

<?php
if ($data['Tel'] !== $data['ConfirmTel']) {
Session::set("FormInfo.{$form->FormName()}.data", $form->getData());
$form->addErrorMessage('Tel', 'Telephone numbers do not match', 'message required');
return $this->redirectBack();
}
<?php
public function index() {
// If they've not seen the intro, show that and set the cookie...
if ( ! Cookie::get('ShownIntro')) {
Cookie::set('ShownIntro', true);
return $this->renderWith(array('IntroPage', 'Page'));
}
// ... otherwise proceed as normal
<ul><!--
--><% loop Menu(1) %><!--
--><li class="$LinkingMode"><!--
--><a href="$Link">$MenuTitle.XML</a><!--
--></li><!--
--><% end_loop %><!--
--></ul>
<?php
class GridFieldDetailFormExtension extends Extension {
/**
* @var array
*/
private static $allowed_actions = array(
'doLock'
);
@kinglozzer
kinglozzer / full.js
Last active August 29, 2015 14:02
JavaScript 3d transform CSS feature detection
// Adds the class 'csstransforms3d' if the browser supports 3d transforms
// Stripped down version of Modernizr's detection: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/css/transforms3d.js
// Assumes the script is always being run in the <head> - will create a body element. Should work outside the head, but is untested
(function(document) {
var docElem = document.documentElement,
div = document.createElement('div'),
body = document.createElement('body');
ret = false,
properties = 'p# p#Property WebkitP# MozP# OP# msP#'.replace(/[#]/g, 'erspective').split(' ');
<?php
if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) {
throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found');
}
class SilverStripe_Sniffs_ControlStructures_ControlSignatureSniff implements PHP_CodeSniffer_Sniff
{
<snippet>
<content><![CDATA[
<?php
class ${TM_FILENAME/(\.php)$/$'/} extends DataObject {
private static \$db = array(
$1
);
<?php
class ParkListing extends Location {
/**
* @param GeocodedLocation $location
* @return DataList
*/
public static function get_by_geo(GeocodedLocation $location) {
$query = new SQLQuery();
<% cached List(FeatureBox).Max(LastEdited) %>
...
<% end_cached %>
SHOW TABLES LIKE 'FeatureBox' 0.0005ms
SHOW FULL FIELDS IN "FeatureBox" 0.0021ms
SELECT DISTINCT "ClassName" FROM "FeatureBox" 0.0002ms
SELECT DISTINCT MAX("LastEdited") FROM "FeatureBox" 0.0002ms
------------------------------------------------------------------------------------------------------
@kinglozzer
kinglozzer / ColumnedList.php
Created July 24, 2014 09:30
Stacking data in X columns
<?php
class ColumnedList extends SS_ListDecorator {
/**
* @param int $columns
* @return array
*/
public function stack($columns) {
$total = $this->list->count();