Check if selected language already has multilanguage fields in DB

@param string $sOxId language abbervation

@return bool
503904
protected function _checkMultilangFieldsExistsInDb($sOxId)
    {
        $iBaseId = $this->_aLangData['params'][$sOxId]['baseId'];
        $sTable = getLangTableName('oxarticles', $iBaseId);
        $sColumn = 'oxtitle' . \OxidEsales\Eshop\Core\Registry::getLang()->getLanguageTag($iBaseId);

        $oDbMetadata = oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class);

        return $oDbMetadata->tableExists($sTable) && $oDbMetadata->fieldExists($sColumn, $sTable);
    }
351112
public function loadOrderArticlesForUser($sOxId)
    {
        if (!$sOxId) {
            $this->clear();

            return;
        }

        $sSelect = "SELECT oxorderarticles.* FROM oxorder ";
        $sSelect .= "left join oxorderarticles on oxorderarticles.oxorderid = oxorder.oxid ";
        $sSelect .= "left join oxarticles on oxorderarticles.oxartid = oxarticles.oxid ";
        $sSelect .= "WHERE oxorder.oxuserid = " . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sOxId);

        $this->selectString($sSelect);
    }
1210430
public function delete($sOxId = null)
    {
        $sOxId = $sOxId ? $sOxId : $this->getId();

        $this->load($sOxId);
        // if record cannot be delete, abort deletion
        if ($blDeleted = parent::delete($sOxId)) {
            $this->_deleteFile();
        }

        return $blDeleted;
    }
954456
public function delete($sOxId = null)
    {
        if (!$sOxId) {
            $sOxId = $this->getId();
        }

        $this->unsetDiscountRelations();
        $this->unsetUserGroups();
        $this->deleteVoucherList();

        return parent::delete($sOxId);
    }
331373
public function hasTranslation($locale = null)
    {
        $locale = $locale ?: $this->locale();

        foreach ($this->translations as $translation) {
            if ($translation->getAttribute($this->getLocaleKey()) == $locale) {
                return true;
            }
        }

        return false;
    }
1005530
private function checkExistingLocale($localeID)
    {
        $result = null;
        $localeRepo = $this->app->make(LocaleRepository::class);
        $existing = $localeRepo->find($localeID);
        if ($existing !== null) {
            if ($existing->isSource()) {
                $result = t("There couldn't be a language team for '%s' since it's the source language", $existing->getDisplayName());
            } elseif ($existing->isApproved()) {
                $result = t("The language team for '%s' already exists", $existing->getDisplayName());
            } elseif ($existing->getRequestedOn() !== null) {
                $result = t(
                    "The language team for '%1\$s' has already been requested on %2\$s",
                    $existing->getDisplayName(),
                    $this->app->make('date')->formatDateTime($existing->getRequestedOn(), true)
                );
            } else {
                $result = t("The language team for '%s' has already been requested", $existing->getDisplayName());
            }
        }

        return $result;
    }
513620
protected function _resetMultiLangDbFields($iLangId)
    {
        $iLangId = (int) $iLangId;

        //skipping reseting language with id = 0
        if ($iLangId) {
            \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->startTransaction();

            try {
                $oDbMeta = oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class);
                $oDbMeta->resetLanguage($iLangId);

                \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->commitTransaction();
            } catch (Exception $oEx) {
                // if exception, rollBack everything
                \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->rollbackTransaction();

                //show warning
                $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\ExceptionToDisplay::class);
                $oEx->setMessage('LANGUAGE_ERROR_RESETING_MULTILANG_FIELDS');
                \OxidEsales\Eshop\Core\Registry::getUtilsView()->addErrorToDisplay($oEx);
            }
        }
    }
262184
public function load($sOxId)
    {
        $sSelect = 'select oxid, oxuserid, oxpaymentsid, DECODE( oxvalue, "' . $this->getPaymentKey() . '" ) as oxvalue
                    from oxuserpayments where oxid = ' . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sOxId);

        return $this->assignRecord($sSelect);
    }
755960
protected function canDeleteLanguage()
    {
        return isset($this->data_language['code'])
            && $this->access('language_delete')
            && $this->language->canDelete($this->data_language['code']);
    }
690452
protected function _generateSearchStr($sOXID, $blSearchPriceCat = false)
    {

        $sCatView = getViewName('oxcategories', $this->getLanguage());
        $sO2CView = getViewName('oxobject2category');

        // we do not use lists here as we don't need this overhead right now
        if (!$blSearchPriceCat) {
            return "select {$sCatView}.* from {$sO2CView} as oxobject2category left join {$sCatView} on
                         {$sCatView}.oxid = oxobject2category.oxcatnid
                         where oxobject2category.oxobjectid=" . \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sOXID) . " and {$sCatView}.oxid is not null ";
        }
        return "select {$sCatView}.* from {$sCatView} where
                      '{$this->oxarticles__oxprice->value}' >= {$sCatView}.oxpricefrom and
                      '{$this->oxarticles__oxprice->value}' <= {$sCatView}.oxpriceto ";
    }
