| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id$ /** * @file * TODO: Enter file description here. */</p> 3 4 /** 5 * Implementation of hook_menu(). 6 */ 7 function identity_menu() { 8 // This is the minimum information you can provide for a menu item. 9 $items['TODO: Enter path'] = array( 10 'title' => 'TODO: Enter menu item title', 11 'page callback' => 'TODO: Enter callback function', 12 'access arguments' => array('TODO: Enter user permissions'), 13 ); 14 // more complex menu item 15 $items['TODO: Enter path'] = array( 16 'title' => 'TODO: Enter menu item title', 17 'description' => 'TODO: Enter description', 18 'page callback' => 'TODO: Enter callback function', 19 'page arguments' => '', // An array of arguments to pass to the page callback function. Integer values pass the corresponding URL component. 20 'access callback' => '', // defaults to user_access() 21 'access arguments' => array('TODO: Enter user permissions'), 22 'weight' => 0, 23 'type' => MENU_NORMAL_ITEM, // One of MENU_NORMAL_ITEM / MENU_CALLBACK / MENU_SUGGESTED_ITEM / MENU_LOCAL_TASK / MENU_DEFAULT_LOCAL_TASK 24 'menu_name' => '', // Menu to place this item in. 25 'title callback' => '', // Function to generate the title, defaults to t(). 26 'title arguments' => '', // Arguments to send to t() or your custom callback. 27 ); 28 // OPTIONAL: Fill in additional static menu items 29 30 return $items; 31 } 32 33 34 /** 35 * Implementation of hook_perm(). 36 */ 37 function identity_perm() { 38 return array('create Identity', 'edit own Identity'); 39 } 40 41 42 /** 43 * Implementation of hook_elements(). 44 */ 45 function identity_elements() { 46 $type['example'] = array('#property' => t('TODO: Fill in appropriate properties and values for element type.')); 47 // OPTIONAL: Define additional element types. 48 return $type; 49 } 50 51 52 /** 53 * Implementation of hook_node_info(). 54 */ 55 function identity_node_info() { 56 57 ############## WORK: add INFO to these!!!! 58 return array( 59 'identity' => array( 60 'name' => '', 61 /* INFO: the human-readable name of the node type. Required. */ 62 'module' => '', 63 /* INFO: a string telling Drupal how a module's functions map to hooks 64 (i.e. if module is defined as example_foo, then example_foo_insert will 65 be called when inserting a node of that type). This string is usually 66 the name of the module in question, but not always. Required. */ 67 'description' => '', 68 'help' => '', 69 'has_title' => '', 70 'title_label' => '', 71 'has_body' => '', 72 'body_label' => '', 73 'min_word_count' => '', 74 'locked' => '', 75 /* INFO: boolean indicating whether the machine-readable name of this 76 content type can (FALSE) or cannot (TRUE) be edited by a site 77 administrator. Optional (defaults to TRUE). */ 78 ), 79 // add further types as needed 80 ); 81 } 82 83 84 /** 85 * Implementation of hook_access(). 86 */ 87 function identity_access($op, $node, $account) { 88 global $user; 89 90 if ($op == 'create') { 91 return user_access('create Identity'); 92 } 93 94 if ($op == 'update' || $op == 'delete') { 95 if (user_access('edit own Identity') && ($user->uid == $node->uid)) { 96 return TRUE; 97 } 98 } 99 } 100 101 102 /** 103 * Implementation of hook_form(). 104 */ 105 function identity_form(&$node, $form_state) { 106 // The site admin can decide if this node type has a title and body, and how 107 // the fields should be labeled. We need to load these settings so we can 108 // build the node form correctly. 109 $type = node_get_types('type', $node); 110 111 if ($type->has_title) { 112 $form['title'] = array( 113 '#type' => 'textfield', 114 '#title' => check_plain($type->title_label), 115 '#required' => TRUE, 116 '#default_value' => $node->title, 117 '#weight' => -5 118 ); 119 } 120 121 if ($type->has_body) { 122 // In Drupal 6, we can use node_body_field() to get the body and filter 123 // elements. This replaces the old textarea + filter_form() method of 124 // setting this up. It will also ensure the teaser splitter gets set up 125 // properly. 126 $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count); 127 } 128 129 // TODO: Enter additional form elements 130 131 return $form; 132 } 133 134 135 /** 136 * Implementation of hook_validate(). 137 */ 138 function identity_validate($node, &$form) { 139 // TODO: Enter form validation code here 140 if (0) { // if bad stuff 141 form_set_error('FORM ELEMENT NAME', t('TODO: Write an error message.')); 142 } 143 } 144 145 146 /** 147 * Implementation of hook_insert(). 148 */ 149 function identity_insert($node) { 150 // TODO: Enter database insertion query here, for example: 151 // db_query("INSERT INTO {node_example} (vid, nid, color, quantity) VALUES (%d, %d, '%s', %d)", $node->vid, $node->nid, $node->color, $node->quantity); 152 } 153 154 155 /** 156 * Implementation of hook_update(). 157 */ 158 function identity_update($node) { 159 // if this is a new node or we're adding a new revision, 160 if ($node->revision) { 161 identity_insert($node); 162 } 163 else { 164 // TODO: Enter database update query here, for example: 165 // db_query("UPDATE {node_example} SET color = '%s', quantity = %d WHERE vid = %d", $node->color, $node->quantity, $node->vid); 166 } 167 } 168 169 170 /** 171 * Implementation of hook_delete(). 172 */ 173 function identity_delete(&$node) { 174 // TODO: Enter database deletion query here, for example: 175 // db_query('DELETE FROM {node_example} WHERE nid = %d', $node->nid); 176 } 177 178 179 /** 180 * Implementation of hook_load(). 181 */ 182 function identity_load($node) { 183 // TODO: Obtain and return additional fields added to the node type, for example: 184 // $additions = db_fetch_object(db_query('SELECT color, quantity FROM {node_example} WHERE vid = %d', $node->vid)); 185 // return $additions; 186 } 187 188 189 /** 190 * Implementation of hook_view(). 191 */ 192 function identity_view($node, $teaser = FALSE, $page = FALSE) { 193 // TODO: Insert additional code (call to theme functions, etc.) to execute when viewing a node, for example: 194 // $node = node_prepare($node, $teaser); 195 // $node->content['myfield'] = array( 196 // '#value' => theme('node_example_order_info', $node), 197 // '#weight' => 1, 198 // ); 199 200 return $node; 201 } 202 203 204 /** 205 * Implementation of hook_footer(). 206 */ 207 function identity_footer($main = 0) { 208 209 } 210 211 212 /** 213 * Implementation of hook_form_alter(). 214 */ 215 function identity_form_alter(&$form, &$form_state, $form_id) { 216 217 } 218
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |