Пример #1
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 string
  */
 public static function printNoteRecord($text, $nlevel, $nrec, $textOnly = false)
 {
     global $WT_TREE;
     $text .= Functions::getCont($nlevel, $nrec);
     // Check if shared note (we have already checked that it exists)
     if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ NOTE/', $nrec, $match)) {
         $note = Note::getInstance($match[1], $WT_TREE);
         $label = 'SHARED_NOTE';
         // If Census assistant installed, allow it to format the note
         if (Module::getModuleByName('GEDFact_assistant')) {
             $html = CensusAssistantModule::formatCensusNote($note);
         } else {
             $html = Filter::formatText($note->getNote(), $WT_TREE);
         }
     } else {
         $note = null;
         $label = 'NOTE';
         $html = 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 GedcomTag::getLabelValue($label, strip_tags($html, '<a><strong><em>'));
     } elseif ($WT_TREE->getPreference('EXPAND_NOTES')) {
         // A multi-line note, and we're expanding notes by default
         return GedcomTag::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($text) = explode("\n", strip_tags($html));
             $first_line = strlen($text) > 100 ? mb_substr($text, 0, 100) . 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> ' . GedcomTag::getLabel($label) . ':</span> ' . '<span id="' . $element_id . '-alt">' . $first_line . '</span>' . '</div>' . '<div class="note-details" id="' . $element_id . '" style="display:none">' . $html . '</div>';
     }
 }
