Révision 62e0cc08
Ajouté par Assos Assos il y a plus de 3 ans
drupal7/sites/all/modules/date_ical/includes/date_ical_plugin_row_ical_fields.inc | ||
---|---|---|
19 | 19 |
$options['title_field'] = array('default' => ''); |
20 | 20 |
$options['description_field'] = array('default' => ''); |
21 | 21 |
$options['location_field'] = array('default' => ''); |
22 |
$options['categories_field'] = array('default' => ''); |
|
22 | 23 |
$options['additional_settings']['skip_blank_dates'] = array('default' => FALSE); |
23 | 24 |
return $options; |
24 | 25 |
} |
... | ... | |
74 | 75 |
'#default_value' => $this->options['location_field'], |
75 | 76 |
'#required' => FALSE, |
76 | 77 |
); |
78 |
$form['categories_field'] = array( |
|
79 |
'#type' => 'select', |
|
80 |
'#title' => t('Categories field'), |
|
81 |
'#description' => t('(optional) The views field to use as the categories for each event (CATEGORIES).'), |
|
82 |
'#options' => $text_field_label_options, |
|
83 |
'#default_value' => $this->options['categories_field'], |
|
84 |
'#required' => FALSE, |
|
85 |
); |
|
77 | 86 |
$form['additional_settings'] = array( |
78 | 87 |
'#type' => 'fieldset', |
79 | 88 |
'#title' => t('Additional settings'), |
... | ... | |
133 | 142 |
if (empty($title)) { |
134 | 143 |
$title = "Undetermined title"; |
135 | 144 |
} |
136 |
throw new BlankDateFieldException(t("The row titled %title has no available Date value. An iCal entry cannot be created for it.", array('%title' => $title))); |
|
145 |
throw new BlankDateFieldException( |
|
146 |
t('The row titled "@title" has no available Date value. An iCal entry cannot be created for it.', |
|
147 |
array('@title' => $title) |
|
148 |
) |
|
149 |
); |
|
137 | 150 |
} |
138 | 151 |
$date = $this->get_row_date($row, $date_field_name); |
139 | 152 |
} |
... | ... | |
173 | 186 |
|
174 | 187 |
// Generate a unique ID for this event by emulating the way the Date module |
175 | 188 |
// creates a Date ID. |
189 |
$is_relationaship = FALSE; |
|
190 |
$date_field_delta = 0; |
|
176 | 191 |
if (isset($row->{"field_data_{$date_field_name}_delta"})) { |
177 | 192 |
$date_field_delta = $row->{"field_data_{$date_field_name}_delta"}; |
178 | 193 |
} |
179 |
else { |
|
194 |
else if (!empty($entity->{$date_field_name})) {
|
|
180 | 195 |
// I'm not sure why the "field_data_{field_name}_delta" field is part of |
181 | 196 |
// the $row, so it's possible that it will sometimes be missing. If it |
182 | 197 |
// is, make an educated guess about the delta by comparing this row's |
183 | 198 |
// start date to each of the entity's dates. |
184 |
$date_field_delta = 0; |
|
185 | 199 |
foreach ($entity->{$date_field_name}['und'] as $ndx => $date_array) { |
186 | 200 |
if ($date['start']->originalTime == $date_array['value']) { |
187 | 201 |
$date_field_delta = $ndx; |
... | ... | |
189 | 203 |
} |
190 | 204 |
} |
191 | 205 |
} |
206 |
else if (!empty($this->display->display_options['fields'][$date_field_name]['relationship'])) { |
|
207 |
// This block covers another potential situation where |
|
208 |
// "field_data_{field_name}_delta" is missing: dates gathered through a |
|
209 |
// relationship. We retrieve the name of the relationship through which |
|
210 |
// the date field is being gathered, and the delta of that relationship, |
|
211 |
// in case it's multi-delta. |
|
212 |
$rel_name = $this->display->display_options['fields'][$date_field_name]['relationship']; |
|
213 |
$rel_delta = $row->index; |
|
214 |
$is_relationaship = TRUE; |
|
215 |
} |
|
216 |
else { |
|
217 |
// We couldn't obtain enough info to determine the real $date_field_delta. |
|
218 |
// So we just leave it as 0. Hopefully this won't cause problems. |
|
219 |
} |
|
192 | 220 |
$entity_id = $row->{$this->view->base_field}; |
193 | 221 |
global $base_url; |
194 | 222 |
$domain = preg_replace('#^https?://#', '', $base_url); |
195 |
$event['uid'] = "calendar.$entity_id.$date_field_name.$date_field_delta@$domain"; |
|
223 |
if (!$is_relationaship) { |
|
224 |
$event['uid'] = "calendar.$entity_id.$date_field_name.$date_field_delta@$domain"; |
|
225 |
} |
|
226 |
else { |
|
227 |
$event['uid'] = "calendar.$entity_id.$rel_name.$rel_delta.$date_field_name.$date_field_delta@$domain"; |
|
228 |
} |
|
196 | 229 |
|
197 | 230 |
// Because of the way that Date implements repeating dates, we're going to |
198 | 231 |
// be given a separate view result for each repeat. We only want to |
... | ... | |
213 | 246 |
$text_fields['summary'] = $this->get_field($row->index, $this->options['title_field']); |
214 | 247 |
$text_fields['description'] = $this->get_field($row->index, $this->options['description_field']); |
215 | 248 |
$text_fields['location'] = $this->get_field($row->index, $this->options['location_field']); |
249 |
$text_fields['categories'] = $this->get_field($row->index, $this->options['categories_field']); |
|
216 | 250 |
|
217 | 251 |
// Allow other modules to alter the rendered text fields before they get |
218 | 252 |
// sanitized for iCal-compliance. This is most useful for fields of type |
... | ... | |
229 | 263 |
$event['summary'] = date_ical_sanitize_text($text_fields['summary']); |
230 | 264 |
$event['location'] = date_ical_sanitize_text($text_fields['location']); |
231 | 265 |
$event['description'] = date_ical_sanitize_text($text_fields['description']); |
266 |
$event['categories'] = date_ical_sanitize_text($text_fields['categories']); |
|
232 | 267 |
|
233 | 268 |
// Allow other modules to alter the event object before it gets passed to |
234 | 269 |
// the style plugin to be converted into an iCal VEVENT. |
Formats disponibles : Unified diff
Weekly update of contrib modules