Return content element templates as array

@param DataContainer $dc

@return array
773552
public function getContentElementTemplates(DataContainer $dc)
	{
		$arrTemplates = array();

		// Get the default templates
		foreach (\TemplateLoader::getPrefixedFiles('ce_') as $strTemplate)
		{
			$arrTemplates[$strTemplate][] = 'root';
		}

		$arrCustomized = glob(TL_ROOT . '/templates/ce_*');

		// Add the customized templates
		if (is_array($arrCustomized))
		{
			foreach ($arrCustomized as $strFile)
			{
				$strTemplate = basename($strFile, strrchr($strFile, '.'));
				$arrTemplates[$strTemplate][] = $GLOBALS['TL_LANG']['MSC']['global'];
			}
		}

		// Add the customized theme templates
		$theme = \ThemeModel::findById($dc->activeRecord->pid);
		
		$arrCustomized = glob(TL_ROOT . '/' . $theme->templates . '/' . 'ce_*');
		if (is_array($arrCustomized))
		{
			foreach ($arrCustomized as $strFile)
			{
				$strTemplate = basename($strFile, strrchr($strFile, '.'));
				$arrTemplates[$strTemplate][] = $theme->name;
			}
		}

		// Show the template sources
		foreach ($arrTemplates as $k=>$v)
		{
			$v = array_filter($v, function($a) {
				return $a != 'root';
			});
			if (empty($v))
			{
				$arrTemplates[$k] = $k;
			}
			else
			{
				$arrTemplates[$k] = $k . ' (' . implode(', ', $v) . ')';
			}
		}

		// Sort the template names
		ksort($arrTemplates);
		
		return $arrTemplates;
	}
897659
public function onOptionsCallback(DataContainer $dc): array
    {
        $value = [];
        $manager = $this->getManagerFromDca($dc);

        if ($manager instanceof DcaFilterAwareInterface) {
            $value = $manager->getFilterOptions($dc);
        }

        return $value;
    }
575286
protected function getTemplateContents()
    {
        $parser = new NameParser($this->argument('name'));

        if ($parser->isCreate()) {
            return Stub::create('/migration/create.stub', [
                'class' => $this->getClass(),
                'table' => $parser->getTable(),
                'fields' => $this->getSchemaParser()->render(),
            ]);
        } elseif ($parser->isAdd()) {
            return Stub::create('/migration/add.stub', [
                'class' => $this->getClass(),
                'table' => $parser->getTable(),
                'fields_up' => $this->getSchemaParser()->up(),
                'fields_down' => $this->getSchemaParser()->down(),
            ]);
        } elseif ($parser->isDelete()) {
            return Stub::create('/migration/delete.stub', [
                'class' => $this->getClass(),
                'table' => $parser->getTable(),
                'fields_down' => $this->getSchemaParser()->up(),
                'fields_up' => $this->getSchemaParser()->down(),
            ]);
        } elseif ($parser->isDrop()) {
            return Stub::create('/migration/drop.stub', [
                'class' => $this->getClass(),
                'table' => $parser->getTable(),
                'fields' => $this->getSchemaParser()->render(),
            ]);
        }

        throw new \InvalidArgumentException('Invalid migration name');
    }
13481
public function getActiveFileTypeSets(DataContainer $dc)
  {
    $arrFileTypeSets = array();
    
    $objFileTypeSets = $this->Database->prepare("SELECT * FROM tl_dms_file_type_sets WHERE published = 1 ORDER BY name")
                ->execute();
    
    while($objFileTypeSets->next())
    {
      $arrFileTypeSets[$objFileTypeSets->id] = $objFileTypeSets->name . "<span style=\"color:#b3b3b3; padding-left:3px;\">[" . \ContaoDMS\DmsUtils::getCuttedAllowedFileTypes($objFileTypeSets->file_types) .  "]</span>";
    }
    
    return $arrFileTypeSets;
  }
464290
def formatted_dc_dict(dc_dict):
    
    for key, element_list in dc_dict.items():
        new_element_list = []
        # Add the content for each element to the new element list.
        for element in element_list:
            new_element_list.append(element['content'])
        dc_dict[key] = new_element_list
    return dc_dict
1063173
public function getRenderTemplates()
    {
        $ClassName = $this->ClassName;

        if (is_object($ClassName)) $ClassName = get_class($ClassName);

        if (!is_subclass_of($ClassName, DataObject::class)) {
            throw new InvalidArgumentException($ClassName . ' is not a subclass of DataObject');
        }

        $templates = [
            'type' => 'Includes'
        ];
        while ($next = get_parent_class($ClassName)) {
            $baseClassName = $this->baseClassName($ClassName);
            if ($this->style) {
                $templates[] = $baseClassName . '_' . $this->style;
            }
            $templates[] = $baseClassName;
            if ($next == DataObject::class) {
                return $templates;
            }
            $ClassName = $next;
        }
    }
308104
public function onloadCallback($dc)
	{
		if (\Input::get('act') === 'create') {
			return;
		}

		if (\Input::get('act') === 'edit') {
			$this->reloadConfig();
		}

		if ($dc->table === 'tl_content' && class_exists('CeAccess')) {
			$ceAccess = new \CeAccess;
			$ceAccess->filterContentElements($dc);
		}

		if (\Input::get('act') === 'editAll') {
			return $this->createDcaMultiEdit($dc);
		}

		$type = $this->getDcaFieldValue($dc, 'type');
		if (!$type || substr($type, 0, 5) !== 'rsce_') {
			return;
		}

		$data = $this->getDcaFieldValue($dc, 'rsce_data', true);
		if ($data && substr($data, 0, 1) === '{') {
			$this->data = json_decode($data, true);
		}

		$createFromPost = \Input::post('FORM_SUBMIT') === $dc->table;
		$tmpField = null;

		if (\Input::get('field') && substr(\Input::get('field'), 0, 11) === 'rsce_field_') {
			// Ensures that the fileTree oder pageTree field exists
			$tmpField = \Input::get('field');
		}
		elseif (
			\Input::get('target')
			&& ($target = explode('.', \Input::get('target'), 3))
			&& $target[0] === $dc->table
			&& substr($target[1], 0, 11) === 'rsce_field_'
		) {
			// Ensures that the fileTree oder pageTree field exists
			$tmpField = $target[1];
		}
		elseif (\Input::post('name') && substr(\Input::post('name'), 0, 11) === 'rsce_field_') {
			// Ensures that the fileTree oder pageTree field exists
			$tmpField = \Input::post('name');
		}

		$this->createDca($dc, $type, $createFromPost, $tmpField);
	}
650326
protected function getContent()
    {
        $template = $this->option('template');
        $data = $this->form->data();

        if ($template) {
            $content = $this->getTemplate($template, [
                'data' => $data,
                'options' => $this->options
            ]);
        } else {
            $visitor = App::instance()->visitor();
            $content = '['.date('c').'] '.$visitor->ip().' '.$visitor->userAgent();

            foreach ($data as $key => $value) {
                if (is_array($value)) {
                    $value = implode(', ', array_filter($value, function ($i) {
                        return $i !== '';
                    }));
                }
                $content .= "\n{$key}: {$value}";
            }
            $content .= "\n\n";
        }

        return $content;
    }
1051184
public function getStartCategoryOptions(\DataContainer $dc)
  {
    $dmsLoader = \DmsLoader::getInstance();
    $params = new \DmsLoaderParams();
    $params->rootCategoryId = 0;
    $arrCategories = $dmsLoader->loadCategories($params);
    $arrCategories = \DmsLoader::flattenCategories($arrCategories);
    
    $arrOptions = array();
    foreach ($arrCategories as $category)
    {
      $indent = "";
      for ($i = 0; $i < $category->getLevel(); $i++)
      {
        $indent .= "&nbsp;&nbsp;&nbsp;&nbsp;";
      }
      $arrOptions[$category->id] = $indent . $category->name;
    }
    
    return $arrOptions;
  }
68515
protected function getTemplateContents()
    {
        return (new Stub('/route-provider.stub', [
            'MODULE' => $this->getModuleName(),
            'NAME' => $this->getFileName(),
            'MODULE_NAMESPACE' => $this->laravel['modules']->config('namespace'),
        ]))->render();
    }
1327159
public function Elements()
    {
        $fcvdo = new \Nblum\FlexibleContent\FlexibleContentVersionedDataObject();
        $defaultStage = $fcvdo->getDefaultStage();
        if (isset($_GET['stage']) && $defaultStage == $_GET['stage'] && \Permission::check('CMS_ACCESS')) {
            $stage = $defaultStage;
        } else {
            $stage = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_live_stage();
        }

        $results = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_by_stage(
            \ContentElement::class,
            $stage
            , [
            'Active' => '1',
            'ParentID' => $this->getField('ID')
        ], [
            'Sort' => 'ASC'
        ]);

        return $results;
    }
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
		}
	}
933682
protected function templateToString($template, array $data)
    {

        $templateFullName = $this->getTemplateFullName($template);

        if (!is_file($templateFullName)) {
            throw new RuntimeException("View cannot render `$template` because the template does not exist");
        }

        $fullData = array_merge($this->attributes, $data);
        $this->levelStartObcache = ob_get_level();
        $this->startSection($this->courentSection);
        $this->protectedIncludeScope($templateFullName, $fullData);
        $output = $this->endSection(true);
        $this->sectionContent[self::CONTENT] = $this->sectionContent[self::C_CONTENT];
        unset($this->sectionContent[self::C_CONTENT]);
        while (ob_get_level() > $this->levelStartObcache) {
            ob_end_clean();
        }

        if (!empty($this->layout)) {
            $layout = $this->layout;
            $this->layout = '';
            return $this->templateToString($layout, $fullData);
        }

        return $output;
    }
953681
private function getTemplates(DataSourceViewInterface $dataSource)
    {
        $templates = [];

        if (isset($this->themes[$dataSource->getName()])) {
            $templates[] = $this->themes[$dataSource->getName()];
        }

        $templates[] = $this->themes[self::DEFAULT_THEME];

        return $templates;
    }
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));
            }
        }
    }
1205242
public function getChildTemplates(string $context): array
    {
        Splash::log()->Deb('Loading Standalone Connector Templates for '.$context);
        $result = array();
        //====================================================================//
        // Safety Check
        if (!in_array($context, array('New', 'Offline', 'Connected'), true)) {
            return $result;
        }
        //====================================================================//
        // Load templates for All Objects
        foreach ($this->getAvailableObjects() as $objectType) {
            $objectService = $this->getObjectService($objectType);
            if (method_exists($objectService, 'get'.$context.'Template')) {
                $result[] = $objectService->{'get'.$context.'Template'}();
            }
        }
        //====================================================================//
        // Return Results
        return $result;
    }
81615
protected function _mapTemplates($data)
    {
        if (array_key_exists($this->_currentExportItem->blockData['name'], $this->_existingImportData) && array_key_exists('Templates', $this->_existingImportData[$this->_currentExportItem->blockData['name']])) {
            $currentCsvTemplates = $this->_existingImportData[$this->_currentExportItem->blockData['name']]['Templates'];
        } else {
            $currentCsvTemplates = '';
        }
        return in_array('*', explode(',', $currentCsvTemplates)) ? $currentCsvTemplates : implode(',', $data);
    }