public function importTheme()
	{
		/** @var FileUpload $objUploader */
		$objUploader = new FileUpload();

		if (Input::post('FORM_SUBMIT') == 'tl_theme_import')
		{
			/** @var Session $objSession */
			$objSession = System::getContainer()->get('session');

			if (!Input::post('confirm'))
			{
				$arrUploaded = $objUploader->uploadTo('system/tmp');

				if (empty($arrUploaded))
				{
					Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
					$this->reload();
				}

				$arrFiles = array();

				foreach ($arrUploaded as $strFile)
				{
					// Skip folders
					if (is_dir($this->strRootDir . '/' . $strFile))
					{
						Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['importFolder'], basename($strFile)));
						continue;
					}

					$objFile = new File($strFile);

					// Skip anything but .cto files
					if ($objFile->extension != 'cto')
					{
						Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension));
						continue;
					}

					$arrFiles[] = $strFile;
				}
			}
			else
			{
				$arrFiles = explode(',', $objSession->get('uploaded_themes'));
			}

			// Check whether there are any files
			if (empty($arrFiles))
			{
				Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
				$this->reload();
			}

			// Store the field names of the theme tables
			$arrDbFields = array
			(
				'tl_files'           => $this->Database->getFieldNames('tl_files'),
				'tl_theme'           => $this->Database->getFieldNames('tl_theme'),
				'tl_style_sheet'     => $this->Database->getFieldNames('tl_style_sheet'),
				'tl_style'           => $this->Database->getFieldNames('tl_style'),
				'tl_module'          => $this->Database->getFieldNames('tl_module'),
				'tl_layout'          => $this->Database->getFieldNames('tl_layout'),
				'tl_image_size'      => $this->Database->getFieldNames('tl_image_size'),
				'tl_image_size_item' => $this->Database->getFieldNames('tl_image_size_item')
			);

			// Proceed
			if (Input::post('confirm') == 1)
			{
				$this->extractThemeFiles($arrFiles, $arrDbFields);
			}
			else
			{
				$objSession->set('uploaded_themes', implode(',', $arrFiles));

				return $this->compareThemeFiles($arrFiles, $arrDbFields);
			}
		}

		// Return the form
		return Message::generate() . '
<div id="tl_buttons">
<a href="'.ampersand(str_replace('&key=importTheme', '', Environment::get('request'))).'" class="header_back" title="'.StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']).'" accesskey="b">'.$GLOBALS['TL_LANG']['MSC']['backBT'].'</a>
</div>
<form action="'.ampersand(Environment::get('request'), true).'" id="tl_theme_import" class="tl_form tl_edit_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_theme_import">
<input type="hidden" name="REQUEST_TOKEN" value="'.REQUEST_TOKEN.'">
<input type="hidden" name="MAX_FILE_SIZE" value="'.Config::get('maxFileSize').'">

<div class="tl_tbox">
  <div class="widget">
    <h3>'.$GLOBALS['TL_LANG']['tl_theme']['source'][0].'</h3>'.$objUploader->generateMarkup().(isset($GLOBALS['TL_LANG']['tl_theme']['source'][1]) ? '
    <p class="tl_help tl_tip">'.$GLOBALS['TL_LANG']['tl_theme']['source'][1].'</p>' : '').'
  </div>
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  <button type="submit" name="save" id="save" class="tl_submit" accesskey="s">'.$GLOBALS['TL_LANG']['tl_theme']['importTheme'][0].'</button>
</div>

</div>
</form>';
	}
public function importTheme()
	{
		
		$objUploader = new FileUpload();

		if (Input::post('FORM_SUBMIT') == 'tl_theme_import')
		{
			
			$objSession = System::getContainer()->get('session');

			if (!Input::post('confirm'))
			{
				$arrUploaded = $objUploader->uploadTo('system/tmp');

				if (empty($arrUploaded))
				{
					Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
					$this->reload();
				}

				$arrFiles = array();

				foreach ($arrUploaded as $strFile)
				{
					
					if (is_dir($this->strRootDir . '/' . $strFile))
					{
						Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['importFolder'], basename($strFile)));
						continue;
					}

					$objFile = new File($strFile);

					
					if ($objFile->extension != 'cto')
					{
						Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $objFile->extension));
						continue;
					}

					$arrFiles[] = $strFile;
				}
			}
			else
			{
				$arrFiles = explode(',', $objSession->get('uploaded_themes'));
			}

			
			if (empty($arrFiles))
			{
				Message::addError($GLOBALS['TL_LANG']['ERR']['all_fields']);
				$this->reload();
			}

			
			$arrDbFields = array
			(
				'tl_files'           => $this->Database->getFieldNames('tl_files'),
				'tl_theme'           => $this->Database->getFieldNames('tl_theme'),
				'tl_style_sheet'     => $this->Database->getFieldNames('tl_style_sheet'),
				'tl_style'           => $this->Database->getFieldNames('tl_style'),
				'tl_module'          => $this->Database->getFieldNames('tl_module'),
				'tl_layout'          => $this->Database->getFieldNames('tl_layout'),
				'tl_image_size'      => $this->Database->getFieldNames('tl_image_size'),
				'tl_image_size_item' => $this->Database->getFieldNames('tl_image_size_item')
			);

			
			if (Input::post('confirm') == 1)
			{
				$this->extractThemeFiles($arrFiles, $arrDbFields);
			}
			else
			{
				$objSession->set('uploaded_themes', implode(',', $arrFiles));

				return $this->compareThemeFiles($arrFiles, $arrDbFields);
			}
		}

		
		return Message::generate() . '
