core-bundle/src/Resources/contao/dca/tl_files.php
public function excludeFolder(Contao\DataContainer $dc)
	{
		$strPath = $dc->id;
		$rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir');

		// Check if the folder has been renamed (see #6432, #934)
		if (Contao\Input::post('name'))
		{
			if (Contao\Validator::isInsecurePath(Contao\Input::post('name')))
			{
				throw new RuntimeException('Invalid file or folder name ' . Contao\Input::post('name'));
			}

			$count = 0;
			$strName = basename($strPath);

			if (($strNewPath = str_replace($strName, Contao\Input::post('name'), $strPath, $count)) && $count > 0 && is_dir($rootDir . '/' . $strNewPath))
			{
				$strPath = $strNewPath;
			}
		}

		// Only show for folders (see #5660)
		if (!is_dir($rootDir . '/' . $strPath))
		{
			return '';
		}

		$objFolder = new Contao\Folder($strPath);

		// Check if the folder or a parent folder is unsynchronized
		$blnUnsynchronized = $objFolder->isUnsynchronized();

		// Disable the checkbox if a parent folder is unsynchronized
		$blnDisable = $blnUnsynchronized && !file_exists($rootDir . '/' . $strPath . '/.nosync');

		// Synchronize or unsynchronize the folder
		if (!$blnDisable && Contao\Input::post('FORM_SUBMIT') == 'tl_files')
		{
			if (Contao\Input::post($dc->inputName))
			{
				if (!$blnUnsynchronized)
				{
					$blnUnsynchronized = true;
					$objFolder->unsynchronize();
				}
			}
			else
			{
				if ($blnUnsynchronized)
				{
					$blnUnsynchronized = false;
					$objFolder->synchronize();
				}
			}
		}

		$class = $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tl_class'] . ' cbx';

		if (Contao\Input::get('act') == 'editAll' || Contao\Input::get('act') == 'overrideAll')
		{
			$class = str_replace(array('w50', 'clr', 'wizard', 'long', 'm12', 'cbx'), '', $class);
		}

		$class = trim('widget ' . $class);

		return '
<div class="' . $class . '">
  <div id="ctrl_' . $dc->field . '" class="tl_checkbox_single_container">
    <input type="hidden" name="' . $dc->inputName . '" value=""><input type="checkbox" name="' . $dc->inputName . '" id="opt_' . $dc->inputName . '_0" class="tl_checkbox" value="1"' . ($blnUnsynchronized ? ' checked="checked"' : '') . ' onfocus="Backend.getScrollOffset()"' . ($blnDisable ? ' disabled' : '') . '> <label for="opt_' . $dc->inputName . '_0">' . $GLOBALS['TL_LANG']['tl_files']['syncExclude'][0] . '</label>
  </div>' . (Contao\Config::get('showHelp') ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_files']['syncExclude'][1] . '</p>' : '') . '
</div>';
	}
public function excludeFolder(Contao\DataContainer $dc)
	{
		$strPath = $dc->id;
		$rootDir = Contao\System::getContainer()->getParameter('kernel.project_dir');

		// Check if the folder has been renamed (see #6432, #934)
		if (Contao\Input::post('name'))
		{
			if (Contao\Validator::isInsecurePath(Contao\Input::post('name')))
			{
				throw new RuntimeException('Invalid file or folder name ' . Contao\Input::post('name'));
			}

			$count = 0;
			$strName = basename($strPath);

			if (($strNewPath = str_replace($strName, Contao\Input::post('name'), $strPath, $count)) && $count > 0 && is_dir($rootDir . '/' . $strNewPath))
			{
				$strPath = $strNewPath;
			}
		}

		// Only show for folders (see #5660)
		if (!is_dir($rootDir . '/' . $strPath))
		{
			return '';
		}

		$objFolder = new Contao\Folder($strPath);

		// Check if the folder or a parent folder is unsynchronized
		$blnUnsynchronized = $objFolder->isUnsynchronized();

		// Disable the checkbox if a parent folder is unsynchronized
		$blnDisable = $blnUnsynchronized && !file_exists($rootDir . '/' . $strPath . '/.nosync');

		// Synchronize or unsynchronize the folder
		if (!$blnDisable && Contao\Input::post('FORM_SUBMIT') == 'tl_files')
		{
			if (Contao\Input::post($dc->inputName))
			{
				if (!$blnUnsynchronized)
				{
					$blnUnsynchronized = true;
					$objFolder->unsynchronize();
				}
			}
			else
			{
				if ($blnUnsynchronized)
				{
					$blnUnsynchronized = false;
					$objFolder->synchronize();
				}
			}
		}

		$class = $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tl_class'] . ' cbx';

		if (Contao\Input::get('act') == 'editAll' || Contao\Input::get('act') == 'overrideAll')
		{
			$class = str_replace(array('w50', 'clr', 'wizard', 'long', 'm12', 'cbx'), '', $class);
		}

		$class = trim('widget ' . $class);

		return '
<div class="' . $class . '">
  <div id="ctrl_' . $dc->field . '" class="tl_checkbox_single_container">
    <input type="hidden" name="' . $dc->inputName . '" value=""><input type="checkbox" name="' . $dc->inputName . '" id="opt_' . $dc->inputName . '_0" class="tl_checkbox" value="1"' . ($blnUnsynchronized ? ' checked="checked"' : '') . ' onfocus="Backend.getScrollOffset()"' . ($blnDisable ? ' disabled' : '') . '> <label for="opt_' . $dc->inputName . '_0">' . $GLOBALS['TL_LANG']['tl_files']['syncExclude'][0] . '</label>
  </div>' . (Contao\Config::get('showHelp') ? '
  <p class="tl_help tl_tip">' . $GLOBALS['TL_LANG']['tl_files']['syncExclude'][1] . '</p>' : '') . '
</div>';
	}
