seochecklist.module in SEO Checklist 5.2
Same filename and directory in other branches
SEO Checklist module allows users to track important SEO techniques on the website.
File
seochecklist.moduleView source
<?php
/**
* @file
* SEO Checklist module allows users to track important SEO techniques on the website.
*/
function seochecklist_help($section) {
if ($section == 'admin/settings/seochecklist') {
return '<p>' . t('Check off each SEO-related task as you complete it. Do not forget to click the <em>Save</em> button!') . '</p>';
}
}
/**
* Implementation of hook_perm().
*/
function seochecklist_perm() {
return array(
'access seochecklist content',
);
}
/**
* Implementation of hook_menu().
*/
function seochecklist_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/seochecklist',
'title' => t('SEO Checklist'),
'description' => t('Keep track of your Drupal Search Engine Optimization tasks.'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'seochecklist_admin_settings',
),
'access' => user_access('access seochecklist content'),
);
}
return $items;
}
/**
* Define the settings form.
*/
function seochecklist_admin_settings() {
global $user;
$form['save_above'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
// Fetch modules and groups from database.
$query = "SELECT id, name, description FROM {seo_group} ORDER BY id";
$result = db_query($query);
$group_id = 0;
// Every group is a fieldset.
while ($data = db_fetch_object($result)) {
$group_id = intval($data->id);
$form['group_' . $group_id] = array(
'#type' => 'fieldset',
'#title' => t($data->name),
'#collapsible' => TRUE,
'#description' => t($data->description),
);
$res = db_query("SELECT download, enable, configure, module, completed, id, name, uid FROM {seo_checklist} WHERE group_id = %d ORDER BY order_id", $group_id);
while ($row = db_fetch_object($res)) {
$row->links = array();
if ($row->completed) {
// Show when and who completed this task.
$row->links[] = t('Completed on %date by !username', array(
'%date' => format_date($row->completed, 'small'),
'!username' => theme('username', user_load(array(
'uid' => $row->uid,
))),
));
}
else {
// Show non-completed sub-tasks.
if ($row->download) {
$row->links[] = l(t('Download'), $row->download, array(
'target' => '_blank',
));
}
if ($row->enable) {
$row->links[] = l(t('Enable'), $row->enable);
}
}
if ($row->configure && (!$row->module || module_exists($row->module))) {
// Show the link to configure if this isn't a module or module is enabled.
$row->links[] = l(t('Configure'), $row->configure);
}
$task = $form['group_' . $group_id]['seochecklist_task_' . $row->id] = array(
'#type' => 'checkbox',
'#title' => t($row->name),
'#default_value' => $row->completed || $row->module && module_exists($row->module),
'#description' => join(' | ', $row->links),
);
if (strpos($row->name, 'Clean URLs') === 0) {
$task['#disabled'] = !variable_get('clean_url', 0);
$task['#default_value'] |= variable_get('clean_url', 0);
}
}
}
$form['extras'] = array(
'#type' => 'fieldset',
'#title' => t('Extras'),
'#collapsible' => TRUE,
);
$form['extras']['seo_checklist_link'] = array(
'#type' => 'checkbox',
'#title' => t('Link to Volacci to thank them for this awesome module.'),
'#default_value' => variable_get('seo_checklist_link', 0),
'#description' => t('A small link will appear at the very bottom of your website. You can disable it at any time by un-checking this box. We really appreciate it!'),
);
$form['extras']['seo_checklist_thanks'] = array(
'#type' => 'checkbox',
'#title' => t('Send us feedback on the Drupal 6 SEO Checklist module or just say <em>Thanks!</em> and we will link to you from our website. Send your feedback and link information to <a href="mailto:@email">@email</a>.', array(
'@email' => 'seochecklist@volacci.com',
)),
'#default_value' => variable_get('seo_checklist_thanks', 0),
'#description' => t('If you do not know why you should link with other websites, read the following article: <a href="@link">Why links help SEO</a>.', array(
'@link' => 'http://www.volacci.com/why-links-help-seo',
)),
);
$form['extras']['seo_checklist_podcast'] = array(
'#type' => 'checkbox',
'#title' => t('Listen to the <a href="@podcast">Volacci Drupal SEO Podcast</a> for more tips and tricks about Drupal SEO.', array(
'@podcast' => 'http://www.volacci.com/podcast',
)),
'#default_value' => variable_get('seo_checklist_podcast', 0),
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
/**
* Submit callback for seochecklist_admin_settings().
*/
function seochecklist_admin_settings_submit($form_id, $form_values) {
global $user;
$count = 0;
foreach ($form_values as $key => $value) {
if (preg_match('/seochecklist_task_/', $key)) {
$key = explode('_', $key);
$key = $key[2];
$current = (bool) db_result(db_query("SELECT completed FROM {seo_checklist} WHERE id = %d", $key));
if ($current != $value) {
// If the checkbox changed states, update the record.
db_query("UPDATE {seo_checklist} SET completed = %d, uid = %d WHERE id = %d", $value ? time() : 0, $user->uid, $key);
$count++;
}
}
}
// Special values not in database.
variable_set('seo_checklist_link', $form_values['seo_checklist_link']);
variable_set('seo_checklist_thanks', $form_values['seo_checklist_thanks']);
variable_set('seo_checklist_podcast', $form_values['seo_checklist_podcast']);
drupal_set_message(format_plural($count, 'Updated @count task successfully.', 'Updated @count tasks successfully.'));
}
/**
* Implementation of hook_footer().
*/
function seochecklist_footer($main = 0) {
if (variable_get('seo_checklist_link', 0)) {
return '<div align="center"><a href="http://www.volacci.com/" target="_blank">Drupal SEO</a></div>';
}
}
Functions
Name![]() |
Description |
---|---|
seochecklist_admin_settings | Define the settings form. |
seochecklist_admin_settings_submit | Submit callback for seochecklist_admin_settings(). |
seochecklist_footer | Implementation of hook_footer(). |
seochecklist_help | @file SEO Checklist module allows users to track important SEO techniques on the website. |
seochecklist_menu | Implementation of hook_menu(). |
seochecklist_perm | Implementation of hook_perm(). |