public function createInverseContext($activectx)
    {
        $inverseContext = array();

        $defaultLanguage = isset($activectx['@language']) ? $activectx['@language'] : '@null';
        $propertyGenerators = isset($activectx['@propertyGenerators']) ? $activectx['@propertyGenerators'] : array();

        unset($activectx['@base']);
        unset($activectx['@vocab']);
        unset($activectx['@language']);
        unset($activectx['@propertyGenerators']);

        $activectx = array_merge($activectx, $propertyGenerators);
        unset($propertyGenerators);

        uksort($activectx, array($this, 'sortTerms'));

        // Put every IRI of each term into the inverse context
        foreach ($activectx as $term => $def) {
            if (null === $def['@id']) {
                // this is necessary since some terms can be decoupled from @vocab
                continue;
            }

            $container = (isset($def['@container'])) ? $def['@container'] : '@null';
            $iri = $def['@id'];

            if (false === isset($inverseContext[$iri]['term']) && (false === $def['@reverse'])) {
                $inverseContext[$iri]['term'] = $term;
            }

            $typeOrLang = '@null';
            $typeLangValue = '@null';

            if (true === $def['@reverse']) {
                $typeOrLang = '@type';
                $typeLangValue = '@reverse';
            } elseif (isset($def['@type'])) {
                $typeOrLang = '@type';
                $typeLangValue = $def['@type'];
            } elseif (array_key_exists('@language', $def)) {  // can be null
                $typeOrLang = '@language';
                $typeLangValue = (null === $def['@language']) ? '@null' : $def['@language'];
            } else {
                // Every untyped term is implicitly set to the default language
                if (false === isset($inverseContext[$iri][$container]['@language'][$defaultLanguage])) {
                    $inverseContext[$iri][$container]['@language'][$defaultLanguage] = $term;
                }
            }

            if (false === isset($inverseContext[$iri][$container][$typeOrLang][$typeLangValue])) {
                $inverseContext[$iri][$container][$typeOrLang][$typeLangValue] = $term;
            }
        }

        // Sort the whole inverse context in reverse order, the longest IRI comes first
        uksort($inverseContext, array($this, 'sortTerms'));
        $inverseContext = array_reverse($inverseContext);

        return $inverseContext;
    }
public function createInverseContext($activectx)
    {
        $inverseContext = array();

        $defaultLanguage = isset($activectx['@language']) ? $activectx['@language'] : '@null';
        $propertyGenerators = isset($activectx['@propertyGenerators']) ? $activectx['@propertyGenerators'] : array();

        unset($activectx['@base']);
        unset($activectx['@vocab']);
        unset($activectx['@language']);
        unset($activectx['@propertyGenerators']);

        $activectx = array_merge($activectx, $propertyGenerators);
        unset($propertyGenerators);

        uksort($activectx, array($this, 'sortTerms'));

        // Put every IRI of each term into the inverse context
        foreach ($activectx as $term => $def) {
            if (null === $def['@id']) {
                // this is necessary since some terms can be decoupled from @vocab
                continue;
            }

            $container = (isset($def['@container'])) ? $def['@container'] : '@null';
            $iri = $def['@id'];

            if (false === isset($inverseContext[$iri]['term']) && (false === $def['@reverse'])) {
                $inverseContext[$iri]['term'] = $term;
            }

            $typeOrLang = '@null';
            $typeLangValue = '@null';

            if (true === $def['@reverse']) {
                $typeOrLang = '@type';
                $typeLangValue = '@reverse';
            } elseif (isset($def['@type'])) {
                $typeOrLang = '@type';
                $typeLangValue = $def['@type'];
            } elseif (array_key_exists('@language', $def)) {  // can be null
                $typeOrLang = '@language';
                $typeLangValue = (null === $def['@language']) ? '@null' : $def['@language'];
            } else {
                // Every untyped term is implicitly set to the default language
                if (false === isset($inverseContext[$iri][$container]['@language'][$defaultLanguage])) {
                    $inverseContext[$iri][$container]['@language'][$defaultLanguage] = $term;
                }
            }

            if (false === isset($inverseContext[$iri][$container][$typeOrLang][$typeLangValue])) {
                $inverseContext[$iri][$container][$typeOrLang][$typeLangValue] = $term;
            }
        }

        // Sort the whole inverse context in reverse order, the longest IRI comes first
        uksort($inverseContext, array($this, 'sortTerms'));
        $inverseContext = array_reverse($inverseContext);

        return $inverseContext;
    }
public function createInverseContext ( $ activectx ) { $ inverseContext = array ( ) ; $ defaultLanguage = isset ( $ activectx [ '@language' ] ) ? $ activectx [ '@language' ] : '@null' ; $ propertyGenerators = isset ( $ activectx [ '@propertyGenerators' ] ) ? $ activectx [ '@propertyGenerators' ] : array ( ) ; unset ( $ activectx [ '@base' ] ) ; unset ( $ activectx [ '@vocab' ] ) ; unset ( $ activectx [ '@language' ] ) ; unset ( $ activectx [ '@propertyGenerators' ] ) ; $ activectx = array_merge ( $ activectx , $ propertyGenerators ) ; unset ( $ propertyGenerators ) ; uksort ( $ activectx , array ( $ this , 'sortTerms' ) ) ; // Put every IRI of each term into the inverse context foreach ( $ activectx as $ term => $ def ) { if ( null === $ def [ '@id' ] ) { // this is necessary since some terms can be decoupled from @vocab continue ; } $ container = ( isset ( $ def [ '@container' ] ) ) ? $ def [ '@container' ] : '@null' ; $ iri = $ def [ '@id' ] ; if ( false === isset ( $ inverseContext [ $ iri ] [ 'term' ] ) && ( false === $ def [ '@reverse' ] ) ) { $ inverseContext [ $ iri ] [ 'term' ] = $ term ; } $ typeOrLang = '@null' ; $ typeLangValue = '@null' ; if ( true === $ def [ '@reverse' ] ) { $ typeOrLang = '@type' ; $ typeLangValue = '@reverse' ; } elseif ( isset ( $ def [ '@type' ] ) ) { $ typeOrLang = '@type' ; $ typeLangValue = $ def [ '@type' ] ; } elseif ( array_key_exists ( '@language' , $ def ) ) { // can be null $ typeOrLang = '@language' ; $ typeLangValue = ( null === $ def [ '@language' ] ) ? '@null' : $ def [ '@language' ] ; } else { // Every untyped term is implicitly set to the default language if ( false === isset ( $ inverseContext [ $ iri ] [ $ container ] [ '@language' ] [ $ defaultLanguage ] ) ) { $ inverseContext [ $ iri ] [ $ container ] [ '@language' ] [ $ defaultLanguage ] = $ term ; } } if ( false === isset ( $ inverseContext [ $ iri ] [ $ container ] [ $ typeOrLang ] [ $ typeLangValue ] ) ) { $ inverseContext [ $ iri ] [ $ container ] [ $ typeOrLang ] [ $ typeLangValue ] = $ term ; } } // Sort the whole inverse context in reverse order, the longest IRI comes first uksort ( $ inverseContext , array ( $ this , 'sortTerms' ) ) ; $ inverseContext = array_reverse ( $ inverseContext ) ; return $ inverseContext ; }
Creates an inverse context to simplify IRI compaction

The inverse context is a multidimensional array that has the
following shape:

<code>
[container|@null|term]
[@type|@language][typeIRI|languageCode]
[@null][@null]
[term|propGen]
[ array of terms ]
</code>

@param array $activectx The active context.

@return array The inverse context.
Creates an inverse context to simplify IRI compaction