1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<?php
/**
* Implementation of hook_permission().
*/
function addmilkshakes_permission() {
return array(
'access addmilkshakes' => array('title' => t('Access addmilkshakes'))
);
}
/**
* Implementation of hook_menu().
*/
function addmilkshakes_menu(){
$items = array();
$items['addmilkshakes'] = array(
'title' => 'Ajouter un milkshake(module en construction)',
'page callback' => 'add_milkshakes',
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
'weight' => -10,
);
return $items;
}
function add_milkshakes($form, &$form_state) {
$form['saveur'] = array(
'#type' => 'textfield',
'#title' => 'Entrez une saveur :',
'#size' => 35,
'#maxlength' => 35,
'#required' => TRUE,
);
$form['recette'] = array(
'#type' => 'textfield',
'#title' => 'Entrez une lien vers la recette :',
'#size' => 35,
'#maxlength' => 35,
'#required' => TRUE,
);
$form['type'] = array(
'#type' => 'textfield',
'#title' => 'Entrez le type de milkshake :',
'#size' => 35,
'#maxlength' => 35,
'#required' => TRUE,
);
$form['cote'] = array(
'#type' => 'select',
'#title' => t('Cote'),
'#required' => TRUE,
'#options' => array(
0 => t('★'),
1 => t('★★'),
2 => t('★★★'),
3 => t('★★★★'),
4 => t('★★★★★')
)
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
$form['actions']['cancel'] = array(
'#markup' => l(t('Cancel'), 'http://eltc.gabriel-cassano.be/?q=milkshake/add'),
);
return $form;
}
function add_milkshakes_submit($form, &$form_state) {
db_insert('drup_milshakes')
->fields(array(
'flavor' => $form_state['values']['saveur'],
'link_recipe' => $form_state['values']['recette'],
'type_milkshake' => $form_state['values']['type'],
'cote' => $form_state['values']['cote']['#options'],
))
->execute();
drupal_set_message("successfully saved Security Settings");
} |
Partager