<?php

/**
 * eSales Media oxVoucher for Contao Open Source CMS
 *
 * Copyright (c) 2015 eSales Media
 *
 * @author  Benjamin Roth [benjamin@esales-media.de]
 * @license proprietary
 */

namespace eSM_oxVoucher;

class ModuleVoucherSearch extends ModuleVoucher
{
	/**
	 * Template
	 * @var string
	 */
	protected $strTemplate = 'mod_oxvoucher_search';

	/**
	 * Parse the template
	 * @return string
	 */
	public function generate()
	{
		if (TL_MODE == 'BE')
		{
			/** @var \BackendTemplate|object $objTemplate */
			$objTemplate = new \BackendTemplate('be_wildcard');

			$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['oxvoucher_search'][0]) . ' ###';
			$objTemplate->title = $this->headline;
			$objTemplate->id = $this->id;
			$objTemplate->link = $this->name;
			$objTemplate->href = 'contao/main.php?do=themes&amp;table=tl_module&amp;act=edit&amp;id=' . $this->id;

			return $objTemplate->parse();
		}

		$this->importOxDbInstance();

		return parent::generate();
	}


	/**
	 * Compile the current element
	 */
	protected function compile()
	{
		$this->Template->searchLabel = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['searchLabel'];
		$this->Template->submitLabel = $GLOBALS['TL_LANG']['MSC']['oxVoucher']['searchSubmitLabel'];
	}

}