Project

General

Profile

« Previous | Next » 

Revision b9577812

Added by Andreas Kohlbecker about 12 years ago

fixing taxon short name function

View differences:

5.x/modules/cdm_dataportal/cdm_dataportal.module
1540 1540
    }
1541 1541
  }
1542 1542
  $nameStr = trim($nameStr);
1543

  
1543 1544
  if($nameStr){
1544 1545
    // do not return short names for these
1545
    //if (stristr(strtolower($nameStr), 'incertae sedis') !== FALSE ||
1546
    //	stristr(strtolower($nameStr), 'nomina excludenda') !== FALSE) {
1547 1546
    if ($name->unplaced || $name->excluded){
1548 1547
      return $nameStr;
1549 1548
    }
1550
    if($pos = stripos($nameStr, ' ')){
1551
      return substr($nameStr, 0, 1).'. '.substr($nameStr, $pos);
1552
    } else {
1553
      return $nameStr;
1549
    /*
1550
     * - 1st capture group (^[a-zA-Z]): Fist letter of uninomial
1551
     * - second capture group ([a-zA-Z]+): remaining letters of uninomial
1552
     * - third capture group (\s+[^(\x2E]+\s+.+$): letters of name,
1553
     *       but only matching if no '(' or '.' in second word of name, ( \x2E = '.' )
1554
     */
1555
    $pattern = '/(^[a-zA-Z])([a-zA-Z]+)(\s+[^(\x2E]+\s+.+$)/';
1556
    if (preg_match($pattern, $string, $matches, PREG_OFFSET_CAPTURE)){
1557
      return $matches[1][0] . "." . $matches[3][0] . "\n";
1554 1558
    }
1555 1559
  } else {
1556 1560
    return $name->titleCache;

Also available in: Unified diff