Пример #1
0
 public function getDisplayMarkup($display, $options = array())
 {
     if (empty($display)) {
         return array();
     }
     $formatters = _addthis_field_info_formatter_field_type();
     if (!array_key_exists($display, $formatters)) {
         return array();
     }
     // The display type exists. Now get it and get the markup.
     $display_information = $formatters[$display];
     // Theme function might only give a display name and
     // render on default implementation.
     if (!isset($options['#display']) || isset($options['#display']['type']) && $options['#display']['type'] != $display) {
         $options['#display'] = isset($options['#display']) ? $options['#display'] : array();
         $options['#display'] = array_merge($options['#display'], $display_information);
         $options['#display']['type'] = $display;
     }
     // When #entity and #entity_type exist, use the entity's URL.
     if (isset($options['#entity']) && isset($options['#entity_type'])) {
         $uri = entity_uri($options['#entity_type'], $options['#entity']);
         $uri['options'] += array('absolute' => TRUE);
         // @todo Add a hook to alter the uri also based on fields from the
         // entity (such as custom share link). Pass $options and $uri. Return
         // a uri object to which we can reset it. Maybe use the alter structure.
         $options['#url'] = url($uri['path'], $uri['options']);
     }
     // @todo Hash the options array and cache the markup.
     // This will save all the extra calls to modules and alters.
     // Allow other modules to alter markup options.
     drupal_alter('addthis_markup_options', $options);
     $markup = array('#display' => $options['#display']);
     // Get all hook implementation to verify later if we can call it.
     $addthis_display_markup_implementations = module_implements('addthis_display_markup');
     // Look for a targeted implementation to call.
     // This should be the default implementation that is called.
     if (function_exists($display_information['module'] . '_addthis_display_markup__' . $display)) {
         $markup += call_user_func_array($display_information['module'] . '_addthis_display_markup__' . $display, array($options));
     } elseif (in_array($display_information['module'], $addthis_display_markup_implementations)) {
         $markup += module_invoke($display_information['module'], 'addthis_display_markup', $display, $options);
     }
     // Allow other modules to alter markup.
     drupal_alter('addthis_markup', $markup);
     return $markup;
 }
Пример #2
0
 public function getDisplayTypes()
 {
     $displays = array();
     foreach ($display_impl = _addthis_field_info_formatter_field_type() as $key => $display) {
         $displays[$key] = t(SafeMarkup::checkPlain($display['label']));
     }
     return $displays;
 }