-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathws_bb.module
88 lines (76 loc) · 2.49 KB
/
ws_bb.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* @file
* Main module file for the Web Services Blueprint & Build tool.
*/
/**
* Implements hook_menu
*/
function ws_bb_menu() {
$items = array();
$items['ws/blueprintbuild/extract'] = array(
'title' => 'Extract new blueprint',
'page callback' => 'ws_bb_extract_page',
'access arguments' => array(1),
'file' => 'inc/ws_bb.extraction.inc',
);
return $items;
}
function ws_bb_theme($existing, $type, $theme, $path) {
return array(
'ws_bb_extract' => array(
'render element' => 'elements',
'template' => 'ws_bb_extract',
'path' => drupal_get_path('module', 'ws_bb') . "/templates",
),
);
}
/**
* Code for the Blueprint & Build feature.
*/
include_once 'ws_bb.features.inc';
/**
* Processes a blueprint into an XML file
*
*
* @param stdClass $blueprint
* A blueprint object which contains a uri property
*
* @param $base_directory
* The directory of the unarchived blueprint directory
*
* @param $site_name
* The name of the site, taken from the name of the directory that contains all of the
* Blueprint files. This is used as part of the XML file's name
*
* @menu_name
* The name of the menu which all of the pages should be included in.
*
*/
function ws_bb_blueprint_processor(stdClass $blueprint, $base_directory, $site_name, $menu_name) {
module_load_include('inc', 'ws_bb', 'inc/ws_bb.parser');
$blueprint_parser = new Blueprint_Parser();
$blueprint_parser->parse($blueprint);
$blueprint_parser->sitemap_converter($blueprint_parser->entries, $base_directory, $site_name, $menu_name);
ws_bb_blueprint_node_create($blueprint, $blueprint_parser->xml_file, $site_name);
$link = l($site_name, "content/blueprints/$site_name");
drupal_set_message(t('Your site has successfully been built.'));
drupal_set_message(t('A node has been created with a link to the xml file used to create this site. If you need to reimport or delete the created content, you may also use the following link: ' . $link));
}
/**
* Create a new Feed Importer node for the created XML
*
*
*/
function ws_bb_blueprint_node_create(stdClass $blueprint, $xml_path, $site_name) {
$node = new stdClass();
$node->type = 'site_blueprint';
node_object_prepare($node);
$node->title = $site_name;
$node->language = LANGUAGE_NONE;
$node->feeds['FeedsHTTPFetcher']['source'] = file_create_url($xml_path);
$path = 'content/blueprints/' . $site_name;
$node->path = array('alias' => $path);
node_save($node);
return;
}