/** * Get an array of all concept classes formatted for an HTML select dropdown. * This method automatically combines classes of the same name across dictionaries * into a single select box. Optionally send a collection of selected classes. * @param ConceptClassCollection $coll_selected * @return array */ public function getHtmlChecklistArray(ConceptClassCollection $coll_selected = null) { /** * $arr_display has 3 fields: value, display, source. Source is another array of * dictionary sources in which the object is present. */ $arr_display = array(); // Combine foreach ($this->getKeys() as $key) { $o = $this->Get($key); if (!isset($arr_display[strtolower($o->name)])) { $arr_display[strtolower($o->name)] = array('value' => strtolower($o->name), 'display' => $o->name, 'hint' => '', 'selected' => false, 'source' => array()); } if ($arr_display[strtolower($o->name)]['selected'] === false && $coll_selected->IsMember($key)) { $arr_display[strtolower($o->name)]['selected'] = true; } $arr_display[strtolower($o->name)]['source'][] = $o->getSourceDictionary()->dict_db; } // Set hint column to indicate the list of dictionaries foreach (array_keys($arr_display) as $key) { $hint = ''; foreach ($arr_display[$key]['source'] as $source_text) { if ($hint) { $hint .= ', '; } $hint .= $source_text; } if ($hint) { $hint = '"' . $arr_display[$key]['display'] . '" is in the following dictionaries: ' . $hint; } $arr_display[$key]['hint'] = $hint; } return $arr_display; }
/** * Loads the concept classes from the specified dictionary. * @return ConceptClassCollection */ public function loadConceptClasses(ConceptSearchSource $css_dict) { // get the data $sql_classes = 'select concept_class_id, name, description, uuid ' . 'from concept_class ' . 'where retired != 1 ' . 'order by name'; if ($this->debug) { echo '<p><b>Loading concept classes for <strong>' . $css_dict->dict_db . '</strong>:</b><br> ' . $sql_classes . '</p>'; } $rsc_classes = mysql_query($sql_classes, $css_dict->getConnection()); if (!$rsc_classes) { echo "could not query db: " . mysql_error(); } // Create the class collection $ccc = new ConceptClassCollection(); while ($row = mysql_fetch_assoc($rsc_classes)) { $cd = new ConceptClass($row['concept_class_id'], $row['name'], $row['description'], $row['uuid']); $cd->setSourceDictionary($css_dict); // $key = '<database_name>:class(<concept_class_id>) $key = $css_dict->dict_db . ':class(' . $row['concept_class_id'] . ')'; $ccc->Add($key, $cd); } return $ccc; }