Skip to content

Instantly share code, notes, and snippets.

<?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();
@kinglozzer
kinglozzer / GroupExtension.php
Last active August 29, 2015 14:05
Editing CSV export fields for a specific group
<?php
class GroupExtension extends Extension {
public function updateCMSFields($fields) {
$gridField = $fields->dataFieldByName('Members');
$exportButton = $gridField->getConfig()->getComponentByType('GridFieldExportButton');
$exportButton->setExportColumns(array(
'FirstName' => 'First name',
'Surname' => 'Last name',
---
Name: rootroutes
---
Director:
rules:
'': 'ArticleController'
'$Identifier': 'ArticleController'
@kinglozzer
kinglozzer / gist:bd3d36302d69d8756734
Created September 29, 2014 11:20
ReflectionClass vs new Class
<?php
// https://gist.github.com/mindplay-dk/3359812
define('NUM_TESTS', 10);
header('Content-type: text/plain');
class Foo
{