Skip to content

Instantly share code, notes, and snippets.

View wernerkrauss's full-sized avatar

Werner Krauß wernerkrauss

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / gist:f72f1214ce27e3acba2a
Created June 17, 2015 13:58
sass / foundation snippet to get a responsive two column table.
.responsive-twocolumn-table {
width: 100%;
th {
display: none;
}
td {
width: 100%;
display: block;
&:first-child {
font-weight: bold;
@wernerkrauss
wernerkrauss / GalleryPic.php
Created June 4, 2015 14:15
Silverstripe GalleryPic Dataobject with Shortcodable interface
<?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 / GalleryPic.php
Created December 3, 2014 11:58
PageGallery extension
<?php
/**
* Class GalleryPic
* @todo: sync Copyright if Image has a db field for it
*/
class GalleryPic extends DataObject
{
private static $db = array(
'Title' => 'Text',
@wernerkrauss
wernerkrauss / MyDataObject.php
Last active August 29, 2015 14:10
Permission check for a DataObject.
class MyDataObject extends DataObject 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',
* );
*/