Archive (remove or historize) obsolete URL aliases (for translations that were removed).

@param int $languageMask all languages bit mask
@param int $languageId removed language Id
@param int $parent
@param string $textMD5 checksum
@param $linkId
779681
private function archiveUrlAliasForDeletedTranslation($languageMask, $languageId, $parent, $textMD5, $linkId)
    {
        // If language mask is composite (consists of multiple languages) then remove given language from entry
        if ($languageMask & ~($languageId | 1)) {
            $this->removeTranslation($parent, $textMD5, $languageId);
        } else {
            // Otherwise mark entry as history
            $this->historize($parent, $textMD5, $linkId);
        }
    }
744652
protected function tagResponse(ReadBlockInterface $block, $nodeId, $siteId, $language)
    {
        $tagManager = $this->get('open_orchestra_base.manager.tag');

        $cacheTags = $this->get('open_orchestra_display.display_block_manager')->getCacheTags($block);

        if (true === $block->isTransverse()) {
            $cacheTags[] = $tagManager->formatNodeIdTag($nodeId);
        }

        $cacheTags[] = $tagManager->formatSiteIdTag($siteId);
        $cacheTags[] = $tagManager->formatLanguageTag($language);

        $this->get('open_orchestra_display.manager.cacheable')->addCacheTags($cacheTags);
    }
705301
public void deleteLinkLocalization(SIBUuid12 linkUuid)
                    throws SINotPossibleInCurrentConfigurationException,
                    SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "deleteLinkLocalization",
                        new Object[] { linkUuid });

        // Get the destination
        LinkTypeFilter filter = new LinkTypeFilter();
        filter.MQLINK = Boolean.FALSE;

        // includeInvisible?
        // filter.VISIBLE = Boolean.TRUE;

        LinkHandler linkHandler =
                        (LinkHandler) linkIndex.findByUuid(linkUuid, filter);

        // Check that we have a handler for this link.
        checkLinkExists(
                        linkHandler != null,
                        linkUuid.toString()); // Only have the Uuid to hand.

        //The lock on the destinationManager is taken to stop 2 threads creating the same
        //destination and also to synchronize dynamic deletes with the
        //creation of aliases.  This stops an alias destination being created that targets a
        //destination in the process of being deleted.
        synchronized (this)
        {
            synchronized (linkHandler)
            {
                // Mark the destination for deletion
                try
                {
                    // Set the deletion flag in the DH persistently. A transaction per DH??
                    LocalTransaction siTran = txManager.createLocalTransaction(true);

                    linkHandler.setToBeDeleted(true);
                    //Adjust the destination lookups in Destination Manager
                    linkIndex.delete(linkHandler);
                    linkHandler.requestUpdate((Transaction) siTran);
                    // commit the transaction
                    siTran.commit();

                    SibTr.info(tc, "LOCAL_LINK_DELETE_INFO_CWSIP0065",
                               new Object[] { linkHandler.getName(), linkHandler.getUuid() });
                } catch (MessageStoreException e)
                {
                    // MessageStoreException shouldn't occur so FFDC.
                    FFDCFilter.processException(
                                                e,
                                                "com.ibm.ws.sib.processor.impl.DestinationManager.deleteLinkLocalization",
                                                "1:3285:1.508.1.7",
                                                this);

                    SibTr.exception(tc, e);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.exit(tc, "deleteLinkLocalization", "SIResourceException");
                    throw new SIResourceException(e);
                } catch (SIException e)
                {
                    // No FFDC code needed

                    SibTr.exception(tc, e);

                    //handleRollback(siTran);
                    //        throw e;
                }

                //Add all the localisations to the set of those requiring clean-up
                linkHandler.addAllLocalisationsForCleanUp();

                //Clear the set of ME's that localise the destination
                linkHandler.clearLocalisingUuidsSet();

            } // eof synchronized on linkHandler

            startAsynchDeletion();

            // Close all connections to the localisation
            // Ensure that before calling these methods, the destination is marked
            // to-be-deleted or is marked as deleted, to avoid any new producers and
            // consumers attaching after we have closed the currently attached ones.
            linkHandler.closeProducers();
            linkHandler.closeConsumers();

            //Delete all aliases that target this destination
            linkHandler.deleteTargettingAliases();

        } // eof synchronized on DestinationManager

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "deleteLinkLocalization");

        return;
    }
