function metatags_quick_admin_path_based in Meta tags quick 8.3
Same name and namespace in other branches
- 7.2 metatags_quick.admin.inc \metatags_quick_admin_path_based()
Display all paths that have defined meta tags
_state
Parameters
type $form:
File
- ./
metatags_quick.admin.inc, line 274
Code
function metatags_quick_admin_path_based($form, $form_state) {
// get current language and module path
global $language;
$module_path = drupal_get_path('module', 'metatags_quick');
// grab language list
$languages = _metatags_quick_language_list();
// create table form
$form['new_path_based'] = array(
'#type' => 'fieldset',
'#title' => t('New path'),
'#collapsible' => FALSE,
'#attached' => array(
'js' => array(
$module_path . '/js/admin.js',
),
'css' => array(
$module_path . '/css/admin.css',
),
),
'new_path' => array(
'#type' => 'container',
'#prefix' => '<div style="float:left">',
'#suffix' => '</div><div style="clear:both;"> </div>',
'path' => array(
'#type' => 'textfield',
'#title' => t('Path:'),
'#maxlength' => 255,
'#description' => t('Enter path starting without a leading "/". "*" can be used as a wildcard at the end of a path.'),
'#prefix' => '<div style="float:left;">',
'#suffix' => '</div>',
),
'language' => array(
'#type' => 'select',
'#title' => t('Select language'),
'#options' => $languages,
'#default_value' => $language->language,
'#prefix' => '<div style="float:left; margin-left: 40px;">',
'#suffix' => '</div><div style="clear:both;"> </div>',
),
'new_path_submit' => array(
'#type' => 'submit',
'#value' => t('Create'),
'#attributes' => array(
'style' => 'margin-bottom: 20px;',
),
),
),
);
$form['path_based'] = array(
'#type' => 'fieldset',
'#title' => t('Manage Paths'),
'#collapsible' => FALSE,
);
$header = array(
'path' => array(
'data' => t('Path'),
'field' => 'p.path',
),
'language' => array(
'data' => t('Language'),
'field' => 'p.lang',
'width' => '10%',
),
'operations' => array(
'data' => t('Operations'),
'width' => '30%',
'colspan' => 2,
),
);
$query = db_select('metatags_quick_path_based', 'p')
->extend('PagerDefault')
->extend('TableSort');
$result = $query
->fields('p')
->limit(50)
->orderByHeader($header)
->execute();
// set up to fill options array
$destination = drupal_get_destination();
$options = array();
// fill options array
foreach ($result as $path) {
$options[] = array(
'path' => $path->path,
'language' => $languages[$path->lang],
'edit' => l(t('Edit'), 'admin/config/search/metatags_quick/path_based/edit', array(
'query' => array(
'pid' => $path->id,
'destination' => $destination['destination'],
),
)),
'delete' => l(t('Delete'), 'admin/config/search/metatags_quick/path_based/delete', array(
'query' => array(
'pid' => $path->id,
'destination' => $destination['destination'],
),
)),
);
}
// add created table
$form['path_based']['existing'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $options,
'#empty' => t('No content available.'),
'#attributes' => array(
'id' => 'path_based',
),
);
// add default page
$form['path_based']['pager'] = array(
'#markup' => theme('pager', array(
'tags' => NULL,
)),
);
// return listing form
return $form;
}