Révision 7e72b748
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/ctools/includes/content.inc | ||
---|---|---|
86 | 86 |
/** |
87 | 87 |
* Fetch metadata on a specific content_type plugin. |
88 | 88 |
* |
89 |
* @param $content type
|
|
89 |
* @param mixed $content
|
|
90 | 90 |
* Name of a panel content type. |
91 | 91 |
* |
92 | 92 |
* @return |
... | ... | |
146 | 146 |
if (is_array($function)) { |
147 | 147 |
$subtypes = $function; |
148 | 148 |
} |
149 |
else if (function_exists($function)) {
|
|
149 |
elseif (function_exists($function)) { |
|
150 | 150 |
// Cast to array to prevent errors from non-array returns. |
151 | 151 |
$subtypes = (array) $function($plugin); |
152 | 152 |
} |
... | ... | |
157 | 157 |
foreach ($subtypes as $id => $subtype) { |
158 | 158 |
// Ensure that the 'subtype_id' value exists. |
159 | 159 |
if (!isset($subtype['subtype_id'])) { |
160 |
$subtype['subtype_id'] = $id; |
|
160 |
$subtypes[$id]['subtype_id'] = $id;
|
|
161 | 161 |
} |
162 | 162 |
|
163 | 163 |
// Use exact name since this is a modify by reference. |
... | ... | |
207 | 207 |
} |
208 | 208 |
|
209 | 209 |
if ($subtype) { |
210 |
// Ensure that the 'subtype_id' value exists. This is also done in |
|
211 |
// ctools_content_get_subtypes(), but it wouldn't be called if the plugin |
|
212 |
// provides the subtype through its own function. |
|
213 |
if (!isset($subtype['subtype_id'])) { |
|
214 |
$subtype['subtype_id'] = $subtype_id; |
|
215 |
} |
|
216 |
|
|
210 | 217 |
ctools_content_prepare_subtype($subtype, $plugin); |
211 | 218 |
} |
212 | 219 |
return $subtype; |
... | ... | |
300 | 307 |
$content->subtype = $subtype; |
301 | 308 |
} |
302 | 309 |
|
303 |
// Override the title if configured to |
|
310 |
// Override the title if configured to.
|
|
304 | 311 |
if (!empty($conf['override_title'])) { |
305 | 312 |
// Give previous title as an available substitution here. |
306 | 313 |
$keywords['%title'] = empty($content->title) ? '' : $content->title; |
... | ... | |
310 | 317 |
} |
311 | 318 |
|
312 | 319 |
if (!empty($content->title)) { |
313 |
// Perform substitutions |
|
320 |
// Perform substitutions.
|
|
314 | 321 |
if (!empty($keywords) || !empty($context)) { |
315 | 322 |
$content->title = ctools_context_keyword_substitute($content->title, $keywords, $context); |
316 | 323 |
} |
317 | 324 |
|
318 |
// Sterilize the title |
|
325 |
// Sterilize the title.
|
|
319 | 326 |
$content->title = filter_xss_admin($content->title); |
320 | 327 |
|
321 | 328 |
// If a link is specified, populate. |
... | ... | |
326 | 333 |
else { |
327 | 334 |
$url = $content->title_link; |
328 | 335 |
} |
329 |
// set defaults so we don't bring up notices
|
|
336 |
// Set defaults so we don't bring up notices.
|
|
330 | 337 |
$url += array('href' => '', 'attributes' => array(), 'query' => array(), 'fragment' => '', 'absolute' => NULL, 'html' => TRUE); |
331 | 338 |
$content->title = l($content->title, $url['href'], $url); |
332 | 339 |
} |
... | ... | |
348 | 355 |
} |
349 | 356 |
|
350 | 357 |
$function = FALSE; |
351 |
|
|
358 |
|
|
352 | 359 |
if (!empty($subtype['check editable'])) { |
353 | 360 |
$function = ctools_plugin_get_function($subtype, 'check editable'); |
354 | 361 |
} |
... | ... | |
379 | 386 |
if (is_array($type)) { |
380 | 387 |
$plugin = $type; |
381 | 388 |
} |
382 |
else if (is_string($type)) {
|
|
389 |
elseif (is_string($type)) { |
|
383 | 390 |
$plugin = ctools_get_content_type($type); |
384 | 391 |
} |
385 | 392 |
else { |
... | ... | |
397 | 404 |
|
398 | 405 |
return $function($subtype, $conf, $pane_context); |
399 | 406 |
} |
400 |
else if (isset($plugin['admin title'])) {
|
|
407 |
elseif (isset($plugin['admin title'])) { |
|
401 | 408 |
return $plugin['admin title']; |
402 | 409 |
} |
403 |
else if (isset($plugin['title'])) {
|
|
410 |
elseif (isset($plugin['title'])) { |
|
404 | 411 |
return $plugin['title']; |
405 | 412 |
} |
406 | 413 |
} |
... | ... | |
435 | 442 |
if (isset($plugin['defaults'])) { |
436 | 443 |
$defaults = $plugin['defaults']; |
437 | 444 |
} |
438 |
else if (isset($subtype['defaults'])) {
|
|
445 |
elseif (isset($subtype['defaults'])) { |
|
439 | 446 |
$defaults = $subtype['defaults']; |
440 | 447 |
} |
441 | 448 |
if (isset($defaults)) { |
... | ... | |
444 | 451 |
return $return; |
445 | 452 |
} |
446 | 453 |
} |
447 |
else if (is_array($defaults)) {
|
|
454 |
elseif (is_array($defaults)) { |
|
448 | 455 |
return $defaults; |
449 | 456 |
} |
450 | 457 |
} |
... | ... | |
478 | 485 |
|
479 | 486 |
if (empty($output) || !is_object($output)) { |
480 | 487 |
$output = new stdClass(); |
481 |
// replace the _ with " " for a better output
|
|
488 |
// Replace the _ with " " for a better output.
|
|
482 | 489 |
$subtype = check_plain(str_replace("_", " ", $subtype)); |
483 | 490 |
$output->title = $subtype; |
484 | 491 |
$output->content = t('No info available.'); |
... | ... | |
487 | 494 |
} |
488 | 495 |
|
489 | 496 |
/** |
490 |
* Add the default FAPI elements to the content type configuration form |
|
497 |
* Add the default FAPI elements to the content type configuration form.
|
|
491 | 498 |
*/ |
492 | 499 |
function ctools_content_configure_form_defaults($form, &$form_state) { |
493 | 500 |
$plugin = $form_state['plugin']; |
... | ... | |
604 | 611 |
if (!empty($subtype['add form'])) { |
605 | 612 |
_ctools_content_create_form_info($form_info, $subtype['add form'], $subtype, $subtype, $op); |
606 | 613 |
} |
607 |
else if (!empty($plugin['add form'])) {
|
|
614 |
elseif (!empty($plugin['add form'])) { |
|
608 | 615 |
_ctools_content_create_form_info($form_info, $plugin['add form'], $plugin, $subtype, $op); |
609 | 616 |
} |
610 | 617 |
} |
... | ... | |
614 | 621 |
if (!empty($subtype['edit form'])) { |
615 | 622 |
_ctools_content_create_form_info($form_info, $subtype['edit form'], $subtype, $subtype, $op); |
616 | 623 |
} |
617 |
else if (!empty($plugin['edit form'])) {
|
|
624 |
elseif (!empty($plugin['edit form'])) { |
|
618 | 625 |
_ctools_content_create_form_info($form_info, $plugin['edit form'], $plugin, $subtype, $op); |
619 | 626 |
} |
620 | 627 |
} |
... | ... | |
633 | 640 |
if (empty($subtype['title'])) { |
634 | 641 |
$title = t('Configure'); |
635 | 642 |
} |
636 |
else if ($op == 'add') {
|
|
643 |
elseif ($op == 'add') { |
|
637 | 644 |
$title = t('Configure new !subtype_title', array('!subtype_title' => $subtype['title'])); |
638 | 645 |
} |
639 | 646 |
else { |
... | ... | |
648 | 655 |
), |
649 | 656 |
); |
650 | 657 |
} |
651 |
else if (is_array($info)) {
|
|
658 |
elseif (is_array($info)) { |
|
652 | 659 |
$form_info['order'] = array(); |
653 | 660 |
$form_info['forms'] = array(); |
654 | 661 |
$count = 0; |
... | ... | |
699 | 706 |
|
700 | 707 |
foreach ($plugins as $id => $plugin) { |
701 | 708 |
foreach (ctools_content_get_subtypes($plugin) as $subtype_id => $subtype) { |
702 |
// exclude items that require content if we're saying we don't
|
|
709 |
// Exclude items that require content if we're saying we don't
|
|
703 | 710 |
// provide it. |
704 | 711 |
if (!empty($subtype['requires content']) && !$has_content) { |
705 | 712 |
continue; |
... | ... | |
739 | 746 |
* Get an array of all content types that can be fed into the |
740 | 747 |
* display editor for the add content list, regardless of |
741 | 748 |
* availability. |
742 |
* |
|
743 | 749 |
*/ |
744 | 750 |
function ctools_content_get_all_types() { |
745 | 751 |
$plugins = ctools_get_content_types(); |
Formats disponibles : Unified diff
Weekly update of contrib modules