497723
public function loadRow($parentId, $textMD5)
    {
        /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */
        $query = $this->dbHandler->createSelectQuery();
        $query->select('*')->from(
            $this->dbHandler->quoteTable($this->table)
        )->where(
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('parent'),
                    $query->bindValue($parentId, null, \PDO::PARAM_INT)
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('text_md5'),
                    $query->bindValue($textMD5, null, \PDO::PARAM_STR)
                )
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetch(\PDO::FETCH_ASSOC);
    }
1168379
public function actionEdit($templateId, $languageId = null)
    {
        $editForm = new EditForm([
            'templateId' => $templateId,
            'languageId' => $languageId
        ]);
        return $this->renderForm($editForm, 'edit');
    }
250137
public function translationRemoved(array $locationIds, $languageCode)
    {
        $languageId = $this->languageHandler->loadByLanguageCode($languageCode)->id;

        $actions = [];
        foreach ($locationIds as $locationId) {
            $actions[] = 'eznode:' . $locationId;
        }
        $this->gateway->bulkRemoveTranslation($languageId, $actions);
    }
71678
public function delete($lang, $id)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess('Tags', 'delete')) {
            return $this->noPermission();
        }

        $tagDeleteRes = $this->deleteTag($id);
        if(gettype($tagDeleteRes) == "boolean") {
            if($tagDeleteRes) {
                return $this->response('Tag is successfully deleted');
            }
        }else{
            return $tagDeleteRes;
        }
        return $this->response('Tag could not be deleted. Please try again later or contact your Administrator!', 500);
    }
93211
function addMultiLink($id, $linkType = 'Entry', $languageKey = null) {
        if (!$languageKey) {
            $languageKey = $this->language;
        }
        $this->links[$languageKey][] = ['sys' => [
                    'type' => 'Link',
                    'linkType' => $linkType,
                    'id' => $id
                ]
        ];
        return $this;
    }
