| 1 |
<?php |
<?php |
| 2 |
// $Id: location_testcase.php,v 1.2.2.2 2009/01/08 22:20:06 bdragon Exp $ |
// $Id: location_testcase.php,v 1.2.2.3 2009/07/29 19:18:33 bdragon Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 24 |
} |
} |
| 25 |
} |
} |
| 26 |
|
|
| 27 |
|
/** |
| 28 |
|
* Get a set of location field defaults. |
| 29 |
|
* This will also enable collection on all parts of the location field. |
| 30 |
|
*/ |
| 31 |
|
function getLocationFieldDefaults() { |
| 32 |
|
// Get the (settable) defaults. |
| 33 |
|
$defaults = array(); |
| 34 |
|
$d = location_invoke_locationapi($location, 'defaults'); |
| 35 |
|
$fields = location_field_names(); |
| 36 |
|
foreach ($fields as $k => $v) { |
| 37 |
|
if (!isset($d[$k]['nodiff'])) { |
| 38 |
|
$defaults[$k] = $d[$k]; |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
foreach ($defaults as $k => $v) { |
| 43 |
|
// Change collection to allow. |
| 44 |
|
$defaults[$k]['collect'] = 1; |
| 45 |
|
} |
| 46 |
|
return $defaults; |
| 47 |
|
} |
| 48 |
|
|
| 49 |
/** |
/** |
| 50 |
* Flatten a post settings array because drupalPost isn't smart enough to. |
* Flatten a post settings array because drupalPost isn't smart enough to. |
| 71 |
} while (node_get_types('type', $name)); |
} while (node_get_types('type', $name)); |
| 72 |
|
|
| 73 |
// Get the (settable) defaults. |
// Get the (settable) defaults. |
| 74 |
$defaults = array(); |
$defaults = $this->getLocationFieldDefaults(); |
|
$d = location_invoke_locationapi($location, 'defaults'); |
|
|
$fields = location_field_names(); |
|
|
foreach ($fields as $k => $v) { |
|
|
if (!isset($d[$k]['nodiff'])) { |
|
|
$defaults[$k] = $d[$k]; |
|
|
} |
|
|
} |
|
|
|
|
|
foreach ($defaults as $k => $v) { |
|
|
// Change collection to allow. |
|
|
$defaults[$k]['collect'] = 1; |
|
|
} |
|
| 75 |
|
|
| 76 |
$settings = array( |
$settings = array( |
| 77 |
'name' => $name, |
'name' => $name, |
| 120 |
/** |
/** |
| 121 |
* Order locations in a node by LID for testing repeatability purposes. |
* Order locations in a node by LID for testing repeatability purposes. |
| 122 |
*/ |
*/ |
| 123 |
function reorderLocations(&$node) { |
function reorderLocations(&$node, $field = 'locations') { |
| 124 |
$locations = array(); |
$locations = array(); |
| 125 |
foreach ($node->locations as $location) { |
foreach ($node->{$field} as $location) { |
| 126 |
$locations[$location['lid']] = $location; |
if ($location['lid']) { |
| 127 |
|
$locations[$location['lid']] = $location; |
| 128 |
|
} |
| 129 |
} |
} |
| 130 |
ksort($locations); |
ksort($locations); |
| 131 |
$node->locations = array(); |
$node->{$field} = array(); |
| 132 |
foreach ($locations as $location) { |
foreach ($locations as $location) { |
| 133 |
$node->locations[] = $location; |
$node->{$field}[] = $location; |
| 134 |
} |
} |
| 135 |
} |
} |
| 136 |
|
|