Révision dd54aff9
Ajouté par Assos Assos il y a plus de 10 ans
htmltest/sites/all/modules/entity/entity.module | ||
---|---|---|
133 | 133 |
foreach ($info['bundles'] as $bundle_name => $bundle_info) { |
134 | 134 |
// Create an empty entity with just the bundle set to check for access. |
135 | 135 |
$dummy_entity = entity_create($entity_type, array( |
136 |
'bundle' => $bundle_name,
|
|
136 |
$info['entity keys']['bundle'] => $bundle_name,
|
|
137 | 137 |
)); |
138 | 138 |
// If modules use a uid, they can default to the current-user |
139 | 139 |
// in their create() method on the storage controller. |
... | ... | |
166 | 166 |
return entity_ui_get_form($entity_type, $entity, 'add'); |
167 | 167 |
} |
168 | 168 |
|
169 |
/** |
|
170 |
* Page callback for viewing an entity. |
|
171 |
* |
|
172 |
* @param Entity $entity |
|
173 |
* The entity to be rendered. |
|
174 |
* |
|
175 |
* @return array |
|
176 |
* A renderable array of the entity in full view mode. |
|
177 |
*/ |
|
178 |
function entity_ui_entity_page_view($entity) { |
|
179 |
module_load_include('inc', 'entity', 'includes/entity.ui'); |
|
180 |
return $entity->view('full', NULL, TRUE); |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* Gets the page title for the passed operation. |
|
185 |
*/ |
|
186 |
function entity_ui_get_page_title($op, $entity_type, $entity = NULL) { |
|
187 |
module_load_include('inc', 'entity', 'includes/entity.ui'); |
|
188 |
$label = entity_label($entity_type, $entity); |
|
189 |
switch ($op) { |
|
190 |
case 'view': |
|
191 |
return $label; |
|
192 |
case 'edit': |
|
193 |
return t('Edit @label', array('@label' => $label)); |
|
194 |
case 'clone': |
|
195 |
return t('Clone @label', array('@label' => $label)); |
|
196 |
case 'revert': |
|
197 |
return t('Revert @label', array('@label' => $label)); |
|
198 |
case 'delete': |
|
199 |
return t('Delete @label', array('@label' => $label)); |
|
200 |
case 'export': |
|
201 |
return t('Export @label', array('@label' => $label)); |
|
202 |
} |
|
203 |
if (isset($entity)) { |
|
204 |
list(, , $bundle) = entity_extract_ids($entity_type, $entity); |
|
205 |
} |
|
206 |
return entity_ui_get_action_title($op, $entity_type, $bundle); |
|
207 |
} |
|
208 |
|
|
169 | 209 |
/** |
170 | 210 |
* A wrapper around entity_load() to load a single entity by name or numeric id. |
171 | 211 |
* |
... | ... | |
582 | 622 |
} |
583 | 623 |
|
584 | 624 |
/** |
585 |
* Determines whether the given user has access to an entity. |
|
625 |
* Determines whether the given user can perform actions on an entity. |
|
626 |
* |
|
627 |
* For create operations, the pattern is to create an entity and then |
|
628 |
* check if the user has create access. |
|
629 |
* |
|
630 |
* @code |
|
631 |
* $node = entity_create('node', array('type' => 'page')); |
|
632 |
* $access = entity_access('create', 'node', $node, $account); |
|
633 |
* @endcode |
|
586 | 634 |
* |
587 | 635 |
* @param $op |
588 | 636 |
* The operation being performed. One of 'view', 'update', 'create' or |
... | ... | |
881 | 929 |
// implementations. |
882 | 930 |
$originals[$name] = $entity->original; |
883 | 931 |
|
884 |
$entity->{$keys['status']} |= ENTITY_IN_CODE; |
|
932 |
if (!isset($entity->{$keys['status']})) { |
|
933 |
$entity->{$keys['status']} = ENTITY_IN_CODE; |
|
934 |
} |
|
935 |
else { |
|
936 |
$entity->{$keys['status']} |= ENTITY_IN_CODE; |
|
937 |
} |
|
885 | 938 |
$entity->is_rebuild = TRUE; |
886 | 939 |
entity_save($entity_type, $entity); |
887 | 940 |
unset($entity->is_rebuild); |
... | ... | |
1396 | 1449 |
$entity_info['node']['form callback'] = 'entity_metadata_form_node'; |
1397 | 1450 |
$entity_info['user']['form callback'] = 'entity_metadata_form_user'; |
1398 | 1451 |
|
1452 |
// URI callbacks. |
|
1453 |
if (!isset($entity_info['file']['uri callback'])) { |
|
1454 |
$entity_info['file']['uri callback'] = 'entity_metadata_uri_file'; |
|
1455 |
} |
|
1456 |
|
|
1399 | 1457 |
// View callbacks. |
1400 | 1458 |
$entity_info['node']['view callback'] = 'entity_metadata_view_node'; |
1401 | 1459 |
$entity_info['user']['view callback'] = 'entity_metadata_view_single'; |
Formats disponibles : Unified diff
Weekly update of contrib modules