? .cache ? .settings Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1082 diff -u -p -r1.1082 common.inc --- includes/common.inc 8 Jan 2010 06:07:03 -0000 1.1082 +++ includes/common.inc 9 Jan 2010 23:50:11 -0000 @@ -6455,6 +6455,23 @@ function entity_get_controller($entity_t } /** + * Returns the path to an entity. + * + * @param $entity_type + * The entity type; e.g. 'node' or 'user'. + * @param $entity + * The entity for which to generate a path. + * @return + * The path for the entity, or NULL if the entity has no page of its own. + */ +function entity_path($entity_type, $entity) { + $info = entity_get_info($entity_type); + if (isset($info['path callback']) && function_exists($info['path callback'])) { + return $info['path callback']($entity); + } +} + +/** * Performs one or more XML-RPC request(s). * * @param $url Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.828 diff -u -p -r1.828 comment.module --- modules/comment/comment.module 8 Jan 2010 07:36:53 -0000 1.828 +++ modules/comment/comment.module 9 Jan 2010 23:45:18 -0000 @@ -97,6 +97,7 @@ function comment_entity_info() { 'comment' => array( 'label' => t('Comment'), 'base table' => 'comment', + 'path callback' => 'comment_path', 'fieldable' => TRUE, 'controller class' => 'CommentController', 'object keys' => array( @@ -126,6 +127,13 @@ function comment_entity_info() { } /** + * Entity path callback. + */ +function comment_path($comment) { + return 'comment/' . $comment->cid; +} + +/** * Implements hook_theme(). */ function comment_theme() { Index: modules/image/image.field.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/image/image.field.inc,v retrieving revision 1.9 diff -u -p -r1.9 image.field.inc --- modules/image/image.field.inc 21 Dec 2009 13:47:32 -0000 1.9 +++ modules/image/image.field.inc 9 Jan 2010 23:49:44 -0000 @@ -463,8 +463,7 @@ function image_field_formatter_view($obj // Check if the formatter involves a link. if (strpos($display['type'], 'image_link_content') === 0) { - list($id) = entity_extract_ids($obj_type, $object); - $path = $obj_type . '/' . $id; + $path = entity_path($obj_type, $object); } elseif (strpos($display['type'], 'image_link_file') === 0) { $link_file = TRUE; Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1201 diff -u -p -r1.1201 node.module --- modules/node/node.module 9 Jan 2010 21:54:00 -0000 1.1201 +++ modules/node/node.module 9 Jan 2010 23:45:17 -0000 @@ -188,6 +188,7 @@ function node_entity_info() { 'controller class' => 'NodeController', 'base table' => 'node', 'revision table' => 'node_revision', + 'path callback' => 'node_path', 'fieldable' => TRUE, 'object keys' => array( 'id' => 'nid', @@ -245,6 +246,13 @@ function node_entity_info() { } /** + * Entity path callback. + */ +function node_path($node) { + return 'node/' . $node->nid; +} + +/** * Implements hook_admin_paths(). */ function node_admin_paths() { Index: modules/system/system.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v retrieving revision 1.117 diff -u -p -r1.117 system.api.php --- modules/system/system.api.php 9 Jan 2010 21:54:01 -0000 1.117 +++ modules/system/system.api.php 9 Jan 2010 23:53:30 -0000 @@ -66,6 +66,8 @@ function hook_hook_info() { * static caching of entities during a page request. Defaults to TRUE. * - load hook: The name of the hook which should be invoked by * DrupalDefaultEntityController:attachLoad(), for example 'node_load'. + * - path callback: A function taking an entity as argument and returning the + * path to the entity. * - fieldable: Set to TRUE if you want your entity type to be fieldable. * - object keys: An array describing how the Field API can extract the * information it needs from the objects of the type. Elements: @@ -126,6 +128,7 @@ function hook_entity_info() { 'controller class' => 'NodeController', 'base table' => 'node', 'revision table' => 'node_revision', + 'path callback' => 'node_path', 'fieldable' => TRUE, 'object keys' => array( 'id' => 'nid', Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.560 diff -u -p -r1.560 taxonomy.module --- modules/taxonomy/taxonomy.module 8 Jan 2010 16:54:06 -0000 1.560 +++ modules/taxonomy/taxonomy.module 9 Jan 2010 23:45:20 -0000 @@ -87,6 +87,7 @@ function taxonomy_entity_info() { 'label' => t('Taxonomy term'), 'controller class' => 'TaxonomyTermController', 'base table' => 'taxonomy_term_data', + 'path callback' => 'taxonomy_term_path', 'fieldable' => TRUE, 'object keys' => array( 'id' => 'tid', @@ -129,6 +130,13 @@ function taxonomy_entity_info() { } /** + * Entity path callback. + */ +function taxonomy_term_path($term) { + return 'taxonomy/term/' . $term->tid; +} + +/** * Return nodes attached to a term across all field instances. * * This function requires taxonomy module to be maintaining its own tables, Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1099 diff -u -p -r1.1099 user.module --- modules/user/user.module 7 Jan 2010 04:54:18 -0000 1.1099 +++ modules/user/user.module 9 Jan 2010 23:45:22 -0000 @@ -149,6 +149,13 @@ function user_entity_info() { } /** + * Entity path callback. + */ +function user_path($user) { + return 'user/' . $user->uid; +} + +/** * Implements hook_field_extra_fields(). */ function user_field_extra_fields() {