Get the table name for the template and calculate an alias if
necessary.
@param $tpl The object template
@return Associative array with keys 'name', 'alias'
197229
protected function processTableName(Node $tpl) {
    $mapper = self::getMapper($tpl->getType());
    $mapperTableName = $mapper->getRealTableName();

    $tableName = $tpl->getProperty(self::PROPERTY_TABLE_NAME);
    if ($tableName == null) {
      $tableName = $mapperTableName;

      // if the template is the child of another node of the same type,
      // we must use a table alias
      $parents = $tpl->getParentsEx(null, null, $tpl->getType());
      foreach ($parents as $curParent) {
        $curParentTableName = $curParent->getProperty(self::PROPERTY_TABLE_NAME);
        if ($curParentTableName == $tableName) {
          $tableName .= '_'.($this->aliasCounter++);
        }
      }
      // set the table name for later reference
      $tpl->setProperty(self::PROPERTY_TABLE_NAME, $tableName);
    }

    return ['name' => $mapperTableName, 'alias' => $tableName];
  }
99385
public function getTablesNames()
    {
        $aTables      = array_keys($this->getTablesCreateSql());
        $prefixTables = $this->getTablePrefix();

        $return = array();
        foreach ($aTables as $table) {
            $return[] = $prefixTables . $table;
        }

        return $return;
    }
1003473
public function getAllTemplates()
    {
        $strCacheDir = $this->container->getParameter('kernel.cache_dir');

        // Try to load from cache
        if (file_exists($strCacheDir.'/contao/config/twig-templates.php')) {
            self::$twigFiles = include $strCacheDir.'/contao/config/twig-templates.php';

            return self::$twigFiles;
        }

        $bundles = $this->kernel->getBundles();

        if (\is_array($bundles)) {
            foreach (array_reverse($bundles) as $key => $value) {
                $path = $this->kernel->locateResource("@$key");

                $dir = rtrim($path, '/').'/Resources/views';

                if (!is_dir($dir)) {
                    continue;
                }
                $finder = new Finder();
                $twigKey = preg_replace('/Bundle$/', '', $key);

                foreach ($finder->in($dir)->files()->name('*.twig') as $file) {
                    /** @var SplFileInfo $file */
                    $name = $file->getBasename();
                    $legacyName = false !== strpos($name, 'html.twig') ? $file->getBasename('.html.twig') : $name;

                    if (isset(self::$twigFiles[$name])) {
                        continue;
                    }

                    self::$twigFiles[$name] = "@$twigKey/".$file->getRelativePathname();

                    if ($legacyName !== $name) {
                        self::$twigFiles[$legacyName] = self::$twigFiles[$name];
                    }
                }
            }
        }

        foreach ($this->container->get('contao.resource_finder')->findIn('templates')->name('*.twig') as $file) {
            $name = $file->getBasename();
            $legacyName = false !== strpos($name, 'html.twig') ? $file->getBasename('.html.twig') : $name;

            /* @var SplFileInfo $file */
            self::$twigFiles[$name] = $file->getRealPath();

            if ($legacyName !== $name) {
                self::$twigFiles[$legacyName] = self::$twigFiles[$name];
            }
        }

        // add root templates
        $rootTemplates = $this->findTemplates($this->containerUtil->getProjectDir().'/templates/');

        if (\is_array($rootTemplates)) {
            foreach ($rootTemplates as $file) {
                $name = basename($file);
                $legacyName = false !== strpos($name, 'html.twig') ? basename($file, '.html.twig') : $name;

                self::$twigFiles[$name] = $file;

                if ($legacyName !== $name) {
                    self::$twigFiles[$legacyName] = self::$twigFiles[$name];
                }
            }
        }

        return self::$twigFiles;
    }
619692
public function getTemplates($dc)
	{
		$prefix = '';

		if($dc instanceof \MultiColumnWizard)
		{
			$dc->field = $dc->strField;
			$dc->table = $dc->strTable;
		}

		if(isset($GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['templatePrefix']))
		{
			$prefix = $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['templatePrefix'];
		}

		$key = null;

		if(isset($GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['templateThemeId']))
		{
			$key = $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['templateThemeId'];
		}

		$key = $key == '' ? null : $dc->activeRecord->$key;

		return $this->getTemplateGroup($prefix, $key);
	}
