Skip to content

Instantly share code, notes, and snippets.

@lerni
lerni / patch.diff
Created October 4, 2021 11:31
silverstripe-framework-pull-9920
diff --git a/src/Control/Cookie.php b/src/Control/Cookie.php
index 9c48b4ced..ce6e4b5fd 100644
--- a/src/Control/Cookie.php
+++ b/src/Control/Cookie.php
@@ -5,6 +5,11 @@ namespace SilverStripe\Control;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injector;
+use function in_array;
+use function strtolower;
<?php
class RequirementsEnhancement extends Requirements {
public static function ldJsonScript($script, $uniquenessID = null) {
self::backend()->ldJsonScript($script, $uniquenessID);
}
}
class Requirements_BackendEnhancement extends Requirements_Backend {
diff --git a/view/Requirements.php b/view/Requirements.php
index a39d0e998..d7004b9a8 100644
--- a/view/Requirements.php
+++ b/view/Requirements.php
@@ -419,6 +419,13 @@ class Requirements implements Flushable {
return self::backend()->debug();
}
+ /**
+ * Output ld+json
diff --git a/model/connect/MySQLDatabase.php b/model/connect/MySQLDatabase.php
index f0628e4..db011c4 100644
--- a/model/connect/MySQLDatabase.php
+++ b/model/connect/MySQLDatabase.php
@@ -42,7 +42,7 @@ class MySQLDatabase extends SS_Database {
$this->connector->connect($parameters);
// This is important!
- $this->setSQLMode('ANSI');
+ $this->setSQLMode('REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE');
@lerni
lerni / gist:1a97635a97ca12a4ee78c10a95218382
Created July 12, 2018 08:02
Focuspoint in tandem with "object-fit" & "object-position"
<!-- FocusPoint can also be used in tandem with css-settings "object-fit" & "object-position". For example useful for a fullscreen-hero, when you don't know how the aspect-ratio of the viewport might look. The example below shows a portrait-, landscape, or 4:3 "square" image depending on the aspect-ratio it is shown. Even if the general rule is not to relay, which picture the browser might pick from the picture-element, it seems to work pretty well. Or in other words: pseudo media-queries in picture-element und css-media query match in praxis pretty well. -->
<picture>
<%-- 8:5 is like macbook pro display--%>
<source media="(min-width: 640px) and (min-aspect-ratio: 8/5)"
srcset="$SlideImage.FocusFillMax(640,400).URL 640w">
<%-- 5:8 is portrait --%>
<source media="(min-width: 400px) and (max-aspect-ratio: 5/8)"
srcset="$SlideImage.FocusFillMax(400,640).URL 720w">
<%-- 4:3 say desktop --%>
<source media="(min-width: 640px) and (min-aspect-ratio: 4/3)"
@lerni
lerni / UniqueTextField
Last active February 22, 2018 12:14
UniqueTextField SilverStripe
<?php
class UniqueTextField extends TextField {
public function Type() {
return 'unique text';
}
protected $restrictedTable;
protected $restrictedField;
diff --git a/core/TempPath.php b/core/TempPath.php
index 88979ba..4f3a94c 100644
--- a/core/TempPath.php
+++ b/core/TempPath.php
@@ -11,8 +11,9 @@
function getTempFolder($base = null) {
$parent = getTempParentFolder($base);
- // The actual temp folder is a subfolder of getTempParentFolder(), named by username
- $subfolder = $parent . DIRECTORY_SEPARATOR . getTempFolderUsername();
// this script loads the YouTube iframe-api, gets all instances and adds enablejsapi & origin-URL to the src-URL
// after initiating the API it adds playing-mode & paused-mode to the iframes
if ($('[src^="https://www.youtube.com/"]').length) {
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
@lerni
lerni / FixedImagickBackend.php
Created June 14, 2017 15:25
SilverStripe Imagick high quality and low file size
<?php
// smart defaults for high quality and low file size
// https://github.com/nwtn/php-respimg/blob/master/src/Respimg.php#L235
// ---
// Only:
// classexists: 'Imagick'
// ---
// Image:
// backend: 'FixedImagickBackend'
// ImagickBackend:
@lerni
lerni / .gitignore
Last active January 22, 2020 22:21
deploy SilverStripe with PHP-Deployer per git-repo
# ignore everything...
/*
# ...but
# htaccess is ignored since we have a different versions for each stage see in /deploy
!/.gitignore
!/composer.json
!/composer.lock
!/.editorconfig
!/README.md