public function indexAction() { $user = OpenSKOS_Db_Table_Users::requireFromIdentity(); $apiClient = new Editor_Models_ApiClient(); $this->view->assign('conceptSchemes', $apiClient->getAllConceptSchemeUriTitlesMap()); $this->view->assign('conceptSchemesId', $apiClient->getConceptSchemeMap('uri', 'uuid')); $this->view->assign('disableSearchProfileChanging', $user->disableSearchProfileChanging); $this->view->assign('exportForm', Editor_Forms_Export::getInstance()); $this->view->assign('deleteForm', Editor_Forms_Delete::getInstance()); $this->view->assign('changeStatusForm', Editor_Forms_ChangeStatus::getInstance()); $this->view->assign('historyData', $user->getUserHistory()); $this->view->assign('searchForm', Editor_Forms_Search::getInstance()); }
/** * Parses all the form data and * loads it into the model. * @param array $formData * @return $sextraData */ public function transformFormData(array &$formData) { $formMapping = $this->_getFormMapping(); // Remove notation from language fields. For editor it is not translatable. $formMapping['languageFields'] = array_diff($formMapping['languageFields'], array('notation')); $extraData = array(); $apiClient = new Editor_Models_ApiClient(); $schemeMap = $apiClient->getConceptSchemeMap('uuid', 'uri'); foreach ($formData as $key => $value) { if (in_array($key, $formMapping['languageFields'])) { foreach ($formData[$key] as $languageCode => $values) { $values = array_filter($values); if (!empty($languageCode) && !empty($values)) { $formData[$key . '@' . $languageCode] = $values; } } unset($formData[$key]); } else { if (in_array($key, $formMapping['uuid2uri'])) { if (is_array($formData[$key]) && array_filter($formData[$key])) { foreach ($formData[$key] as $position => $value) { if (isset($schemeMap[$value])) { $formData[$key][$position] = $schemeMap[$value]; } else { unset($formData[$key][$position]); } } } else { unset($formData[$key]); } } else { if (in_array($key, $formMapping['resourceFields'])) { if (!is_array($formData[$key]) || !array_filter($formData[$key])) { unset($formData[$key]); } else { $formData[$key] = array_filter(array_unique($formData[$key])); foreach ($formData[$key] as $index => $value) { $formData[$key][$index] = $this->_getUriFromUuid($value); } } } else { if (in_array($key, $formMapping['helperFields'])) { unset($formData[$key]); } } } } } foreach ($formData as $key => $value) { if (in_array($key, $formMapping['extraFields'])) { $extraData[$key] = $formData[$key]; unset($formData[$key]); } } return $extraData; }
public function showFormAction() { $this->_helper->_layout->setLayout('editor_modal_box'); $user = OpenSKOS_Db_Table_Users::requireFromIdentity(); if ((bool) $this->getRequest()->getParam('reInitForm', false)) { $this->view->form = new Editor_Forms_SearchOptions(); } else { $this->view->form = Editor_Forms_SearchOptions::getInstance(); } $this->view->form->setAction($this->getFrontController()->getRouter()->assemble(array('controller' => 'search', 'action' => 'set-options'))); $profilesModel = new OpenSKOS_Db_Table_SearchProfiles(); if ((bool) $this->getRequest()->getParam('resetDefaults', false) || (bool) $this->getRequest()->getParam('switchProfile', false)) { // If param searchProfileId is set - loads the form for that profile. $profileId = $this->getRequest()->getParam('searchProfileId', ''); if (!empty($profileId)) { $profile = $profilesModel->find($profileId); if ($profile->count() > 0) { $profileSearchOptions = $profile->current()->getSearchOptions(); $profileSearchOptions = array_merge($profileSearchOptions, array('searchProfileId' => $profileId, 'switchProfile' => false)); $this->view->form->populate($profileSearchOptions); } } else { $this->view->form->populate(Editor_Forms_SearchOptions::getDefaultSearchOptions()); } } else { // If the form is opened (not submited with errors) populate it with the data from the user session. if (!$this->getRequest()->isPost()) { $options = $user->getSearchOptions(); if (empty($options)) { $options = Editor_Forms_SearchOptions::getDefaultSearchOptions(); } $this->view->form->populate($options); } } // Switch profile is set to true only from js $this->view->form->getElement('switchProfile')->setValue(0); // Check is editing and deleting of the selected profile allowed for the current user. $profile = $profilesModel->find($this->view->form->getElement('searchProfileId')->getValue()); if ($profile->count() > 0) { if (!($user->isAllowed('editor.manage-search-profiles', null) || $user->id == $profile->current()->creatorUserId)) { $this->view->form->getElement('save')->setAttrib('class', 'do-not-show'); $this->view->form->getElement('delete')->setAttrib('class', 'do-not-show'); } } else { $this->view->form->getElement('save')->setAttrib('class', 'do-not-show'); $this->view->form->getElement('delete')->setAttrib('class', 'do-not-show'); } // Send profiles options to refresh the search profile selector. $this->view->assign('conceptSchemeOptions', $this->_getConceptSchemeOptions()); $this->view->assign('profilesOptions', $this->_getProfilesSelectOptions()); // Set concept scheme - collections map. $apiClient = new Editor_Models_ApiClient(); $conceptSchemes = $apiClient->getConceptSchemeMap('uri', 'collection'); $collectionsConceptSchemesMap = array_fill_keys(array_values($conceptSchemes), array()); foreach ($conceptSchemes as $conceptSchemeUri => $conceptSchemeCollection) { $collectionsConceptSchemesMap[$conceptSchemeCollection][] = $conceptSchemeUri; } $this->view->assign('collectionsConceptSchemesMap', $collectionsConceptSchemesMap); }