You are here

public function StylesDefault::render in Styles 7.2

Same name and namespace in other branches
  1. 6.2 includes/Styles.inc \StylesDefault::render()
  2. 6 includes/Styles.inc \StylesDefault::render()

Build the output for display.

Parameters

boolean $reset: Optional; if TRUE, the rebuild the output.

Return value

A fully themed snippet of HTML for output.

2 calls to StylesDefault::render()
FileStyles::render in contrib/file_styles/includes/styles/FileStyles.inc
Override the render function to always display a thumbnail in the wysiwyg.
StylesDefault::display in includes/Styles.inc
Display the rendered output.
1 method overrides StylesDefault::render()
FileStyles::render in contrib/file_styles/includes/styles/FileStyles.inc
Override the render function to always display a thumbnail in the wysiwyg.

File

includes/Styles.inc, line 97
Styles.inc Base class for Styles.

Class

StylesDefault
@file Styles.inc Base class for Styles.

Code

public function render($reset = FALSE) {

  // If we need to reset, then set the output to NULL.
  if ($reset) {
    $this
      ->setOutput(NULL);
  }

  // Have we already rendered the output?
  $output = $this
    ->getOutput();

  // We need to render the output the first time around, or if reset.
  if (!isset($output)) {

    // First, we get the array of callable class methods for this object.
    // These may each be called by effects called for by the style.
    // @TODO: Should we have a proper array of allowable effects, rather
    // than our current lazy method of allowing all class functions?
    $methods = get_class_methods($this);

    // Loop through and apply each effect.
    foreach ($this
      ->getEffects() as $effect) {

      // What is the effect?
      $effectName = $effect['name'];
      if ($effectName && in_array($effectName, $methods)) {

        // Apply the effect with its settings.
        $this
          ->{$effectName}($effect['settings']);
      }
      else {

        // Ouch. We have an invalid effect. Flag for bug reporting.
        $variables = $this
          ->getVariables();
        $styleName = $variables['style']['name'];
        watchdog('styles', 'Effect %effect_name not found for %style_name display formatter style of the %class_name class.', array(
          '%effect_name' => $effectName,
          '%style_name' => $styleName,
          '%class_name' => $this
            ->getClassName(),
        ), WATCHDOG_WARNING);
      }
    }

    // Now the output will have been fully built.
    $output = $this
      ->getOutput();
  }
  return $output;
}