980604
function removeTranslation( $languageID )
    {
        $language = eZContentLanguage::fetch( $languageID );

        if ( !$language )
        {
            return false;
        }

        // check if it is not the initial language
        $classInitialLanguageID = $this->attribute( 'initial_language_id' );
        if ( $classInitialLanguageID == $languageID )
        {
            return false;
        }

        $db = eZDB::instance();
        $db->begin();

        $classID = $this->attribute( 'id' );
        $languageID = $language->attribute( 'id' );

        // change language_mask of the object
        $languageMask = (int) $this->attribute( 'language_mask' );
        $languageMask = (int) $languageMask & ~ (int) $languageID;
        $this->setAttribute( 'language_mask', $languageMask );

        // Remove all names in the language
        $db->query( "DELETE FROM ezcontentclass_name
                     WHERE contentclass_id='$classID'
                       AND language_id='$languageID'" );

        $languageLocale = $language->attribute( 'locale' );
        $this->NameList->removeName( $languageLocale );
        $this->DescriptionList->removeName( $languageLocale );

        $this->store();

        // Remove names for attributes in the language
        $attributes = $this->fetchAttributes();
        foreach ( $attributes as $attribute )
        {
            $attribute->removeTranslation( $languageLocale );
            $attribute->store();
        }

        $db->commit();

        return true;
    }
1044392
public function verifyAlias($alias, $langId)
    {
        if (Yii::$app->hasModule($alias) && $this->parent_nav_id == 0) {
            $this->addError('alias', Module::t('nav_item_model_error_modulenameexists', ['alias' => $alias]));

            return false;
        }

        if ($this->parent_nav_id === null) {
            $this->addError('parent_nav_id', Module::t('nav_item_model_error_parentnavidcannotnull'));
            
            return false;
        }

        if ($this->find()->where(['alias' => $alias, 'lang_id' => $langId])->leftJoin('cms_nav', 'cms_nav_item.nav_id=cms_nav.id')->andWhere(['=', 'cms_nav.parent_nav_id', $this->parent_nav_id])->exists()) {
            $this->addError('alias', Module::t('nav_item_model_error_urlsegementexistsalready'));

            return false;
        }
    }
200325
protected function buildSitemap($rootPageId, $languageId)
    {
        if ($languageId !== null) {
            // Language lock enabled
            $rootPageLinkTemplate = 'sitemap-r%s-l%s-p###PAGE###.xml.gz';
            $sitemapIndexFileName = 'index-r%s-l%s.xml.gz';
            $sitemapPageFileName  = 'sitemap-r%s-l%s-p%s.xml.gz';
        } else {
            $rootPageLinkTemplate = 'sitemap-r%s-p###PAGE###.xml.gz';
            $sitemapIndexFileName = 'index-r%s.xml.gz';
            $sitemapPageFileName  = 'sitemap-r%s-p%3$s.xml.gz';
        }

        // Init builder
        $generator = $this->objectManager->get('Metaseo\\Metaseo\\Sitemap\\Generator\\XmlGenerator');
        $fileName  = sprintf($rootPageLinkTemplate, $rootPageId, $languageId);

        $generator->indexPathTemplate = $this->generateSitemapLinkTemplate($fileName);

        // Get list of pages
        $pageCount = $generator->pageCount();

        // Index
        $content  = $generator->sitemapIndex();
        $fileName = sprintf($sitemapIndexFileName, $rootPageId, $languageId);
        $this->writeToFile(PATH_site . '/' . $this->sitemapDir . '/' . $fileName, $content);

        // Page
        for ($i = 0; $i < $pageCount; $i++) {
            $content  = $generator->sitemap($i);
            $fileName = sprintf($sitemapPageFileName, $rootPageId, $languageId, $i);
            $this->writeToFile(PATH_site . '/' . $this->sitemapDir . '/' . $fileName, $content);
        }

        return true;
    }
321689
public function resetLanguage($langId)
    {
        if ((int) $langId === 0) {
            return;
        }

        $tables = $this->getAllTables();

        // removing tables which does not requires reset
        foreach ($this->_aSkipTablesOnReset as $skipTable) {
            if (($skipId = array_search($skipTable, $tables)) !== false) {
                unset($tables[$skipId]);
            }
        }

        foreach ($tables as $tableName) {
            $this->resetMultilangFields($langId, $tableName);
        }
    }
829852
public function cleanup($dirty, $languageCode = null)
    {
        $replacers = $this->replacers['default'];

        if (null !== $languageCode) {
            $replacers = array_merge(
                $replacers,
                (isset($this->replacers[$languageCode]) ? $this->replacers[$languageCode] : [])
            );
        }

        if (count($replacers) > 0) {
            foreach ($replacers as $key => $value) {
                $dirty = str_replace($key, $value, $dirty);
            }
        }

        $clean = strtolower($dirty);

        // Inspired by ZOOLU
        // delete problematic characters
        $clean = str_replace('%2F', '/', urlencode(preg_replace('/([^A-za-z0-9 -_\/])/', '', $clean)));

        // replace multiple dash with one
        $clean = preg_replace('/([-]+)/', '-', $clean);

        // remove dash after slash
        $clean = preg_replace('/\/[-]+/', '/', $clean);

        // delete dash at the beginning or end
        $clean = preg_replace('/^([-])/', '', $clean);
        $clean = preg_replace('/([-])$/', '', $clean);

        // remove double slashes
        $clean = str_replace('//', '/', $clean);

        return $clean;
    }
1298227
public function extractLanguageCodesFromMask($languageMask): array
    {
        $languageCodes = [];
        $languageList = $this->languageHandler->loadList(
            $this->extractLanguageIdsFromMask($languageMask)
        );
        foreach ($languageList as $language) {
            $languageCodes[] = $language->languageCode;
        }

        return $languageCodes;
    }
349000
public function linkTag($text, &$data, &$root)
    {
        parent::linkPlainTag($text, $data, $root);
        $this->_name = '@link';
    }
238145
protected function searchMissingNodeLanguage($nodeId, array $languages, $siteId, NodeRepositoryInterface $nodeRepository)
    {
        $missingLanguages = [];
        foreach ($languages as $language) {
            if ($nodeRepository->countNotDeletedVersions($nodeId, $language, $siteId) === 0) {
                $missingLanguages[] = $language;
            }
        }

        return $missingLanguages;
    }
539738
public function actionDeleteLanguage($id)
    {
        $model = $this->findLanguageModel($id);
        $model->delete();
        return $this->redirect(['edit', 'id' => $model->context_id]);
    }