You are here

jcalendar.module in Calendar 5.2

Same filename and directory in other branches
  1. 6.2 jcalendar/jcalendar.module

jQuery Calendar UI features.

File

jcalendar/jcalendar.module
View source
<?php

/**
 * @file
 * jQuery Calendar UI features.
 */

/**
* Display help and module information
* @param section which section of the site we're displaying help
* @return help text for section
*/
function jcalendar_help($section = '') {
  $output = '';
  switch ($section) {
    case "admin/help#jcalendar":
      $output = '<p>' . t("Creates a popup for calendar dates.") . '</p>';
      break;
  }
  return $output;
}

// function jcalendar_help

/**
* Get calendar node for popup
* @param integer nid Node id.
* @param string id Date field unique id.
* @return string HTML for node
*/
function get_calendar_node($nid, $id) {
  $GLOBALS['devel_shutdown'] = FALSE;
  if (is_numeric($nid)) {
    if ($node = node_load($nid)) {
      if (node_access("view", $node)) {
        $node->date_id = $id;
        $node->date_repeat_show = FALSE;
        print theme('jcalendar_view', $node);
      }
    }
  }
}

/**
* Implemetation of hook_menu()
*/
function jcalendar_menu($may_cache) {
  $items = array();
  if (!$may_cache) {
    $items[] = array(
      'path' => 'jcalendar/getnode',
      'title' => 'Get Calendar Node',
      'callback' => 'get_calendar_node',
      'callback arguments' => array(
        arg(2),
        arg(3),
      ),
      'access' => true,
      'type' => MENU_CALLBACK,
    );
    return $items;
  }
}

/**
* Override the calendar view to inject javascript.
* @param view Which view we are using.
* @return unknown as of yet.
*/
function jcalendar_views_pre_view(&$view) {
  if ($view->calendar_display == 'calendar') {
    $path = drupal_get_path('module', 'jcalendar');
    drupal_add_js('var var_path = ' . drupal_to_js(base_path() . $path) . ";", 'inline');
    drupal_add_js('var var_base_path = ' . drupal_to_js(base_path()) . ";", 'inline');
    drupal_add_js($path . '/jcalendar.js');
    drupal_add_css($path . '/jcalendar.css');
  }
}

/**
 * Overrideable theme for the jcalendar popup view.
 * 
 * Defaults to show the standard teaser view of the node.
 */
function theme_jcalendar_view($node) {
  $output = node_view($node, TRUE);
  $output .= '<div id="nodelink">' . l(t('more'), calendar_get_node_link($node)) . '</div>';
  return $output;
}

Functions

Namesort descending Description
get_calendar_node Get calendar node for popup
jcalendar_help Display help and module information
jcalendar_menu Implemetation of hook_menu()
jcalendar_views_pre_view Override the calendar view to inject javascript.
theme_jcalendar_view Overrideable theme for the jcalendar popup view.