Translate a code, for an (optional) record

@param string            $type
@param GedcomRecord|null $record

@return string
349383
public static function getValue(string $type, GedcomRecord $record = null): string
    {
        if ($record instanceof Individual) {
            $sex = $record->sex();
        } else {
            $sex = 'U';
        }

        switch ($type) {
            case 'adopted':
                if ($sex === 'M') {
                    /* I18N: The name given to a child by its adoptive parents */
                    return I18N::translateContext('MALE', 'adopted name');
                }

                if ($sex === 'F') {
                    /* I18N: The name given to a child by its adoptive parents */
                    return I18N::translateContext('FEMALE', 'adopted name');
                }

                /* I18N: The name given to a child by its adoptive parents */
                return I18N::translate('adopted name');

            case 'aka':
                if ($sex === 'M') {
                    /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
                    return I18N::translateContext('MALE', 'also known as');
                }

                if ($sex === 'F') {
                    /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
                    return I18N::translateContext('FEMALE', 'also known as');
                }

                /* I18N: The name by which an individual is also known. e.g. a professional name or a stage name */
                return I18N::translate('also known as');

            case 'birth':
                if ($sex === 'M') {
                    /* I18N: The name given to an individual at their birth */
                    return I18N::translateContext('MALE', 'birth name');
                }

                if ($sex === 'F') {
                    /* I18N: The name given to an individual at their birth */
                    return I18N::translateContext('FEMALE', 'birth name');
                }

                /* I18N: The name given to an individual at their birth */
                return I18N::translate('birth name');

            case 'change':
                if ($sex === 'M') {
                    /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
                    return I18N::translateContext('MALE', 'change of name');
                }

                if ($sex === 'F') {
                    /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
                    return I18N::translateContext('FEMALE', 'change of name');
                }

                /* I18N: A name chosen by an individual, to replace their existing name (whether legal or otherwise) */
                return I18N::translate('change of name');

            case 'estate':
                if ($sex === 'M') {
                    /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
                    return I18N::translateContext('MALE', 'estate name');
                }

                if ($sex === 'F') {
                    /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
                    return I18N::translateContext('FEMALE', 'estate name');
                }

                /* I18N: A name given to an individual, from the farm or estate on which they lived or worked */
                return I18N::translate('estate name');

            case 'immigrant':
                if ($sex === 'M') {
                    /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
                    return I18N::translateContext('MALE', 'immigration name');
                }

                if ($sex === 'F') {
                    /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
                    return I18N::translateContext('FEMALE', 'immigration name');
                }

                /* I18N: A name taken on immigration - e.g. migrants to the USA frequently anglicized their names */
                return I18N::translate('immigration name');

            case 'maiden':
                // Only women have “maiden” names!
                /* I18N: A woman’s name, before she marries (in cultures where women take their new husband’s name on marriage) */
                return I18N::translate('maiden name');

            case 'married':
                if ($sex === 'M') {
                    /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
                    return I18N::translateContext('MALE', 'married name');
                }

                if ($sex === 'F') {
                    /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
                    return I18N::translateContext('FEMALE', 'married name');
                }

                /* I18N: A name taken on marriage - usually the wife takes the husband’s surname */
                return I18N::translate('married name');

            case 'religious':
                if ($sex === 'M') {
                    /* I18N: A name taken when entering a religion or a religious order */
                    return I18N::translateContext('MALE', 'religious name');
                }

                if ($sex === 'F') {
                    /* I18N: A name taken when entering a religion or a religious order */
                    return I18N::translateContext('FEMALE', 'religious name');
                }

                /* I18N: A name taken when entering a religion or a religious order */
                return I18N::translate('religious name');

            default:
                return $type;
        }
    }
648300
protected function handlesGrant($record, $grantType)
    {
        switch ($grantType) {
            case 'authorization_code':
                return ! $record->firstParty();
            case 'personal_access':
                return $record->personal_access_client;
            case 'password':
                return $record->password_client;
            default:
                return true;
        }
    }
1081771
public function getLanguagableForeignKeys(Record $record)
    {
        return [
            $this->primaryKey               => $record->{$this->primaryKey},
            $this->languagableLanguageField => $this->languagableLanguage->langId(),
        ];
    }
901079
protected static function createFromRecord($record)
    {
        if (is_array($record) && $record['cnvEditorHandle']) {
            /** @var \Concrete\Core\Utility\Service\Text $textHelper */
            $textHelper = Core::make('helper/text');
            $class = '\\Concrete\\Core\\Conversation\\Editor\\' . $textHelper->camelcase(
                    $record['cnvEditorHandle']
                ) . 'Editor';
            /** @var Editor $sc Really this could be any kind of editor but this should help code completion a bit */
            $sc = Core::make($class);
            $sc->setPropertiesFromArray($record);

            return $sc;
        }

        return null;
    }
