| 17 |
if (isset($view->sort[0]['field'])) { |
if (isset($view->sort[0]['field'])) { |
| 18 |
$sort_field = $view->sort[0]['field']; |
$sort_field = $view->sort[0]['field']; |
| 19 |
$matches = array(); |
$matches = array(); |
| 20 |
if (preg_match('/^[^\.]*\.(.*?)_value$/', $sort_field, $matches)) { |
if (strpos($sort_field, "node.") === 0) { |
| 21 |
|
$sort_field = substr($sort_field, 5); |
| 22 |
|
} else if (preg_match('/^[^\.]*\.(.*?)_value$/', $sort_field, $matches)) { |
| 23 |
$sort_field = $matches[1]; |
$sort_field = $matches[1]; |
| 24 |
} // if it's not a cck value |
} |
| 25 |
} // if it's got a sort field |
} // if it's got a sort field |
| 26 |
|
|
| 27 |
if (!isset($sort_field)) { |
if (!isset($sort_field)) { |
| 34 |
foreach ($nodes as $proto_node) { |
foreach ($nodes as $proto_node) { |
| 35 |
$node = node_load($proto_node->nid); |
$node = node_load($proto_node->nid); |
| 36 |
$val = $node->$sort_field; |
$val = $node->$sort_field; |
| 37 |
$val = $val[0]['value']; |
if (is_array($val)) { |
| 38 |
|
if (function_exists('date_custom2unix')) { |
| 39 |
|
$val = date_custom2unix($val[0]['value'], "Y-m-dTH:i:s"); |
| 40 |
|
} else { |
| 41 |
|
$val = strtotime($val[0]['value']); |
| 42 |
|
} |
| 43 |
|
} |
| 44 |
|
// if it's not an array, it's probably a simple unix timestamp. |
| 45 |
|
|
| 46 |
// format_date doesn't handle pre-1970 dates, so we'll use date_format_date |
// format_date doesn't handle pre-1970 dates, so we'll use date_format_date |
| 47 |
// in that case. But both of these provide translation. |
// in that case. But both of these provide translation. |
| 48 |
if (function_exists('date_format_date')) { |
if (function_exists('date_format_date')) { |
| 49 |
$year = date_format_date('Y', strtotime($val)); |
$year = date_format_date('Y', $val); |
| 50 |
$month = date_format_date('F', strtotime($val)); |
$month = date_format_date('F', $val); |
| 51 |
} else { |
} else { |
| 52 |
$year = format_date(strtotime($val), 'custom', 'Y', 0); |
$year = format_date($val, 'custom', 'Y', 0); |
| 53 |
$month = format_date(strtotime($val), 'custom', 'F', 0); |
$month = format_date($val, 'custom', 'F', 0); |
| 54 |
} |
} |
| 55 |
|
|
| 56 |
|
|