Beispiel #1
0
 /**
  * Create a name for this note - apply (and remove) markup, then take
  * a maximum of 100 characters from the first line.
  */
 public function extractNames()
 {
     global $WT_TREE;
     $text = $this->getNote();
     switch ($WT_TREE->preference('FORMAT_TEXT')) {
         case 'markdown':
             $text = WT_Filter::markdown($text);
             $text = strip_tags($text);
             break;
     }
     list($text) = explode("\n", $text);
     $this->_addName('NOTE', strlen($text) > 100 ? mb_substr($text, 0, 100) . WT_I18N::translate('…') : $text, $this->getGedcom());
 }
Beispiel #2
0
 public static function formatText($text, WT_Tree $WT_TREE)
 {
     switch ($WT_TREE->preference('FORMAT_TEXT')) {
         case 'markdown':
             return '<div class="markdown" dir="auto">' . WT_Filter::markdown($text) . '</div>';
             break;
         case '':
         default:
             return '<div style="white-space: pre-wrap;" dir="auto">' . WT_Filter::expandUrls($text) . '</div>';
             break;
     }
 }
Beispiel #3
0
/**
 * print a note record
 *
 * @param string $text
 * @param int    $nlevel   the level of the note record
 * @param string $nrec     the note record to print
 * @param bool   $textOnly Don't print the "Note: " introduction
 *
 * @return boolean
 */
function print_note_record($text, $nlevel, $nrec, $textOnly = false)
{
    global $WT_TREE;
    $text .= get_cont($nlevel, $nrec);
    // Check if shared note (we have already checked that it exists)
    if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
        $note = WT_Note::getInstance($match[1]);
        $label = 'SHARED_NOTE';
        // If Census assistant installed, allow it to format the note
        if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
            $html = GEDFact_assistant_WT_Module::formatCensusNote($note);
        } else {
            $html = WT_Filter::formatText($note->getNote(), $WT_TREE);
        }
    } else {
        $note = null;
        $label = 'NOTE';
        $html = WT_Filter::formatText($text, $WT_TREE);
    }
    if ($textOnly) {
        return strip_tags($text);
    }
    if (strpos($text, "\n") === false) {
        // A one-line note? strip the block-level tags, so it displays inline
        return WT_Gedcom_Tag::getLabelValue($label, strip_tags($html, '<a><strong><em>'));
    } elseif ($WT_TREE->preference('EXPAND_NOTES')) {
        // A multi-line note, and we're expanding notes by default
        return WT_Gedcom_Tag::getLabelValue($label, $html);
    } else {
        // A multi-line note, with an expand/collapse option
        $element_id = Uuid::uuid4();
        // NOTE: class "note-details" is (currently) used only by some third-party themes
        if ($note) {
            $first_line = '<a href="' . $note->getHtmlUrl() . '">' . $note->getFullName() . '</a>';
        } else {
            switch ($WT_TREE->preference('FORMAT_TEXT')) {
                case 'markdown':
                    $text = WT_Filter::markdown($text);
                    $text = html_entity_decode(strip_tags($text, '<a><strong><em>'), ENT_QUOTES | ENT_HTML5, 'UTF-8');
                    break;
            }
            list($text) = explode("\n", $text);
            $first_line = strlen($text) > 100 ? mb_substr($text, 0, 100) . WT_I18N::translate('…') : $text;
        }
        return '<div class="fact_NOTE"><span class="label">' . '<a href="#" onclick="expand_layer(\'' . $element_id . '\'); return false;"><i id="' . $element_id . '_img" class="icon-plus"></i></a> ' . WT_Gedcom_Tag::getLabel($label) . ':</span> ' . '<span id="' . $element_id . '-alt">' . $first_line . '</span>' . '</div>' . '<div class="note-details" id="' . $element_id . '" style="display:none">' . $html . '</div>';
    }
}