On data container submit callback.

@param DataContainer $dc
321747
public function onSubmitCallback(DataContainer $dc)
    {
        // Schedule a news feed update
        if ('tl_news_category' === $dc->table && $dc->id) {
            /** @var Model $modelAdapter */
            $modelAdapter = $this->framework->getAdapter(Model::class);

            $newsIds = $modelAdapter->getReferenceValues('tl_news', 'categories', $dc->id);
            $newsIds = \array_map('intval', \array_unique($newsIds));

            if (\count($newsIds) > 0) {
                $archiveIds = $this->db
                    ->executeQuery('SELECT DISTINCT(pid) FROM tl_news WHERE id IN ('.\implode(',', $newsIds).')')
                    ->fetchAll(\PDO::FETCH_COLUMN, 0);

                $session = $this->session->get('news_feed_updater');
                $session = \array_merge((array) $session, $archiveIds);
                $this->session->set('news_feed_updater', \array_unique($session));
            }
        }
    }
1161792
public function onPanelCallback(DataContainer $dc): string
    {
        /** @var AttributeBagInterface $bag */
        $bag = $this->session->getBag('contao_backend');
        $session = $bag->all();

        $sorting = ['_default', 'total_asc', 'total_desc'];
        $request = $this->requestStack->getCurrentRequest();

        // Store the sorting in the session
        if ('tl_filters' === $request->request->get('FORM_SUBMIT')) {
            $sort = $request->request->get('tl_sort');

            if ('_default' !== $sort && \in_array($sort, $sorting, true)) {
                $session['sorting'][$dc->table] = $sort;
            } else {
                $session['sorting'][$dc->table] = null;
            }

            $bag->replace($session);
        }

        $options = [];

        // Generate the markup options
        foreach ($sorting as $option) {
            $options[] = \sprintf(
                '<option value="%s"%s>%s</option>',
                StringUtil::specialchars($option),
                ($session['sorting'][$dc->table] === $option) ? ' selected="selected"' : '',
                ('_default' === $option) ? $GLOBALS['TL_DCA'][$dc->table]['fields'][$GLOBALS['TL_DCA'][$dc->table]['list']['sorting']['fields'][0]]['label'][0] : $GLOBALS['TL_LANG'][$dc->table]['sortRef'][$option]
            );
        }

        return '

<div class="tl_sorting tl_subpanel">
<strong>'.$GLOBALS['TL_LANG']['MSC']['sortBy'].':</strong>
<select name="tl_sort" id="tl_sort" class="tl_select">
'.\implode("\n", $options).'
</select>
</div>';
    }
784700
public function save($value, $dc)
	{
		// shortcuts
		$start  = ContentWrapper\Model::TYPE_START;
		$stop   = ContentWrapper\Model::TYPE_STOP;
		$sep    = ContentWrapper\Model::TYPE_SEPARATOR;

		// handle issues with contao models
		if(version_compare(VERSION, '3.2', '>=')) {
			try {
				$model = new \ContentModel($dc->activeRecord);
			}
			catch(\Exception $e) {
				$model = \ContentModel::findByPk($dc->id);
			}
		}
		else {
			$model = new \ContentModel($dc->activeRecord);
		}

		$model->type = $value;

		$this->objModel = new ContentWrapper\Model($model);
		$sorting = $this->objModel->sorting;

		// getType will throw an exception if type is not found. use it to detect non content wrapper elements
		try {
			$type = $this->objModel->getType();
		}
		catch(\Exception $e)
		{
			return $value;
		}

		// check for existing parent element and try to create it if not existing
		if($type != $start) {
			if($this->objModel->bootstrap_parentId == '') {
				$parent = ContentWrapper\Repository::findPreviousElement($this->objModel, $start);

				if($parent) {
					// set relation to parent element
					$this->objModel->bootstrap_parentId = $parent->id;

					$end = ContentWrapper\Repository::findRelatedElement($this->objModel, $stop);

					if($end === null) {
						$this->objModel->sorting = $parent->sorting + 2;
					}
					elseif($parent !== null && $parent->sorting > $end->sorting) {
						$this->objModel->sorting = $end->sorting - 2;
					}

					// set relation to parent element
					if($this->objModel->getType() != $start) {
						$this->objModel->bootstrap_parentId = $parent->id;
					}

					$this->objModel->getModel()->save();
				}

				// create parent if possible
				elseif($this->isTrigger($type, $start)) {
					$sorting = $sorting-2;
					$this->createElement($sorting, $start);
				}

				// no parent element exists, throw error
				else
				{
					throw new \Exception(sprintf(
						$GLOBALS['TL_LANG']['ERR']['wrapperStartNotExists'],
						$GLOBALS['TL_LANG']['CTE'][$value][0] ?: $value
					));
				}
			}
		}

		// create separators if possible
		if($type != $sep && ($this->isTrigger($type, $sep) || $this->isTrigger($type, $sep, static::TRIGGER_DELETE)))
		{
			$config   = $GLOBALS['BOOTSTRAP']['wrappers'][$this->objModel->getGroup()][$sep];
			$callback = $config['countExisting'];
			$this->import($callback[0]);
			$existing = $this->$callback[0]->$callback[1]($this->objModel);

			$callback = $config['countRequired'];
			$this->import($callback[0]);
			$required = $this->$callback[0]->$callback[1]($this->objModel);

			if($existing < $required)
			{
				if($this->isTrigger($type, $sep))
				{
					$count = $required - $existing;

					for($i = 0; $i < $count; $i++)
					{
						$this->createElement($sorting, $sep);
					}

					$end = ContentWrapper\Repository::findRelatedElement($this->objModel, $stop);

					if($end && $end->sorting <= $sorting) {
						$sorting = $sorting + 2;
						$end->sorting = $sorting;
						$end->save();
					}
				}
			}
			elseif($required < $existing)
			{
				if($this->isTrigger($type, $sep, static::TRIGGER_DELETE))
				{
					$count = $existing - $required;

					$parentId = $this->objModel->getType() == ContentWrapper\Model::TYPE_START
						? $this->objModel->id
						: $this->objModel->bootstrap_parentId;

					$this->Database
						->prepare('DELETE FROM tl_content WHERE bootstrap_parentId=? AND type=? ORDER BY sorting DESC')
						->limit($count)
						->execute($parentId, $this->objModel->getTypeName($sep));
				}
			}
		}

		// cereate end element
		if($type == $start && $this->isTrigger($type, $stop))
		{
			$end = ContentWrapper\Repository::countRelatedElements($this->objModel, $stop);

			if(!$end) {
				$end = $this->createElement($sorting, $stop);
			}
		}

		return $value;
	}
1191197
public function setLocLat($varValue, \DataContainer $dc)
    {
        if ($varValue != 0)
        {
            if (!Utils::validateLat($varValue))
            {
                throw new \Exception($GLOBALS['TL_LANG']['c4g_maps']['geoy_invalid']);
            }
        }
        return $varValue;
    }
860618
public function delete($dc)
	{
		$model = \ContentModel::findByPk($dc->id);
		$this->objModel = new ContentWrapper\Model($model);

		// getType will throw an exception if type is not found. use it to detect non content wrapper elements
		try {
			$type = $this->objModel->getType();
		}
		catch(\Exception $e)
		{
			return;
		}

		if($this->objModel->getType() == ContentWrapper\Model::TYPE_START)
		{
			$deleteTypes = array();

			if($this->isTrigger($this->objModel->getType(), ContentWrapper\Model::TYPE_SEPARATOR, static::TRIGGER_DELETE)) {
				$deleteTypes[] = $this->objModel->getTypeName(ContentWrapper\Model::TYPE_SEPARATOR);
			}

			if($this->isTrigger($this->objModel->getType(), ContentWrapper\Model::TYPE_STOP, static::TRIGGER_DELETE)) {
				$deleteTypes[] = $this->objModel->getTypeName(ContentWrapper\Model::TYPE_STOP);
			}

			if(!empty($deleteTypes)) {
				$this->Database
					->prepare(sprintf(
						'DELETE FROM tl_content WHERE bootstrap_parentId=? AND type IN(\'%s\')',
						implode('\',\'', $deleteTypes)
					))
					->execute($this->objModel->id);
			}
		}
		elseif($this->objModel->getType() == ContentWrapper\Model::TYPE_STOP) {
			if($this->isTrigger($this->objModel->getType(), ContentWrapper\Model::TYPE_SEPARATOR, static::TRIGGER_DELETE)) {
				$this->Database
					->prepare('DELETE FROM tl_content WHERE bootstrap_parentId=? AND type=?')
					->execute(
						$this->objModel->bootstrap_parentId,
						$this->objModel->getTypeName(ContentWrapper\Model::TYPE_SEPARATOR)
					);
			}

			if($this->isTrigger($this->objModel->getType(), ContentWrapper\Model::TYPE_START, static::TRIGGER_DELETE)) {
				$query = sprintf('DELETE FROM %s WHERE id=?', $this->objModel->getModel()->getTable());

				\Database::getInstance()
					->prepare($query)
					->execute($this->objModel->bootstrap_parentId);
			}
		}
		else {
			// todo: handle seperator delete actions
		}
	}
379354
public function addBreadcrumb(\DataContainer $dc)
  {
    // Set a new cat
    if (isset($_GET['cat']))
    {
      $this->Session->set('tl_category_id', $this->Input->get('cat'));
      $this->redirect(preg_replace('/&cat=[^&]*/', '', $this->Environment->request));
    }

    $intCategoryId = $this->Session->get('tl_category_id');

    if ($intCategoryId < 1)
    {
      return;
    }

    $arrIds = array();
    $arrLinks = array();

    // Generate breadcrumb trail
    $category = $this->getCategoryForId($intCategoryId, true, false);

    if ($category == null)
    {
      $this->Session->set('tl_category_id', 0);
      return;
    }

    // Add root link
    $arrLinks[] = '<img src="system/modules/DocumentManagementSystem/assets/dms.png" width="16" height="16" alt=""> <a href="' . $this->addToUrl('cat=0') . '">' . $GLOBALS['TL_LANG']['MSC']['filterAll'] . '</a>';
    foreach ($category->getPath(false) as $eachCategory)
    {
      $image = 'category.png';
      if (!$eachCategory->isPublished())
      {
        $image = 'category_1.png';
      }
      if ($eachCategory->id == $intCategoryId)
      {
        $arrLinks[] = $this->generateImage('system/modules/DocumentManagementSystem/assets/' . $image, '', "") . ' ' . $eachCategory->name;
      }
      else
      {
        $arrLinks[] = $this->generateImage('system/modules/DocumentManagementSystem/assets/' . $image, '', "") . ' <a href="' . $this->addToUrl('cat='.$eachCategory->id) . '">' . $eachCategory->name . '</a>';
      }
    }

    // Limit tree
    $GLOBALS['TL_DCA']['tl_dms_categories']['list']['sorting']['root'] = array($intCategoryId);

    // Insert breadcrumb menu
    $GLOBALS['TL_DCA']['tl_dms_categories']['list']['sorting']['breadcrumb'] .= '

<ul id="tl_breadcrumb">
  <li>' . implode(' &gt; </li><li>', $arrLinks) . '</li>
</ul>';
  }
592731
public function setLocLat($varValue, \DataContainer $dc)
    {
        if ($varValue != 0)
        {
            if (!\con4gis\MapsBundle\Resources\contao\classes\Utils::validateLat($varValue))
            {
                throw new \Exception($GLOBALS['TL_LANG']['c4g_maps']['geoy_invalid']);
            }
        }
        return $varValue;
    }
920780
public function validateDatePeriod($val, DataContainer $dc) {
		if(strtotime(\Input::post('start')) > strtotime(\Input::post('end'))) {
			throw new \Exception('Start date should be before end date');
		}
		else return $val;
	}
96989
public function setLocLon($varValue, \DataContainer $dc)
    {
        if ($varValue != 0)
        {
            if (!\con4gis\MapsBundle\Resources\contao\classes\Utils::validateLon($varValue))
            {
                throw new \Exception($GLOBALS['TL_LANG']['c4g_maps']['geox_invalid']);
            }
        }
        return $varValue;
    }
422290
public function validateMaxUploadFileSize($varValue, DataContainer $dc)
	{
		$arrValue = deserialize($varValue);
		$dmsUnit = $arrValue['unit'];
		$dmsVal = \Document::convertFileSize((double) $arrValue['value'], $dmsUnit, \Document::FILE_SIZE_UNIT_BYTE);
		$phpVal = $this->getPhpUploadMaxFilesize();
		
		if ($dmsVal > $phpVal)
		{
			throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['dmsMaxUploadFileSize'], \Document::formatFileSize(\Document::convertFileSize($phpVal, \Document::FILE_SIZE_UNIT_BYTE, $dmsUnit), $dmsUnit)));
		}
		
		return $varValue;
	}
274969
public function handleDropDatabase(): void
	{
		$this->checkHandlerPermission(false);

		$this->app->dropDatabase();
		$this->app->clearCache();
		$this->flashNotifier->success('dockbar.management.database.databaseDroped');
		$this->presenter->redirect('this');
	}
268727
public function sendAsyncByDb(\PDO $connection) : void
    {
        if ($this->data) {
            throw new DataNotSupportedException();
        }

        $connection->exec('NOTIFY ' . static::NAME);
    }
819036
void submit() {

        CmsObject cms = A_CmsUI.getCmsObject();
        try {
            List<CmsUUID> changedIds = Lists.newArrayList();
            CmsResourceDeleteMode mode = (CmsResourceDeleteMode)m_deleteSiblings.getValue();
            for (CmsResource resource : m_context.getResources()) {
                changedIds.add(resource.getStructureId());
                CmsLockActionRecord lockRecord = CmsLockUtil.ensureLock(cms, resource);
                try {
                    cms.deleteResource(cms.getSitePath(resource), mode);
                } finally {
                    if (lockRecord.getChange().equals(LockChange.locked)) {
                        if (!resource.getState().isNew()) {
                            try {
                                cms.unlockResource(resource);
                            } catch (CmsVfsResourceNotFoundException e) {
                                LOG.warn(e.getLocalizedMessage(), e);
                            } catch (CmsLockException e) {
                                LOG.warn(e.getLocalizedMessage(), e);
                            }
                        }
                    }
                }
            }
            m_context.finish(changedIds);
        } catch (Exception e) {
            m_context.error(e);
        }
    }
242791
public function getDmsTemplates(DataContainer $dc)
  {
    $intPid = $dc->activeRecord->pid;
    
    if ($this->Input->get('act') == 'overrideAll')
    {
      $intPid = $this->Input->get('id');
    }
    
    return $this->getTemplateGroup('mod_' . $dc->activeRecord->type, $intPid);
  }
465534
public function process_submission() {
        global $DB;
        // Delete all records, then add back the ones that should be allowed.
        $DB->delete_records($this->tablename);
        foreach ($this->roles as $fromroleid => $notused) {
            foreach ($this->roles as $targetroleid => $alsonotused) {
                if (optional_param('s_' . $fromroleid . '_' . $targetroleid, false, PARAM_BOOL)) {
                    $this->set_allow($fromroleid, $targetroleid);
                }
            }
        }
    }
681327
public function loadDc(string $table)
    {
        if (!isset($GLOBALS['TL_DCA'][$table]) || null === $GLOBALS['TL_DCA'][$table]) {
            /** @var Controller $controller */
            $controller = $this->framework->getAdapter(Controller::class);

            $controller->loadDataContainer($table);
        }
    }
926128
public function onsubmitCallback($dc)
	{
		$activeRecord = $dc->activeRecord;
		if (!$activeRecord) {
			return;
		}

		if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') {

			// Find the next columns or column element
			$nextElement = \Database::getInstance()
				->prepare('
					SELECT type
					FROM tl_content
					WHERE pid = ?
						AND (ptable = ? OR ptable = ?)
						AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\')
						AND sorting > ?
					ORDER BY sorting ASC
					LIMIT 1
				')
				->execute(
					$activeRecord->pid,
					$activeRecord->ptable ?: 'tl_article',
					$activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable,
					$activeRecord->sorting
				);

			// Check if a stop element should be created
			if (
				!$nextElement->type
				|| ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop')
				|| ($activeRecord->type === 'rs_column_start' && (
					$nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop'
				))
			) {
				$set = array();

				// Get all default values for the new entry
				foreach ($GLOBALS['TL_DCA']['tl_content']['fields'] as $field => $config) {
					if (array_key_exists('default', $config)) {
						$set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default'];
						if ($GLOBALS['TL_DCA']['tl_content']['fields'][$field]['eval']['encrypt']) {
							$set[$field] = \Encryption::encrypt($set[$field]);
						}
					}
				}

				$set['pid'] = $activeRecord->pid;
				$set['ptable'] = $activeRecord->ptable ?: 'tl_article';
				$set['type'] = substr($activeRecord->type, 0, -5) . 'stop';
				$set['sorting'] = $activeRecord->sorting + 1;
				$set['invisible'] = $activeRecord->invisible;
				$set['start'] = $activeRecord->start;
				$set['stop'] = $activeRecord->stop;
				$set['tstamp'] = time();

				\Database::getInstance()
					->prepare('INSERT INTO tl_content %s')
					->set($set)
					->execute();
			}

		}
	}