Skip to content

Instantly share code, notes, and snippets.

View wernerkrauss's full-sized avatar

Werner Krauß wernerkrauss

View GitHub Profile
@wernerkrauss
wernerkrauss / BreadcrumbsTemplate.ss
Created July 10, 2015 08:45
Expanded breadcrumbs template for Silverstripe 3.1
<% if $Pages %>
<a href="/">Home</a>
<% loop $Pages %>
<% if $AdditionalBreadcrumbsBefore %>
<% loop $AdditionalBreadcrumbsBefore %>
&raquo; <a href="$Link" class="breadcrumb-$Up.Pos-$Pos">$MenuTitle.XML</a>
<% end_loop %>
<% end_if %>
&raquo; <a href="$Link" class="breadcrumb-$Pos">$MenuTitle.XML</a>
<% if $AdditionalBreadcrumbsAfter %>
@wernerkrauss
wernerkrauss / NetwerkstattDataObjectCMSPermissionExtension.php
Created July 15, 2015 19:50
Silverstripe Extension for DataObjects to be editable by other members. You can enable this in Security section
<?php
class NetwerkstattDataObjectCMSPermissionExtension extends DataExtension implements PermissionProvider {
/**
* Return a map of permission codes to add to the dropdown shown in the Security section of the CMS.
* array(
* 'VIEW_SITE' => 'View the site',
* );
*/
@wernerkrauss
wernerkrauss / GalleryPic.php
Created July 20, 2015 13:27
Simple Silverstripe gallery for a page
<?php
/**
* Class GalleryPic
* @todo: sync Copyright if Image has a db field for it
*/
class GalleryPic extends DataObject implements Shortcodable
{
private static $db = array(
'Title' => 'Text',
@wernerkrauss
wernerkrauss / getdate.bat
Last active August 29, 2015 14:27 — forked from thoroc/getdate.bat
Auto MySQL Backup For Windows Servers By Matt Moeller
@ECHO off
SETLOCAL
IF [%1]==[] goto s_start
ECHO GETDATE.cmd
ECHO Returns the date independent of regional settings
ECHO Creates the environment variables %v_year% %v_month% %v_day%
ECHO.
ECHO SYNTAX
ECHO GETDATE
@wernerkrauss
wernerkrauss / TranslatableControllerExtension.php
Last active January 5, 2016 14:42 — forked from Zauberfisch/TranslatableControllerExtension.php
SilverStripe Translatable defaults snippets
<?php
// file: mysite/code/TranslatableControllerExtension.php
class TranslatableControllerExtension extends Extension {
/**
* save the current controller to ensure we have access to it,
* this is necessary because Security crates a fake Page_Controller to render templates
* @var Controller
*/
protected static $actual_current_controller;
@wernerkrauss
wernerkrauss / NetwerkstattStringFieldExtension.php
Created April 18, 2016 11:05
Silverstripe extension to replace some stuff in $Title and other StringFields
<?php
/**
* Created by IntelliJ IDEA.
* User: Werner M. Krauß <[email protected]>
* Date: 01.12.2015
* Time: 15:36
*/
class NetwerkstattStringFieldExtension extends Extension {
@wernerkrauss
wernerkrauss / SilverstripeDataObject.php
Last active May 25, 2016 06:34
Some PHPStorm / Intellij IDEA file templates for SilverStripe development
<?php
#parse("PHP File Header.php")
class ${NAME} extends DataObject {
private static \$db = array();
private static \$has_one = array();
private static \$has_many = array();
@wernerkrauss
wernerkrauss / ss3-php7.patch
Created October 27, 2016 10:51
Silverstripe 3.2 PHP7 Patch
From 6d2a7ac089e1412cf6444fcff575c8780e93a6f9 Mon Sep 17 00:00:00 2001
From: Mark Guinn <[email protected]>
Date: Tue, 15 Mar 2016 09:58:44 +0000
Subject: [PATCH 1/3] Applied 327/migrate
---
core/Diff.php | 21 +-
model/connect/DBSchemaManager.php | 4 +-
model/fieldtypes/Double.php | 2 +-
model/fieldtypes/Float.php | 2 +-
@wernerkrauss
wernerkrauss / _config.php
Created November 30, 2016 13:31
redirect to main domain (e.g. from domain.com.host.com to domain.com)
if (Director::isLive()) {
$hostname = gethostname();
$http_host = $_SERVER['HTTP_HOST'];
if (strpos($http_host, $hostname) !== false) {
//redirect to original domain
$destURL = str_replace('.' . $hostname, '', $http_host);
$response = new SS_HTTPResponse();
@wernerkrauss
wernerkrauss / gist:8ef7b7e576a23458151c6cfffb920129
Created December 6, 2016 10:02
SilverStripe Fluent Problem (Row size too large)
private static $create_table_options = array(
'MySQLDatabase' => 'ENGINE=InnoDB ROW_FORMAT=COMPRESSED'
);