public function addKeyword($num, $type = "") { $val = new ClassificationKeywords(); $val->setKeywordType($type); $form = new ClassificationKeywordsForm($val); $this->embeddedForms['newKeywords']->embedForm($num, $form); //Re-embedding the container $this->embedForm('newKeywords', $this->embeddedForms['newKeywords']); }
include dirname(__FILE__) . '/../../bootstrap/Doctrine.php'; $t = new lime_test(14, new lime_output_color()); $taxs = Doctrine::getTable('Taxonomy')->findOneByName('Falco Peregrinus eliticus'); $t->info('findWithParents($id)'); $taxa = Doctrine::getTable('Taxonomy')->findWithParents($taxs->getId()); $t->isnt($taxa, null, 'we got a taxa'); $t->is($taxa->count(), 9, 'we got all parent of the taxa'); $t->is($taxa[7]->getId(), $taxs->getParentRef(), 'Parent is correct'); $t->is($taxa[1]->Level->__toString(), 'kingdom', 'get Level'); $t->is($taxs->getNameWithFormat(), '<i>Falco Peregrinus eliticus</i>', 'get Name without extinct'); $taxs->setExtinct('true'); $t->is($taxs->getNameWithFormat(), '<i>Falco Peregrinus eliticus</i> †', 'get Name without extinct'); $t->is(DarwinTable::getFilterForTable('classification_syonymies'), "ClassificationSyonymiesFormFilter", 'Filter Form name'); $t->is(DarwinTable::getFormForTable('classification_syonymies'), "ClassificationSyonymiesForm", 'Form Name'); $t->is(DarwinTable::getModelForTable('classification_syonymies'), "ClassificationSyonymies", 'Model Name'); $t->is(Doctrine::getTable('Taxonomy')->find(4)->toArray(), true, 'We got the record with find'); $t->is(Doctrine::getTable('Taxonomy')->find(-1)->toArray(), true, 'Record bellow 0 are found with find'); $keywords = Doctrine::getTable('ClassificationKeywords')->findForTable('taxonomy', 4); $t->is(count($keywords), 0, 'No KW per default'); $kw_full = ClassificationKeywords::getTags('taxonomy'); $avail_kw = array_keys($kw_full); $kw = new ClassificationKeywords(); $kw->setReferencedRelation('taxonomy'); $kw->setRecordId(4); $kw->setKeywordType($avail_kw[1]); $kw->setKeyword('Falco Peregrinus'); $kw->save(); $keywords = Doctrine::getTable('ClassificationKeywords')->findForTable('taxonomy', 4); $t->is(count($keywords), 1, 'The new Keyword'); $t->is($keywords[0]->getKeywordType(), $avail_kw[1], 'We get the new keyword');
/** * Add a keyword in the classification keywords table * @param string $name Type of keyword to add */ private function addKeyword($name) { $classification_keyword = new ClassificationKeywords(); $classification_keyword->setKeywordType($name); $classification_keyword->setKeyword($this->cdata); $this->staging_catalogue->addRelated($classification_keyword); }
<?php } ?> </tbody> </table> <h3><?php echo __('Possible Keywords'); ?> </h3> <ul class="name_tags"> <?php foreach (ClassificationKeywords::getTags($sf_request->getParameter('table'), $sf_request->getParameter('kingdom')) as $key => $name) { ?> <?php $keyword = ClassificationKeywords::getTagsTitleAndColor($key); ?> <li <?php echo 'class =' . $keyword['class'] . ' id=' . $key; ?> ><?php echo link_to(__($name), 'catalogue/addKeyword?key=' . $key, array('title' => __($keyword['title']))); ?> </li> <?php } ?> </ul> <table class="bottom_actions"> <tfoot>
public function handleKeyword($tag, $value, $staging) { // Check that it's an authorized keyword for the domain encountered, if not do not create keyword... if (!in_array($tag, array_keys($this->known_keywords))) { return; } if ($this->known_keywords[$tag] != '') { $this->level_name = $this->known_keywords[$tag]; if ($value != '') { if (!$this->catalogue_parent) { $this->catalogue_parent = new Hstore(); } $this->catalogue_parent[$this->known_keywords[$tag]] = $value; $staging['taxon_parents'] = $this->catalogue_parent->export(); } elseif ($value === "") { return; } } $keyword = new ClassificationKeywords(); $keyword->fromArray(array('keyword_type' => $tag, 'keyword' => $value)); $this->scientificName .= "{$value} "; $staging->addRelated($keyword); }