1343686
public function saveinnlang()
    {
        $soxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");
        // checkbox handling
        if (!isset($aParams['oxlinks__oxactive'])) {
            $aParams['oxlinks__oxactive'] = 0;
        }

        $oLinks = oxNew(\OxidEsales\Eshop\Application\Model\Links::class, getViewName('oxlinks'));
        $iEditLanguage = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editlanguage");

        if ($soxId != "-1") {
            $oLinks->loadInLang($iEditLanguage, $soxId);
        } else {
            $aParams['oxlinks__oxid'] = null;
            //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
        }

        //Disable editing for derived items
        if ($oLinks->isDerived()) {
            return;
        }

        $oLinks->setLanguage(0);
        $oLinks->assign($aParams);

        // apply new language
        $oLinks->setLanguage(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("new_lang"));
        $oLinks->save();

        // set oxid if inserted
        $this->setEditObjectId($oLinks->getId());
    }
641347
private function isMultiLangEnvironment()
    {
        // use the multilanguage parameter, if it exists
        if ($this->container->hasParameter('kunstmaan_admin.multi_language')) {
            return $this->container->getParameter('kunstmaan_admin.multi_language');
        }

        // This is a pretty silly implementation.
        // It just checks if it can find _locale in the routing.yml
        $routingFile = file_get_contents($this->rootDir.'/app/config/routing.yml');

        return preg_match('/_locale:/i', $routingFile);
    }
1197456
function hasConflicts( $editLanguage = false )
    {
        $object = $this->contentObject();
        if ( !$editLanguage )
            $editLanguage = $this->initialLanguageCode();

        // Get versions (with published or archived status)
        $versions = $object->versions( true, array( 'conditions' => array( 'status' => array( array( eZContentObjectVersion::STATUS_PUBLISHED, eZContentObjectVersion::STATUS_ARCHIVED ) ),
                                                                           'language_code' => $editLanguage ) ) );

        $conflictVersions = array();
        foreach ( array_keys( $versions ) as $key )
        {
            $version =& $versions[$key];
            if ( $version->attribute( 'modified' ) > $this->attribute( 'created' ) )
            {
                $conflictVersions[] = $version;
            }
        }
        if ( !count( $conflictVersions ) )
        {
            return false;
        }

        return $conflictVersions;
    }
45881
public function hasTranslation($language_id = null, $checkIsPublished = true)
    {
        /** @var \DevGroup\Multilingual\Multilingual $multilingual */
        $multilingual = Yii::$app->multilingual;
        if ($language_id === null) {
            $language_id = $multilingual->language_id;
        }
        /** @var ActiveRecord $owner */
        $owner = $this->owner;

        if ($language_id === $multilingual->language_id) {
            // we were asked for default language
            /** @var ActiveRecord $translation */
            $translation = $owner->{$this->defaultTranslationRelation};
            if ($translation === null) {
                return false;
            }

            if ($checkIsPublished === true) {
                return $this->checkIsPublished($translation);
            }
        }

        /* @var ActiveRecord $translation */
        foreach ($owner->{$this->translationRelation} as $translation) {
            if ($translation->getAttribute('language_id') === $language_id) {
                if ($checkIsPublished === true) {
                    return $this->checkIsPublished($translation);
                } else {
                    return true;
                }
            }
        }
        return false;
    }
644372
public function isMultilang()
	{
		// Flag to avoid doing multiple database queries.
		static $tested = false;

		// Status of language filter plugin.
		static $enabled = false;

		// If being called from the front-end, we can avoid the database query.
		if (\App::isSite())
		{
			return \App::get('language.filter');
		}

		// If already tested, don't test again.
		if (!$tested)
		{
			// Determine status of language filter plug-in.
			$db = \App::get('db');
			$query = $db->getQuery()
				->select('enabled')
				->from('#__extensions')
				->whereEquals('type', 'plugin')
				->whereEquals('folder', 'system')
				->whereEquals('element', 'languagefilter');
			$db->setQuery($query->toString());

			$enabled = $db->loadResult();
			$tested  = true;
		}

		return $enabled;
	}
603556
protected function hasLanguageCodesAsKeys(array $fields)
    {
        $languageCodes = $this->getContentLanguageCodes();

        foreach ($fields as $fieldIdentifier => $fieldData) {
            if (!is_array($fieldData) || empty($fieldData)) {
                return false;
            }

            foreach ($fieldData as $key => $data) {
                if (!in_array($key, $languageCodes, true)) {
                    return false;
                }
            }
        }

        return true;
    }
253737
public function isMultiLanguage($host = null)
    {
        $host = $this->getRealHost($host);

        if (isset($this->hosts[$host])) {
            $hostInfo = $this->hosts[$host];

            return 'multi_lang' === $hostInfo['type'];
        }

        return parent::isMultiLanguage();
    }