social_content_tumblr.install in Social Content 7.2
Install/uninstall code for Social Content: Tumblr.
File
modules/tumblr/social_content_tumblr.installView source
<?php
/**
* @file
* Install/uninstall code for Social Content: Tumblr.
*/
/**
* Create the tumblr text format.
*/
function social_content_tumblr_create_text_format() {
// Exported format: Tumblr.
$format = (object) array(
'format' => 'tumblr',
'name' => 'Tumblr',
'cache' => 1,
'status' => 1,
'weight' => 0,
'filters' => array(
'filter_html' => array(
'weight' => -10,
'status' => 1,
'settings' => array(
'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>',
'filter_html_help' => 1,
'filter_html_nofollow' => 0,
),
),
),
);
filter_format_save($format);
}
/**
* Create the tumblr text format.
*/
function social_content_tumblr_install() {
if (variable_get('social_content_create_text_formats', TRUE)) {
social_content_tumblr_create_text_format();
}
$create_bundle = variable_get('social_content_create_bundles', TRUE);
if (!$create_bundle) {
return;
}
$t = get_t();
// Create and save a new content object.
// Machine name of the content type.
$type = 'tumblr';
// Define the node type.
$tumblr_post = array(
'type' => $type,
'name' => $t('Tumblr'),
'base' => 'node_content',
'title_label' => $t('Title'),
'description' => $t('A post imported from Tumblr.'),
'custom' => TRUE,
);
// Set other node defaults not declared above.
$content_type = node_type_set_defaults($tumblr_post);
// Add the body field.
node_add_body_field($content_type, $t('Body'));
// Save the content type.
node_type_save($content_type);
// Update persistent variables with settings.
// Add persistent variables that control settings.
variable_set('additional_settings__active_tab_' . $type, 'edit-menu');
// 0 = disabled, 1 = optional, 2 = required.
variable_set('node_preview_' . $type, 0);
// array(0 => 'status', 1 => 'promote', 2 => 'sticky', 3 => 'revision') remove to uncheck.
variable_set('node_options_' . $type, array(
0 => 'status',
));
// 1 = Display author and date information, 0 = none.
variable_set('node_submitted_' . $type, 0);
variable_set('menu_options_' . $type, array());
variable_set('menu_parent_' . $type, 'main-menu:0');
module_load_include('inc', 'social_content_tumblr', 'social_content_tumblr.fields');
$fields = social_content_tumblr_field_default_field_bases();
foreach ($fields as $field_name => $field) {
if (field_info_field($field_name) == NULL) {
field_create_field($field);
}
}
$instances = social_content_tumblr_field_default_field_instances();
foreach ($instances as $instance) {
if (field_info_instance($instance['entity_type'], $instance['field_name'], $type) == NULL) {
$instance['entity_type'] = 'node';
$instance['bundle'] = $tumblr_post['type'];
field_create_instance($instance);
}
}
}
/**
* Create tumblr text format.
*
* Implements hook_update_N().
*/
function social_content_tumblr_update_7000() {
social_content_tumblr_create_text_format();
}
Functions
Name![]() |
Description |
---|---|
social_content_tumblr_create_text_format | Create the tumblr text format. |
social_content_tumblr_install | Create the tumblr text format. |
social_content_tumblr_update_7000 | Create tumblr text format. |