This repository has been archived by the owner on Nov 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-2.0' of https://github.com/bitsecondal/farmosnws
- Loading branch information
Showing
12 changed files
with
613 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ xmlrpc.php | |
.project* | ||
.settings* | ||
|
||
# ignore mkdocs files | ||
site/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* Module configuration form | ||
* | ||
* @return Returns loaded form array object | ||
*/ | ||
function farmosnws_admin_form() { | ||
$form = array(); | ||
|
||
$form['farmosnws_weather_feeds_dir'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t('Feeds Directory'), | ||
'#required' => TRUE, | ||
'#description' => t('The full directory path to where weather feeds should be saved to.'), | ||
'#default_value' => variable_get('farmosnws_weather_feeds_dir'), | ||
); | ||
|
||
$form['farmosnws_locations'] = array( | ||
'#type' => 'textfield', | ||
'#title' => t('Locations'), | ||
'#description' => t('Enter the locations that you would like weather data pulled for. Each location must be entered must be separated by commas. Feeds can be found on the ' . l('NWS XML feeds page', 'http://w1.weather.gov/xml/current_obs/') . '.'), | ||
'#required' => TRUE, | ||
'#default_value' => variable_get('farmosnws_locations'), | ||
); | ||
|
||
$form['farmosnws_temp_units'] = array( | ||
'#type' => 'select', | ||
'#title' => t('Measurement Units'), | ||
'#required' => TRUE, | ||
'#options' => array( | ||
'us' => t('Fahrenheit'), | ||
'metric' => t('Celsius'), | ||
), | ||
'#description' => t('Select the system of measurement that you would like to use.'), | ||
'#default_value' => variable_get('farmosnws_temp_units'), | ||
); | ||
|
||
$form['farmosnws_delete_xml'] = array( | ||
'#type' => 'select', | ||
'#title' => t('Delete Processed XML'), | ||
'#required' => TRUE, | ||
'#options' => array( | ||
'yes' => 'Yes', | ||
'no' => 'No', | ||
), | ||
'#description' => t('Delete the National Weather Service XML feed after it has been processed.'), | ||
'#default_value' => variable_get('farmosnws_delete_xml', 'yes'), | ||
); | ||
|
||
return system_settings_form($form); | ||
} | ||
|
||
/** | ||
* | ||
* Validate the module settings | ||
*/ | ||
function farmosnws_admin_form_validate($form, &$form_state) { | ||
// validate that the work directory exists and can be created | ||
$weatherfeedsdir = $form_state['values']['farmosnws_weather_feeds_dir']; | ||
|
||
$direxist = farmosnws_create_feed_dir($weatherfeedsdir); | ||
if ( $direxist == FALSE ){ | ||
form_set_error('farmosnws_weather_feeds_dir', 'The weather feed directory cannot be created. Please verify that Drupal as write permissions and try again.'); | ||
} | ||
} // end if | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = FarmOS NWS | ||
description = Imports data from the National Weather Service into Drupal for use by FarmOS. | ||
core = 7.x | ||
package = farmOS | ||
version = 7.x-2.0 | ||
dependencies[] = farm | ||
dependencies[] = farm_quantity | ||
dependencies[] = farm_log_observation | ||
|
||
files[] = farmosnws.module | ||
files[] = farmosnws.admin.inc | ||
|
||
configure = admin/config/services/farmosnws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* implements hook_install() | ||
*/ | ||
function farmosnws_install() { | ||
|
||
// add the quantity types | ||
|
||
// get the vocabulary id | ||
$vocab_qty_units = taxonomy_vocabulary_machine_name_load('farm_quantity_units'); | ||
|
||
// list of terms to add | ||
$terms_qty_list = array('Fahrenheit', 'Celsius', 'Percent Humdity', 'Direction', 'Inches', 'MPH', 'Miles', 'Knots', 'KM', 'Degrees'); | ||
|
||
// check if the term exists, if it does not then add it | ||
foreach($terms_qty_list as $term_qty_item) { | ||
$taxterm = taxonomy_get_term_by_name($term_qty_item); | ||
|
||
if (count($taxterm) == 0) { | ||
$tax_qty_term = new stdClass(); | ||
$tax_qty_term->name = $term_qty_item; | ||
$tax_qty_term->vid = $vocab_qty_units->vid; | ||
taxonomy_term_save($tax_qty_term); | ||
|
||
watchdog('farmosnws', 'Created ' . $term_qty_item . ' taxonomy term.', array(), WATCHDOG_INFO, NULL); | ||
} | ||
else { | ||
watchdog('farmosnws', 'Matched taxonomy term ' . $term_qty_item, array(), WATCHDOG_INFO, NULL); | ||
} | ||
} | ||
|
||
// set default variable values | ||
variable_set('farmosnws_temp_units', 'us'); | ||
variable_set('farmosnws_delete_xml', 'yes'); | ||
} | ||
|
||
/** | ||
* | ||
* implements hook_enable() | ||
*/ | ||
function farmosnws_enable() { | ||
// notice to visit configuration page to set initial values for variables | ||
drupal_set_message(t("Visit the module " . l("configuration page", 'admin/config/services/farmosnws') . " to complete module setup."), 'warning', FALSE); | ||
watchdog('farmosnws', 'Visit the module configuration page to complete module setup', array(), WATCHDOG_INFO, NULL); | ||
} | ||
|
||
/** | ||
* | ||
* implements hook_uninstall() | ||
*/ | ||
function farmosnws_uninstall() { | ||
// delete all the variables created by the module | ||
$query = "select name from {variable} where name like :varname"; | ||
$result = db_query($query, array(':varname' => db_like('farmosnws') . '%')); | ||
|
||
foreach($result as $row) { | ||
variable_del($row->name); | ||
} // end foreach | ||
|
||
menu_rebuild(); | ||
|
||
watchdog('farmosnws', 'FarmOS NWS module has been uninstalled', array(), WATCHDOG_INFO, NULL); | ||
} // end function | ||
|
Oops, something went wrong.