You are here

panopoly_news_demo.install in Panopoly News 7

File

panopoly_news_demo/panopoly_news_demo.install
View source
<?php

/**
 * @file
 * panopoly_news_demo.install
 */

/**
 * Implements hook_enable().
 */
function panopoly_news_demo_enable() {
  _panopoly_core_import_demo_content(array(
    'PanopolyNewsDemoTerm',
    'PanopolyNewsDemoNode',
  ));
}

/**
 * Implements hook_disable().
 */
function panopoly_news_demo_disable() {
  _panopoly_core_rollback_demo_content(array(
    'PanopolyNewsDemoNode',
    'PanopolyNewsDemoTerm',
  ));
}

/**
 * Update demo content for Panopoly News.
 */
function panopoly_news_demo_update_7001(&$sandbox) {

  // Delete old demo content which was supplied by the defaultcontent module.
  // Take care not to delete any edited nodes (we assume that it the title
  // wasnt changed, that the node is safe to delete).
  $nodes = array(
    'panopoly-news-demo-0' => 'When do the Games Start?',
    'panopoly-news-demo-1' => 'A Wonderful Fountain',
    'panopoly-news-demo-2' => 'Enjoy the Roman Countryside',
    'panopoly-news-demo-3' => 'The Majestic Arch',
    'panopoly-news-demo-4' => 'The All Important Wreath',
    'panopoly-news-demo-5' => 'A Roman Bench',
  );
  foreach ($nodes as $machine_name => $title) {
    if ($nid = defaultcontent_get_default($machine_name)) {
      $node = node_load($nid, NULL, TRUE);
      if ($node->title == $title) {
        node_delete($nid);
        defaultcontent_set_default($machine_name, FALSE);
      }
    }
  }

  // Import updated demo content
  if (module_exists('panopoly_news')) {
    module_enable(array(
      'migrate',
    ));
    _panopoly_core_import_demo_content(array(
      'PanopolyNewsDemoTerm',
      'PanopolyNewsDemoNode',
    ));
  }
}

Functions

Namesort descending Description
panopoly_news_demo_disable Implements hook_disable().
panopoly_news_demo_enable Implements hook_enable().
panopoly_news_demo_update_7001 Update demo content for Panopoly News.