diff --git a/modules/simplytest_import/simplytest_import.module b/modules/simplytest_import/simplytest_import.module
index a4621bb..6548532 100644
--- a/modules/simplytest_import/simplytest_import.module
+++ b/modules/simplytest_import/simplytest_import.module
@@ -37,12 +37,11 @@ function simplytest_import_form($form) {
'#options' => array(
'path' => t('Path to file'),
'upload' => t('Upload'),
+ 'download' => t('Automatic download (expirimental)'),
),
'#default_value' => $defaults['method'],
+ '#after_build' => array('simplytest_import_dependencies_curl'),
);
- if (is_callable('curl_init')) {
- $form['method']['#options']['download'] = t('Automatic download (expirimental)');
- }
$form['path'] = array(
'#type' => 'textfield',
@@ -80,6 +79,17 @@ function simplytest_import_form($form) {
}
/**
+ * After build callback; Check if cURL is available.
+ */
+function simplytest_import_dependencies_curl($element) {
+ if (!is_callable('curl_init')) {
+ $element['download']['#attributes']['disabled'] = TRUE;
+ $element['download']['#title'] = t('Automatic download (Requires cURL)', array('@url' => 'http://php.net/manual/en/book.curl.php'));
+ }
+ return $element;
+}
+
+/**
* Validation handler for building the batch.
*/
function simplytest_import_form_validate($form, &$form_state) {
@@ -109,10 +119,11 @@ function simplytest_import_form_validate($form, &$form_state) {
}
// Move the file into temporary://
- if (!$file = file_unmanaged_copy($_FILES['files']['tmp_name']['upload'], "temporary://{$_FILES['files']['name']['upload']}", FILE_EXISTS_RENAME)) {
+ $file = file_unmanaged_copy($_FILES['files']['tmp_name']['upload'], 'temporary://' . $_FILES['files']['name']['upload'], FILE_EXISTS_RENAME);
+ if (!$file) {
form_set_error('upload', t('The specified file %name could not be copied to %destination.', array(
'%name' => $_FILES['files']['name']['upload'],
- '%destination' => "temporary://{$_FILES['files']['name']['upload']}",
+ '%destination' => 'temporary://' . $_FILES['files']['name']['upload'],
)));
return FALSE;
}
@@ -189,8 +200,7 @@ function simplytest_import_batch_operation_download_xml($file, &$context) {
* Batch operation; Process the XML file.
*/
function simplytest_import_batch_operation_process_xml($file, &$context) {
- $xml = simplexml_load_file($file);
-
+ // Setup the batch information on first run.
if (!isset($context['sandbox']['index'])) {
$defaults = variable_get('simplytest_import', array('count' => 100));
@@ -199,6 +209,10 @@ function simplytest_import_batch_operation_process_xml($file, &$context) {
$context['sandbox']['index'] = 0;
}
+ // Load the projects data as a SimpleXML object.
+ $xml = simplexml_load_file($file);
+
+ // Iterate through projects.
$count = 0;
while ($context['sandbox']['index'] < $context['sandbox']['max'] && $count < $context['sandbox']['count']) {
if (isset($xml->project[$context['sandbox']['index']])) {
@@ -209,6 +223,7 @@ function simplytest_import_batch_operation_process_xml($file, &$context) {
$count++;
}
+ // Provide contextual information for the Batch API frontend.
$context['message'] = t('Projects imported: @index of @max.', array(
'@index' => $context['sandbox']['index'],
'@max' => $context['sandbox']['max'],
diff --git a/modules/simplytest_launch/simplytest_launch.module b/modules/simplytest_launch/simplytest_launch.module
index db97f37..2893b81 100644
--- a/modules/simplytest_launch/simplytest_launch.module
+++ b/modules/simplytest_launch/simplytest_launch.module
@@ -143,7 +143,7 @@ function simplytest_launch_block_launcher_form($form = array()) {
'#disabled' => !$enabled,
);
- $form['submit'] = array(
+ $form['launch'] = array(
'#type' => 'submit',
'#default_value' => t('Launch sandbox'),
'#disabled' => !$enabled,
diff --git a/scripts/sources/common b/scripts/sources/common
index 0da7e0b..94e40c3 100644
--- a/scripts/sources/common
+++ b/scripts/sources/common
@@ -22,7 +22,7 @@ s_info_file_get() {
# Make sure info files are unix encoded before reading them.
dos2unix -q "$1"
# Cut out the value.
- grep -m 1 "$2" "$1" | sed 's/^ *//g' | sed -n "s/$2[^=]*=[ ]*//p" | sed "s/[\"|\']//g"
+ grep -m 1 "$2[ ]*=" "$1" | sed 's/^ *//g' | sed -n "s/$2[^=]*=[ ]*//p" | sed "s/[\"|\']//g"
}
##
@@ -36,7 +36,7 @@ s_info_file_get_all() {
# Make sure info files are unix encoded before reading them.
dos2unix -q "$1"
# Cut out the values.
- cat "$1" | grep "$2" | sed 's/^ *//g' | sed -n "s/$2[^=]*=[ ]*//p" | sed "s/[\"|\']//g"
+ cat "$1" | grep "$2\[\][ ]*" | sed 's/^ *//g' | sed -n "s/$2[^=]*=[ ]*//p" | sed "s/[\"|\']//g"
}
##
diff --git a/simplytest.install b/simplytest.install
index 09b290e..9c44785 100644
--- a/simplytest.install
+++ b/simplytest.install
@@ -89,12 +89,18 @@ function simplytest_install() {
/**
* Implements hook_install_tasks().
+ *
+ * @TODO: Add the Import interface for users installing via the UI to choose how
+ * they want to supply the projects data.
*/
function simplytest_install_tasks() {
- $tasks['simplytest_import'] = array(
- 'display_name' => st('Import projects'),
- 'type' => 'batch',
- );
+ $file = drupal_get_path('module', 'simplytest') . '/libraries/simplytest_import/projects.xml';
+ if (file_exists($file)) {
+ $tasks['simplytest_import'] = array(
+ 'display_name' => st('Import projects'),
+ 'type' => 'batch',
+ );
+ }
return $tasks;
}
diff --git a/themes/simplytesty/style-narrow.css b/themes/simplytesty/style-narrow.css
index 54e985f..8dbf38a 100644
--- a/themes/simplytesty/style-narrow.css
+++ b/themes/simplytesty/style-narrow.css
@@ -65,3 +65,8 @@
.ui-autocomplete.ui-menu {
width: 80% !important;
}
+#simplytest-launch-block-launcher-form .dropbutton-wrapper {
+ display: block;
+ float: none;
+ padding-right: 0;
+}
\ No newline at end of file