diff -u simpleviews.module simpleviews.module --- simpleviews.module 29 Oct 2009 16:37:02 -0000 +++ simpleviews.module 2 Nov 2009 22:39:32 -0000 @@ -63,18 +63,23 @@ } /** - * Implementation of hook_perm(). + * Implement hook_permission(). * * Defines access permissions that may be assigned to roles and used to restrict * access. */ -function simpleviews_perm() { - return array('administer simpleviews'); +function simpleviews_permission() { + return array( + 'administer simpleviews' => array( + 'title' => t('Administer SimpleViews'), + 'description' => t('Create, edit and delete Views via the SimpleViews interface.'), + ), + ); } /** - * Implementation of hook_theme(). + * Implement hook_theme(). * * Returns information about every themable function defined by the module. */ @@ -82,11 +87,11 @@ $items = array(); $items['simpleviews_overview_form'] = array( - 'arguments' => array('form' => array()), + 'render element' => 'form', 'file' => 'simpleviews.pages.inc', ); $items['simpleviews_edit_form'] = array( - 'arguments' => array('form' => array()), + 'render element' => 'form', 'file' => 'simpleviews.pages.inc', ); @@ -94,7 +99,7 @@ } /** - * Implementation of hook_form_alter(). + * Implement hook_form_alter(). * * Adds the 'make a listing page' checkbox on each content type's settings form. */ @@ -138,8 +143,7 @@ * A single record in array format, or FALSE if none matched the incoming ID. */ function simpleviews_item_load($svid) { - $sql = "SELECT * FROM {simpleviews} WHERE svid = %d"; - $result = db_query($sql, $svid); + $result = db_query("SELECT * FROM {simpleviews} WHERE svid = :svid", array(':svid' => $svid)); if ($record = $result->fetchAssoc()) { return $record; } @@ -184,14 +188,13 @@ * An int containing the ID of an item. */ function simpleviews_item_delete($svid) { - $sql = 'DELETE FROM {simpleviews} WHERE svid = %d'; - db_query($sql, $svid); - + db_query('DELETE FROM {simpleviews} WHERE svid = :svid', array(':svid' => $svid)); + module_invoke_all('simpleviews_refresh'); } /** - * Implementation of hook_views_api. + * Implement hook_views_api(). */ function simpleviews_views_api() { return array( diff -u simpleviews.pages.inc simpleviews.pages.inc --- simpleviews.pages.inc 29 Oct 2009 16:37:02 -0000 +++ simpleviews.pages.inc 2 Nov 2009 22:39:32 -0000 @@ -12,7 +12,7 @@ * @see simpleviews_overview_form_submit() * @see theme_simpleviews_overview_form() */ -function simpleviews_overview_form(&$form_state) { +function simpleviews_overview_form($form, &$form_state) { $results = db_query( "SELECT * FROM {simpleviews}", array(), @@ -59,19 +59,19 @@ $path = drupal_get_path('module', 'simpleviews') . '/images/'; $links[] = array( - 'title' => theme('image', $path . 'text-editor.png', t('Edit')), + 'title' => theme('image', array('path' => $path . 'text-editor.png', 'alt' => t('Edit'))), 'href' => 'admin/structure/simpleviews/' . $item['svid'] . '/edit', 'html' => TRUE, ); $links[] = array( - 'title' => theme('image', $path . 'edit-delete.png', t('Delete')), + 'title' => theme('image', array('path' => $path . 'edit-delete.png', 'alt' => t('Delete'))), 'href' => 'admin/structure/simpleviews/' . $item['svid'] . '/delete', 'html' => TRUE, ); $form['operations'] = array( '#type' => 'markup', - '#markup' => theme('links', $links), + '#markup' => theme('links', array('links' => $links)), ); return $form; @@ -86,7 +86,8 @@ * @ingroup forms * @see simpleviews_overview_form() */ -function theme_simpleviews_overview_form($form) { +function theme_simpleviews_overview_form($variables) { + $form = $variables['form']; $rows = array(); foreach (element_children($form['items']) as $key) { $row = array(); @@ -110,7 +111,7 @@ // on the form itself after we're done, so hidden security fields and other // elements (like buttons) will appear properly at the bottom of the form. $header = array(t('Title'), t('Path'), t('Operations')); - $output = theme('table', $header, $rows); + $output = theme('table', array('header' => $header, 'rows' => $rows)); $output .= drupal_render_children($form); return $output; @@ -130,7 +131,7 @@ * @see simpleviews_form_submit() * @see simpleviews_form_delete() */ -function simpleviews_form(&$form_state, $simpleview = array()) { +function simpleviews_form($form, &$form_state, $simpleview = array()) { $form['simpleview'] = _simpleviews_form($simpleview); $form['buttons']['submit'] = array( @@ -282,7 +283,8 @@ /** * Simple theme wrapper for the simpleview edit form, adds CSS and JS. */ -function theme_simpleviews_edit_form($form) { +function theme_simpleviews_edit_form($variables) { + $form = $variables['form']; drupal_add_css(drupal_get_path('module', 'simpleviews') . '/simpleviews.css'); drupal_add_js(drupal_get_path('module', 'simpleviews') . '/simpleviews.js'); @@ -337,7 +339,7 @@ * @see simpleviews_delete_confirm_submit() * @see confirm_form() */ -function simpleviews_delete_confirm(&$form_state, $item) { +function simpleviews_delete_confirm($form, &$form_state, $item) { $form['svid'] = array( '#type' => 'value', '#value' => $item['svid'], @@ -362,7 +364,6 @@ * @ingroup formapi * @see simpleviews_form() */ - function simpleviews_delete_confirm_submit($form, &$form_state) { if ($form_state['values']['confirm']) { simpleviews_item_delete($form_state['values']['svid']);