public function addSourcesImagesNotesInput($xml) { $tm = new TipManager(); $sources = null; $notes = null; $images = null; if (isset($xml)) { $sources = $xml->source_citation; $images = $xml->image; $notes = $xml->note; } // add source input $rows = ''; if (isset($sources)) { $sortedSources = array(); $maxId = 0; // sort sources, display holes caused by blanking out an entire source record foreach ($sources as $source) { $id = (int) substr((string) $source['id'], 1); $sortedSources[$id] = $source; if ($maxId < $id) { $maxId = $id; } } for ($i = 1; $i <= $maxId; $i++) { $rows .= $this->addSourceInput($i - 1, @$sortedSources[$i]); } } $result = "<a name=\"sourcesSection\"></a><h2>Source Citations<small>" . $tm->addMsgTip('SourceCitations', 400) . "</small></h2><table id=\"source_input\" border=0>" . $rows . '</table><div class="addESINLink"><a href="javascript:void(0);" onClick="addSource(); return preventDefaultAction(event);">Add source citation</a></div>'; // add image input $display = 'none'; $rows = ''; if (isset($images)) { // sort images, display holes caused by image deletion $sortedImages = array(); $maxId = 0; foreach ($images as $image) { $id = (int) substr((string) $image['id'], 1); if ($maxId < $id) { $maxId = $id; } } foreach ($images as $image) { $id = (int) substr((string) $image['id'], 1); if (isset($sortedImages[$id])) { // caused by a bug, move the image to the end rather than lose it $maxId += 1; $id = $maxId; $image['id'] = 'I' . $id; } $sortedImages[$id] = $image; } for ($i = 1; $i <= $maxId; $i++) { $display = 'block'; $rows .= $this->addImageInput($i - 1, @$sortedImages[$i]); } } $result .= "<a name=\"imagesSection\"></a><h2>Images</h2><table id=\"image_input\" border=0 style=\"display:{$display}\">" . '<tr><th>ID</th><th>Primary' . $tm->addMsgTip('ImagePrimary') . '</th><th>Title' . $tm->addMsgTip('ImageFilename') . '</th><th></th><th>Caption' . $tm->addMsgTip('ImageCaption') . '</th></tr>' . $rows . '</table><div class="addESINLink"><a href="javascript:void(0);" onClick="addImage(); return preventDefaultAction(event);">Add image</a></div>'; // add note input $display = 'none'; $rows = ''; if (isset($notes)) { $i = 0; foreach ($notes as $note) { $display = 'block'; $rows .= $this->addNoteInput($i, $note); $i++; } } $result .= "<a name=\"notesSection\"></a><h2>Notes</h2><table id=\"note_input\" border=0 width=\"670px\" style=\"display:{$display}\">" . '<tr><th>ID</th><th width="90%">Text' . $tm->addMsgTip('NoteText') . '</th></tr>' . $rows . '</table><div class="addESINLink"><a href="javascript:void(0);" onClick="addNote(); return preventDefaultAction(event);">Add note</a></div>'; $result .= $tm->getTipTexts(); return $result; }
/** * Public function that creates a single instance */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Create edit fields from xml property */ protected function toEditFields(&$textbox1) { global $wgOut, $wgScriptPath, $wgRequest; $result = ''; $target = $wgRequest->getVal('target'); // add javascript functions $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>"); // if ($target && $target != 'AddPage') { // $result .= "<p><font color=red>Add any additional information you have about the source". // ($target == 'gedcom' ? ' and save the page' : ', save the page, then close this window'). // ".</font></p>"; // } $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/jquery.multiSelect.yui.1.js\"></script>"); $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/source.18.js\"></script>"); $tm = new TipManager(); $sourceType = ''; $authors = ''; $sourceTitle = ''; $subtitle = ''; $publisher = ''; $dateIssued = ''; $placeIssued = ''; $seriesName = ''; $pages = ''; $references = ''; $surnames = ''; $places = ''; $subjects = array(); $ethnicity = ''; $religion = ''; $occupation = ''; $fromYear = ''; $toYear = ''; $invalidStyle = ' style="background-color:#fdd;"'; $fromYearStyle = ''; $toYearStyle = ''; $exists = isset($this->xml); if (!$exists) { // construct <source> text from request $text = Source::getPageText($wgRequest->getVal('sty'), $wgRequest->getVal('st'), $wgRequest->getVal('a'), $wgRequest->getVal('p'), $wgRequest->getVal('pi'), $wgRequest->getVal('pu')); $this->xml = StructuredData::getXml('source', $text); } if (isset($this->xml)) { $sourceType = htmlspecialchars((string) $this->xml->source_type); foreach ($this->xml->author as $author) { $authors .= htmlspecialchars((string) $author) . "\n"; } $sourceTitle = htmlspecialchars((string) $this->xml->source_title); if (!$sourceTitle) { $sourceTitle = htmlspecialchars($this->titleString); } $subtitle = htmlspecialchars((string) $this->xml->subtitle); $publisher = htmlspecialchars((string) $this->xml->publisher); if (!$publisher) { $publisher = htmlspecialchars((string) $this->xml->publication_info); } $dateIssued = htmlspecialchars((string) $this->xml->date_issued); $placeIssued = htmlspecialchars((string) $this->xml->place_issued); $seriesName = htmlspecialchars((string) $this->xml->series_name); $volumes = htmlspecialchars((string) $this->xml->volumes); $pages = htmlspecialchars((string) $this->xml->pages); $references = htmlspecialchars((string) $this->xml->references); foreach ($this->xml->surname as $surname) { $surnames .= htmlspecialchars((string) $surname) . "\n"; } foreach ($this->xml->place as $place) { $places .= htmlspecialchars((string) $place) . "\n"; } foreach ($this->xml->subject as $subject) { $subjects[] = htmlspecialchars((string) $subject); } if (count($subjects) == 0 && (string) $this->xml->source_category) { $subjects[] = htmlspecialchars((string) $this->xml->source_category); } $ethnicity = htmlspecialchars((string) $this->xml->ethnicity); $religion = htmlspecialchars((string) $this->xml->religion); $occupation = htmlspecialchars((string) $this->xml->occupation); $fromYear = htmlspecialchars((string) $this->xml->from_year); $toYear = htmlspecialchars((string) $this->xml->to_year); $url = htmlspecialchars((string) $this->xml->url); // old $callNumber = htmlspecialchars((string) $this->xml->call_number); // old $repoName = htmlspecialchars((string) $this->xml->repository_name); // old $repoAddr = htmlspecialchars((string) $this->xml->repository_addr); // old } $missingAvailability = false; if (isset($this->xml)) { foreach ($this->xml->repository as $repository) { // the source_location condition is temporary if (!(string) $repository['availability'] && stripos((string) $repository['source_location'], 'www.familysearch.org/Eng/Library/fhlcatalog') === false) { $missingAvailability = true; } } if ($url && stripos($url, 'www.familysearch.org/Eng/Library/fhlcatalog') === false) { $missingAvailability = true; } } if ($missingAvailability) { $result .= "<p><font color=red>Please select an Availability</font></p>"; } if (!StructuredData::isValidYear($fromYear) || !StructuredData::isValidYear($toYear)) { if (!StructuredData::isValidYear($fromYear)) { $fromYearStyle = $invalidStyle; } if (!StructuredData::isValidYear($toYear)) { $toYearStyle = $invalidStyle; } $result .= "<p><font color=red>The year range is not valid</font></p>"; } // display edit fields $result .= "<h2>Source information</h2><table>" . '<tr><td align=right>Type:</td><td align=left>' . StructuredData::addSelectToHtml(1, 'source_type', self::$SOURCE_TYPE_OPTIONS, $sourceType, 'onChange="showSourceFields()"') . $tm->addMsgTip('SourceType') . '</td></tr>' . '<tr id="authors_row"><td align=right>Authors:<br/><font size=\\"-1\\"><i>one per line<br/>surname, given</i></font></td>' . "<td align=left><textarea tabindex=\"1\" name=\"authors\" rows=\"3\" cols=\"60\">{$authors}</textarea></td></tr>" . "<tr id=\"source_title_row\"><td align=right>Title:</td><td align=left><input tabindex=\"1\" name=\"source_title\" value=\"{$sourceTitle}\" size=\"60\"/></td></tr>" . "<tr id=\"subtitle_row\"><td align=right>Subtitle:</td><td align=left><input tabindex=\"1\" name=\"subtitle\" value=\"{$subtitle}\" size=\"60\"/></td></tr>" . "<tr id=\"publisher_row\"><td align=right>Publisher:</td><td align=left><input tabindex=\"1\" name=\"publisher\" value=\"{$publisher}\" size=\"60\"/></td></tr>" . "<tr id=\"date_issued_row\"><td align=right>Date issued:</td><td align=left><input tabindex=\"1\" name=\"date_issued\" value=\"{$dateIssued}\" size=\"20\"/></td></tr>" . "<tr id=\"place_issued_row\"><td align=right>Place issued:</td><td align=left><input tabindex=\"1\" name=\"place_issued\" value=\"{$placeIssued}\" size=\"60\"/></td></tr>" . "<tr id=\"series_name_row\"><td align=right>Periodical/Series name:</td><td align=left><input tabindex=\"1\" class=\"source_input\" name=\"series_name\" value=\"{$seriesName}\" size=\"60\"/></td></tr>" . "<tr id=\"volumes_row\"><td align=right>Number of volumes:</td><td align=left><input tabindex=\"1\" name=\"volumes\" value=\"{$volumes}\" size=\"10\"/></td></tr>" . "<tr id=\"pages_row\"><td align=right>Volume/Film#/Pages:</td><td align=left><input tabindex=\"1\" name=\"pages\" value=\"{$pages}\" size=\"20\"/></td></tr>" . "<tr id=\"references_row\"><td align=right>References/Cites:</td><td align=left><input tabindex=\"1\" name=\"references\" value=\"{$references}\" size=\"60\"/></td></tr>" . "</table>"; $result .= '<h2>Coverage</h2><table>' . "<tr><td align=right>Surnames covered:<br/><i>one per line</i></td><td align=left><textarea tabindex=\"1\" name=\"surnames\" rows=\"3\" cols=\"60\">{$surnames}</textarea></td></tr>" . "<tr><td align=right>Places covered:<br/><i>one per line</i></td><td align=left><textarea class=\"place_input\" tabindex=\"1\" name=\"places\" rows=\"3\" cols=\"60\">{$places}</textarea></td></tr>" . "<tr><td align=right>Year range:</td><td align=left><input tabindex=\"1\" name=\"fromYear\" value=\"{$fromYear}\" size=\"5\"{$fromYearStyle}/>" . " - <input tabindex=\"1\" name=\"toYear\" value=\"{$toYear}\" size=\"5\"{$toYearStyle}/></td></tr>" . "<tr><td align=right>Subject:</td><td align=left>" . StructuredData::addSelectToHtml(1, 'subject', self::$SOURCE_SUBJECT_OPTIONS, $subjects, 'multiple="multiple"') . "</td></tr>" . "<tr id=\"ethnicity_row\"><td align=right>Ethnicity/Culture:</td><td align=left>" . StructuredData::addSelectToHtml(1, 'ethnicity', self::$ETHNICITY_OPTIONS, $ethnicity) . "</td></tr>" . "<tr id=\"religion_row\"><td align=right>Religion:</td><td align=left>" . StructuredData::addSelectToHtml(1, 'religion', self::$RELIGION_OPTIONS, $religion) . "</td></tr>" . "<tr id=\"occupation_row\"><td align=right>Occupation:</td><td align=left>" . StructuredData::addSelectToHtml(1, 'occupation', self::$OCCUPATION_OPTIONS, $occupation) . "</td></tr>" . "</table>"; $rows = ''; $i = 0; if (isset($this->xml)) { foreach ($this->xml->repository as $repository) { $rows .= $this->addRepositoryInput($i, htmlspecialchars((string) $repository['title']), htmlspecialchars((string) $repository['source_location']), htmlspecialchars((string) $repository['availability']), (string) $repository['availability'] ? '' : $invalidStyle); $i++; } if ($url) { $rows .= $this->addRepositoryInput($i, '', $url, '', $invalidStyle); $i++; } if ($callNumber || $repoName) { $rows .= $this->addRepositoryInput($i, $repoName, $callNumber, '', $invalidStyle); $i++; } } if ($i == 0) { $rows .= $this->addRepositoryInput($i, '', '', '', ''); $i++; } $result .= '<h2>Repositories</h2>'; $result .= '<table id="repository_table" border="0" width="500px" style="display:block">'; $result .= '<tr><th></th><th>Repository name</th><th>Location (call#, URL) of source within repository</th><th>Availability</th></tr>'; $result .= "{$rows}</table><a href=\"javascript:void(0)\" onClick=\"addRepository('" . implode(',', self::$SOURCE_AVAILABILITY_OPTIONS) . "'); return preventDefaultAction(event);\">Add Repository</a>"; $result .= $tm->getTipTexts(); $result .= "<br><br>Text:<br>"; return $result; }
/** * Create edit fields from xml property * textbox1 passed by reference for efficiency; don't change it */ protected function toEditFields(&$textbox1) { global $wgOut, $wgScriptPath, $wgESINHandler, $wgRequest; $result = ''; // $target = $wgRequest->getVal('target'); // add javascript functions $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/jquery.tablednd_0_5.yui.1.js\"></script>"); $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/personfamily.31.js\"></script>"); $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>"); $tm = new TipManager(); $name = null; $altNames = null; $invalidStyle = ' style="background-color:#fdd;"'; $genderStyle = ''; $childOfFamilyStyle = ''; $spouseOfFamilyStyle = ''; $genderString = ''; $childOfFamilies = array(); $spouseOfFamilies = array(); $exists = isset($this->xml); if (!$exists) { // && !StructuredData::isRedirect($textbox1)) { // construct <person> text from What Links Here and from request $oldText = $this->getPageTextFromWLH(true, $wgRequest); $this->xml = StructuredData::getXml('person', $oldText); } if (isset($this->xml)) { $name = $this->xml->name; $altNames = $this->xml->alt_name; $genderString = (string) $this->xml->gender; $childOfFamilies = StructuredData::getTitlesAsArray($this->xml->child_of_family); $spouseOfFamilies = StructuredData::getTitlesAsArray($this->xml->spouse_of_family); } $this->addRequestMembers('pf', $childOfFamilies); $this->addRequestMembers('sf', $spouseOfFamilies); if (ESINHandler::isLiving($this->xml)) { $result .= "<p><font color=red>This person was born/christened less than 110 years ago and does not have a death/burial date. Living people cannot be entered into WeRelate.org.</font></p>"; } else { if (!$this->isGedcomPage && !StructuredData::titleStringHasId($this->titleString)) { $result .= "<p><font color=red>The page title does not have an ID; please create a page with an ID using <a href='/wiki/Special:AddPage/Person'>Add page</a></font></p>"; } } if ($exists && !$genderString) { $result .= "<p><font color=red>You must select a gender</font></p>"; $genderStyle = $invalidStyle; } if (StructuredData::titlesOverlap($childOfFamilies, $spouseOfFamilies)) { $result .= "<p><font color=red>This person cannot be a child of and a spouse of the same family</font></p>"; $childOfFamilyStyle = $invalidStyle; $spouseOfFamilyStyle = $invalidStyle; } if (!$this->isGedcomPage && (StructuredData::titlesMissingId($childOfFamilies) || !StructuredData::titlesExist(NS_FAMILY, $childOfFamilies))) { $result .= "<p><font color=red>Parents family page not found; please remove it, save this page, then add a new one</font></p>"; } if (!$this->isGedcomPage && (StructuredData::titlesMissingId($spouseOfFamilies) || !StructuredData::titlesExist(NS_FAMILY, $spouseOfFamilies))) { $result .= "<p><font color=red>Spouse family page not found; please remove it, save this page, then add a new one</font></p>"; } if (ESINHandler::hasAmbiguousDates($this->xml)) { $result .= "<p><font color=red>Please write dates in \"<i>D MMM YYYY</i>\" format so they are unambiguous (ie 5 Jan 1900)</font></p>"; } // add name input table $rows = ''; $display = 'none'; if (isset($altNames)) { $i = 1; foreach ($altNames as $altName) { $display = 'inline'; $rows .= $this->addNameInput($i, $altName); $i++; } } $result .= '<h2>Name</h2>'; $result .= '<table id="name_input" border=0 cellpadding=3>' . '<tr><th></th><th>Name prefix' . $tm->addMsgTip('TitlePrefix') . '</th><th>Given' . $tm->addMsgTip('GivenName') . '</th><th>Surname' . $tm->addMsgTip('Surname') . '</th>' . '<th>Name suffix' . $tm->addMsgTip('TitleSuffix') . '</th>' . '<th></th><th>Source(s)' . $tm->addMsgTip('NameSourceIDs') . '</th><th></th><th>Note(s)' . $tm->addMsgTip('NameNoteIDs') . '</th></tr>' . $this->addNameInput(0, $name, $display) . $rows . '</table><div class="addESINLink"><a href="javascript:void(0);" onClick="addName(\'' . implode(',', self::$NAME_TYPES) . '\'); return preventDefaultAction(event);">Add alternate name</a></div>'; // add gender input $result .= '<br><br><label for="gender">Gender: </label>' . StructuredData::addSelectToHtml(1, 'gender', Person::$GENDER_OPTIONS, $genderString, $genderStyle) . '<br><br>'; // add child of family input $result .= $this->addFamilyInput($childOfFamilies, 'child_of_family', 'Parents and siblings family', 'ChildOfFamily', $childOfFamilyStyle, $tm, $invalidStyle); //, substr($target, 0, 5) == 'child'); // add spouse of family input $result .= $this->addFamilyInput($spouseOfFamilies, 'spouse_of_family', 'Spouse and children family', 'SpouseOfFamily', $spouseOfFamilyStyle, $tm, $invalidStyle); //, substr($target, 0, 4) == 'wife' || substr($target, 0, 7) == 'husband'); // add event_fact input table $result .= $wgESINHandler->addEventsFactsInput($this->xml, self::$STD_EVENT_TYPES, self::$OTHER_EVENT_TYPES); // add sources, images, notes input tables $result .= $wgESINHandler->addSourcesImagesNotesInput($this->xml); $result .= $tm->getTipTexts(); $result .= '<h2>Personal History</h2>'; return $result; }
/** * Create edit fields from xml property */ protected function toEditFields(&$textbox1) { global $wgOut, $wgScriptPath; // add javascript functions $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>"); $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/userpage.4.js\"></script>"); $tm = new TipManager(); $invalidStyle = ' style="background-color:#fdd;"'; $result = ''; if ($this->isSubpage) { $surnames = ''; $places = ''; $fromYear = ''; $toYear = ''; $fromYearStyle = ''; $toYearStyle = ''; if (isset($this->xml)) { $fromYear = htmlspecialchars((string) $this->xml->from_year); $toYear = htmlspecialchars((string) $this->xml->to_year); foreach ($this->xml->surname as $surname) { $surnames .= htmlspecialchars($surname) . "\n"; } foreach ($this->xml->place as $place) { $places .= htmlspecialchars($place) . "\n"; } if (!StructuredData::isValidYear($fromYear) || !StructuredData::isValidYear($toYear)) { if (!StructuredData::isValidYear($fromYear)) { $fromYearStyle = $invalidStyle; } if (!StructuredData::isValidYear($toYear)) { $toYearStyle = $invalidStyle; } $result .= "<p><font color=red>The year range is not valid</font></p>"; } } $result .= "<br><label for=\"surnames\">Surnames (one per line):</label><br><textarea tabindex=\"1\" name=\"surnames\" rows=\"3\" cols=\"60\">{$surnames}</textarea>"; $result .= "<br><label for=\"places\">Places (one per line):</label><br><textarea class=\"place_input\" tabindex=\"1\" name=\"places\" rows=\"3\" cols=\"60\">{$places}</textarea>"; $result .= "<table><tr>"; $result .= "<td align=left>Year range:</td><td align=left><input tabindex=\"1\" name=\"fromYear\" value=\"{$fromYear}\" size=\"5\"{$fromYearStyle}/>"; $result .= " - <input tabindex=\"1\" name=\"toYear\" value=\"{$toYear}\" size=\"5\"{$toYearStyle}/>"; $result .= "</td></tr></table>Text:<br>"; } else { $display = 'none'; $rows = ''; $i = 0; if (isset($this->xml)) { foreach ($this->xml->researching as $researching) { $display = 'block'; $rows .= "<tr><td><input type=\"hidden\" name=\"researching_id{$i}\" value=\"" . ($i + 1) . "\"/>" . "<input tabindex=\"1\" type=\"text\" size=20 name=\"researching_surname{$i}\" value=\"" . htmlspecialchars((string) $researching['surname']) . "\"/></td>" . "<td><input class=\"place_input\" tabindex=\"1\" type=\"text\" size=30 name=\"researching_place{$i}\" value=\"" . htmlspecialchars((string) $researching['place']) . "\"/></td></tr>\n"; $i++; } } $result .= '<h2>Surnames and/or places you are researching' . $tm->addMsgTip('UserResearching') . '</h2>' . "<table id=\"researching_table\" border=0 width=\"500px\" style=\"display:{$display}\"><tr><th>Surname</th><th>Place (state, province, or country)</th></tr>" . "{$rows}</table><a href=\"javascript:void(0)\" onClick=\"addResearchInput(); return preventDefaultAction(event);\">Add Surname and/or Place</a>"; $result .= '<br><br><h2>Text' . $tm->addMsgTip('UserText') . '</h2>'; $result .= $tm->getTipTexts(); } return $result; }