public function getSuggestedValues($bas_id)
    {
        /** @var \databox $databox */
        $databox = $this->app->findDataboxById(\phrasea::sbasFromBas($this->app, $bas_id));
        $collection = \collection::getByBaseId($this->app, $bas_id);
        $structFields = $suggestedValues = $basePrefs = [];

        /** @var \databox_field $meta */
        foreach ($databox->get_meta_structure() as $meta) {
            if ($meta->is_readonly()) {
                continue;
            }

            $structFields[$meta->get_name()] = $meta;
        }

        if ($sxe = simplexml_load_string($collection->get_prefs())) {
            $z = $sxe->xpath('/baseprefs/sugestedValues');
            if ($z && is_array($z)) {
                $f = 0;
                foreach ($z[0] as $ki => $vi) {
                    if ($vi && isset($structFields[$ki])) {
                        foreach ($vi->value as $oneValue) {
                            $suggestedValues[] = [
                                'key'   => $ki,
                                'value' => $f,
                                'name'  => (string) $oneValue
                            ];
                            $f++;
                        }
                    }
                }
            }

            $z = $sxe->xpath('/baseprefs');
            if ($z && is_array($z)) {
                /**
                 * @var string $ki
                 * @var \SimpleXMLElement $vi
                 */
                foreach ($z[0] as $ki => $vi) {
                    $pref = ['status' => null, 'xml'    => null];

                    if ($ki == 'status') {
                        $pref['status'] = $vi;
                    } elseif ($ki != 'sugestedValues') {
                        $pref['xml'] = $vi->asXML();
                    }

                    $basePrefs[] = $pref;
                }
            }
        }

        return $this->render('admin/collection/suggested_value.html.twig', [
            'collection'      => $collection,
            'databox'         => $databox,
            'suggestedValues' => $suggestedValues,
            'structFields'    => $structFields,
            'basePrefs'       => $basePrefs,
        ]);
    }
public function getSuggestedValues($bas_id)
    {
        /** @var \databox $databox */
        $databox = $this->app->findDataboxById(\phrasea::sbasFromBas($this->app, $bas_id));
        $collection = \collection::getByBaseId($this->app, $bas_id);
        $structFields = $suggestedValues = $basePrefs = [];

        /** @var \databox_field $meta */
        foreach ($databox->get_meta_structure() as $meta) {
            if ($meta->is_readonly()) {
                continue;
            }

            $structFields[$meta->get_name()] = $meta;
        }

        if ($sxe = simplexml_load_string($collection->get_prefs())) {
            $z = $sxe->xpath('/baseprefs/sugestedValues');
            if ($z && is_array($z)) {
                $f = 0;
                foreach ($z[0] as $ki => $vi) {
                    if ($vi && isset($structFields[$ki])) {
                        foreach ($vi->value as $oneValue) {
                            $suggestedValues[] = [
                                'key'   => $ki,
                                'value' => $f,
                                'name'  => (string) $oneValue
                            ];
                            $f++;
                        }
                    }
                }
            }

            $z = $sxe->xpath('/baseprefs');
            if ($z && is_array($z)) {
                /**
                 * @var string $ki
                 * @var \SimpleXMLElement $vi
                 */
                foreach ($z[0] as $ki => $vi) {
                    $pref = ['status' => null, 'xml'    => null];

                    if ($ki == 'status') {
                        $pref['status'] = $vi;
                    } elseif ($ki != 'sugestedValues') {
                        $pref['xml'] = $vi->asXML();
                    }

                    $basePrefs[] = $pref;
                }
            }
        }

        return $this->render('admin/collection/suggested_value.html.twig', [
            'collection'      => $collection,
            'databox'         => $databox,
            'suggestedValues' => $suggestedValues,
            'structFields'    => $structFields,
            'basePrefs'       => $basePrefs,
        ]);
    }
public function getSuggestedValues ( $ bas_id ) { /** @var \databox $databox */ $ databox = $ this -> app -> findDataboxById ( \ phrasea :: sbasFromBas ( $ this -> app , $ bas_id ) ) ; $ collection = \ collection :: getByBaseId ( $ this -> app , $ bas_id ) ; $ structFields = $ suggestedValues = $ basePrefs = [ ] ; /** @var \databox_field $meta */ foreach ( $ databox -> get_meta_structure ( ) as $ meta ) { if ( $ meta -> is_readonly ( ) ) { continue ; } $ structFields [ $ meta -> get_name ( ) ] = $ meta ; } if ( $ sxe = simplexml_load_string ( $ collection -> get_prefs ( ) ) ) { $ z = $ sxe -> xpath ( '/baseprefs/sugestedValues' ) ; if ( $ z && is_array ( $ z ) ) { $ f = 0 ; foreach ( $ z [ 0 ] as $ ki => $ vi ) { if ( $ vi && isset ( $ structFields [ $ ki ] ) ) { foreach ( $ vi -> value as $ oneValue ) { $ suggestedValues [ ] = [ 'key' => $ ki , 'value' => $ f , 'name' => ( string ) $ oneValue ] ; $ f ++ ; } } } } $ z = $ sxe -> xpath ( '/baseprefs' ) ; if ( $ z && is_array ( $ z ) ) { /**
                 * @var string $ki
                 * @var \SimpleXMLElement $vi
                 */ foreach ( $ z [ 0 ] as $ ki => $ vi ) { $ pref = [ 'status' => null , 'xml' => null ] ; if ( $ ki == 'status' ) { $ pref [ 'status' ] = $ vi ; } elseif ( $ ki != 'sugestedValues' ) { $ pref [ 'xml' ] = $ vi -> asXML ( ) ; } $ basePrefs [ ] = $ pref ; } } } return $ this -> render ( 'admin/collection/suggested_value.html.twig' , [ 'collection' => $ collection , 'databox' => $ databox , 'suggestedValues' => $ suggestedValues , 'structFields' => $ structFields , 'basePrefs' => $ basePrefs , ] ) ; }
Display suggested values

@param integer $bas_id  The collection base_id
@return string
Display suggested values