' . t('On this page you can enter the default values for the meta tags of your site.') . '
';
break;
case 'admin/content/nodewords/meta-tags/errorpage_403':
$output = '' . t('On this page you can enter the meta tags for the access denied
error page of your site.') . '
';
break;
case 'admin/content/nodewords/meta-tags/errorpage_404':
$output = '' . t('On this page you can enter the meta tags for the page not found
error page of your site.') . '
';
break;
default:
$output = '';
break;
}
return $output;
}
/**
* Implements hook_menu().
*/
function nodewords_admin_menu() {
$admin_access = array('administer meta tags');
$items = array();
$items['admin/content/nodewords'] = array(
'title' => 'Meta tags',
'page callback' => 'drupal_get_form',
'page arguments' => array('nodewords_admin_settings_form'),
'description' => 'Configure HTML meta tags for all the content.',
'access arguments' => $admin_access,
'type' => MENU_NORMAL_ITEM,
'file' => 'nodewords_admin.admin.inc',
);
$items['admin/content/nodewords/settings'] = array(
'title' => 'General settings',
'access arguments' => $admin_access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
'file' => 'nodewords_admin.admin.inc',
);
$items['admin/content/nodewords/default'] = array(
'title' => 'Default meta tags',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nodewords_admin_tags_edit_form', array(
'type' => NODEWORDS_TYPE_DEFAULT,
)
),
'access arguments' => $admin_access,
'type' => MENU_LOCAL_TASK,
'file' => 'nodewords_admin.admin.inc',
);
$items['admin/content/nodewords/meta-tags'] = array(
'title' => 'Specific meta tags',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nodewords_admin_tags_edit_form', array(
'type' => NODEWORDS_TYPE_ERRORPAGE, 'id' => 403,
)
),
'access arguments' => $admin_access,
'type' => MENU_LOCAL_TASK,
'file' => 'nodewords_admin.admin.inc',
);
$items['admin/content/nodewords/meta-tags/errorpage_403'] = array(
'title' => 'Error 403 page',
'access arguments' => $admin_access,
'type' => MENU_DEFAULT_LOCAL_TASK,
'file' => 'nodewords_admin.admin.inc',
);
$items['admin/content/nodewords/meta-tags/errorpage_404'] = array(
'title' => 'Error 404 page',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nodewords_admin_tags_edit_form', array(
'type' => NODEWORDS_TYPE_ERRORPAGE, 'id' => 404,
)
),
'access arguments' => $admin_access,
'type' => MENU_LOCAL_TASK,
'file' => 'nodewords_admin.admin.inc',
);
return $items;
}
/**
* Implements hook_node_operations().
*/
function nodewords_admin_node_operations() {
$operations = array(
'delete_metatags' => array(
'label' => t('Delete meta tags'),
'callback' => 'nodewords_admin_mass_update',
'callback arguments' => array('type' => NODEWORDS_TYPE_NODE, 'operation' => 'delete'),
),
);
return $operations;
}
/**
* Implements hook_theme().
*/
function nodewords_admin_theme() {
return array(
'nodewords_admin_enabled_metatags' => array(
'arguments' => array('form' => array()),
'file' => 'nodewords_admin.admin.inc',
),
'nodewords_admin_output_fieldset' => array(
'arguments' => array('form' => array()),
'file' => 'nodewords_admin.admin.inc',
),
);
}
/**
* Implements hook_user_operations().
*/
function nodewords_admin_user_operations() {
$operations = array(
'delete_metatags' => array(
'label' => t('Delete meta tags'),
'callback' => 'nodewords_admin_mass_update',
'callback arguments' => array('type' => NODEWORDS_TYPE_USER, 'operation' => 'delete'),
),
);
return $operations;
}
/**
* Delete the nodes meta tags.
*
* @param $ids
* An array of IDs.
* @param $type
* The type of the object associated with the IDs (NODEWORDS_TYPE_NODE, NODEWORDS_TYPE_USER,
* NODEWORDS_TYPE_PAGER, NODEWORDS_TYPE_PAGE, ...).
* @param $operation
* The operation to execute (currently implemented: delete).
*/
function nodewords_admin_mass_update($ids, $type, $operation = 'delete') {
if ($operation == 'delete') {
if (count($ids) <= 10) {
db_query("DELETE FROM {nodewords} WHERE id IN (" . db_placeholders($ids, 'int') . ") AND type = %d",
array_merge($ids, array($type))
);
if ($type == NODEWORDS_TYPE_PAGE) {
foreach ($ids as $id) {
module_invoke_all('nodewords_delete_tags',
array('type' => NODEWORDS_TYPE_PAGE, 'id' => $id)
);
}
}
drupal_set_message(t('The update has been performed.'));
}
else {
$batch = array(
'operations' => array(
array('_nodewords_mass_delete_batch_process', array($ids, $type))
),
'finished' => '_nodewords_admin_mass_update_batch_finished',
'title' => t('Processing'),
'progress_message' => '',
'error_message' => t('The update has encountered an error.'),
'file' => drupal_get_path('module', 'nodewords_admin') .'/nodewords_admin.admin.inc',
);
batch_set($batch);
}
}
}