public function addAliasButton($arrButtons, Contao\DataContainer $dc)
	{
		// Generate the aliases
		if (Contao\Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias']))
		{
			/** @var Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */
			$objSession = Contao\System::getContainer()->get('session');

			$session = $objSession->all();
			$ids = $session['CURRENT']['IDS'];

			foreach ($ids as $id)
			{
				$objPage = Contao\PageModel::findWithDetails($id);

				if ($objPage === null)
				{
					continue;
				}

				$dc->id = $id;
				$dc->activeRecord = $objPage;

				$strAlias = '';

				// Generate new alias through save callbacks
				foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback)
				{
					if (\is_array($callback))
					{
						$this->import($callback[0]);
						$strAlias = $this->{$callback[0]}->{$callback[1]}($strAlias, $dc);
					}
					elseif (\is_callable($callback))
					{
						$strAlias = $callback($strAlias, $dc);
					}
				}

				// The alias has not changed
				if ($strAlias == $objPage->alias)
				{
					continue;
				}

				// Initialize the version manager
				$objVersions = new Contao\Versions('tl_page', $id);
				$objVersions->initialize();

				// Store the new alias
				$this->Database->prepare("UPDATE tl_page SET alias=? WHERE id=?")
							   ->execute($strAlias, $id);

				// Create a new version
				$objVersions->create();
			}

			$this->redirect($this->getReferer());
		}

		// Add the button
		$arrButtons['alias'] = '<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">'.$GLOBALS['TL_LANG']['MSC']['aliasSelected'].'</button> ';

		return $arrButtons;
	}
public function addAliasButton($arrButtons, Contao\DataContainer $dc)
	{
		
		if (Contao\Input::post('FORM_SUBMIT') == 'tl_select' && isset($_POST['alias']))
		{
			
			$objSession = Contao\System::getContainer()->get('session');

			$session = $objSession->all();
			$ids = $session['CURRENT']['IDS'];

			foreach ($ids as $id)
			{
				$objPage = Contao\PageModel::findWithDetails($id);

				if ($objPage === null)
				{
					continue;
				}

				$dc->id = $id;
				$dc->activeRecord = $objPage;

				$strAlias = '';

				
				foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback)
				{
					if (\is_array($callback))
					{
						$this->import($callback[0]);
						$strAlias = $this->{$callback[0]}->{$callback[1]}($strAlias, $dc);
					}
					elseif (\is_callable($callback))
					{
						$strAlias = $callback($strAlias, $dc);
					}
				}

				
				if ($strAlias == $objPage->alias)
				{
					continue;
				}

				
				$objVersions = new Contao\Versions('tl_page', $id);
				$objVersions->initialize();

				
				$this->Database->prepare("UPDATE tl_page SET alias=? WHERE id=?")
							   ->execute($strAlias, $id);

				
				$objVersions->create();
			}

			$this->redirect($this->getReferer());
		}

		
		$arrButtons['alias'] = '<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">'.$GLOBALS['TL_LANG']['MSC']['aliasSelected'].'</button> ';

		return $arrButtons;
	}
public function addAliasButton ( $ arrButtons , Contao \ DataContainer $ dc ) { // Generate the aliases if ( Contao \ Input :: post ( 'FORM_SUBMIT' ) == 'tl_select' && isset ( $ _POST [ 'alias' ] ) ) { /** @var Symfony\Component\HttpFoundation\Session\SessionInterface $objSession */ $ objSession = Contao \ System :: getContainer ( ) -> get ( 'session' ) ; $ session = $ objSession -> all ( ) ; $ ids = $ session [ 'CURRENT' ] [ 'IDS' ] ; foreach ( $ ids as $ id ) { $ objPage = Contao \ PageModel :: findWithDetails ( $ id ) ; if ( $ objPage === null ) { continue ; } $ dc -> id = $ id ; $ dc -> activeRecord = $ objPage ; $ strAlias = '' ; // Generate new alias through save callbacks foreach ( $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ 'alias' ] [ 'save_callback' ] as $ callback ) { if ( \ is_array ( $ callback ) ) { $ this -> import ( $ callback [ 0 ] ) ; $ strAlias = $ this -> { $ callback [ 0 ] } -> { $ callback [ 1 ] } ( $ strAlias , $ dc ) ; } elseif ( \ is_callable ( $ callback ) ) { $ strAlias = $ callback ( $ strAlias , $ dc ) ; } } // The alias has not changed if ( $ strAlias == $ objPage -> alias ) { continue ; } // Initialize the version manager $ objVersions = new Contao \ Versions ( 'tl_page' , $ id ) ; $ objVersions -> initialize ( ) ; // Store the new alias $ this -> Database -> prepare ( "UPDATE tl_page SET alias=? WHERE id=?" ) -> execute ( $ strAlias , $ id ) ; // Create a new version $ objVersions -> create ( ) ; } $ this -> redirect ( $ this -> getReferer ( ) ) ; } // Add the button $ arrButtons [ 'alias' ] = '<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">' . $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'aliasSelected' ] . '</button> ' ; return $ arrButtons ; }
Automatically generate the folder URL aliases

@param array                $arrButtons
@param Contao\DataContainer $dc

@return array
Automatically generate the folder URL aliases