Skip to content

Instantly share code, notes, and snippets.

View imcbride's full-sized avatar

Ian McBride imcbride

View GitHub Profile
<?php
/**
* Implements hook_entity_view_mode_alter().
*/
function midd_entity_view_mode_alter(&$view_mode, $context) {
if ($context['entity_type'] == 'node' &&
$context['entity']->nid != arg(1) &&
$context['entity']->type == 'news') {
$view_mode = 'teaser';
<?php
function midd_preprocess_node_news(&$vars) {
if (arg(1) != $vars['nid']) {
$vars['template_files'][] = 'node-newslist';
}
}
<?php
/**
* Prepares variables for node.tpl.php
*
* @see node.tpl.php
*/
function midd_preprocess_node(&$variables) {
$function = __FUNCTION__ . '__' . $variables['node']->type;
if (function_exists($function)) {
{% set timestamp = node.field_event_time.value|date('U') %}
<article{{ attributes }}>
{% if label %}
<header>
<h1>{{ label }}</h1>
<h2>{{ timestamp|format_date('museum_date') }}
</header>
{% endif %}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.DirectoryServices;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
@imcbride
imcbride / middlebury_profile_sync.install.php
Created July 11, 2017 14:42
middlebury_profile_sync install
<?php
/**
* @file
* Contains install, uninstall and update functions for Middlebury Profile Sync.
*/
/**
* Implements hook_install().
*/
<?php
$photo_dir = file_default_scheme() . '://middlebury_profile_sync';
if ($profile->hasPhoto() && file_prepare_directory($photo_dir)) {
$photo = $profile->getPhoto();
$id = $profile->getId();
$destination = $photo_dir . '/' . $id . '.' . pathinfo($photo, PATHINFO_EXTENSION);
$file = system_retrieve_file($photo, $destination, TRUE, FILE_EXISTS_REPLACE);
@imcbride
imcbride / samlauth-logging-debug-accounts.patch
Created April 30, 2018 17:35
Patch for drupal/samlauth to add logging for account issues.
diff --git a/src/SamlService.php b/src/SamlService.php
index b068e3d..a542592 100644
--- a/src/SamlService.php
+++ b/src/SamlService.php
@@ -155,6 +155,9 @@ class SamlService {
throw new RuntimeException('Could not authenticate.');
}
+ // Added by Adam Franco 2017-11-02 to help debug authentication and account issues.
+ $this->logger->debug('SAML attributes: @saml', ['@saml' => json_encode($this->getAttributes())]);
@imcbride
imcbride / video-embed-html5-force-refresh-parameter.patch
Last active June 22, 2020 13:05
Patch for drupal/video_embed_html5
diff --git a/src/Plugin/video_embed_field/Provider/Html5.php b/src/Plugin/video_embed_field/Provider/Html5.php
index a645be6..413f9d8 100644
--- a/src/Plugin/video_embed_field/Provider/Html5.php
+++ b/src/Plugin/video_embed_field/Provider/Html5.php
@@ -94,7 +94,7 @@ class Html5 extends ProviderPluginBase {
/**
* {@inheritdoc}
*/
- public function downloadThumbnail() {
+ public function downloadThumbnail($force_refresh = false) {
diff --git a/src/Typogrify.php b/src/Typogrify.php
index 44855f0..107323d 100644
--- a/src/Typogrify.php
+++ b/src/Typogrify.php
@@ -190,7 +190,7 @@ class Typogrify {
([^<>\s]+ # must be flollowed by non-tag non-space characters
\s* # optional white space!
(<\/(a|em|span|strong|i|b)[^>]*>\s*)* # optional closing inline tags with optional white space after each
- ((<\/(p|h[1-6]|li|dt|dd)>)|$)) # end with a closing p, h1-6, li or the end of the string
+ ((<\/(p|h[1-6])>)|$)) # end with a closing p, h1-6, li or the end of the string