Skip to content

Instantly share code, notes, and snippets.

View nyeholt's full-sized avatar

Marcus nyeholt

  • Symbiote
  • Melbourne
View GitHub Profile
diff --git a/src/ResultList.php b/src/ResultList.php
index f941340..aefd6d0 100644
--- a/src/ResultList.php
+++ b/src/ResultList.php
@@ -55,7 +55,7 @@ class ResultList extends ViewableData implements SS_List, Limitable
//If we are in live reading mode, only return published documents
if (Versioned::get_stage() == Versioned::LIVE) {
- $publishedFilter = new Query\BoolQuery();
+ $publishedFilter = $query->hasParam('post_filter') ? $query->getParam('post_filter') : new Query\BoolQuery();
@nyeholt
nyeholt / build-config.php
Created February 18, 2020 01:58
Builds satis config from a composer.lock file
<?php
$lockfile = json_decode(file_get_contents(__DIR__ . '/../composer.lock'), true);
$satis = [
'name' => 'my/project-dependencies',
'homepage' => 'http://apache/satis/web',
'repositories' => [
[
"type" => "composer",
diff --git vendor/heyday/silverstripe-elastica/src/ResultList.php vendor/heyday/silverstripe-elastica/src/ResultList.php
index a178198..13b9f65 100644
--- vendor/heyday/silverstripe-elastica/src/ResultList.php
+++ vendor/heyday/silverstripe-elastica/src/ResultList.php
@@ -41,11 +41,19 @@ class ResultList extends ViewableData implements SS_List
'_type'
));
+ $query->setSource([
+ 'ID',
<?php
class Page extends SiteTree implements NotifiedOn {
private static $db = array(
);
private static $has_one = array(
);
@nyeholt
nyeholt / .gitconfig
Created January 7, 2016 22:23
Git aliases
[alias]
update-from = "!f() { git fetch $1 --prune; git merge --ff-only $1/$2 || git rebase --preserve-merges $1/$2; }; f"
ff = merge --ff-only
nf = merge --no-ff
<?php
if (defined('YML_PROXY_CONFIG_FILE')) {
$ymlFile = YML_PROXY_CONFIG_FILE;
if ($ymlFile{0} != '/') {
$ymlFile = BASE_PATH . '/' . $ymlFile;
}
$publisherName = defined('PROXY_PUBLISHER') ? PROXY_PUBLISHER : null;
$dynamicName = defined('PROXY_DYNAMIC_PUBLISHER') ? PROXY_DYNAMIC_PUBLISHER : null;
$array = Yaml::parse(file_get_contents($ymlFile));
@nyeholt
nyeholt / Gruntfile.js
Created December 9, 2015 23:31
Grunt config
module.exports = function(grunt) {
// COMMANDS
// comple css and js - $ grunt
// optim - run $ grunt imgoptim
// FILE STRUCTURE
// css/app.css, css/app.min.css
@nyeholt
nyeholt / site-data-service.php
Last active December 9, 2015 02:56
Fake Plastic Trees
<?php
/**
* Capture / cache some commonly used data elements for each page
*
* @author marcus
*/
class SiteDataService {
protected $items = array();
<?php
public function fakeplastictrees() {
$fields = array(
'ID', 'Title', 'MenuTitle', 'URLSegment', 'ParentID', 'CanViewType'
);
$query = new SQLQuery($fields, 'SiteTree');
$query = $query->setOrderBy('ParentID', 'ASC');
$query->addWhere('"CanViewType" NOT IN (\'LoggedInUsers\', \'OnlyTheseUsers\')');
<?php
/**
* @author Marcus Nyeholt <marcus@silverstripe.com.au>
*/
class FacebookService {
static $api_urls = array(
'object' => 'https://graph.facebook.com/%s',
'auth' => 'https://graph.facebook.com/oauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials',