views.inc 879 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Generate new context classes by argument settings on the view.
  4. */
  5. function ctools_views_get_argument_context($argument) {
  6. if ($argument['type'] == 'context') {
  7. if (strpos($argument['context'], '.')) {
  8. list($context, $converter) = explode('.', $argument['context'], 2);
  9. }
  10. else {
  11. // Backwards-compat for before we had a system for delimiting the data
  12. // we retrieve out of context objects.
  13. $context = $argument['context'];
  14. }
  15. if ($context == 'term' || $context == 'vocabulary') {
  16. $context = 'entity:taxonomy_' . $context;
  17. }
  18. elseif ($entity = entity_get_info($context)) {
  19. $context = 'entity:' . $context;
  20. }
  21. $class = 'ctools_context_' . (empty($argument['context_optional']) ? 'required' : 'optional');
  22. $new_context = new $class($argument['label'], $context);
  23. return $new_context;
  24. }
  25. }