[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/ctools_plugin_example/ -> ctools_plugin_example.module (source)

   1  <?php
   2  // $Id: ctools_plugin_example.module,v 1.1 2009/08/17 22:07:14 merlinofchaos Exp $
   3  
   4  /*
   5   * @file
   6   *
   7   * Working sample module to demonstrate CTools 3 plugins
   8   *
   9   * This sample module is only intended to demonstrate how external modules can
  10   * provide ctools plugins. There is no useful functionality, and it's only
  11   * intended for developers or for educational use.
  12   *
  13   * As far as possible, everything is kept very simple, not exercising all of
  14   * the capabilities of CTools or Panels.
  15   *
  16   * Although the ctools documentation suggests that strict naming conventions
  17   * be followed, this code attempts to follow only the conventions which are
  18   * required (the hooks), in order to demonstrate the difference. You can
  19   * certainly use the conventions, but it's important to know the difference
  20   * between a convention and a requirement.
  21   *
  22   * The advanced_help module is required, because both CTools and this module
  23   * provide help that way.
  24   *
  25   * There is a demonstration panel provided at /ctools_plugin_example/123
  26   */
  27  
  28  /**
  29   * Implementation of hook_menu
  30   */
  31  function ctools_plugin_example_menu() {
  32    $items = array();
  33  
  34    $items["admin/settings/ctools_plugin_example"] = array(
  35      'title' => 'CTools plugin example',
  36      'description' => t("Demonstration code, advanced help, and a demo panel to show how to build ctools plugins."),
  37      'page callback' => 'ctools_plugin_example_explanation_page',
  38      'access arguments' => array('administer site configuration'),
  39      'type' => MENU_NORMAL_ITEM,
  40    );
  41  
  42    return $items;
  43  }
  44  
  45  /**
  46   * Implementation of hook_ctools_plugin_directory().
  47   *
  48   * It simply tells panels where to find the .inc files that define various
  49   * args, contexts, content_types. In this case the subdirectories of
  50   * ctools_plugin_example/panels are used.
  51   */
  52  function ctools_plugin_example_ctools_plugin_directory($module, $plugin) {
  53    if ($module == 'ctools' && !empty($plugin)) {
  54      return "plugins/$plugin";
  55    }
  56  }
  57  
  58  /**
  59   * Implement hook_ctools_plugin_api().
  60   *
  61   * If you do this, CTools will pick up default panels pages in
  62   * <modulename>.pages_default.inc
  63   */
  64  function ctools_plugin_example_ctools_plugin_api($module, $api) {
  65    // @todo -- this example should explain how to put it in a different file.
  66    if ($module == 'panels_mini' && $api == 'panels_default') {
  67      return array('version' => 1);
  68    }
  69    if ($module == 'page_manager' && $api == 'pages_default') {
  70      return array('version' => 1);
  71    }
  72  }
  73  
  74  /**
  75   * Just provide an explanation page for the admin section
  76   * @return unknown_type
  77   */
  78  function ctools_plugin_example_explanation_page() {
  79    $content = '<p>' . t("The CTools Plugin Example is simply a developer's demo of how to create plugins for CTools. It provides no useful functionality for an ordinary user.") . '</p>';
  80  
  81    $content .= '<p>' . t(
  82      'There is a demo panel demonstrating much of the functionality provided at
  83      <a href="@demo_url">CTools demo panel</a>, and you can find documentation on the examples at
  84      !ctools_plugin_example_help.
  85      CTools itself provides documentation at !ctools_help. Mostly, though, the code itself is intended to be the teacher.
  86      You can find it in %path.',
  87      array(
  88        '@demo_url' => url('ctools_plugin_example/xxxxx'),
  89        '!ctools_plugin_example_help' => theme('advanced_help_topic', 'ctools_plugin_example', 'Chaos-Tools--CTools--Plugin-Examples', 'title'),
  90        '!ctools_help' => theme('advanced_help_topic', 'ctools', 'plugins', 'title'),
  91        '%path' => drupal_get_path('module', 'ctools_plugin_example'),
  92      )) . '</p>';
  93  
  94    return $content;
  95  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7