Пример #2
0
 if ($type === 'media') {
     $medialist = QueryMedia::mediaList('', 'include', 'title', $filter, '');
     echo '<div id="find-output">';
     if ($medialist) {
         foreach ($medialist as $media) {
             echo '<div class="find-media-media">';
             echo '<div class="find-media-thumb">', $media->displayImage(), '</div>';
             echo '<div class="find-media-details">', $media->getFullName(), '</div>';
             if (!$embed) {
                 echo '<p><a href="#" dir="auto" onclick="pasteid(\'', $media->getXref(), '\');">', $media->getFilename(), '</a></p>';
             } else {
                 echo '<p><a href="#" dir="auto" onclick="pasteid(\'', $media->getXref(), '\', \'', '\', \'', Filter::escapeJs($media->getFilename()), '\');">', Filter::escapeHtml($media->getFilename()), '</a></p> ';
             }
             if ($media->fileExists()) {
                 $imgsize = $media->getImageAttributes();
                 echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
             }
             echo '<ul>';
             $found = false;
             foreach ($media->linkedIndividuals('OBJE') as $indindividual) {
                 echo '<li>', $indindividual->getFullName(), '</li>';
                 $found = true;
             }
             foreach ($media->linkedFamilies('OBJE') as $family) {
                 echo '<li>', $family->getFullName(), '</li>';
                 $found = true;
             }
             foreach ($media->linkedSources('OBJE') as $source) {
                 echo '<li>', $source->getFullName(), '</li>';
                 $found = true;
             }
Пример #3
0
/**
 * Show an option to preserve the existing CHAN record when editing.
 *
 * @param GedcomRecord $record
 *
 * @return string
 */
function keep_chan(GedcomRecord $record = null)
{
    global $WT_TREE;
    if (Auth::isAdmin()) {
        if ($record) {
            $details = GedcomTag::getLabelValue('DATE', $record->lastChangeTimestamp()) . GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($record->lastChangeUser()));
        } else {
            $details = '';
        }
        return '<tr><td class="descriptionbox wrap width25">' . GedcomTag::getLabel('CHAN') . '</td><td class="optionbox wrap">' . '<input type="checkbox" name="keep_chan" value="1" ' . ($WT_TREE->getPreference('NO_UPDATE_CHAN') ? 'checked' : '') . '>' . I18N::translate('Keep the existing “last change” information') . $details . '</td></tr>';
    } else {
        return '';
    }
}
Пример #4
0
 /**
  * Print a row for the media tab on the individual page.
  *
  * @param Fact $fact
  * @param int $level
  */
 public static function printMainMedia(Fact $fact, $level)
 {
     $factrec = $fact->getGedcom();
     $parent = $fact->getParent();
     if ($fact->isPendingAddition()) {
         $styleadd = 'new';
         $can_edit = $level == 1 && $fact->canEdit();
     } elseif ($fact->isPendingDeletion()) {
         $styleadd = 'old';
         $can_edit = false;
     } else {
         $styleadd = '';
         $can_edit = $level == 1 && $fact->canEdit();
     }
     // -- find source for each fact
     preg_match_all('/(?:^|\\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches);
     foreach ($matches[1] as $xref) {
         $media = Media::getInstance($xref, $fact->getParent()->getTree());
         // Allow access to "1 OBJE @non_existent_source@", so it can be corrected/deleted
         if (!$media || $media->canShow()) {
             if ($level > 1) {
                 echo '<tr class="row_obje2">';
             } else {
                 echo '<tr>';
             }
             echo '<td class="descriptionbox';
             if ($level > 1) {
                 echo ' rela';
             }
             echo ' ', $styleadd, ' width20">';
             preg_match("/^\\d (\\w*)/", $factrec, $factname);
             $factlines = explode("\n", $factrec);
             // 1 BIRT Y\n2 SOUR ...
             $factwords = explode(" ", $factlines[0]);
             // 1 BIRT Y
             $factname = $factwords[1];
             // BIRT
             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 = $ematch[1];
                     echo $factname;
                 } else {
                     echo GedcomTag::getLabel($factname, $parent);
                 }
             } elseif ($can_edit) {
                 echo '<a onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '">';
                 echo GedcomTag::getLabel($factname, $parent), '</a>';
                 echo '<div class="editfacts">';
                 echo '<div class="editlink"><a class="editicon" onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '"><span class="link_text">', I18N::translate('Edit'), '</span></a></div>';
                 echo '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\'\', factgedcom:\'' . rawurlencode($factrec) . '\'},function(){location.reload();})" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>';
                 echo '<div class="deletelink"><a class="deleteicon" onclick="return delete_fact(\'', I18N::translate('Are you sure you want to delete this fact?'), '\', \'', $parent->getXref(), '\', \'', $fact->getFactId(), '\');" href="#" title="', I18N::translate('Delete'), '"><span class="link_text">', I18N::translate('Delete'), '</span></a></div>';
                 echo '</div>';
             } else {
                 echo GedcomTag::getLabel($factname, $parent);
             }
             echo '</td>';
             echo '<td class="optionbox ', $styleadd, ' wrap">';
             if ($media) {
                 echo '<span class="field">';
                 echo $media->displayImage();
                 echo '<a href="' . $media->getHtmlUrl() . '">';
                 echo '<em>';
                 foreach ($media->getAllNames() as $name) {
                     if ($name['type'] != 'TITL') {
                         echo '<br>';
                     }
                     echo $name['full'];
                 }
                 echo '</em>';
                 echo '</a>';
                 echo '</span>';
                 echo GedcomTag::getLabelValue('FORM', $media->mimeType());
                 $imgsize = $media->getImageAttributes('main');
                 if (!empty($imgsize['WxH'])) {
                     echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
                 }
                 if ($media->getFilesizeraw() > 0) {
                     echo GedcomTag::getLabelValue('__FILE_SIZE__', $media->getFilesize());
                 }
                 $mediatype = $media->getMediaType();
                 if ($mediatype) {
                     echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype));
                 }
                 switch ($media->isPrimary()) {
                     case 'Y':
                         echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes'));
                         break;
                     case 'N':
                         echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no'));
                         break;
                 }
                 echo FunctionsPrint::printFactNotes($media->getGedcom(), 1);
                 echo self::printFactSources($media->getGedcom(), 1);
             } else {
                 echo $xref;
             }
             echo '</td></tr>';
         }
     }
 }
