views.inc 897 B

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