/** * search by group * @author : ELGUENNUNI Sohaib, s.elguennuni@gmail.com * @param type $array_member * @param type $group_tag * @param type $model */ public static function Group_Tag(&$array_member, $group_tag, $model) { $tagGroup = new TagGroups(); $listGroupTag = $tagGroup->findGroupByPriority($group_tag); foreach ($listGroupTag as $group) { if ($array_member['limit'] > 0) { App_Tag_Search_Criteria::Criteria_Tag($array_member, $group->group_id, $model); } } }
public function getName($view = null, $countriesOnly = false) { if ($this->_get('id') == 0) { return '-'; } $nbr = count($this->TagGroups); if (!$nbr) { return "No Tags"; } $str = '<ul class="search_tags">'; foreach ($this->TagGroups as $group) { if (!$countriesOnly || $countriesOnly && $group->getSubGroupName() == 'country') { $str .= '<li><label>' . $group->getSubGroupName() . '<span class="gtu_group"> - ' . TagGroups::getGroup($group->getGroupName()) . '</span></label><ul class="name_tags' . ($view !== null ? "_view" : "") . '">'; $tags = explode(";", $group->getTagValue()); foreach ($tags as $value) { if (strlen($value)) { $str .= '<li>' . trim($value) . '</li>'; } } $str .= '</ul><div class="clear"></div>'; if ($countriesOnly) { break; } } } $str .= '</ul>'; return $str; }
<?php include dirname(__FILE__) . '/../../bootstrap/Doctrine.php'; $t = new lime_test(15, new lime_output_color()); $t->info('distinct SubGroup()'); $sgroups = Doctrine::getTable('TagGroups')->getDistinctSubGroups('administrative area'); $t->is(count($sgroups), 3, 'Get all administrative sub groups'); $t->is($sgroups['country'], 'country', 'Country is set'); $sgroups = Doctrine::getTable('TagGroups')->getDistinctSubGroups('brol'); $t->is(count($sgroups), 1, 'Get administrative sub groups for this unused'); $t->is($sgroups[''], '', 'thre is only the empty'); $t->info('getPropositions'); $props = Doctrine::getTable('TagGroups')->getPropositions('brussels'); $t->is(count($props), 4, 'We got 4 props'); $props = Doctrine::getTable('TagGroups')->getPropositions('Bruselo'); $t->is(count($props), 2, 'Got 2 prop'); $t->is($props[0]['tag'], 'Brussels', 'Brussels is showed'); $props = Doctrine::getTable('TagGroups')->getPropositions('brussels', 'administrative area', 'city'); $t->is(count($props), 3, 'We got 3 props'); $t->isnt($props[0]['tag'], 'Big White Mountain', 'Purpose from only 1 group'); $t->info('fetchTag'); $gtu = Doctrine::getTable('Gtu')->findOneByCode('irsnb'); $tags = Doctrine::getTable('TagGroups')->fetchTag(array($gtu->getId())); $t->is(count($tags), 1, 'We got 1 gtu'); $t->is(count($tags[$gtu->getId()]), 2, 'We got 2 group'); $t->is($tags[$gtu->getId()][0]->getGroupName(), 'administrative area', 'administrative is the group'); $t->is($tags[$gtu->getId()][0]->getSubGroupName(), 'country', 'country is the sub group'); $t->is(count($tags[$gtu->getId()][0]->Tags), 4, 'We got 4 tags'); $t->is(TagGroups::getGroup('populated'), 'Populated Places', 'Get a Tag group');
<a class="sub_group"><?php echo __('Add Sub Group'); ?> </a> </fieldset> <?php } ?> </div> <div class="gtu_groups_add"> <select id="groups_select"> <option value=""></option> <?php foreach (TagGroups::getGroups() as $k => $v) { ?> <option value="<?php echo $k; ?> "><?php echo $v; ?> </option> <?php } ?> </select> <a href="<?php echo url_for('gtu/addGroup' . ($form->getObject()->isNew() ? '' : '?id=' . $form->getObject()->getId())); ?>
/** * Return tags for a GTU without the country part */ public function executeCompleteTag(sfWebRequest $request) { $gtu = false; if ($request->hasParameter('id') && $request->getParameter('id')) { $spec = Doctrine::getTable('Specimens')->fetchOneWithRights($request->getParameter('id'), $this->getUser()); if ($spec->getHasEncodingRights() || $this->getUser()->isAtLeast(Users::ADMIN)) { $gtu = Doctrine::getTable('Gtu')->find($spec->getGtuRef()); } else { $this->forwardToSecureAction(); } } $this->forward404Unless($gtu); $str = '<ul class="search_tags">'; foreach ($gtu->TagGroups as $group) { $str .= '<li><label>' . $group->getSubGroupName() . '<span class="gtu_group"> - ' . TagGroups::getGroup($group->getGroupName()) . '</span></label>'; if ($request->hasParameter('view')) { $str .= '<ul class="name_tags_view">'; } else { $str .= '<ul class="name_tags">'; } $tags = explode(";", $group->getTagValue()); foreach ($tags as $value) { if (strlen($value)) { $str .= '<li>' . trim($value) . '</li>'; } } $str .= '</ul><div class="clear" />'; } if ($gtu->getLocation()) { $str .= '<li><label>Lat./Long.: </label>' . round($gtu->getLatitude(), 6) . '/' . round($gtu->getLongitude(), 6) . '</li>'; } if ($gtu->getElevation()) { $str .= '<li><label>Alt.: </label>' . $gtu->getElevation() . ' +- ' . $gtu->getElevationAccuracy() . ' m</li>'; } $str .= '</ul><div class="clear" />'; return $this->renderText($str); }