Skip to content

Instantly share code, notes, and snippets.

View bueckl's full-sized avatar

Jochen Gülden bueckl

View GitHub Profile
<!doctype html>
<html>
<head>
<!-- Run in full-screen mode. -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Make the status bar black with white text. -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<%-- Page.ss --%>
<div class="language-chooser">
<% include LanguageChooser %>
</div>
<div id="language-switch">
@bueckl
bueckl / LanguageChooser.less
Created September 15, 2014 15:48
LanguageChooser.less
.language-chooser {
// .box-shadow(-2px 2px 2px rgba(0,0,0,.1));
position: absolute;
right: 30px;
top: 6px;
z-index: 99050;
// background: white;
font-size: 13px;
@bueckl
bueckl / FadeInOutOnScrollDown
Last active November 28, 2015 19:05
Fadeout on Scroll
$(window).on('scroll', function() {
var header = $("header");
var scrollBottom = $(document).height() - $(this).scrollTop() - $(this).height();
if ($(this).scrollTop() > 350 && scrollBottom > 450 ) {
if (!header.data('faded')) header.data('faded', 1).stop(true).fadeTo(400, 0);
} else if (header.data('faded')) {
header.data('faded', 0).stop(true).fadeTo(400, 1);
}
});
@bueckl
bueckl / DateNice
Last active August 29, 2015 14:18
Format Date in CMS #SilverStripe
public function getNiceCreated() {
return $this->obj('Created')->FormatI18N('%d.%m.%Y');
}
public function getNiceEventDate() {
$Event = $this->Invoice()->Event();
return $Event->dbObject('EndDate')->FormatI18N('%d.%m.%Y');
}
Or in Template!
@bueckl
bueckl / Currency
Created April 10, 2015 08:32
Currency EUR quick and dirt #SS3
<?php
class CurrencyEuro extends Currency {
protected static $currencySymbol = '€';
public function Nice() {
$val = number_format(abs($this->value), 2, ',', '.') . '&nbsp;' . self::$currencySymbol;
if($this->value < 0) return "($val)";
else return $val;
@bueckl
bueckl / gist:5fe6e23be7ba48285a48
Last active August 29, 2015 14:20
Download Files in Folder as ZIP #SS3 #SilverStripe
/**
* @return SS_HTTPRequest
*/
public function assetbackup() {
$name = $this->Title . '.zip';
$tmpName = TEMP_FOLDER . '/' . $name;
$zip = new ZipArchive();
if(!$zip->open($tmpName, ZipArchive::OVERWRITE)) {
user_error('Client Export Extension: Unable to read/write temporary zip archive', E_USER_ERROR);
return;
@bueckl
bueckl / TabOrder
Created May 20, 2015 08:57
Silverstripe SS3 moving arounf Tabs / TabOrder
public function getCMSFields() {
$fields = parent::getCMSFields();
$TabSet = $fields->findOrMakeTab('Root');
$Main = $TabSet->fieldByName('Main');
$TabSet->removeByName('Main');
………………
@bueckl
bueckl / isEmptyObject
Created May 25, 2015 18:48
Silverstripe SS3 isEmptyObject
function isEmptyObject($o) {
if ( $o->toMap()['ID'] > 0) {
return false;
} else {
return true;
}
}
@bueckl
bueckl / gist:5b6e5a3d8c9cfdd2ac9f
Created May 27, 2015 18:40
SS3, Silverstripe, GridField config Field #Casting #Formating
$gridField->getConfig()->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
'Created' => 'Erstellt',
'Code' => 'Code',
'Value' => 'Wert',
'Origin' => 'Gutscheinart',
'Invoice.Buyer.FirstName' => 'Vorname',
'Invoice.Buyer.Surname' => 'Nachname',
'inUse' => 'Benutzt'
));