first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<?php
/**
*
* $event['uid'] - a unique id for the event (usually the url).
* $event['summary'] - the name of the event.
* $event['start'] - the formatted start date of the event.
* $event['end'] - the formatted end date of the event.
* $event['all_day'] - whether the item is an all day event.
* $event['rrule'] - the RRULE of the event, if any.
* $event['timezone'] - the formatted timezone name of the event, if any.
* $event['url'] - the url for the event.
* $event['location'] - the name of the event location.
* $event['description'] - a description of the event.
*
* Note that there are empty spaces after RRULE, URL, LOCATION, etc
* that are needed to make sure we get the required line break.
*
* If you are editing this file, remember that all output lines generated by it
* must end with DOS-style \r\n line endings, and not Unix-style \n, in order to
* be compliant with the iCal spec (see http://tools.ietf.org/html/rfc5545#section-3.1)
*/
$date = date_now('UTC');
$current_date = !empty($event['current_date']) ? $event['current_date'] : $date->format(DATE_FORMAT_ICAL);
print "BEGIN:VEVENT\r\n";
print "UID:" . $event['uid'] . "\r\n";
print "SUMMARY:" . $event['summary'] . "\r\n";
print "DTSTAMP:" . $current_date . "Z\r\n";
if ($event['all_day']):
print "DTSTART;VALUE=DATE:" . $event['start'] . "\r\n";
else:
print "DTSTART:" . $event['start'] . "Z\r\n";
endif;
if (!empty($event['end'])):
if (!empty($event['all_day'])):
print "DTEND;VALUE=DATE:" . $event['end'] . "\r\n";
else:
print "DTEND:" . $event['end'] . "Z\r\n";
endif;
endif;
if (!empty($event['rrule'])) {
print $event['rrule'] . "\r\n";
}
if (!empty($event['url'])) {
print "URL;VALUE=URI:" . $event['url'] . "\r\n";
}
if (!empty($event['location'])) {
print "LOCATION:" . $event['location'] . "\r\n";
}
if (!empty($event['description'])) {
print "DESCRIPTION:" . $event['description'] . "\r\n";
}
print "END:VEVENT\r\n";

View File

@@ -0,0 +1,22 @@
<?php
/**
* $title
* The name of the calendar.
*
* If you are editing this file, remember that all output lines generated by it
* must end with DOS-style \r\n line endings, and not Unix-style \n, in order to
* be compliant with the iCal spec (see http://tools.ietf.org/html/rfc5545#section-3.1)
*/
if (empty($method)) {
$method = 'PUBLISH';
}
print "BEGIN:VCALENDAR\r\n";
print "VERSION:2.0\r\n";
print "METHOD:$method\r\n";
if (!empty($title)) {
print "X-WR-CALNAME;VALUE=TEXT:$title\r\n";
}
print "PRODID:-//Drupal iCal API//EN\r\n";
// Note that $rows already has the right line endings and needs no more.
print "$rows";
print "END:VCALENDAR\r\n";

View File

@@ -0,0 +1,22 @@
name = Calendar iCal DEPRECATED!
description = DEPRECATED, Use Date iCal instead.
dependencies[] = views
dependencies[] = date_api
dependencies[] = date_views
dependencies[] = calendar
package = Date/Time
core = 7.x
files[] = calendar_ical.install
files[] = calendar_ical.module
files[] = calendar_plugin_style_ical.inc
files[] = calendar_plugin_row_ical_node.inc
files[] = calendar-style-ical.tpl.php
files[] = calendar-row-ical-node.tpl.php
files[] = theme.inc
; Information added by drupal.org packaging script on 2012-02-24
version = "7.x-3.0"
core = "7.x"
project = "calendar"
datestamp = "1330089637"

View File

@@ -0,0 +1,11 @@
<?php
/**
* @file
* Install, update and uninstall functions for the calendar_ical module.
*
*/
function calendar_ical_update_last_removed() {
return 6000;
}

View File