1044711
protected static function toMongoObjects($record)
    {
        if (!empty($record)) {
            foreach ($record as $key => $data) {
                if (!is_object($data)) {
                    if (is_string($data) && (static::DEFAULT_ID_FIELD == $key)) {
                        $record[$key] = static::idToMongoId($data);
                    } elseif (is_array($data)) {
                        if (1 === count($data)) {
                            // using typed definition, i.e. {"$date" : "2014-08-02T08:40:12.569Z" }
                            if (array_key_exists('$date', $data)) {
                                $temp = $data['$date'];
                                if (empty($temp)) {
                                    // empty means create with current time
                                    $record[$key] = new UTCDateTime(time() * 1000);
                                } elseif (is_string($temp)) {
                                    $record[$key] = new UTCDateTime(strtotime($temp) * 1000);
                                } elseif (is_int($temp)) {
                                    $record[$key] = new UTCDateTime($temp * 1000);
                                }
                            } elseif (isset($data['$id'])) {
                                $record[$key] = static::idToMongoId($data['$id']);
                            } elseif (isset($data['$oid'])) {
                                $record[$key] = static::idToMongoId($data['$oid']);
                            } else {
                                $record[$key] = static::toMongoObjects($data);
                            }
                        }
                    }
                }
            }
        }

        return $record;
    }
98032
public function handle( Record $record )
    {
        if (is_null( $this->aggregateRecord )) {
            $this->setAggregateRecord( $record ); // first record

            return null;
        }

        if ($this->aggregateRecord->pushRecord( $record )) {
            return null;
        }

        return $this->setAggregateRecord( $record );
    }
934158
private function addRecordToCart(GedcomRecord $record): void
    {
        $cart = Session::get('cart', []);

        $tree_name = $record->tree()->name();

        // Add this record
        $cart[$tree_name][$record->xref()] = true;

        // Add directly linked media, notes, repositories and sources.
        preg_match_all('/\n\d (?:OBJE|NOTE|SOUR|REPO) @(' . Gedcom::REGEX_XREF . ')@/', $record->gedcom(), $matches);

        foreach ($matches[1] as $match) {
            $cart[$tree_name][$match] = true;
        }

        Session::put('cart', $cart);
    }
909032
public function updateRecord(GedcomRecord $record): string
    {
        $old_gedcom = $record->gedcom();

        $new_gedcom = preg_replace([
            '/(\n1.*@.+@.*(?:(?:\n[2-9].*)*))((?:\n1.*(?:\n[2-9].*)*)*\1)/',
            '/(\n2.*@.+@.*(?:(?:\n[3-9].*)*))((?:\n2.*(?:\n[3-9].*)*)*\1)/',
            '/(\n3.*@.+@.*(?:(?:\n[4-9].*)*))((?:\n3.*(?:\n[4-9].*)*)*\1)/',
        ], '$2', $old_gedcom);

        return $new_gedcom;
    }
1162265
public function parseMessage(\Imi\Log\Record $record): string
    {
        return str_replace($find, $replace, $record->getMessage());
    }
1327914
private function removeNullValues(array $record)
    {
        // 值为NULL的字段不用缓存
        foreach ($record as $key => $val) {
            if ($val === null) {
                unset($record[$key]);
            }
        }

        return $record;
    }
493988
public function getArchiveAction($gridField, $record)
    {
        /* @var DataObject|Versioned $record */
        if (!$record->hasMethod('canArchive') || !$record->canArchive()) {
            return null;
        }

        $title = _t(__CLASS__ . '.Archive', "Archive");

        $field = GridField_FormAction::create(
            $gridField,
            'ArchiveRecord' . $record->ID,
            false,
            "archiverecord",
            ['RecordID' => $record->ID]
        )
            ->addExtraClass('action--archive btn--icon-md font-icon-box btn--no-text grid-field__icon-action action-menu--handled')
            ->setAttribute('classNames', 'action--archive font-icon-box')
            ->setDescription($title)
            ->setAttribute('aria-label', $title);

        return $field;
    }
163658
protected function processChildRecord($record)
    {
        $id = (int)$record['uid'];
        $this->checkOptions($record);
        /* @var $recordContentObjectRenderer ContentObjectRenderer */
        $recordContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
        $recordContentObjectRenderer->start($record, 'tt_content');
        $this->processedRecordVariables[$id] = ['data' => $record];
        if (
            (int)$this->options['recursive'] > 0 &&
            $record['CType'] === 'gridelements_pi1' &&
            !empty($record['tx_gridelements_backend_layout'])
        ) {
            $childProcessorConfiguration = $this->containerProcessorConfiguration;
            $childProcessorConfiguration['dataProcessing.']['0.'] = $this->processorConfiguration;
            $childProcessorConfiguration['dataProcessing.']['0.']['recursive'] = (int)$this->options['recursive'] - 1;
            $childProcessorConfiguration['dataProcessing.']['0'] = 'GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor';
            $this->processedRecordVariables[$id] = $this->contentDataProcessor->process(
                $recordContentObjectRenderer,
                $childProcessorConfiguration,
                $this->processedRecordVariables[$id]
            );
        } else {
            $this->processedRecordVariables[$id] = $this->contentDataProcessor->process(
                $recordContentObjectRenderer,
                $this->containerProcessorConfiguration,
                $this->processedRecordVariables[$id]
            );
        }
    }
