Skip to content

Instantly share code, notes, and snippets.

View johnrobertwilson's full-sized avatar

John Robert Wilson johnrobertwilson

View GitHub Profile
@johnrobertwilson
johnrobertwilson / gist:1838197
Created February 15, 2012 19:05
XML parsing
$file_path = drupal_get_path('module', 'cc_ingestion_engine') . '/xml/cbindicators_revised.xml';
include($file_path . '/cc_ingestion_engine.module');
$content = utf8_encode(file_get_contents($file_path));
$xml = simplexml_load_string($content);
$areas_xml_object = $xml->areas;
$charts_xml_object = $xml->charts;
$chart_types = $xml->chart_types;
$definition_sources_xml_object = $xml->definitionsources;
$indicators_xml_object = $xml->indicators;
$measures_xml_object = $xml->measures;
/**
* Saves a InstagramMedia object to {drupagram}
*/
function drupagram_media_save($media) {
// Cleanse the full_name field of bad chars
if (!empty($media)) {
if (!empty($media->likes)) {
if (!empty($media->likes['data'])){
foreach ($media->likes['data'] as $index => $like_item) {
# new file: config/vcl/energy.vcl
# modified: docroot/sites/all/modules/contrib/bean
# modified: docroot/sites/all/modules/custom/energy_content/energy_content.field_group.inc
# modified: docroot/sites/all/modules/custom/energy_content/energy_content.install
# modified: docroot/sites/all/modules/custom/energy_content/energy_content.module
# modified: docroot/sites/all/modules/custom/energy_content/fields/energy_content.fields.homepage.inc
# modified: docroot/sites/all/modules/custom/energy_content/includes/pages.inc
# modified: docroot/sites/all/modules/custom/energy_content/plugins/bean/latest_downloads_listing.inc
# modified: docroot/sites/all/modules/custom/energy_content/theme/theme.inc
# modified: docroot/sites/all/modules/custom/energy_offices/energy_offices.module
@johnrobertwilson
johnrobertwilson / gist:1499142
Created December 19, 2011 22:11
Commit WTF?
# new file: ../../../config/vcl/energy.vcl
# modified: modules/contrib/bean
# modified: modules/custom/energy_content/energy_content.field_group.inc
# modified: modules/custom/energy_content/energy_content.install
# modified: modules/custom/energy_content/energy_content.module
# modified: modules/custom/energy_content/fields/energy_content.fields.homepage.inc
# modified: modules/custom/energy_content/includes/pages.inc
# modified: modules/custom/energy_content/plugins/bean/latest_downloads_listing.inc
# modified: modules/custom/energy_content/theme/theme.inc
# modified: modules/custom/energy_offices/energy_offices.module
@johnrobertwilson
johnrobertwilson / gist:1452467
Created December 9, 2011 17:23
Display settings
Array
(
[plugin] => energy_highcharts_embed
[data] => Array
(
[highcharts_embed_code] => (function($) { $(document).ready(function() {
console.log('javascript executed');
console.log($('#energy-highcharts-embed-container-327403'));
@johnrobertwilson
johnrobertwilson / gist:1402498
Created November 28, 2011 23:00
state_machine
<?php
/**
* @file
* state_machine.module
*/
/**
* Class file loader for base.inc.
*/
function state_machine_load_class_file() {
if (!class_exists('StateMachine')) {
@johnrobertwilson
johnrobertwilson / gist:1383075
Created November 21, 2011 16:11
Form Alter what?
/**
* Implementation of hook_form_alter
*/
function socialflow_form_alter(&$form, &$form_state, $form_id) {
$socialflow_entities = variable_get('socialflow_entities',array());
//check settings for entity type and bundle
if(array_key_exists('#entity_type', $form) &&
array_key_exists($form['#entity_type'], $socialflow_entities) &&
array_key_exists('#bundle', $form) &&
@johnrobertwilson
johnrobertwilson / gist:1346326
Created November 7, 2011 21:57
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot be null
/**
* Add a "silverpop form bean creators" role for users who can create beans of silverpop_form type.
*/
function energy_content_update_7046(&$sandbox) {
$perms = array();
$new_role = new stdClass();
$new_role->name = 'silverpop form block creators';
$status = user_role_save($new_role);
$perms = array();
@johnrobertwilson
johnrobertwilson / gist:1281668
Created October 12, 2011 16:10
highcharts page???
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>HighCharts - jsFiddle demo</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.5.2.js'></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
@johnrobertwilson
johnrobertwilson / gist:1278603
Created October 11, 2011 16:29
db query example
/**
* socialflow_record_history
*/
function socialflow_record_history($entity_type, $bundle, $entity_id) {
//check to see if the record exists
$check_query = db_query(
'SELECT count(entity_id)
FROM socialflow_history
WHERE entity_type = :entity_type
AND bundle = :bundle