@@ -0,0 +1,95 @@
<?php
/**
* Implementation of hook_views_api().
*
* This one is used as the base to reduce errors when updating.
*/
function calendar_ical_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'calendar_ical'),
);
}
/**
* @file
* Adds ical functionality to Calendar.
*/
function calendar_ical_theme() {
return array(
'calendar_ical_icon' => array(
'variables' => array('url'),
),
);
}
function theme_calendar_ical_icon($vars) {
$url = $vars['url'];
$variables = array(
'path' => drupal_get_path('module', 'date_api') . '/images/ical16x16.gif',
'title' => t('Add to calendar'), t('Add to calendar'),
);
if ($image = theme('image', $variables)) {
return '<div style="text-align:right"><a href="' . check_url($url) . '" class="ical-icon" title="ical">' . $image . '</a></div>';
}
}
/**
* Implements hook_entity_info_alter().
*
* Add an 'iCal' view mode for nodes, similar to RSS view mode.
*/
function calendar_ical_entity_info_alter(&$info) {
$info['node']['view modes'] += array(
'ical' => array(
'label' => t('iCal'),
'custom settings' => FALSE,
),
);
}
/**
* Implementation of hook_views_plugins
*/
function calendar_ical_views_plugins() {
$module_path = drupal_get_path('module', 'calendar_ical');
module_load_include('inc', 'calendar_ical', 'theme.inc');
$data = array(
'module' => 'calendar_ical', // This just tells our themes are elsewhere.
'style' => array(
'ical' => array(
'title' => t('DEPRECATED iCal Feed'),
'help' => t('Generates an iCal VCALENDAR feed from a view.'),
'handler' => 'calendar_plugin_style_ical',
'path' => "$module_path",
'theme' => 'calendar_style_ical',
'theme file' => 'theme.inc',
'theme path' => "$module_path",
'uses fields' => TRUE,
'uses grouping' => FALSE,
'uses row plugin' => TRUE,
'uses options' => TRUE,
'type' => 'feed',
'even empty' => TRUE,
),
),
'row' => array(
'ical_node' => array(
'title' => t('DEPRECATED iCal Fields'),
'help' => t('Display each node as an iCal VEVENT item.'),
'handler' => 'calendar_plugin_row_ical_node',
'path' => "$module_path",
'theme' => 'calendar_row_ical_node',
'theme file' => 'theme.inc',
'theme path' => "$module_path",
'base' => array('node'), // only works with 'node' as base.
'uses options' => TRUE,
'uses fields' => FALSE,
'type' => 'feed',
),
),
);
return $data;
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* @file
* Contains the iCal row style plugin.
*/
/**
* Plugin which creates a view on the resulting object
* and formats it as an iCal VEVENT.
*/
class calendar_plugin_row_ical_node extends views_plugin_row {
// Basic properties that let the row style follow relationships.
var $base_table = 'node';
var $base_field = 'nid';
// Stores the nodes loaded with pre_render.
var $nodes = array();
function option_definition() {
$options = parent::option_definition();
$options['date_field'] = array('default' => array());
return $options;
}
/**
* Provide a form for setting options.
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$data = date_views_fields('node');
$options = array();
foreach ($data['name'] as $item => $value) {
// We only want to see one value for each field, skip '_value2', and other columns.
if ($item == $value['fromto'][0]) {
$options[$item] = $value['label'];
}
}
$form['date_field'] = array(
'#type' => 'select',
'#title' => t('Date field'),
'#options' => $options,
'#default_value' => $this->options['date_field'],
'#description' => t('Please identify the node field to use as the iCal date for each item in this view. Add a Date Filter or a Date Argument to the view to limit results to content in a specified date range.'),
'#required' => TRUE,
'#prefix' => t("The node title will be used as the 'summary' and the node view will be used as the 'description' for the iCal event. To control the description, hide or show fields for the iCal view mode on the 'Display Fields' screen. Keep in mind that any html in the node view will be stripped out in the feed, to comply with the iCal standards."),
);
}
function pre_render($values) {
$nids = array();
foreach ($values as $row) {
$nids[] = $row->{$this->field_alias};
}
if (!empty($nids)) {
$this->nodes = node_load_multiple($nids);
}
}
function render($row) {
global $base_url;
$nid = $row->{$this->field_alias};
if (!is_numeric($nid)) {
return;
}
// Load the specified node:
$node = $this->nodes[$nid];
if (empty($node)) {
return;
}
$data = date_views_fields('node');
$info = $data['name'][$this->options['date_field']];
$field_name = str_replace(array('_value', '_value2'), '', $info['real_field_name']);
$table_name = $info['table_name'];
$delta_field = $info['delta_field'];
$is_field = $info['is_field'];
// Identify the field value that matched our query.
$item = $node->$field_name;
$node->date_id = array();
$start = NULL;
$end = NULL;
if ($is_field) {
$lang = $node->language;
$delta = isset($row->$delta_field) ? $row->$delta_field : 0;
$item = array_key_exists($lang, $item) ? $item[$lang][$delta] : $item['und'][$delta];
$node->date_id[] = 'calendar.' . $node->nid . '.' . $field_name . '.' . $delta;
if (!empty($item['value'])) {
$start = new dateObject($item['value'], $item['timezone_db']);
if (array_key_exists('value2', $item)) {
$end = new dateObject($item['value2'], $item['timezone_db']);
}
else {
$end = clone $start;
}
}
}
elseif (!$is_field && !empty($item)) {
$start = new dateObject($item, $item['timezone_db']);
$end = new dateObject($item, $item['timezone_db']);
}
// Set the item date to the proper display timezone;
$start->setTimezone(new dateTimezone($item['timezone']));
$end->setTimezone(new dateTimezone($item['timezone']));
$start_formatted = $start->format(DATE_FORMAT_DATETIME);
$end_formatted = $end->format(DATE_FORMAT_DATETIME);
$all_day = date_is_all_day($start_formatted, $end_formatted, date_granularity_precision($info['granularity']));
// According to RFC 2445 (clarified in RFC 5545) the DTEND value is
// non-inclusive. When it is a DATE rather than a DATETIME, this means
// that we should add one day to its value.
if ($all_day) {
$end->modify("+1 day");
}
// If we don't have an iCal date value, go no further.
if (empty($start)) {
return;
}
module_load_include('inc', 'date_api', 'date_api_ical');
$item_text = '';
// Create the rendered display using the display settings from the 'iCal' view mode.
node_build_content($node, 'ical');
if (!empty($node->content)) {
// We render node contents and force links to be last.
$links = drupal_render($node->content['links']);
$item_text .= drupal_render($node->content) . $links;
}
$event = array();
$event['summary'] = date_ical_escape_text($node->title);
$event['all_day'] = $all_day;
$event['start'] = $start->format($all_day ? DATE_FORMAT_ICAL_DATE : DATE_FORMAT_ICAL);
$event['end'] = $end->format($all_day ? DATE_FORMAT_ICAL_DATE : DATE_FORMAT_ICAL);
$event['description'] = date_ical_escape_text($item_text);
$event['url'] = url("node/$node->nid", array('absolute' => TRUE));
$event['uid'] = !empty($node->date_id) ? $node->date_id[0] : $event['url'];
$event['rrule'] = $is_field && array_key_exists('rrule', $item) ? $item['rrule'] : '';
return theme($this->theme_functions(),
array(
'view' => $this->view,
'options' => $this->options,
'event' => $event
));
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* @file
* Views style plugin for the Calendar iCal module.
*/
/**
* Default style plugin to render an iCal feed.
*/
class calendar_plugin_style_ical extends views_plugin_style_rss {
function attach_to($display_id, $path, $title) {
$display = $this->view->display[$display_id]->handler;
$url_options = array();
$input = $this->view->get_exposed_input();
if ($input) {
$url_options['query'] = $input;
}
$url_options['absolute'] = TRUE;
$url = url($this->view->get_url(NULL, $path), $url_options);
if (empty($this->preview)) {
$this->view->feed_icon = theme('calendar_ical_icon', array('url' => $url, 'title' => $title));
drupal_add_html_head_link(array(
'rel' => 'alternate',
'type' => 'application/calendar',
'title' => $title,
'href' => $url
));
}
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Override the text in the RSS description field.
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('iCal description'),
'#default_value' => $this->options['description'],
'#description' => t('This will appear in the iCal feed itself.'),
);
}
function render() {
if (empty($this->row_plugin)) {
debug('views_plugin_style_default: Missing row plugin');
return;
}
$rows = '';
foreach ($this->view->result as $row_index => $row) {
$this->view->row_index = $row_index;
$rows .= $this->row_plugin->render($row);
}
$output = theme($this->theme_functions(),
array(
'view' => $this->view,
'options' => $this->options,
'rows' => $rows
));
unset($this->view->row_index);
return $output;
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* @file
* Theme files for Calendar iCal.
*/
/**
* Preprocess an iCal feed
*/
function template_preprocess_calendar_style_ical(&$vars) {
global $base_url;
global $language;
$view = $vars['view'];
$view_title = $view->get_title();
$title = variable_get('site_name', 'Drupal');
if ($slogan = variable_get('site_slogan', '')) {
$title .= ' - ' . $slogan;
}
$title .= !empty($view_title) ? ': ' . $view_title : '';
$vars['title'] = check_plain($title);
// During live preview we don't want to output the header since the contents
// of the feed are being displayed inside a normal HTML page.
if (empty($vars['view']->live_preview)) {
// Keep devel module from appending queries to ical export.
$GLOBALS['devel_shutdown'] = FALSE;
drupal_add_http_header('Content-Type', 'application/calendar; charset=utf-8');
}
}
/**
* Default theme function for all iCal rows.
*/
function template_preprocess_calendar_row_ical_node(&$vars) {
$view = &$vars['view'];
$options = &$vars['options'];
$item = &$vars['row'];
}