<div id="tl_buttons">
<a href="'.ampersand(str_replace('&key=importTheme', '', Environment::get('request'))).'" class="header_back" title="'.StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']).'" accesskey="b">'.$GLOBALS['TL_LANG']['MSC']['backBT'].'</a>
</div>
<form action="'.ampersand(Environment::get('request'), true).'" id="tl_theme_import" class="tl_form tl_edit_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_theme_import">
<input type="hidden" name="REQUEST_TOKEN" value="'.REQUEST_TOKEN.'">
<input type="hidden" name="MAX_FILE_SIZE" value="'.Config::get('maxFileSize').'">

<div class="tl_tbox">
  <div class="widget">
    <h3>'.$GLOBALS['TL_LANG']['tl_theme']['source'][0].'</h3>'.$objUploader->generateMarkup().(isset($GLOBALS['TL_LANG']['tl_theme']['source'][1]) ? '
    <p class="tl_help tl_tip">'.$GLOBALS['TL_LANG']['tl_theme']['source'][1].'</p>' : '').'
  </div>
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  <button type="submit" name="save" id="save" class="tl_submit" accesskey="s">'.$GLOBALS['TL_LANG']['tl_theme']['importTheme'][0].'</button>
</div>

</div>
</form>';
	}
public function importTheme ( ) { /** @var FileUpload $objUploader */ $ objUploader = new FileUpload ( ) ; if ( Input :: post ( 'FORM_SUBMIT' ) == 'tl_theme_import' ) { /** @var Session $objSession */ $ objSession = System :: getContainer ( ) -> get ( 'session' ) ; if ( ! Input :: post ( 'confirm' ) ) { $ arrUploaded = $ objUploader -> uploadTo ( 'system/tmp' ) ; if ( empty ( $ arrUploaded ) ) { Message :: addError ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'all_fields' ] ) ; $ this -> reload ( ) ; } $ arrFiles = array ( ) ; foreach ( $ arrUploaded as $ strFile ) { // Skip folders if ( is_dir ( $ this -> strRootDir . '/' . $ strFile ) ) { Message :: addError ( sprintf ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'importFolder' ] , basename ( $ strFile ) ) ) ; continue ; } $ objFile = new File ( $ strFile ) ; // Skip anything but .cto files if ( $ objFile -> extension != 'cto' ) { Message :: addError ( sprintf ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'filetype' ] , $ objFile -> extension ) ) ; continue ; } $ arrFiles [ ] = $ strFile ; } } else { $ arrFiles = explode ( ',' , $ objSession -> get ( 'uploaded_themes' ) ) ; } // Check whether there are any files if ( empty ( $ arrFiles ) ) { Message :: addError ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'all_fields' ] ) ; $ this -> reload ( ) ; } // Store the field names of the theme tables $ arrDbFields = array ( 'tl_files' => $ this -> Database -> getFieldNames ( 'tl_files' ) , 'tl_theme' => $ this -> Database -> getFieldNames ( 'tl_theme' ) , 'tl_style_sheet' => $ this -> Database -> getFieldNames ( 'tl_style_sheet' ) , 'tl_style' => $ this -> Database -> getFieldNames ( 'tl_style' ) , 'tl_module' => $ this -> Database -> getFieldNames ( 'tl_module' ) , 'tl_layout' => $ this -> Database -> getFieldNames ( 'tl_layout' ) , 'tl_image_size' => $ this -> Database -> getFieldNames ( 'tl_image_size' ) , 'tl_image_size_item' => $ this -> Database -> getFieldNames ( 'tl_image_size_item' ) ) ; // Proceed if ( Input :: post ( 'confirm' ) == 1 ) { $ this -> extractThemeFiles ( $ arrFiles , $ arrDbFields ) ; } else { $ objSession -> set ( 'uploaded_themes' , implode ( ',' , $ arrFiles ) ) ; return $ this -> compareThemeFiles ( $ arrFiles , $ arrDbFields ) ; } } // Return the form return Message :: generate ( ) . '
<div id="tl_buttons">
<a href="' . ampersand ( str_replace ( '&key=importTheme' , '' , Environment :: get ( 'request' ) ) ) . '" class="header_back" title="' . StringUtil :: specialchars ( $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'backBTTitle' ] ) . '" accesskey="b">' . $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'backBT' ] . '</a>
</div>
<form action="' . ampersand ( Environment :: get ( 'request' ) , true ) . '" id="tl_theme_import" class="tl_form tl_edit_form" method="post" enctype="multipart/form-data">
<div class="tl_formbody_edit">
<input type="hidden" name="FORM_SUBMIT" value="tl_theme_import">
<input type="hidden" name="REQUEST_TOKEN" value="' . REQUEST_TOKEN . '">
<input type="hidden" name="MAX_FILE_SIZE" value="' . Config :: get ( 'maxFileSize' ) . '">

<div class="tl_tbox">
  <div class="widget">
    <h3>' . $ GLOBALS [ 'TL_LANG' ] [ 'tl_theme' ] [ 'source' ] [ 0 ] . '</h3>' . $ objUploader -> generateMarkup ( ) . ( isset ( $ GLOBALS [ 'TL_LANG' ] [ 'tl_theme' ] [ 'source' ] [ 1 ] ) ? '
    <p class="tl_help tl_tip">' . $ GLOBALS [ 'TL_LANG' ] [ 'tl_theme' ] [ 'source' ] [ 1 ] . '</p>' : '' ) . '
  </div>
</div>

</div>

<div class="tl_formbody_submit">

<div class="tl_submit_container">
  <button type="submit" name="save" id="save" class="tl_submit" accesskey="s">' . $ GLOBALS [ 'TL_LANG' ] [ 'tl_theme' ] [ 'importTheme' ] [ 0 ] . '</button>
</div>

</div>
</form>' ; }
Import a theme

@return string
Import a theme