1144690
public function getFinalName($name){

        try { 

            return parent::findTemplate($name);

        } catch(\Twig_Error_Loader $e){ 

            $exts = \App::config('TEMPLATE_EXTENSION');

            if($exts){

                if(!is_array($exts)){
                    $exts = Array($exts);
                }//if

                foreach($exts as $e){

                    try {
                        return parent::findTemplate($name . $e);
                    } catch(\Twig_Error_Loader $e){ }

                }//foreach

            }//if

        }//catch

        throw new \Twig_Error_Loader("Twig Error Loader Exception : Could name find template `{$name}`");

    }
1241185
public function getShortName() {
        $name = $this->getName();
        //Strip out the table name
        if(substr($name, 0, strlen($this->getTableName())) == $this->getTableName() && lcfirst(substr($name, strlen($this->getTableName()))) != 'source') {
            $name = lcfirst(substr($name, strlen($this->getTableName())));
        }
        return $name;
    }
506706
protected function loadTpl($tpl)
    {
        $this->tplBase = $this->request->args('tplBase') ? $this->request->args('tplBase') : dirname($tpl);
        $content = file_get_contents($tpl);
        $this->prepareTpl($content);
        return json_decode($content, true);
    }
964773
public function getConnectionTableName()
    {
        $type_names = [$this->getSourceTypeName(), $this->getTargetTypeName()];
        sort($type_names);

        return implode('_', $type_names);
    }
404231
public function getTableAlias($table_name = null)
    {
        if (!$table_name) {
            $table_name = $this->getTableName();
        }
        $bits = explode("_", $table_name);
        $alias = '';
        foreach ($bits as $bit) {
            $alias .= strtolower(substr($bit, 0, 1));
        }
        return $alias;
    }
1022826
protected function getFirstTableAlias(
        /*# string */ $left
    )/*# : string */ {
        if (false !== strpos($left, '.')) { // alias exists
            return '';
        } else { // prepend first table alias
            $tables = &$this->getClause('TABLE');
            reset($tables);
            $alias = key($tables);
            return (is_int($alias) ? $tables[$alias][0] : $alias) . '.';
        }
    }
460890
public static function getFields($tbl): array
    {
        if (Settings::isCacheEnabled()) {
            $cache_key = 'db_table_columns_' . $tbl;
            $cacher = Cacher::getInstance()->getDefaultCacher();

            if (!isset(self::$_cached_tbl_columns[$tbl])) {
                self::$_cached_tbl_columns[$tbl] = $cacher->get($cache_key);
            }
        }

        if (isset(self::$_cached_tbl_columns[$tbl])) {
            return self::$_cached_tbl_columns[$tbl];
        }

        $res = [];
        $sql = self::getInstance()->sql_query("SHOW COLUMNS FROM `$tbl`");

        while ($q = $sql->fetch(PDO::FETCH_NUM)) {
            $res[] = $q[0];
        }

        if (Settings::isCacheEnabled()) {
            $cacher->set($cache_key, $res, 86400);
        }

        return self::$_cached_tbl_columns[$tbl] = $res;
    }
383500
protected function getTableFullName()
    {
        $prefix = !empty($this->tablePrefix) && is_string($this->tablePrefix) ? $this->tablePrefix . '_' : '';
        return $prefix . $this->tableName;
    }
244137
public function alias($alias)
    {
        if (is_array($alias)) {
            foreach ($alias as $key => $val) {
                $this->options['alias'][$key] = $val;
            }
        } else {
            if (isset($this->options['table'])) {
                $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table'];
                if (false !== strpos($table, '__')) {
                    $table = $this->parseSqlTable($table);
                }
            } else {
                $table = $this->getTable();
            }

            $this->options['alias'][$table] = $alias;
        }
        return $this;
    }
174584
public function getOutput($tpl = null)
    {
        $output = $this->fetch($tpl);
        if ($this->isError($output)) {
            $text = $this->configList[self::ERROR_TEXT];
            return $text; //TODO: escape this output?
        } else {
            return $output;
        }
    }
1007300
public function getTableForAlias($alias)
    {
        if (isset($this->aliases[$alias])) {
            return $this->aliases[$alias];
        }

        return null;
    }
888692
public function getTableName()
    {
        if ($this->tableName) {
            return $this->tableName;
        }

        return $this->namingStrategy->classToTableName($this->name);
    }
655052
public function getOutput($tpl = null)
	{
	    $output = $this->fetch($tpl);
        if ($this->isError($output)) {
            $text = $this->__config['error_text'];
            return $this->escape($text);
        } else {
            return $output;
        }
	}