Skip to content

Instantly share code, notes, and snippets.

@dhaley
Created February 4, 2013 17:56
Show Gist options
  • Save dhaley/4708327 to your computer and use it in GitHub Desktop.
Save dhaley/4708327 to your computer and use it in GitHub Desktop.
drupal source file
<?php
/**
* @file
* A drupal cli execution script.
*
* Run drupal API hooks from the command line.
* This is useful before putting functionality in a site install.
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
define('DRUPAL_ROOT', getcwd());
// Necessary if running from command line!
$_SERVER['REMOTE_ADDR'] = "localhost";
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
require_once "includes/install.inc";
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
print "foo man chew\n";
Vcr_Content_Create_Bean_Block_install();
/**
* Verifies the syntax of the given e-mail address.
*
* Empty e-mail addresses are allowed. See RFC 2822 for details.
*
* @return bool
* TRUE if the address is in a valid format, and FALSE if it isn't.
*/
function Vcr_Content_Create_Bean_Block_install() {
$text_bean_content = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
$ocg_button_contact_us = vcr_content_create_bean_block('OCG Contact Us Button', 'ocg_button_contact_us', "<a href='/vcr/contact'><span class='button_header'>Contact Us</span>$text_bean_content</a>");
// if (!_vcr_create_bean_ref('Proposal Preparation & Submission', $ocg_button_contact_us)) {
// die("Could not create VCR-54");
// }
// look up page entity
// 'body', 'field_call_action', 'field_footer', 'field_header', 'field_inner_content', 'field_override_right_sidebar', 'field_right_sidebar',
$ocg_button_contact_us = vcr_content_create_bean_block('OCG Contact Us Button 2', 'ocg_button_contact_us2', "<a href='/vcr/contact'><span class='button_header'>Contact Us</span>$text_bean_content</a>");
$bean_id = $ocg_button_contact_us->bid;
$page_title = 'OCG (Sponsored Research)';
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->propertyCondition('type', 'page')
->propertyCondition('title', "$page_title")
->execute();
if (!empty($entities['node'])) {
$node = node_load(array_shift(array_keys($entities['node'])));
}
$node->field_inner_content['und'][0]['target_id'] = $bean_id;
node_save($node);
}
/**
* Verifies the syntax of the given e-mail address.
*
* Empty e-mail addresses are allowed. See RFC 2822 for details.
*
* @param string $title
* A string containing an email address.
*
* @return bool
* TRUE if the address is in a valid format, and FALSE if it isn't.
*/
function Vcr_Content_Create_Bean_block($title, $delta, $default_content) {
$vcr_bean = bean_create(array('type' => 'block'));
$vcr_bean->label = $title;
$vcr_bean->title = $title;
$vcr_bean->delta = $delta;
$vcr_bean->field_block_text[LANGUAGE_NONE][0]['value'] = $default_content;
$vcr_bean->field_block_text[LANGUAGE_NONE][0]['format'] = 'wysiwyg';
$vcr_bean->save();
return $vcr_bean;
}
print "finished maynard\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment