本文整理汇总了PHP中WT_Filter::formatText方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_Filter::formatText方法的具体用法?PHP WT_Filter::formatText怎么用?PHP WT_Filter::formatText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_Filter
的用法示例。
在下文中一共展示了WT_Filter::formatText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_main_notes
function print_main_notes(WT_Fact $fact, $level)
{
global $WT_TREE, $SHOW_FACT_ICONS;
$factrec = $fact->getGedcom();
$fact_id = $fact->getFactId();
$parent = $fact->getParent();
$pid = $parent->getXref();
if ($fact->isNew()) {
$styleadd = ' new';
$can_edit = $level == 1 && $fact->canEdit();
} elseif ($fact->isOld()) {
$styleadd = ' old';
$can_edit = false;
} else {
$styleadd = '';
$can_edit = $level == 1 && $fact->canEdit();
}
$ct = preg_match_all("/{$level} NOTE (.*)/", $factrec, $match, PREG_SET_ORDER);
for ($j = 0; $j < $ct; $j++) {
// Note object, or inline note?
if (preg_match("/{$level} NOTE @(.*)@/", $match[$j][0], $nmatch)) {
$note = WT_Note::getInstance($nmatch[1]);
if ($note && !$note->canShow()) {
continue;
}
} else {
$note = null;
}
if ($level >= 2) {
echo '<tr class="row_note2"><td class="descriptionbox rela ', $styleadd, ' width20">';
} else {
echo '<tr><td class="descriptionbox ', $styleadd, ' width20">';
}
if ($can_edit) {
echo '<a onclick="return edit_record(\'', $pid, '\', \'', $fact_id, '\');" href="#" title="', WT_I18N::translate('Edit'), '">';
if ($level < 2) {
if ($SHOW_FACT_ICONS) {
echo '<i class="icon-note"></i> ';
}
if ($note) {
echo WT_Gedcom_Tag::getLabel('SHARED_NOTE');
} else {
echo WT_Gedcom_Tag::getLabel('NOTE');
}
echo '</a>';
echo '<div class="editfacts">';
echo "<div class=\"editlink\"><a class=\"editicon\" onclick=\"return edit_record('{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . WT_I18N::translate('Edit') . "\"><span class=\"link_text\">" . WT_I18N::translate('Edit') . "</span></a></div>";
echo '<div class="copylink"><a class="copyicon" href="#" onclick="return copy_fact(\'', $pid, '\', \'', $fact_id, '\');" title="' . WT_I18N::translate('Copy') . '"><span class="link_text">' . WT_I18N::translate('Copy') . '</span></a></div>';
echo "<div class=\"deletelink\"><a class=\"deleteicon\" onclick=\"return delete_fact('" . WT_I18N::translate('Are you sure you want to delete this fact?') . "', '{$pid}', '{$fact_id}');\" href=\"#\" title=\"" . WT_I18N::translate('Delete') . "\"><span class=\"link_text\">" . WT_I18N::translate('Delete') . "</span></a></div>";
if ($note) {
echo '<a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . WT_I18N::translate('View') . '"><span class="link_text">' . WT_I18N::translate('View') . '</span></a>';
}
echo '</div>';
}
} else {
if ($level < 2) {
if ($SHOW_FACT_ICONS) {
echo '<i class="icon-note"></i> ';
}
if ($note) {
echo WT_Gedcom_Tag::getLabel('SHARED_NOTE');
} else {
echo WT_Gedcom_Tag::getLabel('NOTE');
}
}
$factlines = explode("\n", $factrec);
// 1 BIRT Y\n2 NOTE ...
$factwords = explode(" ", $factlines[0]);
// 1 BIRT Y
$factname = $factwords[1];
// BIRT
$parent = WT_GedcomRecord::getInstance($pid);
if ($factname == 'EVEN' || $factname == 'FACT') {
// Add ' EVEN' to provide sensible output for an event with an empty TYPE record
$ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch);
if ($ct > 0) {
$factname = trim($ematch[1]);
echo $factname;
} else {
echo WT_Gedcom_Tag::getLabel($factname, $parent);
}
} else {
if ($factname != 'NOTE') {
// Note is already printed
echo WT_Gedcom_Tag::getLabel($factname, $parent);
if ($note) {
echo '<div class="editfacts"><a class="icon-note" href="', $note->getHtmlUrl(), '" title="' . WT_I18N::translate('View') . '"><span class="link_text">' . WT_I18N::translate('View') . '</span></a></div>';
}
}
}
}
echo '</td>';
if ($note) {
// Note objects
if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
// If Census assistant installed, allow it to format the note
$text = GEDFact_assistant_WT_Module::formatCensusNote($note);
} else {
$text = WT_Filter::formatText($note->getNote(), $WT_TREE);
}
//.........这里部分代码省略.........
示例2: array
');
$linked_indi = $controller->record->linkedIndividuals('NOTE');
$linked_fam = $controller->record->linkedFamilies('NOTE');
$linked_obje = $controller->record->linkedMedia('NOTE');
$linked_sour = $controller->record->linkedSources('NOTE');
$facts = array();
foreach ($controller->record->getFacts() as $fact) {
if ($fact->getTag() != 'CONT') {
$facts[] = $fact;
}
}
// Legacy formatting, created by the census assistant
if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
$text = GEDFact_assistant_WT_Module::formatCensusNote($controller->record);
} else {
$text = WT_Filter::formatText($controller->record->getNote(), $WT_TREE);
}
?>
<div id="note-details">
<h2><?php
echo $controller->record->getFullName();
?>
</h2>
<div id="note-tabs">
<ul>
<li>
<a href="#note-edit">
<span><?php
echo WT_I18N::translate('Details');
?>
</span>
示例3: print_note_record
/**
* 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 {
list($first_line) = explode("\n", $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>';
}
}
示例4: formatCensusNote
public static function formatCensusNote(WT_Note $note)
{
global $WT_TREE;
$headers = array('AgM' => 'Age at first marriage', 'Age' => 'Age at last birthday', 'Assets' => 'Assets = Owned,Rented - Value,Rent - Radio - Farm', 'BIC' => 'Born in County', 'BOE' => 'Born outside England', 'BP' => 'Birthplace - (Chapman format)', 'Birthplace' => 'Birthplace (Full format)', 'Bmth' => 'Month of birth - If born within Census year', 'ChB' => 'Children born alive', 'ChD' => 'Children who have died', 'ChL' => 'Children still living', 'DOB' => 'Date of birth', 'Edu' => 'Education - At School, Can Read, Can Write', 'EmD' => 'Employed?', 'EmN' => 'Unemployed?', 'EmR' => 'Employer?', 'Employ' => 'Employment', 'Eng?' => 'English spoken?', 'EngL' => 'English spoken?, if not, Native Language', 'FBP' => 'Father’s Birthplace - (Chapman format)', 'Health' => 'Health - 1.Blind, 2.Deaf & Dumb, 3.Idiotic, 4.Insane, 5.Disabled etc', 'Home' => 'Home Ownership - Owned/Rented-Free/Mortgaged-Farm/House-Farm Schedule number', 'Industry' => 'Industry', 'Infirm' => 'Infirmities - 1. Deaf & Dumb, 2. Blind, 3. Lunatic, 4. Imbecile/feeble-minded', 'Lang' => 'If Foreign Born - Native Language', 'MBP' => 'Mother’s Birthplace - (Chapman format)', 'MC' => 'Marital Condition - Married, Single, Unmarried, Widowed or Divorced', 'Mmth' => 'Month of marriage - If married during Census Year', 'MnsE' => 'Months employed during Census Year', 'MnsU' => 'Months unemployed during Census Year', 'N/A' => 'If Foreign Born - Naturalized, Alien', 'NL' => 'If Foreign Born - Native Language', 'Name' => 'Full Name or Married name if married', 'Occupation' => 'Occupation', 'Par' => 'Parentage - Father if foreign born, Mother if foreign born', 'Race' => 'Race or Color - Black, White, Mulatto, Asian, Indian, Chinese etc', 'Relation' => 'Relationship to Head of Household', 'Sex' => 'Male or Female', 'Situ' => 'Situation - Disease, Infirmity, Convict, Pauper etc', 'Ten' => 'Tenure - Owned/Rented, (if owned)Free/Morgaged', 'Vet' => 'War Veteran?', 'WH' => 'Working at Home?', 'War' => 'War or Expedition', 'WksU' => 'Weeks unemployed during Census Year', 'YOI' => 'If Foreign Born - Year of immigration', 'YON' => 'If Foreign Born - Year of naturalization', 'YUS' => 'If Foreign Born - Years in the USA', 'YrsM' => 'Years Married, or Y if married in Census Year');
if (preg_match('/(.*)((?:\\n.*)*)\\n\\.start_formatted_area\\.\\n(.*)((?:\\n.*)*)\\n.end_formatted_area\\.((?:\\n.*)*)/', $note->getNote(), $match)) {
// This looks like a census-assistant shared note
$title = WT_Filter::escapeHtml($match[1]);
$preamble = WT_Filter::escapeHtml($match[2]);
$header = WT_Filter::escapeHtml($match[3]);
$data = WT_Filter::escapeHtml($match[4]);
$postamble = WT_Filter::escapeHtml($match[5]);
$fmt_headers = array();
foreach ($headers as $key => $value) {
$fmt_headers['.b.' . $key] = '<span title="' . WT_Filter::escapeHtml($value) . '">' . $key . '</span>';
}
// Substitue header labels and format as HTML
$thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>';
// Format data as HTML
$tbody = '';
foreach (explode("\n", $data) as $row) {
$tbody .= '<tr>';
foreach (explode('|', $row) as $column) {
$tbody .= '<td>' . $column . '</td>';
}
$tbody .= '</tr>';
}
return $title . "\n" . '<p>' . $preamble . '</p>' . '<table class="table-census-assistant">' . '<thead>' . $thead . '</thead>' . '<tbody>' . $tbody . '</tbody>' . '</table>' . '<p>' . $postamble . '</p>';
} else {
// Not a census-assistant shared note - apply default formatting
return WT_Filter::formatText($note->getNote(), $WT_TREE);
}
}