<?php

/**
 * Slick slider for Contao
 *
 * Copyright (c) 2016 Benjamin Roth
 *
 * @license LGPL-3.0+
 */

namespace eSM_slick;


/**
 * Front end content element slick slider start.
 */
class ContentSlickSliderStop extends \ContentElement
{

	/**
	 * Template
	 * @var string
	 */
	protected $strTemplate = 'ce_slick_slider_stop';

  public function generate()
  {
    if (TL_MODE === 'BE') {
      return parent::generate();
    }

    $parentKey = ($this->arrData['ptable'] ?: 'tl_article') . '__' . $this->arrData['pid'];

    if (isset($GLOBALS['TL_ESM_SLICK'][$parentKey])) {
      unset($GLOBALS['TL_ESM_SLICK'][$parentKey]);
    }

    if (!empty($GLOBALS['TL_ESM_SLICK_STACK'][$parentKey])) {
      $GLOBALS['TL_ESM_SLICK'][$parentKey] = array_pop($GLOBALS['TL_ESM_SLICK_STACK'][$parentKey]);
    }

    return parent::generate();
  }


  /**
	 * Generate the content element
	 */
	protected function compile()
	{
		if (TL_MODE == 'BE')
		{
			$this->strTemplate = 'be_wildcard';

			/** @var \BackendTemplate|object $objTemplate */
			$objTemplate = new \BackendTemplate($this->strTemplate);

			$this->Template = $objTemplate;
			$this->Template->title = $this->headline;
		}
	}
}