You are here

mmenu.install in Mobile sliding menu 7

Same filename and directory in other branches
  1. 8 mmenu.install
  2. 7.3 mmenu.install
  3. 7.2 mmenu.install

Install and uninstall functions for the mobile sliding menu module.

File

mmenu.install
View source
<?php

/**
 * @file
 * Install and uninstall functions for the mobile sliding menu module.
 */

/**
 * Removes variables on uninstall.
 */
function mmenu_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'mmenu_%'");
  cache_clear_all('variables', 'cache');
}

/**
 * Implementation of hook_requirements().
 *
 * @param $phase The phase in which hook_requirements is run: install/runtime.
 */
function mmenu_requirements($phase) {
  $t = get_t();
  $requirements = array();
  switch ($phase) {
    case 'runtime':
      $library_main = libraries_detect('mmenu.main');
      $library_hammer = libraries_detect('mmenu.hammer');
      $library_jquery_hammer = libraries_detect('mmenu.jquery.hammer');
      $description_installed = t('To check for newer versions of Mmenu, go to <a href="!url" target="_blank">' . $library_main['vendor url'] . '</a>.', array(
        "!url" => $library_main['vendor url'],
      ));
      $description_missing = t('The Mmenu library was not detected. Please follow the instructions on the <a href="!url" target="_blank">Mmenu project page</a> to install the Mmenu library.', array(
        "!url" => url('http://drupal.org/project/mmenu'),
      ));
      if (!empty($library_main['installed'])) {
        $requirements['mmenu_main_version'] = array(
          'title' => $t('Mmenu: Main'),
          'value' => $library_main['version'],
          'description' => $description_installed,
          'severity' => REQUIREMENT_OK,
        );
      }
      else {
        $requirements['mmenu_main_library'] = array(
          'title' => $t('Mmenu: Main'),
          'value' => $t('Missing'),
          'description' => $description_missing . ' ' . $description_installed,
          'severity' => REQUIREMENT_ERROR,
        );
      }
      $description_installed = t('To check for newer versions of Hammer.js, go to <a href="!url" target="_blank">' . $library_hammer['vendor url'] . '</a>.', array(
        "!url" => $library_hammer['vendor url'],
      ));
      $description_missing = t('The Hammer.js library was not detected. Please follow the instructions on the <a href="!url" target="_blank">Mmenu project page</a> to install the library.', array(
        "!url" => url('http://drupal.org/project/mmenu'),
      ));
      if (!empty($library_hammer['installed'])) {
        $requirements['mmenu_hammer_version'] = array(
          'title' => $t('Mmenu: Hammer.js'),
          'value' => $library_hammer['version'],
          'description' => $description_installed,
          'severity' => REQUIREMENT_OK,
        );
      }
      else {
        $requirements['mmenu_hammer_library'] = array(
          'title' => $t('Mmenu: Hammer.js'),
          'value' => $t('Missing'),
          'description' => $description_missing . ' ' . $description_installed,
          'severity' => REQUIREMENT_ERROR,
        );
      }
      $description_installed = t('To check for newer versions of jQuery plugin for Hammer.js, go to <a href="!url" target="_blank">' . $library_jquery_hammer['vendor url'] . '</a>.', array(
        "!url" => $library_jquery_hammer['vendor url'],
      ));
      $description_missing = t('The jQuery plugin for Hammer.js library was not detected. Please follow the instructions on the <a href="!url" target="_blank">Mmenu project page</a> to install the library.', array(
        "!url" => url('http://drupal.org/project/mmenu'),
      ));
      if (!empty($library_jquery_hammer['installed'])) {
        $requirements['mmenu_jquery_hammer_version'] = array(
          'title' => $t('Mmenu: jQuery plugin for Hammer.js'),
          'value' => $library_jquery_hammer['version'],
          'description' => $description_installed,
          'severity' => REQUIREMENT_OK,
        );
      }
      else {
        $requirements['mmenu_jquery_hammer_library'] = array(
          'title' => $t('Mmenu: jQuery plugin for Hammer.js'),
          'value' => $t('Missing'),
          'description' => $description_missing . ' ' . $description_installed,
          'severity' => REQUIREMENT_ERROR,
        );
      }
      break;
  }
  return $requirements;
}

Functions

Namesort descending Description
mmenu_requirements Implementation of hook_requirements().
mmenu_uninstall Removes variables on uninstall.