function metatags_quick_admin_path_based_edit in Meta tags quick 8.3
Same name and namespace in other branches
- 7.2 metatags_quick.admin.inc \metatags_quick_admin_path_based_edit()
Displays a form to the user allowing him to edit the path and all the fields of the metatag entity associated with that path
_state
Parameters
array $form:
File
- ./
metatags_quick.admin.inc, line 409
Code
function metatags_quick_admin_path_based_edit($form, &$form_state) {
$controller = new DrupalDefaultEntityController('metatags_path_based');
if (isset($_GET['pid'])) {
$entity_id = (int) $_GET['pid'];
}
else {
$entity_id = db_select('metatags_quick_path_based', 'm')
->fields('m', array(
'id',
))
->condition('lang', check_plain($_GET['lang']))
->condition('path', check_plain($_GET['path']))
->execute()
->fetchField();
}
if (!$entity_id) {
$entity_id = db_insert('metatags_quick_path_based')
->fields(array(
'lang' => check_plain($_GET['lang']),
'path' => check_plain($_GET['path']),
))
->execute();
$entity = new stdClass();
$entity->id = $entity_id;
$entity->lang = check_plain($_GET['lang']);
$entity->path = check_plain($_GET['path']);
}
else {
$entities = $controller
->load(array(
$entity_id,
));
$entity = $entities[$entity_id];
}
$form_state['entity'] = $entity;
field_attach_form('metatags_path_based', $entity, $form, $form_state, LANGUAGE_NONE);
//
$form['entity_id'] = array(
'#type' => 'hidden',
'#value' => $entity_id,
);
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Edit path'),
'#description' => t('Enter path starting without a leading "/". "*" can be used as a wildcard at the end of a path.'),
'#default_value' => html_entity_decode($entity->path),
'#maxlength' => 255,
'#weight' => '-50',
);
$form['lang'] = array(
'#title' => t('Edit language'),
'#type' => 'select',
'#options' => _metatags_quick_language_list(),
'#default_value' => $entity->lang,
'#weight' => '-40',
);
//
$form['submit'] = array(
'#value' => t('Submit'),
'#type' => 'submit',
'#weight' => '49',
);
$form['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#weight' => 20,
'#submit' => array(
'metatags_quick_admin_path_based_edit_cancel',
),
'#weight' => '50',
);
return $form;
}