public function excludeFolder ( Contao \ DataContainer $ dc ) { $ strPath = $ dc -> id ; $ rootDir = Contao \ System :: getContainer ( ) -> getParameter ( 'kernel.project_dir' ) ; // Check if the folder has been renamed (see #6432, #934) if ( Contao \ Input :: post ( 'name' ) ) { if ( Contao \ Validator :: isInsecurePath ( Contao \ Input :: post ( 'name' ) ) ) { throw new RuntimeException ( 'Invalid file or folder name ' . Contao \ Input :: post ( 'name' ) ) ; } $ count = 0 ; $ strName = basename ( $ strPath ) ; if ( ( $ strNewPath = str_replace ( $ strName , Contao \ Input :: post ( 'name' ) , $ strPath , $ count ) ) && $ count > 0 && is_dir ( $ rootDir . '/' . $ strNewPath ) ) { $ strPath = $ strNewPath ; } } // Only show for folders (see #5660) if ( ! is_dir ( $ rootDir . '/' . $ strPath ) ) { return '' ; } $ objFolder = new Contao \ Folder ( $ strPath ) ; // Check if the folder or a parent folder is unsynchronized $ blnUnsynchronized = $ objFolder -> isUnsynchronized ( ) ; // Disable the checkbox if a parent folder is unsynchronized $ blnDisable = $ blnUnsynchronized && ! file_exists ( $ rootDir . '/' . $ strPath . '/.nosync' ) ; // Synchronize or unsynchronize the folder if ( ! $ blnDisable && Contao \ Input :: post ( 'FORM_SUBMIT' ) == 'tl_files' ) { if ( Contao \ Input :: post ( $ dc -> inputName ) ) { if ( ! $ blnUnsynchronized ) { $ blnUnsynchronized = true ; $ objFolder -> unsynchronize ( ) ; } } else { if ( $ blnUnsynchronized ) { $ blnUnsynchronized = false ; $ objFolder -> synchronize ( ) ; } } } $ class = $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ $ dc -> field ] [ 'eval' ] [ 'tl_class' ] . ' cbx' ; if ( Contao \ Input :: get ( 'act' ) == 'editAll' || Contao \ Input :: get ( 'act' ) == 'overrideAll' ) { $ class = str_replace ( array ( 'w50' , 'clr' , 'wizard' , 'long' , 'm12' , 'cbx' ) , '' , $ class ) ; } $ class = trim ( 'widget ' . $ class ) ; return '
<div class="' . $ class . '">
  <div id="ctrl_' . $ dc -> field . '" class="tl_checkbox_single_container">
    <input type="hidden" name="' . $ dc -> inputName . '" value=""><input type="checkbox" name="' . $ dc -> inputName . '" id="opt_' . $ dc -> inputName . '_0" class="tl_checkbox" value="1"' . ( $ blnUnsynchronized ? ' checked="checked"' : '' ) . ' onfocus="Backend.getScrollOffset()"' . ( $ blnDisable ? ' disabled' : '' ) . '> <label for="opt_' . $ dc -> inputName . '_0">' . $ GLOBALS [ 'TL_LANG' ] [ 'tl_files' ] [ 'syncExclude' ] [ 0 ] . '</label>
  </div>' . ( Contao \ Config :: get ( 'showHelp' ) ? '
  <p class="tl_help tl_tip">' . $ GLOBALS [ 'TL_LANG' ] [ 'tl_files' ] [ 'syncExclude' ] [ 1 ] . '</p>' : '' ) . '
</div>' ; }
Return a checkbox to exclude a folder from synchronization

@param Contao\DataContainer $dc

@return string

@throws RuntimeException
Return a checkbox to exclude a folder from synchronization