| 1 |
<?php
|
| 2 |
// $Id: seochecklist.admin.inc,v 1.5 2009/10/23 00:00:15 davereid Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Define the settings form.
|
| 6 |
*/
|
| 7 |
function seochecklist_admin_settings() {
|
| 8 |
global $user;
|
| 9 |
|
| 10 |
$form['save_above'] = array(
|
| 11 |
'#type' => 'submit',
|
| 12 |
'#value' => t('Save'),
|
| 13 |
);
|
| 14 |
|
| 15 |
// Fetch modules and groups from database.
|
| 16 |
$query = "SELECT id, name, description FROM {seo_group} ORDER BY id";
|
| 17 |
|
| 18 |
$result = db_query($query);
|
| 19 |
$group_id = 0;
|
| 20 |
|
| 21 |
// Every group is a fieldset.
|
| 22 |
while ($data = db_fetch_object($result)) {
|
| 23 |
$group_id = intval($data->id);
|
| 24 |
|
| 25 |
$form['group_' . $group_id] = array(
|
| 26 |
'#type' => 'fieldset',
|
| 27 |
'#title' => t($data->name),
|
| 28 |
'#collapsible' => TRUE,
|
| 29 |
'#description' => t($data->description),
|
| 30 |
);
|
| 31 |
|
| 32 |
$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);
|
| 33 |
while ($row = db_fetch_object($res)) {
|
| 34 |
$row->links = array();
|
| 35 |
|
| 36 |
if ($row->completed) {
|
| 37 |
// Show when and who completed this task.
|
| 38 |
$row->links[] = t('Completed on %date by !username', array('%date' => format_date($row->completed, 'small'), '!username' => theme('username', user_load($row->uid))));
|
| 39 |
}
|
| 40 |
else {
|
| 41 |
// Show non-completed sub-tasks.
|
| 42 |
if ($row->download) {
|
| 43 |
$row->links[] = l(t('Download'), $row->download, array('attributes' => array('target' => '_blank')));
|
| 44 |
}
|
| 45 |
if ($row->enable) {
|
| 46 |
$row->links[] = l(t('Enable'), $row->enable);
|
| 47 |
}
|
| 48 |
}
|
| 49 |
|
| 50 |
if ($row->configure && (!$row->module || module_exists($row->module))) {
|
| 51 |
// Show the link to configure if this isn't a module or module is enabled.
|
| 52 |
$row->links[] = l(t('Configure'), $row->configure);
|
| 53 |
}
|
| 54 |
|
| 55 |
if (variable_get('seo_checklist_book_references', 1) && $page = seochecklist_get_book_references($row->id)) {
|
| 56 |
$row->links[] = t('SEO book page @page', array('@page' => $page));
|
| 57 |
}
|
| 58 |
|
| 59 |
$form['group_' . $group_id]['seochecklist_nodetypes_' . intval($row->id)] = array(
|
| 60 |
'#type' => 'checkbox',
|
| 61 |
'#title' => t($row->name),
|
| 62 |
'#default_value' => $row->completed || ($row->module && module_exists($row->module)),
|
| 63 |
'#description' => join(' | ', $row->links),
|
| 64 |
);
|
| 65 |
if (strpos($row->name, 'Clean URLs') === 0) {
|
| 66 |
$form['group_' . $group_id]['seochecklist_nodetypes_' . intval($row->id)]['#disabled'] = !variable_get('clean_url', 0);
|
| 67 |
$form['group_' . $group_id]['seochecklist_nodetypes_' . intval($row->id)]['#default_value'] |= variable_get('clean_url', 0);
|
| 68 |
}
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
| 72 |
$form['extras'] = array(
|
| 73 |
'#type' => 'fieldset',
|
| 74 |
'#title' => t('Extras'),
|
| 75 |
'#collapsible' => TRUE,
|
| 76 |
);
|
| 77 |
$form['extras']['seo_checklist_link'] = array(
|
| 78 |
'#type' => 'checkbox',
|
| 79 |
'#title' => t("Link to Volacci to thank them for this awesome module. <strong>Don't forget to click Save!</strong>"),
|
| 80 |
'#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!!!"),
|
| 81 |
'#default_value' => variable_get('seo_checklist_link', 0),
|
| 82 |
);
|
| 83 |
$form['extras']['seo_checklist_thanks'] = array(
|
| 84 |
'#type' => 'checkbox',
|
| 85 |
'#title' => t("Link to us then send us feedback on the Drupal 6 SEO Checklist module or just say \"Thanks!\" and we will link to you from our website. Send your feedback and link information to !email. (If you don't know why you should link with other websites, read this: !link.)", array('!email' => l('seochecklist@volacci.com', 'mailto:seochecklist@volacci.com'), '!link' => l('Why links help SEO', 'http://www.volacci.com/why-links-help-seo'))),
|
| 86 |
'#default_value' => variable_get('seo_checklist_thanks', 0),
|
| 87 |
);
|
| 88 |
$form['extras']['seo_checklist_podcast'] = array(
|
| 89 |
'#type' => 'checkbox',
|
| 90 |
'#title' => t("Listen to the Volacci Drupal SEO Podcast for more tips and tricks about Drupal SEO: !link", array('!link' => l('http://www.volacci.com/podcast', 'http://www.volacci.com/podcast'))),
|
| 91 |
'#default_value' => variable_get('seo_checklist_podcast', 0),
|
| 92 |
);
|
| 93 |
$form['extras']['seo_checklist_book_references'] = array(
|
| 94 |
'#type' => 'checkbox',
|
| 95 |
'#title' => t('Include page number references from the <a href="@book-link">Drupal 6 SEO Book</a> by Ben Finklea.', array('@book-link' => 'http://www.drupalseobook.com/')),
|
| 96 |
'#default_value' => variable_get('seo_checklist_book_references', 1),
|
| 97 |
);
|
| 98 |
|
| 99 |
$form['save'] = array(
|
| 100 |
'#type' => 'submit',
|
| 101 |
'#value' => t('Save'),
|
| 102 |
'#weight' => 100,
|
| 103 |
);
|
| 104 |
|
| 105 |
return $form;
|
| 106 |
}
|
| 107 |
|
| 108 |
/**
|
| 109 |
* Submit callback for seochecklist_admin_settings().
|
| 110 |
*/
|
| 111 |
function seochecklist_admin_settings_submit($form, &$form_state) {
|
| 112 |
global $user;
|
| 113 |
|
| 114 |
foreach ($form_state['values'] as $key => $value) {
|
| 115 |
if (preg_match('/seochecklist_nodetypes/', $key)) {
|
| 116 |
$key = explode('_', $key);
|
| 117 |
$key = $key[2];
|
| 118 |
$current = (bool) db_result(db_query("SELECT completed FROM {seo_checklist} WHERE id = %d", $key));
|
| 119 |
if ($current != $value) {
|
| 120 |
// If the checkbox changed states, update the record.
|
| 121 |
db_query("UPDATE {seo_checklist} SET completed = %d, uid = %d WHERE id = %d", ($value ? time() : 0), $user->uid, $key);
|
| 122 |
}
|
| 123 |
}
|
| 124 |
}
|
| 125 |
|
| 126 |
// Special values not in database.
|
| 127 |
variable_set('seo_checklist_link', $form_state['values']['seo_checklist_link']);
|
| 128 |
variable_set('seo_checklist_thanks', $form_state['values']['seo_checklist_thanks']);
|
| 129 |
variable_set('seo_checklist_podcast', $form_state['values']['seo_checklist_podcast']);
|
| 130 |
variable_set('seo_checklist_book_references', $form_state['values']['seo_checklist_book_references']);
|
| 131 |
}
|