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