Revision 582db59d
Added by Assos Assos almost 9 years ago
drupal7/modules/node/node.api.php | ||
---|---|---|
950 | 950 |
* 'recent', or 'comments'. The values should be arrays themselves, with the |
951 | 951 |
* following keys available: |
952 | 952 |
* - title: (required) The human readable name of the ranking mechanism. |
953 |
* - join: (optional) The part of a query string to join to any additional
|
|
953 |
* - join: (optional) An array with information to join any additional
|
|
954 | 954 |
* necessary table. This is not necessary if the table required is already |
955 | 955 |
* joined to by the base query, such as for the {node} table. Other tables |
956 | 956 |
* should use the full table name as an alias to avoid naming collisions. |
... | ... | |
974 | 974 |
'title' => t('Average vote'), |
975 | 975 |
// Note that we use i.sid, the search index's search item id, rather than |
976 | 976 |
// n.nid. |
977 |
'join' => 'LEFT JOIN {vote_node_data} vote_node_data ON vote_node_data.nid = i.sid', |
|
977 |
'join' => array( |
|
978 |
'type' => 'LEFT', |
|
979 |
'table' => 'vote_node_data', |
|
980 |
'alias' => 'vote_node_data', |
|
981 |
'on' => 'vote_node_data.nid = i.sid', |
|
982 |
), |
|
978 | 983 |
// The highest possible score should be 1, and the lowest possible score, |
979 | 984 |
// always 0, should be 0. |
980 | 985 |
'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)', |
... | ... | |
1079 | 1084 |
* @ingroup node_api_hooks |
1080 | 1085 |
*/ |
1081 | 1086 |
function hook_prepare($node) { |
1082 |
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE)); |
|
1083 |
if ($file) { |
|
1084 |
if (!image_get_info($file->uri)) { |
|
1085 |
form_set_error($field_name, t('Uploaded file is not a valid image')); |
|
1086 |
return; |
|
1087 |
} |
|
1088 |
} |
|
1089 |
else { |
|
1090 |
return; |
|
1087 |
if (!isset($node->mymodule_value)) { |
|
1088 |
$node->mymodule_value = 'foo'; |
|
1091 | 1089 |
} |
1092 |
$node->images['_original'] = $file->uri; |
|
1093 |
_image_build_derivatives($node, TRUE); |
|
1094 |
$node->new_file = TRUE; |
|
1095 | 1090 |
} |
1096 | 1091 |
|
1097 | 1092 |
/** |
Also available in: Unified diff
Update Drupal core to version 7.40