/** * Gets an array of the available search options. * * @return array */ public static function getAvailableSearchOptions() { $options['labels']['prefLabel'] = _('preferred'); $options['labels']['altLabel'] = _('alternative'); $options['labels']['hiddenLabel'] = _('hidden'); $options['statuses']['none'] = _('none'); // We can not filter by status deleted. Those concepts are not shown. $statuses = array_diff(OpenSKOS_Concept_Status::getStatuses(), [OpenSKOS_Concept_Status::DELETED]); foreach ($statuses as $status) { $options['statuses'][$status] = _($status); } $options['docproperties']['definition'] = _('definition'); $options['docproperties']['example'] = _('example'); $options['docproperties']['changeNote'] = _('change note'); $options['docproperties']['editorialNote'] = _('editorial note'); $options['docproperties']['historyNote'] = _('history note'); $options['docproperties']['scopeNote'] = _('scope note'); $options['interactiontypes']['created'] = _('created'); $options['interactiontypes']['modified'] = _('modified'); $options['interactiontypes']['approved'] = _('approved'); return $options; }
/** * * @param Zend_Console_Getopt $opts * @return OpenSKOS_Rdf_Parser */ public function setOpts(Zend_Console_Getopt $opts) { try { $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo str_replace('[ options ]', '[ options ] file', $e->getUsageMessage()); throw new OpenSKOS_Rdf_Parser_Exception($e->getMessage()); } if (null !== $opts->help) { echo str_replace('[ options ]', '[ options ] file', $opts->getUsageMessage()); throw new OpenSKOS_Rdf_Parser_Exception('', 0); } if ($opts->status) { $statuses = OpenSKOS_Concept_Status::getStatuses(); if (!in_array($opts->status, $statuses)) { throw new OpenSKOS_Rdf_Parser_Exception('Illegal `status` value, must be one of `' . implode('|', $statuses) . '`', 0); } } foreach (self::$required as $opt) { if (null === $this->_opts->{$opt}) { throw new OpenSKOS_Rdf_Parser_Exception("missing required parameter `{$opt}`"); } } $this->_opts = $opts; if (null !== $this->_opts->help) { $this->printUsageMessageAndExit(); } if (null !== $opts->limit) { $this->setLimit((int) $opts->limit); } if (null !== $opts->from) { $this->setFrom((int) $opts->from); } $this->_bootstrap(); $files = $this->_opts->getRemainingArgs(); if (count($files) !== 1) { throw new OpenSKOS_Rdf_Parser_Exception(str_replace('[ options ]', '[ options ] file', $this->_opts->getUsageMessage())); } $this->setFiles($files); $model = new OpenSKOS_Db_Table_Tenants(); $tenant = $model->find($opts->tenant)->current(); if (null === $tenant) { throw new OpenSKOS_Rdf_Parser_Exception("No such tenant: `{$opts->tenant}`"); } $model = new OpenSKOS_Db_Table_Collections(); if (preg_match('/^\\d+$/', $opts->collection)) { $collection = $model->find($opts->collection)->current(); } else { $collection = $model->findByCode($opts->collection, $opts->tenant); } if (null === $collection) { throw new OpenSKOS_Rdf_Parser_Exception("No such collection: `{$opts->collection}`"); } else { $this->_collection = $collection; } return $this; }