/**
  * Selector is a string key or an array of keys. Keys may be in one of these formats:
  * 
  * Fully specified Integer:     <dictionary_name>:class(<concept_class_id>)
  * Fully specified name:		<dictionary_name>:class(<concept_class_name>)
  * Default dictionary:  		<concept_class_id>
  * Only name:					<concept_class_name>
  * 
  * <concept_class_name> must be quoted if it contains non-word characters.
  * Note that setDefaultDictionary() must be called if using the default dictionary format.
  */
 public function getClasses($selector)
 {
     $ccc = new ConceptClassCollection();
     if (!is_array($selector)) {
         $selector = array($selector);
     }
     foreach ($selector as $key) {
         $key = strtolower(trim($key));
         // <dictionary_name>:class(<concept_class_id>) OR <dictionary_name>:class(<concept_class_name>)
         if (strpos($key, ':class(', 0) !== false && strpos($key, ')', strlen($key) - 1) !== false) {
             // Parse out dict_name and class_identifier
             $dict_name = trim(substr($key, 0, strpos($key, ':class')));
             $class_identifier = trim(substr($key, strlen($dict_name) + strlen(':class('), strlen($key) - strlen($dict_name) - strlen(':class(') - 1));
             if (substr($class_identifier, 0, 1) == '"' && substr($class_identifier, strlen($class_identifier) - 1, 1) == '"') {
                 $class_identifier = trim(substr($class_identifier, 1, strlen($class_identifier) - 2));
             }
             // <dictionary_name>:class(<concept_class_id>)
             if ($this->isInteger($class_identifier)) {
                 $new_key = $dict_name . ':class(' . $class_identifier . ')';
                 if ($this->IsMember($new_key)) {
                     $ccc->Add($new_key, $this->Get($new_key));
                 }
             } else {
                 foreach ($this->getKeys() as $class_key) {
                     $class = $this->Get($class_key);
                     if (strtolower($class->name) == $class_identifier && strtolower($class->getSourceDictionary()->dict_db) == $dict_name) {
                         $ccc->Add($class_key, $class);
                         break;
                     }
                 }
             }
         } else {
             // <concept_class_id> - this uses the default dictionary setting
             if ($this->isInteger($key)) {
                 // Default dictionary key
                 if (!$this->css_dict) {
                     trigger_error('Default dictionary must be set in ConceptClassCollection if using default dictionary format', E_USER_ERROR);
                 }
                 $key = $this->css_dict->dict_db . ':class(' . $key . ')';
                 if ($this->IsMember($key)) {
                     $ccc->Add($key, $this->Get($key));
                 }
             } else {
                 foreach ($this->getKeys() as $class_key) {
                     $class = $this->Get($class_key);
                     if (strtolower($class->name) == $key) {
                         $ccc->Add($class_key, $class);
                     }
                 }
             }
         }
     }
     return $ccc;
 }
 /**
  * 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;
 }