Default site content

Reorganized the auto creation of default site content, using Features only as a convenient wrapper for a configuration script. The UUID / node export / Features integration approach is too buggy to be usable, either creating duplicates of content nodes, displaying cryptic warnings, or being impossible to revert.

This feature generates a default Help page, complete with menu link.

(DBOINCP-3)
This commit is contained in:
Tristan Olive 2013-11-12 13:51:20 -05:00
parent 8012ef82ad
commit 9e35006fb4
7 changed files with 95 additions and 43 deletions

View File

@ -0,0 +1,11 @@
<?php
/**
* Implementation of hook_ctools_plugin_api().
*/
function default_site_content_ctools_plugin_api() {
list($module, $api) = func_get_args();
if ($module == "strongarm" && $api == "strongarm") {
return array("version" => 1);
}
}

View File

@ -0,0 +1,10 @@
name = "Default site content"
description = "Creates basic pages, such as Help and About Us"
core = "6.x"
package = "Features"
version = "6.x-0.1"
project = "default_site_content"
dependencies[] = "boinc_standard"
dependencies[] = "strongarm"
features[ctools][] = "strongarm:strongarm:1"
features[variable][] = "boinc_default_site_content"

View File

@ -0,0 +1,57 @@
<?php
include_once('default_site_content.features.inc');
/**
* Make some changes to configurations after the feature has been enabled
*/
function default_site_content_enable() {
$initialized = variable_get('boinc_default_site_content_init', 0);
if (!$initialized) {
// Construct the Help page
$node = array(
'type' => 'page',
'title' => t('Help'),
'uid' => 1,
'status' => 1, // published
'promote' => 0, // not promoted to front page
'path' => 'help',
'pathauto_perform_alias' => FALSE,
'created' => time(),
'changed' => time(),
'comment' => 0, // disable comments
'moderate' => 0,
'body' => preg_replace('/>\s+</', '><',
'<p>Use this page to provide help and support for your site\'s
visitors:</p>
<ul>
<li>Add a link to your primary forum for getting help</li>
<li>Add a link to a page describing your screensaver</li>
<li>Add links to your social media outlets like Facebook or Twitter</li>
<li>Get help regarding <a href="http://boinc.berkeley.edu/help.php" target="_blank">BOINC in general</a></li>
</ul>'),
'sticky' => 0,
'format' => 4,
//'teaser' => $teaser,
);
$node = (object) $node; // node_save requires an object
node_save($node);
$item = array(
'link_path' => drupal_get_normal_path('help'),
'link_title' => t('Help'),
'menu_name' => 'primary-links',
'weight' => 50,
);
menu_link_save($item);
menu_cache_clear_all();
variable_set('boinc_default_site_content_init', 1);
}
}
function default_site_content_disable() {
//menu_link_delete(NULL, drupal_get_normal_path('help'));
//menu_cache_clear_all();
}

View File

@ -0,0 +1,17 @@
<?php
/**
* Implementation of hook_strongarm().
*/
function default_site_content_strongarm() {
$export = array();
$strongarm = new stdClass;
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'boinc_default_site_content';
$strongarm->value = 1;
$export['boinc_default_site_content'] = $strongarm;
return $export;
}

View File

@ -1,33 +0,0 @@
<?php
/**
* Implementation of hook_menu_default_menu_links().
*/
function help_and_support_menu_default_menu_links() {
$menu_links = array();
// Exported menu link: primary-links:http://boinc.berkeley.edu/help.php
$menu_links['primary-links:http://boinc.berkeley.edu/help.php'] = array(
'menu_name' => 'primary-links',
'link_path' => 'http://boinc.berkeley.edu/help.php',
'router_path' => '',
'link_title' => 'Help',
'options' => array(
'attributes' => array(
'title' => '',
),
),
'module' => 'menu',
'hidden' => '0',
'external' => '1',
'has_children' => '0',
'expanded' => '0',
'weight' => '-46',
);
// Translatables
// Included for use with string extractors like potx.
t('Help');
return $menu_links;
}

View File

@ -1,7 +0,0 @@
name = "Help and support"
description = "Menu link to BOINC help"
core = "6.x"
package = "Features"
dependencies[] = "features"
dependencies[] = "menu"
features[menu_links][] = "primary-links:http://boinc.berkeley.edu/help.php"

View File

@ -1,3 +0,0 @@
<?php
// Drupal needs this blank file.