You are here

search_autocomplete.admin.inc in Search Autocomplete 6.4

Search Autocomplete Sets the admin part of the module: permissions, hooks, callbacks, etc...

@author Miroslav Talenberg (Dominique CLAUSE) <http://www.axiomcafe.fr/contact>

Sponsored by: www.axiomcafe.fr

File

search_autocomplete.admin.inc
View source
<?php

/**
 * @file
 * Search Autocomplete
 * Sets the admin part of the module: permissions, hooks, callbacks, etc...
 *
 * @author
 * Miroslav Talenberg (Dominique CLAUSE) <http://www.axiomcafe.fr/contact>
 *
 * Sponsored by:
 * www.axiomcafe.fr
 */

/**
 * Implementation of hook_perm().
 * Valid permissions for this module
 * @return
 *   An array of valid permissions for the autocomplete module
 */
function search_autocomplete_perm() {
  return array(
    t('administer Search Autocomplete'),
    t('use Search Autocomplete'),
  );
}

// function search_autocomplete_perm()

/**
 * Implementation of hook_theme().
 * Define the function to render our forms
 */
function search_autocomplete_theme($existing, $type, $theme, $path) {
  return array(
    'search_autocomplete_treelist_form' => array(
      // register theme function for draggable treelist search forms
      'arguments' => array(
        'form' => NULL,
      ),
    ),
  );
}

/**
 * Implementation of hook_menu().
 * Create an administration page to access admin form
 */
function search_autocomplete_menu() {

  // create the admin setting page: list of forms
  $items['admin/settings/search_autocomplete'] = array(
    'title' => 'Search Autocomplete settings',
    'description' => 'Choose settings for autocompletion in input forms.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_autocomplete_treelist_form',
    ),
    'access arguments' => array(
      t('administer Search Autocomplete'),
    ),
    'file' => 'search_autocomplete.form.treelist.inc',
  );
  $items['admin/settings/search_autocomplete/treelist'] = array(
    'title' => 'Search Autocomplete',
    'access arguments' => array(
      t('administer Search Autocomplete'),
    ),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -1,
  );

  // create an admin setting page: add a new form
  $items['admin/settings/search_autocomplete/add'] = array(
    'title' => 'Add a form',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_autocomplete_form_add',
    ),
    'access arguments' => array(
      t('administer Search Autocomplete'),
    ),
    'file' => 'search_autocomplete.form.add.inc',
    'type' => MENU_LOCAL_TASK,
  );

  // create an admin setting page: configure a form
  $items['admin/settings/search_autocomplete/%/configure'] = array(
    'title' => 'Search Autocomplete - Configuration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_autocomplete_form_configure',
    ),
    'access arguments' => array(
      t('administer Search Autocomplete'),
    ),
    'file' => 'search_autocomplete.form.configure.inc',
  );

  // create an admin setting page: delete a form
  $items['admin/settings/search_autocomplete/%/delete'] = array(
    'title' => 'Search Autocomplete - Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_autocomplete_form_delete',
    ),
    'access arguments' => array(
      t('administer Search Autocomplete'),
    ),
    'file' => 'search_autocomplete.form.delete.inc',
  );

  // create a callback page for JSON suggestions
  $items['search_autocomplete/autocomplete'] = array(
    'title' => 'Autocompleton when using view',
    'page callback' => 'search_autocomplete_autocomplete',
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
    'access arguments' => array(
      'access content',
    ),
    'file' => 'search_autocomplete.autocomplete.inc',
  );
  $items['views/autocomplete'] = array(
    'title' => 'Autocomplete view selector',
    'page callback' => 'search_autocomplete_views_autocomplete',
    // access not properly checked on callbacks (see function)
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
    'access arguments' => array(
      'access content',
    ),
    'file' => 'search_autocomplete.autocomplete.inc',
  );
  return $items;
}

/**
 * Implements hook_help().
 */
function search_autocomplete_help($path, $arg) {
  $help = '';
  switch ($path) {
    case 'admin/modules#description':
      $help = t('Allows the users with the right permission to use advanced autocompletion features on forms.');
      break;
    case 'admin/settings/search_autocomplete':
      $help = '<div>' . t('Search Autocomplete helps you to enhance your search forms with autocompleted suggestions.') . '</div>';
      $help .= '<div>' . t('Use this form to activate the forms you want to autocomplete.') . '</div>';
      $help .= '<div>' . t('You may want to add new possible form to autocomplete. To do so, please use the tab <a href="search_autocomplete/add">Add a form</a>.') . '</div>';
      break;
    case 'admin/settings/search_autocomplete/add':
      $help = '<div>' . t('This page allows you to add a new form to be autocompleted with the Search Autocomplete module.') . '</div>';
      $help .= '<div>' . t('This is an advanced feature configuration. Use it only if you know what you are doing and after reading <a href="http://projects.axiomcafe.fr/search-autocomplete">documentation</a>. If you wish help, please ask for a new default form to be added in the next release of Search Autocomplete module.') . '</div>';
      break;
    case 'admin/settings/search_autocomplete/%/configure':
      $help = '<div>' . t('You are currently configuring the options to autocomplete a form.') . '</div>';
      $help .= '<div>' . t('Every children forms will be modified as well.') . '</div>';
      break;
  }
  return $help;
}

Functions

Namesort descending Description
search_autocomplete_help Implements hook_help().
search_autocomplete_menu Implementation of hook_menu(). Create an administration page to access admin form
search_autocomplete_perm Implementation of hook_perm(). Valid permissions for this module
search_autocomplete_theme Implementation of hook_theme(). Define the function to render our forms