802658
public static function toScalarValues($record)
    {
        return array_map(
            function ($v) {
                if (!is_scalar($v)) {
                    return '<' . gettype($v) . '>';
                }
                return $v;
            },
            (array)$record
        );
    }
161304
public function getStatement($type = null)
    {
        if (is_null($this->statement)) {
            $this->buffer = array();
            $this->next = false;

            $sql = "SELECT * FROM {$this->connection->getDialect()->grammarEscape($this->collection->getName())}";

            $wheres = array();
            $data = array();

            foreach ($this->criteria as $key => $value) {
                $wheres[] = $a= $this->connection->getDialect()->grammarExpression(
                    $key,
                    $value,
                    $this->collection,
                    $data
                );
            }

            if (!empty($wheres)) {
                $sql .= ' WHERE '.implode(' AND ', $wheres);
            }

            if (isset($this->sorts)) {
                $sorts = array();

                foreach ($this->sorts as $key => $value) {
                    if ($value == 1) {
                        $op = ' ASC';
                    } else {
                        $op = ' DESC';
                    }

                    $sorts[] = $this->connection->getDialect()->grammarEscape($key).$op;
                }

                if (!empty($sorts)) {
                    $sql .= ' ORDER BY '.implode(',', $sorts);
                }
            }

            if (isset($this->limit) || isset($this->skip)) {
                $sql .= ' LIMIT '.($this->limit ?: -1).' OFFSET '.($this->skip ?: 0);
            }

            
            $this->statement = $this->connection->getRaw()->prepare($sql);

            $this->statement->execute($data);
        }

        return $this->statement;
    }
23572
protected function getSpecsMarkup($record)
    {
        if (!$record || !$record->exists()) {
            return null;
        }
        return sprintf(
            '<div class="editor__specs">%s %s</div>',
            $record->getSize(),
            $this->getStatusFlagMarkup($record)
        );
    }
844388
private function preParse($record)
    {
        $container = $this->preParse->handle(new ParserContainer($this, $record));

        if ($container instanceof ParserContainer) {
            return $container->getValue();
        }

        throw new \RuntimeException();
    }
499307
public function getStatement($type = null)
    {
        $data = array();
        $wheres = array();
        $matchOrs = array();

        if (is_null($this->match)) {
            $criteria = $this->translateCriteria($this->criteria);
            
            if ($criteria) {
                foreach ($criteria as $key => $value) {
                    $wheres[] = $this->dialect->grammarExpression($key, $value,$this->collection, $data);
                }
            }
        } else {
            $schema = $this->collection->schema();

            $i = 0;

            foreach ($schema as $key => $value) {
                if ($value instanceof \Norm\Schema\Reference) {
                    $foreign = $value['foreign'];
                    $foreignLabel = $value['foreignLabel'];
                    $foreignKey = $value['foreignKey'];
                    $matchOrs[] = $this->getQueryReference($key, $foreign, $foreignLabel, $foreignKey, $i);
                } else {
                    $matchOrs[] = $key.' LIKE :f'.$i;
                    $i++;
                }
            }

            $wheres[] = '('.implode(' OR ', $matchOrs).')';
        }

        $select  = '';

        if ($this->skip > 0 or $this->limit > 0) {
            $select .= 'rownum r, ';
        }

        $select  .= $this->collection->getName().'.*';
        $query   = 'SELECT '.$select.' FROM '.$this->collection->getName();
        $order   = '';

        if ($this->sortBy) {
            foreach ($this->sortBy as $key => $value) {
                if ($value == 1) {
                    $op = ' ASC';
                } else {
                    $op = ' DESC';
                }
                $order[] = $key . $op;
            }

            if (!empty($order)) {
                $order = ' ORDER BY '.implode(',', $order);
            }
        }

        if (!empty($wheres)) {
            $query .= ' WHERE '.implode(' AND ', $wheres);
        }

        $limit = '';

        if ($this->skip > 0) {
            $limit = 'r > '.($this->skip).' AND ROWNUM <= (SELECT COUNT(ROWNUM) FROM ('.$query.'))';

            if ($this->limit > 0) {
                $limit = 'r > '.($this->skip).' AND ROWNUM <= ' . $this->limit;
            }
        } elseif ($this->limit > 0) {
            $limit = 'r <= ' . $this->limit;
        }

        $query .= $order;

        if ($limit !== '') {
            $query = 'SELECT * FROM ('.$query.') WHERE '.$limit;
        }
        
        $statement = oci_parse($this->raw, $query);

        foreach ($data as $key => $value) {
            oci_bind_by_name($statement, ':'.$key, $data[$key]);
        }

        if ($matchOrs) {
            
            $match = '%'.$this->match.'%';

            foreach ($matchOrs as $key => $value) {
                oci_bind_by_name($statement, ':f'.$key, $match);
            }
        }
        
        oci_execute($statement);

        $result = array();

        while ($row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
            $result[] = $row;
        }


        $this->rows = $result;

        oci_free_statement($statement);

        $this->index = -1;

    }