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:1204124
Created September 8, 2011 18:04
Getting all entities and bundles
foreach (entity_get_info() as $entity_type => $entity_info) {
foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
$labels[$entity_type][$bundle] = !empty($bundle_info['label']) ? $bundle_info['label'] : FALSE;
}
}
/Developer/D7: git clone [email protected]:bdglide/socialflow-drupal-module.git
Cloning into socialflow-drupal-module...
remote: Counting objects: 18, done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 18 (delta 2), reused 18 (delta 2)
Receiving objects: 100% (18/18), done.
Resolving deltas: 100% (2/2), done.
/Developer/D7: ll
total 160
drwxr-xr-x 10 jr admin 340 Sep 12 15:41 .
@johnrobertwilson
johnrobertwilson / gist:1214818
Created September 13, 2011 19:29
Entities by typ
/**
* Form builder for the bundle configuration form.
*
* @see apachesolr_indexer_config_form_submit().
*/
function apachesolr_indexer_config_form() {
$form['bundles'] = array(
'#type' => 'markup',
'#markup' => t('Select the entity types and bundles that should be indexed.'),
);
@johnrobertwilson
johnrobertwilson / gist:1215479
Created September 13, 2011 23:32
Easy Drupal 7 Tables output
$data = array(0 => 'data1', 1 => 'data2', 2 => 'data3');
$data_table = array(
'#theme' => 'table',
'#header' => array(t('data index'), t('data value')),
'#empty' => t('You have no content channels for this account.'),
'#rows' => array(),
);
if(!empty($data)){
foreach($data as $data_item_index => $data_item){
@johnrobertwilson
johnrobertwilson / gist:1218466
Created September 15, 2011 03:39
Bad Cron Hook
/**
* Implements hook_cron().
*/
function apachesolr_indexer_cron() {
$cron_limit = variable_get('apachesolr_cron_limit', 50);
$rows = apachesolr_indexer_get_entities_to_index('apachesolr_search', $cron_limit);
apachesolr_indexer_enqueue($rows);
@johnrobertwilson
johnrobertwilson / gist:1218471
Created September 15, 2011 03:42
get entities to index
/**
* Returns an array of rows from a query based on an indexing namespace.
*/
function apachesolr_indexer_get_entities_to_index($namespace, $limit) {
$rows = array();
if (variable_get('apachesolr_read_only', 0)) {
return $rows;
}
$last_change = variable_get('apachesolr_indexer_last_run', 0);
@johnrobertwilson
johnrobertwilson / gist:1250747
Created September 29, 2011 13:43
settings.php
<?php
// $Id: default.settings.php,v 1.51 2010/10/11 23:49:48 dries Exp $
/**
* @file
* Drupal site-specific configuration file.
*
* IMPORTANT NOTE:
* This file may have been set to read-only by the Drupal installation
* program. If you make changes to this file, be sure to protect it again
@johnrobertwilson
johnrobertwilson / gist:1250751
Created September 29, 2011 13:46
dev settings
<?php
/**
* @file
* Drupal site-specific configuration file.
*/
/**
* Database settings must be pulled from a separate file which will not be
* put into version control.
*/
@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
@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">