Пример #5
0
if ($controller->record->canShow()) {
    // Highlight image or silhouette
    echo '<div id="indi_mainimage">', $controller->record->displayImage(), '</div>';
    echo '<div id="header_accordion1">';
    // contain accordions for names
    echo '<h3 class="name_one ', $controller->getPersonStyle($controller->record), '"><span>', $controller->record->getFullName(), '</span>';
    // First name accordion header
    $bdate = $controller->record->getBirthDate();
    $ddate = $controller->record->getDeathDate();
    echo '<span class="header_age">';
    if ($bdate->isOK() && !$controller->record->isDead()) {
        // If living display age
        echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate), true), $controller->record, 'span');
    } elseif ($bdate->isOK() && $ddate->isOK()) {
        // If dead, show age at death
        echo GedcomTag::getLabelValue('AGE', FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, $ddate), false), $controller->record, 'span');
    }
    echo '</span>';
    // Display summary birth/death info.
    echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>';
    // Display gender icon
    foreach ($controller->record->getFacts() as $fact) {
        if ($fact->getTag() == 'SEX') {
            $controller->printSexRecord($fact);
        }
    }
    echo '</h3>';
    // close first name accordion header
    // Display name details
    foreach ($controller->record->getFacts() as $fact) {
        if ($fact->getTag() == 'NAME') {
Пример #6
0
    /**
     * Print a family group.
     *
     * @param Family $family
     * @param string $type
     * @param string $label
     */
    private function printFamily(Family $family, $type, $label)
    {
        global $controller;
        if ($family->getTree()->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
            $access_level = Auth::PRIV_HIDE;
        } else {
            $access_level = Auth::accessLevel($family->getTree());
        }
        ?>
		<table>
			<tr>
				<td>
					<i class="icon-cfamily"></i>
				</td>
				<td>
					<span class="subheaders"> <?php 
        echo $label;
        ?>
</span>
					<a class="noprint" href="<?php 
        echo $family->getHtmlUrl();
        ?>
"> - <?php 
        echo I18N::translate('View this family');
        ?>
</a>
				</td>
			</tr>
		</table>
		<table class="facts_table">
		<?php 
        ///// HUSB /////
        $found = false;
        foreach ($family->getFacts('HUSB', false, $access_level) as $fact) {
            $found |= !$fact->isPendingDeletion();
            $person = $fact->getTarget();
            if ($person instanceof Individual) {
                if ($fact->isPendingAddition()) {
                    $class = 'facts_label new';
                } elseif ($fact->isPendingDeletion()) {
                    $class = 'facts_label old';
                } else {
                    $class = 'facts_label';
                }
                ?>
					<tr>
					<td class="<?php 
                echo $class;
                ?>
">
						<?php 
                echo Functions::getCloseRelationshipName($controller->record, $person);
                ?>
					</td>
					<td class="<?php 
                echo $controller->getPersonStyle($person);
                ?>
">
						<?php 
                echo Theme::theme()->individualBoxLarge($person);
                ?>
					</td>
					</tr>
				<?php 
            }
        }
        if (!$found && $family->canEdit()) {
            ?>
			<tr>
				<td class="facts_label"></td>
				<td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php 
            echo $family->getXref();
            ?>
', 'HUSB');"><?php 
            echo I18N::translate('Add a husband to this family');
            ?>
</a></td>
			</tr>
			<?php 
        }
        ///// WIFE /////
        $found = false;
        foreach ($family->getFacts('WIFE', false, $access_level) as $fact) {
            $person = $fact->getTarget();
            if ($person instanceof Individual) {
                $found |= !$fact->isPendingDeletion();
                if ($fact->isPendingAddition()) {
                    $class = 'facts_label new';
                } elseif ($fact->isPendingDeletion()) {
                    $class = 'facts_label old';
                } else {
                    $class = 'facts_label';
                }
                ?>
				<tr>
					<td class="<?php 
                echo $class;
                ?>
">
						<?php 
                echo Functions::getCloseRelationshipName($controller->record, $person);
                ?>
					</td>
					<td class="<?php 
                echo $controller->getPersonStyle($person);
                ?>
">
						<?php 
                echo Theme::theme()->individualBoxLarge($person);
                ?>
					</td>
				</tr>
				<?php 
            }
        }
        if (!$found && $family->canEdit()) {
            ?>
			<tr>
				<td class="facts_label"></td>
				<td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php 
            echo $family->getXref();
            ?>
', 'WIFE');"><?php 
            echo I18N::translate('Add a wife to this family');
            ?>
</a></td>
			</tr>
			<?php 
        }
        ///// MARR /////
        $found = false;
        $prev = new Date('');
        foreach ($family->getFacts(WT_EVENTS_MARR . '|' . WT_EVENTS_DIV, true) as $fact) {
            $found |= !$fact->isPendingDeletion();
            if ($fact->isPendingAddition()) {
                $class = ' new';
            } elseif ($fact->isPendingDeletion()) {
                $class = ' old';
            } else {
                $class = '';
            }
            ?>
			<tr>
				<td class="facts_label">
				</td>
				<td class="facts_value<?php 
            echo $class;
            ?>
">
					<?php 
            echo GedcomTag::getLabelValue($fact->getTag(), $fact->getDate()->display() . ' — ' . $fact->getPlace()->getFullName());
            ?>
				</td>
			</tr>
			<?php 
            if (!$prev->isOK() && $fact->getDate()->isOK()) {
                $prev = $fact->getDate();
            }
        }
        if (!$found && $family->canShow() && $family->canEdit()) {
            // Add a new marriage
            ?>
			<tr>
				<td class="facts_label">
				</td>
				<td class="facts_value">
					<a href="#" onclick="return add_new_record('<?php 
            echo $family->getXref();
            ?>
', 'MARR');">
						<?php 
            echo I18N::translate('Add marriage details');
            ?>
					</a>
				</td>
			</tr>
			<?php 
        }
        ///// CHIL /////
        $child_number = 0;
        foreach ($family->getFacts('CHIL', false, $access_level) as $fact) {
            $person = $fact->getTarget();
            if ($person instanceof Individual) {
                if ($fact->isPendingAddition()) {
                    $child_number++;
                    $class = 'facts_label new';
                } elseif ($fact->isPendingDeletion()) {
                    $class = 'facts_label old';
                } else {
                    $child_number++;
                    $class = 'facts_label';
                }
                $next = new Date('');
                foreach ($person->getFacts(WT_EVENTS_BIRT, true) as $bfact) {
                    if ($bfact->getDate()->isOK()) {
                        $next = $bfact->getDate();
                        break;
                    }
                }
                ?>
				<tr>
					<td class="<?php 
                echo $class;
                ?>
">
						<?php 
                echo self::ageDifference($prev, $next, $child_number);
                ?>
						<?php 
                echo Functions::getCloseRelationshipName($controller->record, $person);
                ?>
					</td>
					<td class="<?php 
                echo $controller->getPersonStyle($person);
                ?>
">
						<?php 
                echo Theme::theme()->individualBoxLarge($person);
                ?>
					</td>
				</tr>
				<?php 
                $prev = $next;
            }
        }
        // Re-order children / add a new child
        if ($family->canEdit()) {
            if ($type == 'FAMS') {
                $add_child_text = I18N::translate('Add a son or daughter');
            } else {
                $add_child_text = I18N::translate('Add a brother or sister');
            }
            ?>
			<tr class="noprint">
				<td class="facts_label">
					<?php 
            if (count($family->getChildren()) > 1) {
                ?>
					<a href="#" onclick="reorder_children('<?php 
                echo $family->getXref();
                ?>
');tabswitch(5);"><i class="icon-media-shuffle"></i> <?php 
                echo I18N::translate('Re-order children');
                ?>
</a>
					<?php 
            }
            ?>
				</td>
				<td class="facts_value">
					<a href="#" onclick="return add_child_to_family('<?php 
            echo $family->getXref();
            ?>
');"><?php 
            echo $add_child_text;
            ?>
</a>
					<span style='white-space:nowrap;'>
						<a href="#" class="icon-sex_m_15x15" onclick="return add_child_to_family('<?php 
            echo $family->getXref();
            ?>
','M');"></a>
						<a href="#" class="icon-sex_f_15x15" onclick="return add_child_to_family('<?php 
            echo $family->getXref();
            ?>
','F');"></a>
					</span>
				</td>
			</tr>
			<?php 
        }
        echo '</table>';
        return;
    }
Пример #7
0
     } else {
         $SELECT1 = " 1 ASC";
     }
     if ($length > 0) {
         $SELECT1 .= " LIMIT :length OFFSET :start";
         $ARGS1['length'] = $length;
         $ARGS1['start'] = $start;
     }
     $rows = Database::prepare($SELECT1)->execute($ARGS1)->fetchAll();
     // Total filtered/unfiltered rows
     $recordsFiltered = Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
     $recordsTotal = Database::prepare($SELECT2)->execute($ARGS2)->fetchOne();
     $data = array();
     foreach ($rows as $row) {
         $media = Media::getInstance($row->xref, Tree::findById($row->gedcom_id), $row->gedcom);
         $data[] = array(GedcomTag::getLabelValue('URL', $row->m_filename), $media->displayImage(), mediaObjectInfo($media));
     }
     break;
 case 'unused':
     // Which trees use this media folder?
     $media_trees = Database::prepare("SELECT gedcom_name, gedcom_name" . " FROM `##gedcom`" . " JOIN `##gedcom_setting` USING (gedcom_id)" . " WHERE setting_name='MEDIA_DIRECTORY' AND setting_value = :media_folder AND gedcom_id > 0")->execute(array('media_folder' => $media_folder))->fetchAssoc();
     $disk_files = all_disk_files($media_folder, $media_path, $subfolders, $search);
     $db_files = all_media_files($media_folder, $media_path, $subfolders, $search);
     // All unused files
     $unused_files = array_diff($disk_files, $db_files);
     $recordsTotal = count($unused_files);
     // Filter unused files
     if ($search) {
         $unused_files = array_filter($unused_files, function ($x) use($search) {
             return strpos($x, $search) !== false;
         });