public function createAction() { $this->_requireAccess('editor.concepts', 'propose', self::RESPONSE_TYPE_PARTIAL_HTML); $this->_helper->_layout->setLayout('editor_central_content'); $notation = OpenSKOS_Db_Table_Notations::getNext(); $initialLanguage = Zend_Registry::get('Zend_Locale')->getLanguage(); $editorOptions = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('editor'); if (!empty($editorOptions['languages']) && !in_array($initialLanguage, $editorOptions['languages'])) { // If the browser language is supported $initialLanguage = key($editorOptions['languages']); } $concept = new Editor_Models_Concept(new Api_Models_Concept(array('prefLabel@' . $initialLanguage => array($this->getRequest()->getParam('label')), 'notation' => array($notation)))); $form = Editor_Forms_Concept::getInstance(true); $formData = $concept->toForm(); $form->getElement('conceptSchemeSelect')->setMultiOptions($formData['conceptSchemeSelect']); $form->populate($formData); $this->view->form = $form->setAction($this->getFrontController()->getRouter()->assemble(array('controller' => 'concept', 'action' => 'save'))); }
/** * Registers the notation of the document in the database, or generates one if the document does not have notation. * * @return OpenSKOS_Solr */ public function registerOrGenerateNotation() { if (isset($this->data['class']) && $this->data['class'] == 'Concept' || isset($this->data['class'][0]) && $this->data['class'][0] == 'Concept') { $currentNotation = ''; if (isset($this->data['notation']) && isset($this->data['notation'][0])) { $currentNotation = $this->data['notation'][0]; } if (empty($currentNotation)) { $this->fieldnames[] = 'notation'; $this->data['notation'] = array(OpenSKOS_Db_Table_Notations::getNext()); // Adds the notation to the xml. At the end just before </rdf:Description> $closingTag = '</rdf:Description>'; $notationTag = '<skos:notation>' . $this->data['notation'][0] . '</skos:notation>'; $xml = $this->data['xml']; $xml = str_replace($closingTag, $notationTag . $closingTag, $xml); $this->data['xml'] = $xml; } else { if (!OpenSKOS_Db_Table_Notations::isRegistered($currentNotation)) { // If we do not have the notation registered - register it. OpenSKOS_Db_Table_Notations::register($currentNotation); } } } return $this; }