| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: seochecklist.admin.inc,v 1.11 2010/05/25 13:13:44 eclipsegc Exp $ 3 4 /** 5 * @file 6 * Administrative page callbacks for the seochecklist module. 7 */ 8 9 define('SEOCHECKLIST_BOOK_PURCHASE', 'http://www.packtpub.com/drupal-6-search-engine-optimization-seo/mid/170909568gh3?utm_source=volacci.com%2F&utm_medium=affiliate&utm_content=authorsite&utm_campaign=mdb_000690'); 10 11 /** 12 * Define the settings form. 13 */ 14 function seochecklist_admin_settings() { 15 global $user; 16 17 $form['save_above'] = array( 18 '#type' => 'submit', 19 '#value' => t('Save'), 20 ); 21 22 // Fetch modules and groups from database. 23 $query = "SELECT id, name, description FROM {seo_group} ORDER BY id"; 24 25 $result = db_query($query); 26 $group_id = 0; 27 28 // Every group is a fieldset. 29 while ($data = db_fetch_object($result)) { 30 $group_id = intval($data->id); 31 32 $form['group_' . $group_id] = array( 33 '#type' => 'fieldset', 34 '#title' => t($data->name), 35 '#collapsible' => TRUE, 36 '#description' => t($data->description), 37 '#group' => 'seochecklist', 38 ); 39 40 $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); 41 while ($row = db_fetch_object($res)) { 42 $row->links = array(); 43 44 if ($row->completed) { 45 // Show when and who completed this task. 46 $row->links[] = t('Completed on %date by !username', array('%date' => format_date($row->completed, 'small'), '!username' => theme('username', user_load($row->uid)))); 47 } 48 else { 49 // Show non-completed sub-tasks. 50 if ($row->download) { 51 $row->links[] = l(t('Download'), $row->download, array('attributes' => array('target' => '_blank'))); 52 } 53 if ($row->enable) { 54 $row->links[] = l(t('Enable'), $row->enable); 55 } 56 } 57 58 if ($row->configure && (!$row->module || module_exists($row->module))) { 59 // Show the link to configure if this isn't a module or module is enabled. 60 $row->links[] = l(t('Configure'), $row->configure); 61 } 62 63 if (variable_get('seo_checklist_book_references', 1) && $page = seochecklist_get_book_references($row->id)) { 64 $row->links[] = t('See <a href="@book-purchase">Drupal 6 SEO</a> p. @page', array('@page' => $page, '@book-purchase' => SEOCHECKLIST_BOOK_PURCHASE)); 65 } 66 67 $task = $form['group_' . $group_id]['seochecklist_task_' . $row->id] = array( 68 '#type' => 'checkbox', 69 '#title' => t($row->name), 70 '#default_value' => $row->completed || ($row->module && module_exists($row->module)), 71 '#description' => join(' | ', $row->links), 72 ); 73 if (strpos($row->name, 'Clean URLs') === 0) { 74 $task['#disabled'] = !variable_get('clean_url', 0); 75 $task['#default_value'] |= variable_get('clean_url', 0); 76 } 77 } 78 } 79 80 $form['extras'] = array( 81 '#type' => 'fieldset', 82 '#title' => t('Extras'), 83 '#collapsible' => TRUE, 84 '#group' => 'seochecklist', 85 ); 86 $form['extras']['seo_checklist_link'] = array( 87 '#type' => 'checkbox', 88 '#title' => t('Link to Volacci to thank them for this awesome module.'), 89 '#default_value' => variable_get('seo_checklist_link', 0), 90 '#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!'), 91 ); 92 $form['extras']['seo_checklist_thanks'] = array( 93 '#type' => 'checkbox', 94 '#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')), 95 '#default_value' => variable_get('seo_checklist_thanks', 0), 96 '#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')), 97 ); 98 $form['extras']['seo_checklist_podcast'] = array( 99 '#type' => 'checkbox', 100 '#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')), 101 '#default_value' => variable_get('seo_checklist_podcast', 0), 102 ); 103 $form['extras']['seo_checklist_book_references'] = array( 104 '#type' => 'checkbox', 105 '#title' => t('Include page number references from the <a href="@book">Drupal 6 SEO Book</a> by Ben Finklea.', array('@book' => 'http://www.drupalseobook.com/')), 106 '#default_value' => variable_get('seo_checklist_book_references', 1), 107 '#description' => t('<a href="@book-purchase">Purchase from Packt Publishing</a>', array('@book-purchase' => SEOCHECKLIST_BOOK_PURCHASE)), 108 ); 109 $form['extras']['buy_seo_book'] = array( 110 '#type' => 'checkbox', 111 '#title' => t('Buy Drupal 6 Search Engine Optimization by Ben Finklea from <a href="@amazon">Amazon</a> or <a href="@packt">Packt</a>.', array('@amazon' => 'http://www.amazon.com/gp/product/1847198228?ie=UTF8&tag=dvdcentral02&linkCode=as2&camp=1789&creative=390957&creativeASIN=1847198228', '@packt' => 'https://www.packtpub.com/drupal-6-search-engine-optimization-seo/book?mid/170909568gh3')), 112 '#default_value' => variable_get('seo_checklist_buy_book', 1), 113 ); 114 115 $form['save'] = array( 116 '#type' => 'submit', 117 '#value' => t('Save'), 118 '#weight' => 100, 119 ); 120 121 if (module_exists('vertical_tabs')) { 122 $form['#pre_render'][] = 'vertical_tabs_form_pre_render'; 123 $form['save_above']['#attributes']['class'] = 'js-hide'; 124 } 125 else { 126 drupal_set_message(t('Your SEO Checklist interface (in addition to your content and content type edit pages) will be greatly enhanced by installing the <a href="@vertical-tabs">Vertical Tabs module</a>.', array('@vertical-tabs' => 'http://drupal.org/project/vertical_tabs')), 'status', FALSE); 127 } 128 129 return $form; 130 } 131 132 /** 133 * Submit callback for seochecklist_admin_settings(). 134 */ 135 function seochecklist_admin_settings_submit($form, &$form_state) { 136 global $user; 137 138 $count = 0; 139 foreach ($form_state['values'] as $key => $value) { 140 if (preg_match('/seochecklist_task_/', $key)) { 141 $key = explode('_', $key); 142 $key = $key[2]; 143 $current = (bool) db_result(db_query("SELECT completed FROM {seo_checklist} WHERE id = %d", $key)); 144 if ($current != $value) { 145 // If the checkbox changed states, update the record. 146 db_query("UPDATE {seo_checklist} SET completed = %d, uid = %d WHERE id = %d", ($value ? time() : 0), $user->uid, $key); 147 $count++; 148 } 149 } 150 } 151 152 // Special values not in database. 153 variable_set('seo_checklist_link', $form_state['values']['seo_checklist_link']); 154 variable_set('seo_checklist_thanks', $form_state['values']['seo_checklist_thanks']); 155 variable_set('seo_checklist_podcast', $form_state['values']['seo_checklist_podcast']); 156 variable_set('seo_checklist_book_references', $form_state['values']['seo_checklist_book_references']); 157 158 drupal_set_message(format_plural($count, 'Updated @count task successfully.', 'Updated @count tasks successfully.')); 159 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |