diff options
72 files changed, 1163 insertions, 1275 deletions
diff --git a/ancestry.php b/ancestry.php index b675738fd2..4739dd8c07 100644 --- a/ancestry.php +++ b/ancestry.php @@ -43,9 +43,7 @@ $nonfamfacts[] = 'UID'; $nonfamfacts[] = ''; $controller=new WT_Controller_Ancestry(); -$controller->init(); - -print_header(/* I18N: %s is a person's name */ WT_I18N::translate('Ancestors of %s', $controller->name)); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; @@ -236,4 +234,3 @@ case 3: echo '</div>'; break; } -print_footer(); diff --git a/descendancy.php b/descendancy.php index e879617458..6c4c0caaa9 100644 --- a/descendancy.php +++ b/descendancy.php @@ -41,9 +41,7 @@ $nonfamfacts[] = 'UID'; $nonfamfacts[] = ''; $controller=new WT_Controller_Descendancy(); -$controller->init(); - -print_header(/* I18N: %s is a person's name */ WT_I18N::translate('Descendants of %s', $controller->name)); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; @@ -153,7 +151,6 @@ case 3: //-- Family list echo '</div>'; break; } -print_footer(); function indi_desc($person, $n, $array) { if ($n<1) { @@ -182,5 +179,3 @@ function fam_desc($person, $n, $array) { } return $array; } - -?> diff --git a/family.php b/family.php index 23c22d530d..2d36639d8d 100644 --- a/family.php +++ b/family.php @@ -28,19 +28,18 @@ define('WT_SCRIPT_NAME', 'family.php'); require './includes/session.php'; -$controller = new WT_Controller_Family(); -$controller->init(); +$controller=new WT_Controller_Family(); -if ($controller->family && $controller->family->canDisplayDetails()) { - print_header($controller->getPageTitle()); - if ($controller->family->isMarkedDeleted()) { +if ($controller->record && $controller->record->canDisplayDetails()) { + $controller->pageHeader(); + if ($controller->record->isMarkedDeleted()) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This family has been deleted. You should review the deletion and then %1$s or %2$s it.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->family->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->family->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -51,14 +50,14 @@ if ($controller->family && $controller->family->canDisplayDetails()) { ' ', help_link('pending_changes'), '</p>'; } - } elseif (find_updated_record($controller->family->getXref(), WT_GED_ID)!==null) { + } elseif (find_updated_record($controller->record->getXref(), WT_GED_ID)!==null) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This family has been edited. You should review the changes and then %1$s or %2$s them.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->family->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->family->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -70,21 +69,17 @@ if ($controller->family && $controller->family->canDisplayDetails()) { '</p>'; } } -} elseif ($controller->family && $SHOW_PRIVATE_RELATIONSHIPS) { - print_header($controller->getPageTitle()); +} elseif ($controller->record && $SHOW_PRIVATE_RELATIONSHIPS) { + $controller->pageHeader(); // Continue - to display the children/parents/grandparents. // We'll check for showing the details again later } else { - header('HTTP/1.0 403 Forbidden'); - print_header(WT_I18N::translate('Family')); + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); + $controller->pageHeader(); echo '<p class="ui-state-error">', WT_I18N::translate('This family does not exist or you do not have permission to view it.'), '</p>'; - print_footer(); exit; } -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - if (WT_USE_LIGHTBOX) { require_once WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_call_js.php'; } @@ -94,23 +89,23 @@ $show_full = "1"; echo WT_JS_START; echo 'function show_gedcom_record() {'; -echo ' var recwin=window.open("gedrecord.php?pid=', $controller->family->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; +echo ' var recwin=window.open("gedrecord.php?pid=', $controller->record->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; echo '}'; -echo 'function showchanges() { window.location="'.$controller->family->getRawUrl().'"; }'; +echo 'function showchanges() { window.location="'.$controller->record->getRawUrl().'"; }'; echo WT_JS_END; ?> <table align="center" width="95%"> <tr> <td> - <p class="name_head"><?php echo $controller->family->getFullName(); ?></p> + <p class="name_head"><?php echo $controller->record->getFullName(); ?></p> </td> </tr> </table> <table id="family_page" align="center" width="95%"> <tr valign="top"> <td valign="top" style="width: <?php echo $pbwidth+30; ?>px;"><!--//List of children//--> - <?php print_family_children($controller->getFamilyID()); ?> + <?php print_family_children($controller->record->getXref()); ?> </td> <td> <!--//parents pedigree chart and Family Details//--> <table width="100%"> @@ -122,23 +117,23 @@ echo WT_JS_END; <td colspan="2"> <table><tr><td> <!--//parents pedigree chart //--> <?php - echo print_family_parents($controller->getFamilyID()); + echo print_family_parents($controller->record->getXref()); if (WT_USER_CAN_EDIT) { - if ($controller->difffam) { - $husb=$controller->difffam->getHusband(); + if ($controller->diff_record) { + $husb=$controller->diff_record->getHusband(); } else { - $husb=$controller->family->getHusband(); + $husb=$controller->record->getHusband(); } if (!$husb) { - echo '<a href="javascript: ', WT_I18N::translate('Add a new father'), '" onclick="return addnewparentfamily(\'\', \'HUSB\', \'', $controller->famid, '\');">', WT_I18N::translate('Add a new father'), help_link('edit_add_parent'), '</a><br />'; + echo '<a href="javascript: ', WT_I18N::translate('Add a new father'), '" onclick="return addnewparentfamily(\'\', \'HUSB\', \'', $controller->record->getXref(), '\');">', WT_I18N::translate('Add a new father'), help_link('edit_add_parent'), '</a><br />'; } - if ($controller->difffam) { - $wife=$controller->difffam->getWife(); + if ($controller->diff_record) { + $wife=$controller->diff_record->getWife(); } else { - $wife=$controller->family->getWife(); + $wife=$controller->record->getWife(); } if (!$wife) { - echo '<a href="javascript: ', WT_I18N::translate('Add a new mother'), '" onclick="return addnewparentfamily(\'\', \'WIFE\', \'', $controller->famid, '\');">', WT_I18N::translate('Add a new mother'), help_link('edit_add_parent'), '</a><br />'; + echo '<a href="javascript: ', WT_I18N::translate('Add a new mother'), '" onclick="return addnewparentfamily(\'\', \'WIFE\', \'', $controller->record->getXref(), '\');">', WT_I18N::translate('Add a new mother'), help_link('edit_add_parent'), '</a><br />'; } } ?> @@ -148,8 +143,8 @@ echo WT_JS_END; <tr> <td colspan="2"> <?php - if ($controller->family->canDisplayDetails()) { - print_family_facts($controller->family); + if ($controller->record->canDisplayDetails()) { + print_family_facts($controller->record); } else { echo '<p class="ui-state-highlight">', WT_I18N::translate('The details of this family are private.'), '</p>'; } @@ -160,6 +155,3 @@ echo WT_JS_END; </td> </tr> </table> -<br /> -<?php -print_footer(); diff --git a/hourglass.php b/hourglass.php index a39ab098f7..195908d914 100644 --- a/hourglass.php +++ b/hourglass.php @@ -28,10 +28,8 @@ define('WT_SCRIPT_NAME', 'hourglass.php'); require './includes/session.php'; -$controller = new WT_Controller_Hourglass(); -$controller->init(); - -print_header(/* I18N: %s is a person's name */ WT_I18N::translate('Hourglass chart of %s', $controller->name)); +$controller=new WT_Controller_Hourglass(); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; @@ -146,5 +144,3 @@ $controller->print_person_pedigree(WT_Person::getInstance($controller->pid), 1); sizeLines(); //--> </script> -<?php -print_footer(); diff --git a/hourglass_ajax.php b/hourglass_ajax.php index 210dae63bf..d542a1865b 100644 --- a/hourglass_ajax.php +++ b/hourglass_ajax.php @@ -34,8 +34,7 @@ require './includes/session.php'; * label the pair as a pair. */ -$controller = new WT_Controller_Hourglass(); -$controller->init(); +$controller=new WT_Controller_Hourglass(); header('Content-type: text/html; charset=UTF-8'); // -- print html header information diff --git a/imageview.php b/imageview.php index dae86062c5..11b42f60f4 100644 --- a/imageview.php +++ b/imageview.php @@ -26,14 +26,10 @@ define('WT_SCRIPT_NAME', 'imageview.php'); require './includes/session.php'; -$controller = new WT_Controller_Media(); -$controller->init(); +$controller=new WT_Controller_Media(); print_simple_header(WT_I18N::translate('Image viewer')); -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - if (!$controller->mediaobject) { echo '<b>', WT_I18N::translate('Unable to find record with ID'), '</b><br /><br />'; print_footer(); @@ -207,5 +203,5 @@ if (!$controller->mediaobject->isExternal() && !$controller->mediaobject->fileEx echo "</form>"; echo "<div style=\"position: relative; \">"; echo "</div>"; -echo "<div class=\"center\"><br /><a href=\"javascript:;\" onclick=\"window.close();\">".WT_I18N::translate('Close Window')."</a></div><br />"; +echo "<div class=\"center\"><br /><a href=\"javascript:;\" onclick=\"window.close();\">".WT_I18N::translate('Close Window')."</a></div>"; print_simple_footer(); diff --git a/includes/functions/functions_print.php b/includes/functions/functions_print.php index 2ca1df2265..15ed29612a 100644 --- a/includes/functions/functions_print.php +++ b/includes/functions/functions_print.php @@ -248,93 +248,42 @@ function print_pedigree_person($person, $style=1, $count=0, $personcount="1") { * This function should be called by every page, except popups, before anything is output. * * Popup pages, because of their different format, should invoke function print_simple_header() instead. -* -* @param string $title the title to put in the <TITLE></TITLE> header tags */ function print_header($title, $view='full') { + // Import global variables into the local scope, for the theme's header.php global $bwidth, $BROWSERTYPE, $SEARCH_SPIDER, $cart; global $GEDCOM, $GEDCOM_TITLE, $action, $query; global $stylesheet, $print_stylesheet, $headerfile, $print_headerfile; global $WT_IMAGES, $TEXT_DIRECTION, $REQUIRE_AUTHENTICATION; global $controller; - $GEDCOM_TITLE = get_gedcom_setting(WT_GED_ID, 'title'); - $META_DESCRIPTION=''; - $META_ROBOTS='noindex,nofollow'; - $META_GENERATOR=''; - $LINK_CANONICAL=''; - - $index_this_page=false; - $access_denied=false; - - if (isset($controller) && (in_array(WT_SCRIPT_NAME, array('family.php', 'individual.php', 'note.php', 'repo.php', 'source.php' )))) { - switch (get_class($controller)) { - case 'WT_Controller_Family': - // family.php - if ($controller->family) { - $LINK_CANONICAL=$controller->family->getHtmlUrl(); - if ($controller->family->canDisplayDetails()) $index_this_page=true; else $access_denied=true; - } - break; - case 'WT_Controller_Individual': - // individual.php - if ($controller->indi) { - $LINK_CANONICAL=$controller->indi->getHtmlUrl(); - if ($controller->indi->canDisplayDetails()) $index_this_page=true; else $access_denied=true; - } - break; - case 'WT_Controller_Note': - // note.php - if ($controller->note) { - $LINK_CANONICAL=$controller->note->getHtmlUrl(); - if ($controller->note->canDisplayDetails()) $index_this_page=true; else $access_denied=true; - } - break; - case 'WT_Controller_Repository': - // repo.php - if ($controller->repository) { - $LINK_CANONICAL=$controller->repository->getHtmlUrl(); - if ($controller->repository->canDisplayDetails()) $index_this_page=true; else $access_denied=true; - } - break; - case 'WT_Controller_Source': - // source.php - if ($controller->source) { - $LINK_CANONICAL=$controller->source->getHtmlUrl(); - if ($controller->source->canDisplayDetails()) $index_this_page=true; else $access_denied=true; - } - break; - default: - break; + // Initialise variables for the theme's header.php + if ($controller instanceof WT_Controller_GedcomRecord) { + $LINK_CANONICAL=$controller->getCanonicalUrl(); + $META_ROBOTS=$controller->getMetaRobots(); + if ($controller->record && !$controller->record->canDisplayName()) { + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); } - } - - if (WT_SCRIPT_NAME=='index.php') { + } elseif (WT_SCRIPT_NAME=='index.php') { $LINK_CANONICAL='index.php?ctype=gedcom&ged='.WT_GEDURL; - $index_this_page=true; - } - - // listing pages - if (in_array(WT_SCRIPT_NAME, array('famlist.php', 'indilist.php', 'notelist.php', 'repolist.php', 'sourcelist.php'))) { - $index_this_page=true; - } - - if ($index_this_page) { $META_ROBOTS='index,follow'; - } - + } elseif (in_array(WT_SCRIPT_NAME, array('famlist.php', 'indilist.php', 'notelist.php', 'repolist.php', 'sourcelist.php'))) { + $LINK_CANONICAL=''; + $META_ROBOTS='index,follow'; + } else { + $LINK_CANONICAL=''; + $META_ROBOTS='noindex,nofollow'; + } + $GEDCOM_TITLE = get_gedcom_setting(WT_GED_ID, 'title'); if ($view=='full') { - $META_DESCRIPTION=get_gedcom_setting(WT_GED_ID, 'META_DESCRIPTION'); - if (empty($META_DESCRIPTION)) { - $META_DESCRIPTION=$GEDCOM_TITLE; - } + $META_DESCRIPTION=get_gedcom_setting(WT_GED_ID, 'META_DESCRIPTION', $GEDCOM_TITLE); $META_GENERATOR=WT_WEBTREES.' - '.WT_WEBTREES_URL; + } else { + $META_DESCRIPTION=''; + $META_GENERATOR=''; } header('Content-Type: text/html; charset=UTF-8'); - if ($access_denied) { - header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden'); - } // The title often includes the names of records, which may have markup // that cannot be used in the page title. diff --git a/individual.php b/individual.php index 62ce2212b3..5aa205e704 100644 --- a/individual.php +++ b/individual.php @@ -35,18 +35,21 @@ $nonfacts = array('FAMS', 'FAMC', 'MAY', 'BLOB', 'CHIL', 'HUSB', 'WIFE', 'RFN', $nonfamfacts = array(/*'NCHI',*/ 'UID', ''); $controller=new WT_Controller_Individual(); -$controller->init(); -if ($controller->indi && $controller->indi->canDisplayDetails()) { - print_header($controller->getPageTitle()); - if ($controller->indi->isMarkedDeleted()) { +if ($controller->record && $controller->record->canDisplayDetails()) { + if (safe_GET('action')=='ajax') { + $controller->ajaxRequest(); + exit; + } + $controller->pageHeader(); + if ($controller->record->isMarkedDeleted()) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This individual has been deleted. You should review the deletion and then %1$s or %2$s it.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->indi->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->indi->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -57,14 +60,14 @@ if ($controller->indi && $controller->indi->canDisplayDetails()) { ' ', help_link('pending_changes'), '</p>'; } - } elseif (find_updated_record($controller->indi->getXref(), WT_GED_ID)!==null) { + } elseif (find_updated_record($controller->record->getXref(), WT_GED_ID)!==null) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This individual has been edited. You should review the changes and then %1$s or %2$s them.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->indi->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->indi->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -76,34 +79,29 @@ if ($controller->indi && $controller->indi->canDisplayDetails()) { '</p>'; } } -} elseif ($controller->indi && $controller->indi->canDisplayName()) { +} elseif ($controller->record && $controller->record->canDisplayName()) { // Just show the name. - print_header($controller->getPageTitle()); - echo '<h2>', $controller->indi->getFullName(), '</h2>'; + $controller->pageHeader(); + echo '<h2>', $controller->record->getFullName(), '</h2>'; echo '<p class="ui-state-highlight">', WT_I18N::translate('The details of this individual are private.'), '</p>'; - print_footer(); exit; } else { - header('HTTP/1.0 403 Forbidden'); - print_header(WT_I18N::translate('Individual')); + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); + $controller->pageHeader(); echo '<p class="ui-state-error">', WT_I18N::translate('This individual does not exist or you do not have permission to view it.'), '</p>'; - print_footer(); exit; } -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - // tell tabs that use jquery that it is already loaded define('WT_JQUERY_LOADED', 1); -$linkToID=$controller->pid; // -- Tell addmedia.php what to link to +$linkToID=$controller->record->getXref(); // -- Tell addmedia.php what to link to echo WT_JS_START; echo 'function show_gedcom_record() {'; -echo ' var recwin=window.open("gedrecord.php?pid=', $controller->indi->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; +echo ' var recwin=window.open("gedrecord.php?pid=', $controller->record->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; echo '}'; -echo 'function showchanges() { window.location="'.$controller->indi->getRawUrl().'"; }'; +echo 'function showchanges() { window.location="'.$controller->record->getRawUrl().'"; }'; ?> @@ -190,7 +188,7 @@ echo '<div id="main" class="use-sidebar sidebar-at-right" style="visibility:hidden;">', //overall page container '<div id="indi_left">', '<div id="indi_header">'; -if ($controller->indi->canDisplayDetails()) { +if ($controller->record->canDisplayDetails()) { echo '<div id="indi_mainimage">'; // Display highlight image if ($controller->canShowHighlightedObject()) { echo $controller->getHighlightedObject(); @@ -198,11 +196,11 @@ if ($controller->indi->canDisplayDetails()) { echo '</div>'; // close #indi_mainimage $globalfacts=$controller->getGlobalFacts(); echo '<div id="header_accordion1">'; // contain accordions for names - echo '<h3 class="name_one ', $controller->getPersonStyle($controller->indi), '"><span>', $controller->indi->getFullName(), '</span>'; // First name accordion header - $bdate=$controller->indi->getBirthDate(); - $ddate=$controller->indi->getDeathDate(); + 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->indi->isDead()) { + if ($bdate->isOK() && !$controller->record->isDead()) { // If living display age echo strip_tags(WT_Gedcom_Tag::getLabelValue('AGE', get_age_at_event(WT_Date::GetAgeGedcom($bdate), true)), '<span>'); } elseif ($bdate->isOK() && $ddate->isOK()) { @@ -211,7 +209,7 @@ if ($controller->indi->canDisplayDetails()) { } echo '</span>'; // Display summary birth/death info. - echo '<span id="dates">', $controller->indi->getLifeSpan(), '</span>'; + echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>'; //Display gender icon foreach ($globalfacts as $key=>$value) { $fact = $value->getTag(); @@ -252,7 +250,7 @@ foreach ($controller->tabs as $tab) { if ($tab->hasTabContent()) { if ($tab->canLoadAjax()) { // AJAX tabs load only when selected - echo '<li class="'.$greyed_out.'"><a title="', $tab->getName(), '" href="',$controller->indi->getHtmlUrl(),'&action=ajax&module=', $tab->getName(), '">'; + echo '<li class="'.$greyed_out.'"><a title="', $tab->getName(), '" href="',$controller->record->getHtmlUrl(),'&action=ajax&module=', $tab->getName(), '">'; } else { // Non-AJAX tabs load immediately echo '<li class="'.$greyed_out.'"><a title="', $tab->getName(), '" href="#', $tab->getName(), '">'; @@ -282,4 +280,3 @@ echo 'var catch_and_ignore; function paste_id(value) {catch_and_ignore = value;}', 'jQuery("html, body").animate({scrollTop: jQuery("#header").offset().top});', // scroll the page to top WT_JS_END; -print_footer(); diff --git a/library/WT/Controller/AdvancedSearch.php b/library/WT/Controller/AdvancedSearch.php index 22e9f1a0cd..ae8b81f439 100644 --- a/library/WT/Controller/AdvancedSearch.php +++ b/library/WT/Controller/AdvancedSearch.php @@ -1,5 +1,5 @@ <?php -// Controller for the Advanced Search Page +// Controller for the advanced search page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -36,12 +36,6 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search { function __construct() { parent::__construct(); - } - /** - * Initialization function - */ - function init() { - parent :: init(); if (empty($_REQUEST['action'])) { $this->action="advanced"; } diff --git a/library/WT/Controller/Ancestry.php b/library/WT/Controller/Ancestry.php index 6076c827ce..a4984d8e21 100644 --- a/library/WT/Controller/Ancestry.php +++ b/library/WT/Controller/Ancestry.php @@ -1,5 +1,5 @@ <?php -// Controller for the Ancestry Page +// Controller for the ancestry chart // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -30,7 +30,7 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_charts.php'; -class WT_Controller_Ancestry extends WT_Controller_Base { +class WT_Controller_Ancestry extends WT_Controller_Chart { var $pid = ''; var $user = false; var $show_cousins; @@ -42,10 +42,7 @@ class WT_Controller_Ancestry extends WT_Controller_Base { var $show_full; var $cellwidth; - /** - * Initialization function - */ - function init() { + function __construct() { global $USE_RIN, $MAX_ALIVE_AGE, $GEDCOM, $bwidth, $bheight, $pbwidth, $pbheight, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS; global $DEFAULT_PEDIGREE_GENERATIONS, $PEDIGREE_GENERATIONS, $MAX_PEDIGREE_GENERATIONS, $OLD_PGENS, $box_width, $Dbwidth, $Dbheight; global $show_full; @@ -88,6 +85,11 @@ class WT_Controller_Ancestry extends WT_Controller_Base { else $this->cellwidth=(strlen($this->name)*14); } + // What should this page show in the browser's title bar? + public function getPageTitle() { + return /* I18N: %s is a person's name */ WT_I18N::translate('Ancestors of %s', $this->name); + } + /** * print a child ascendancy * diff --git a/library/WT/Controller/Base.php b/library/WT/Controller/Base.php index 732a3dc34a..9899328ff4 100644 --- a/library/WT/Controller/Base.php +++ b/library/WT/Controller/Base.php @@ -1,5 +1,5 @@ <?php -// Base controller for all controller classes +// Base controller for all other controllers // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -29,9 +29,176 @@ if (!defined('WT_WEBTREES')) { } class WT_Controller_Base { - var $action =null; + private $page_header=false; // Used to automatically print the footer - function __construct() { - $this->action =safe_GET('action'); + // Startup activity + public function __construct() { + } + + // Shutdown activity + public function __destruct() { + // If we printed a header, automatically print a footer + if ($this->page_header) { + $this->pageFooter(); + } + } + + // What should this page show in the browser's title bar? + public function getPageTitle() { + return ''; + } + + // What is the preferred URL for this page? + public function getCanonicalUrl() { + return ''; + } + + // How should robots index this page? + public function getMetaRobots() { + // Most pages are not designed for search engines + return 'noindex,nofollow'; + } + + // Print the page header, using the theme + public function pageHeader() { + // Once we've displayed the header, we should no longer write session data. + Zend_Session::writeClose(); + + // Import global variables into the local scope, for the theme's header.php + global $BROWSERTYPE, $SEARCH_SPIDER, $WT_IMAGES, $TEXT_DIRECTION, $REQUIRE_AUTHENTICATION; + global $stylesheet, $headerfile; + + // The title often includes the names of records, which may have markup + // that cannot be used in the page title. + $title=htmlspecialchars_decode(strip_tags($this->getPageTitle())); + + // Initialise variables for the theme's header.php + $LINK_CANONICAL =$this->getCanonicalUrl(); + $META_ROBOTS =$this->getMetaRobots(); + $GEDCOM_TITLE =get_gedcom_setting(WT_GED_ID, 'title'); + $META_DESCRIPTION=get_gedcom_setting(WT_GED_ID, 'META_DESCRIPTION', $GEDCOM_TITLE); + $META_GENERATOR =WT_WEBTREES.'-'.WT_VERSION_TEXT.' - '.WT_WEBTREES_URL; + $META_TITLE =get_gedcom_setting(WT_GED_ID, 'META_TITLE'); + if ($META_TITLE) { + $title.=' - '.$META_TITLE; + } + + $javascript= + '<script type="text/javascript" src="'.WT_JQUERY_URL.'"></script>'. + '<script type="text/javascript" src="'.WT_JQUERYUI_URL.'"></script>'. + '<script type="text/javascript" src="'.WT_STATIC_URL.'js/jquery/jquery.jeditable.min.js"></script>'. + '<script type="text/javascript" src="'.WT_STATIC_URL.'js/jquery/jquery.dataTables.min.js"></script>'. + '<script type="text/javascript" src="'.WT_STATIC_URL.'js/jquery/jquery.cookie.js"></script>'. + WT_JS_START.' + // Give JavaScript access to some PHP constants + var WT_STATIC_URL = "'.WT_STATIC_URL.'"; + var WT_THEME_DIR = "'.WT_THEME_DIR.'"; + var WT_MODULES_DIR = "'.WT_MODULES_DIR.'"; + var textDirection = "'.$TEXT_DIRECTION.'"; + var browserType = "'.$BROWSERTYPE.'"; + var WT_SCRIPT_NAME = "'.WT_SCRIPT_NAME.'"; + var WT_LOCALE = "'.WT_LOCALE.'"; + /* keep the session id when opening new windows */ + var sessionid = "'.Zend_Session::getId().'"; + var sessionname = "'.WT_SESSION_NAME.'"; + var accesstime = '.WT_DB::prepare("SELECT UNIX_TIMESTAMP(NOW())")->fetchOne().'; + var plusminus = new Array(); + plusminus[0] = new Image(); + plusminus[0].src = "'.$WT_IMAGES["plus"].'"; + plusminus[0].title = "'.WT_I18N::translate('Show Details').'"; + plusminus[1] = new Image(); + plusminus[1].src = "'.$WT_IMAGES["minus"].'"; + plusminus[1].title = "'.WT_I18N::translate('Hide Details').'"; + var zoominout = new Array(); + zoominout[0] = new Image(); + zoominout[0].src = "'.$WT_IMAGES["zoomin"].'"; + zoominout[1] = new Image(); + zoominout[1].src = "'.$WT_IMAGES["zoomout"].'"; + var arrows = new Array(); + arrows[0] = new Image(); + arrows[0].src = "'.$WT_IMAGES["larrow2"].'"; + arrows[1] = new Image(); + arrows[1].src = "'.$WT_IMAGES["rarrow2"].'"; + arrows[2] = new Image(); + arrows[2].src = "'.$WT_IMAGES["uarrow2"].'"; + arrows[3] = new Image(); + arrows[3].src = "'.$WT_IMAGES["darrow2"].'"; + + function delete_record(pid, linenum, mediaid) { + if (!mediaid) mediaid=""; + if (confirm(\''.WT_I18N::translate('Are you sure you want to delete this fact?').'\')) { + window.open(\'edit_interface.php?action=delete&pid=\'+pid+\'&linenum=\'+linenum+\'&mediaid=\'+mediaid+"&"+sessionname+"="+sessionid, \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); + } + return false; + } + + function message(username, method, url, subject) { + if ((!url)||(url=="")) url=\''.addslashes(urlencode(get_query_url())).'\'; + if ((!subject)||(subject=="")) subject=""; + window.open(\'message.php?to=\'+username+\'&method=\'+method+\'&url=\'+url+\'&subject=\'+subject+"&"+sessionname+"="+sessionid, \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); + return false; + } + + var whichhelp = \'help_'.WT_SCRIPT_NAME.'\'; + '. + WT_JS_END. + '<script src="'.WT_STATIC_URL.'js/webtrees.js" type="text/javascript"></script>'; + + header('Content-Type: text/html; charset=UTF-8'); + $view='full'; + require WT_ROOT.$headerfile; + + // Allow the browser to format the header/menus while we generate the page + flush(); + } + + // Print the page footer, using the theme + protected function pageFooter() { + global $footerfile, $WT_IMAGES, $TEXT_DIRECTION; + + $view='full'; + require WT_ROOT.$footerfile; + + if (WT_DEBUG_SQL) { + echo WT_DB::getQueryLog(); + } + echo WT_JS::render(); + echo '</body></html>'; + } + + // Get significant information from this page, to allow other pages such as + // charts and reports to initialise with the same records + public function getSignificantIndividual() { + global $PEDIGREE_ROOT_ID; + + $individual=WT_Person::getInstance(WT_USER_GEDCOM_ID); + if (!$individual) { + $individual=WT_Person::getInstance(WT_USER_ROOT_ID); + } + if (!$individual) { + $individual=WT_Person::getInstance( + WT_DB::prepare( + "SELECT MIN(i_id) FROM `##individuals` WHERE i_file=?" + )->execute(array(WT_GED_ID))->fetchOne() + ); + } + if (!$individual) { + // always return a record + $individual=new WT_Person('0 @I@ INDI'); + } + return $individual; + } + public function getSignificantFamily() { + $individual=$this->getSignificantIndividual(); + if ($individual) { + foreach ($individual->getChildFamilies() as $family) { + return $family; + } + foreach ($individual->getSpouseFamilies() as $family) { + return $family; + } + } + // always return a record + return new WT_Family('0 @F@ FAM'); } } diff --git a/library/WT/Controller/Chart.php b/library/WT/Controller/Chart.php new file mode 100644 index 0000000000..5874b1f49c --- /dev/null +++ b/library/WT/Controller/Chart.php @@ -0,0 +1,29 @@ +<?php +// Base controller for all chart pages +// +// webtrees: Web based Family History software +// Copyright (C) 2011 webtrees development team. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ + +if (!defined('WT_WEBTREES')) { + header('HTTP/1.0 403 Forbidden'); + exit; +} + +class WT_Controller_Chart extends WT_Controller_Base { +} diff --git a/library/WT/Controller/Descendancy.php b/library/WT/Controller/Descendancy.php index 7c4bb23631..b38011e9b6 100644 --- a/library/WT/Controller/Descendancy.php +++ b/library/WT/Controller/Descendancy.php @@ -1,5 +1,5 @@ <?php -// Controller for the Descendancy Page +// Controller for the descendancy chart // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -30,7 +30,7 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_charts.php'; -class WT_Controller_Descendancy extends WT_Controller_Base { +class WT_Controller_Descendancy extends WT_Controller_Chart { var $pid = ""; var $descPerson = null; @@ -56,49 +56,49 @@ class WT_Controller_Descendancy extends WT_Controller_Base { var $cellwidth; var $show_cousins; - /** - * Initialization function - */ - function init() { - global $USE_RIN, $MAX_ALIVE_AGE, $bwidth, $bheight, $pbwidth, $pbheight, $GEDCOM, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS, $show_full; + function __construct() { + global $USE_RIN, $MAX_ALIVE_AGE, $bwidth, $bheight, $pbwidth, $pbheight, $GEDCOM, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS, $show_full; - // Extract parameters from form - $this->pid =safe_GET_xref('pid'); - $this->show_full =safe_GET('show_full', array('0', '1'), $PEDIGREE_FULL_DETAILS); - $this->chart_style=safe_GET_integer('chart_style', 0, 3, 0); - $this->generations=safe_GET_integer('generations', 2, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS); - $this->box_width =safe_GET_integer('box_width', 50, 300, 100); + // Extract parameters from form + $this->pid =safe_GET_xref('pid'); + $this->show_full =safe_GET('show_full', array('0', '1'), $PEDIGREE_FULL_DETAILS); + $this->chart_style=safe_GET_integer('chart_style', 0, 3, 0); + $this->generations=safe_GET_integer('generations', 2, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS); + $this->box_width =safe_GET_integer('box_width', 50, 300, 100); - // This is passed as a global. A parameter would be better... - $show_full=$this->show_full; + // This is passed as a global. A parameter would be better... + $show_full=$this->show_full; - if (!isset($this->personcount)) $this->personcount = 1; + if (!isset($this->personcount)) $this->personcount = 1; - $this->Dbwidth*=$this->box_width/100; + $this->Dbwidth*=$this->box_width/100; - if (!$this->show_full) { - $bwidth *= $this->box_width / 150; - } else { - $bwidth*=$this->box_width/100; - } + if (!$this->show_full) { + $bwidth *= $this->box_width / 150; + } else { + $bwidth*=$this->box_width/100; + } - if (!$this->show_full) { - $bheight = $bheight / 1.5; - } + if (!$this->show_full) { + $bheight = $bheight / 1.5; + } - $pbwidth = $bwidth+12; - $pbheight = $bheight+14; + $pbwidth = $bwidth+12; + $pbheight = $bheight+14; - $this->action =safe_GET('action'); + // Validate form variables + $this->pid=check_rootid($this->pid); - // Validate form variables - $this->pid=check_rootid($this->pid); + if (strlen($this->name)<30) $this->cellwidth="420"; + else $this->cellwidth=(strlen($this->name)*14); - if (strlen($this->name)<30) $this->cellwidth="420"; - else $this->cellwidth=(strlen($this->name)*14); + $this->descPerson = WT_Person::getInstance($this->pid); + $this->name=$this->descPerson->getFullName(); + } - $this->descPerson = WT_Person::getInstance($this->pid); - $this->name=$this->descPerson->getFullName(); + // What should this page show in the browser's title bar? + public function getPageTitle() { + return /* I18N: %s is a person's name */ WT_I18N::translate('Descendants of %s', $this->name); } /** diff --git a/library/WT/Controller/Family.php b/library/WT/Controller/Family.php index 1eef89db52..ee37379368 100644 --- a/library/WT/Controller/Family.php +++ b/library/WT/Controller/Family.php @@ -1,5 +1,5 @@ <?php -// Controller for the Family Page +// Controller for the family page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -32,57 +32,71 @@ require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; require_once WT_ROOT.'includes/functions/functions_charts.php'; -class WT_Controller_Family extends WT_Controller_Base { - var $famid = ''; - var $family = null; - var $difffam = null; +class WT_Controller_Family extends WT_Controller_GedcomRecord { + var $diff_record; + var $record = null; var $user = null; var $display = false; var $famrec = ''; var $title = ''; - function init() { + public function __construct() { global $Dbwidth, $bwidth, $pbwidth, $pbheight, $bheight; $bwidth = $Dbwidth; $pbwidth = $bwidth + 12; $pbheight = $bheight + 14; - $this->famid = safe_GET_xref('famid'); + $xref = safe_GET_xref('famid'); - $gedrec = find_family_record($this->famid, WT_GED_ID); + $gedrec = find_family_record($xref, WT_GED_ID); if (empty($gedrec)) { - $gedrec = "0 @".$this->famid."@ FAM\n"; + $gedrec = "0 @".$xref."@ FAM\n"; } - if (find_family_record($this->famid, WT_GED_ID) || find_updated_record($this->famid, WT_GED_ID)!==null) { - $this->family = new WT_Family($gedrec); - $this->family->ged_id=WT_GED_ID; // This record is from a file - } else if (!$this->family) { + if (find_family_record($xref, WT_GED_ID) || find_updated_record($xref, WT_GED_ID)!==null) { + $this->record = new WT_Family($gedrec); + $this->record->ged_id=WT_GED_ID; // This record is from a file + } else if (!$this->record) { return false; } - $this->famid=$this->family->getXref(); // Correct upper/lower case mismatch + $xref=$this->record->getXref(); // Correct upper/lower case mismatch //-- if the user can edit and there are changes then get the new changes if (WT_USER_CAN_EDIT) { - $newrec = find_updated_record($this->famid, WT_GED_ID); + $newrec = find_updated_record($xref, WT_GED_ID); if (!empty($newrec)) { - $this->difffam = new WT_Family($newrec); - $this->difffam->setChanged(true); + $this->diff_record = new WT_Family($newrec); + $this->diff_record->setChanged(true); + $this->record->diffMerge($this->diff_record); } } - - $this->family->diffMerge($this->difffam); } - function getFamilyID() { - return $this->famid; + // Get significant information from this page, to allow other pages such as + // charts and reports to initialise with the same records + public function getSignificantIndividual() { + if ($this->record) { + foreach ($this->record->getSpouses() as $individual) { + return $individual; + } + foreach ($this->record->getChildren() as $individual) { + return $individual; + } + } + return parent::getSignificantIndividual(); + } + public function getSignificantFamily() { + if ($this->record) { + return $this->record; + } + return parent::getSignifcantFamily(); } // $tags is an array of HUSB/WIFE/CHIL function getTimelineIndis($tags) { - preg_match_all('/\n1 (?:'.implode('|', $tags).') @('.WT_REGEX_XREF.')@/', $this->family->getGedcomRecord(), $matches); + preg_match_all('/\n1 (?:'.implode('|', $tags).') @('.WT_REGEX_XREF.')@/', $this->record->getGedcomRecord(), $matches); foreach ($matches[1] as &$match) { $match='pids[]='.$match; } @@ -90,24 +104,12 @@ class WT_Controller_Family extends WT_Controller_Base { } /** - * return the title of this page - * @return string the title of the page to go in the <title> tags - */ - function getPageTitle() { - if ($this->family) { - return $this->family->getFullName(); - } else { - return WT_I18N::translate('Family'); - } - } - - /** * get edit menu */ function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->family || $this->family->isMarkedDeleted()) { + if (!$this->record || $this->record->isMarkedDeleted()) { return null; } @@ -120,22 +122,22 @@ class WT_Controller_Family extends WT_Controller_Base { if (WT_USER_CAN_EDIT) { // edit_fam / members $submenu = new WT_Menu(WT_I18N::translate('Change Family Members'), '#', 'menu-fam-change'); - $submenu->addOnclick("return change_family_members('".$this->getFamilyID()."');"); + $submenu->addOnclick("return change_family_members('".$this->record->getXref()."');"); $submenu->addIcon('edit_fam'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_fam'); $menu->addSubmenu($submenu); // edit_fam / add child $submenu = new WT_Menu(WT_I18N::translate('Add a child to this family'), '#', 'menu-fam-addchil'); - $submenu->addOnclick("return addnewchild('".$this->getFamilyID()."');"); + $submenu->addOnclick("return addnewchild('".$this->record->getXref()."');"); $submenu->addIcon('edit_fam'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_fam'); $menu->addSubmenu($submenu); // edit_fam / reorder_children - if ($this->family->getNumberOfChildren() > 1) { + if ($this->record->getNumberOfChildren() > 1) { $submenu = new WT_Menu(WT_I18N::translate('Re-order children'), '#', 'menu-fam-orderchil'); - $submenu->addOnclick("return reorder_children('".$this->getFamilyID()."');"); + $submenu->addOnclick("return reorder_children('".$this->record->getXref()."');"); $submenu->addIcon('edit_fam'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_reord_fam'); $menu->addSubmenu($submenu); @@ -145,7 +147,7 @@ class WT_Controller_Family extends WT_Controller_Base { // edit/view raw gedcom if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-fam-editraw'); - $submenu->addOnclick("return edit_raw('".$this->getFamilyID()."');"); + $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); $submenu->addIcon('gedcom'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_raw'); $menu->addSubmenu($submenu); @@ -164,7 +166,7 @@ class WT_Controller_Family extends WT_Controller_Base { // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-fam-del'); - $submenu->addOnclick("if (confirm('".WT_I18N::translate('Deleting the family will unlink all of the individuals from each other but will leave the individuals in place. Are you sure you want to delete this family?')."')) jQuery.post('action.php',{action:'delete-family',xref:'".$this->family->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("if (confirm('".WT_I18N::translate('Deleting the family will unlink all of the individuals from each other but will leave the individuals in place. Are you sure you want to delete this family?')."')) jQuery.post('action.php',{action:'delete-family',xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('remove'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_delete'); $menu->addSubmenu($submenu); @@ -177,7 +179,7 @@ class WT_Controller_Family extends WT_Controller_Base { '#', 'menu-fam-addfav' ); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->family->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('favorites'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_fav'); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/GedcomRecord.php b/library/WT/Controller/GedcomRecord.php new file mode 100644 index 0000000000..27f9519b47 --- /dev/null +++ b/library/WT/Controller/GedcomRecord.php @@ -0,0 +1,60 @@ +<?php +// Base controller for all GedcomRecord controllers +// +// webtrees: Web based Family History software +// Copyright (C) 2011 webtrees development team. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ + +if (!defined('WT_WEBTREES')) { + header('HTTP/1.0 403 Forbidden'); + exit; +} + +class WT_Controller_GedcomRecord extends WT_Controller_Base { + public $record; // individual, source, repository, etc. + + // What should this page show in the browser's title bar? + public function getPageTitle() { + if ($this->record) { + if ($this->record->canDisplayName()) { + // e.g. "John Doe" or "1881 Census of Wales" + return $this->record->getFullName(); + } else { + // e.g. "Individual" or "Source" + return WT_Gedcom_Tag::getLabel($this->record->getType()); + } + } else { + // No such record + return WT_I18N::translate('Not found'); + } + } + + // What is the preferred URL for this page? + public function getCanonicalUrl() { + if ($this->record) { + return $this->record->getHtmlUrl(); + } else { + return parent::getCanonicalUrl(); + } + } + + // How should robots index this page? + public function getMetaRobots() { + return 'index,follow'; + } +} diff --git a/library/WT/Controller/Hourglass.php b/library/WT/Controller/Hourglass.php index 5737e14862..86f46514cb 100644 --- a/library/WT/Controller/Hourglass.php +++ b/library/WT/Controller/Hourglass.php @@ -1,5 +1,5 @@ <?php -// Controller for the Hourglass Page +// Controller for the hourglass chart // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -43,7 +43,7 @@ $nonfacts[] = ""; $nonfamfacts[] = "UID"; $nonfamfacts[] = ""; -class WT_Controller_Hourglass extends WT_Controller_Base { +class WT_Controller_Hourglass extends WT_Controller_Chart { var $pid = ""; var $canedit = false; @@ -60,12 +60,8 @@ class WT_Controller_Hourglass extends WT_Controller_Base { var $ARID; var $arrwidth; var $arrheight; - /////////////////////////////////////// - /** - * Initialization function - */ - function init($rootid='', $show_full=1, $generations=3) { + function __construct($rootid='', $show_full=1, $generations=3) { global $USE_RIN, $MAX_ALIVE_AGE, $GEDCOM, $bheight, $bwidth, $bhalfheight, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS; global $WT_IMAGES, $TEXT_DIRECTION, $show_full; @@ -79,7 +75,6 @@ class WT_Controller_Hourglass extends WT_Controller_Base { // This is passed as a global. A parameter would be better... $show_full=$this->show_full; - if (!empty($_REQUEST["action"])) $this->action = $_REQUEST["action"]; if (!empty($rootid)) $this->pid = $rootid; //-- flip the arrows for RTL languages @@ -113,6 +108,11 @@ class WT_Controller_Hourglass extends WT_Controller_Base { if ($this->dgenerations<1) $this->dgenerations=1; } + // What should this page show in the browser's title bar? + public function getPageTitle() { + return /* I18N: %s is a person's name */ WT_I18N::translate('Hourglass chart of %s', $this->name); + } + /** * Prints pedigree of the person passed in. Which is the descendancy * diff --git a/library/WT/Controller/Individual.php b/library/WT/Controller/Individual.php index 1d4f32d578..90c46a2f09 100644 --- a/library/WT/Controller/Individual.php +++ b/library/WT/Controller/Individual.php @@ -1,5 +1,5 @@ <?php -// Controller for the Individual Page +// Controller for the individual page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -31,123 +31,117 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; -class WT_Controller_Individual extends WT_Controller_Base { - var $pid = ''; - var $indi = null; - var $diffindi = null; +class WT_Controller_Individual extends WT_Controller_GedcomRecord { var $name_count = 0; var $total_names = 0; var $SEX_COUNT = 0; - var $tabs; var $Fam_Navigator = 'YES'; var $NAME_LINENUM = null; var $SEX_LINENUM = null; var $globalfacts = null; + public $tabs; - function init() { + function __construct() { global $USE_RIN, $MAX_ALIVE_AGE, $SEARCH_SPIDER; global $DEFAULT_PIN_STATE, $DEFAULT_SB_CLOSED_STATE; global $Fam_Navigator; - $this->pid = safe_GET_xref('pid'); + $xref = safe_GET_xref('pid'); - $gedrec = find_person_record($this->pid, WT_GED_ID); + $gedrec = find_person_record($xref, WT_GED_ID); if ($USE_RIN && $gedrec==false) { - $this->pid = find_rin_id($this->pid); - $gedrec = find_person_record($this->pid, WT_GED_ID); + $xref = find_rin_id($xref); + $gedrec = find_person_record($xref, WT_GED_ID); } if (empty($gedrec)) { - $gedrec = "0 @".$this->pid."@ INDI\n"; + $gedrec = "0 @".$xref."@ INDI\n"; } - if (find_person_record($this->pid, WT_GED_ID) || find_updated_record($this->pid, WT_GED_ID)!==null) { - $this->indi = new WT_Person($gedrec); - $this->indi->ged_id=WT_GED_ID; // This record is from a file - } else if (!$this->indi) { + if (find_person_record($xref, WT_GED_ID) || find_updated_record($xref, WT_GED_ID)!==null) { + $this->record = new WT_Person($gedrec); + $this->record->ged_id=WT_GED_ID; // This record is from a file + } else if (!$this->record) { return false; } - $this->pid=$this->indi->getXref(); // Correct upper/lower case mismatch - //-- if the user can edit and there are changes then get the new changes if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { - $newrec = find_updated_record($this->pid, WT_GED_ID); + $newrec = find_updated_record($xref, WT_GED_ID); if (!empty($newrec)) { - $this->diffindi = new WT_Person($newrec); - $this->diffindi->setChanged(true); + $diff_record = new WT_Person($newrec); + $diff_record->setChanged(true); + $this->record->diffMerge($diff_record); } } - $this->indi->diffMerge($this->diffindi); + $this->tabs=WT_Module::getActiveTabs(); + } - // Initialise tabs - $this->tabs = WT_Module::getActiveTabs(); - foreach ($this->tabs as $mod) { - $mod->setController($this); + // Page title + function getPageTitle() { + if ($this->record && $this->record->canDisplayDetails()) { + return parent::getPageTitle().' '.$this->record->getLifespan(); + } else { + return parent::getPageTitle(); } + } - if (!isset($_SESSION['WT_pin']) && $DEFAULT_PIN_STATE) - $_SESSION['WT_pin'] = true; - - if (!isset($_SESSION['WT_sb_closed']) && $DEFAULT_SB_CLOSED_STATE) - $_SESSION['WT_sb_closed'] = true; - - //-- handle ajax calls - if ($this->action=="ajax") { - $tab = 0; - if (isset($_REQUEST['module'])) { - $tabname = $_REQUEST['module']; - if ($SEARCH_SPIDER) { - // Search engines should not make AJAX requests - header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); - exit; - } - if (!array_key_exists($tabname, $this->tabs)) { - // An AJAX request for a non-existant tab? - header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); - exit; - } - header("Content-Type: text/html; charset=UTF-8"); //AJAX calls do not have the meta tag headers and need this set - header("X-Robots-Tag: noindex,follow"); //AJAX pages should not show up in search results, any links can be followed though - $mod = $this->tabs[$tabname]; - if ($mod) { - echo $mod->getTabContent(); - // Allow the other tabs to modify this one - e.g. lightbox does this. - echo WT_JS_START; - foreach (WT_Module::getActiveTabs() as $module) { - echo $module->getJSCallback(); - } - echo WT_JS_END; - } + // Get significant information from this page, to allow other pages such as + // charts and reports to initialise with the same records + public function getSignificantIndividual() { + if ($this->record) { + return $this->record; + } + return parent::getSignificantIndividual(); + } + public function getSignificantFamily() { + if ($this->record) { + foreach ($this->record->getChildFamilies() as $family) { + return $family; } - - if (isset($_REQUEST['sb_closed'])) { - if ($_REQUEST['sb_closed']=='true') $_SESSION['WT_sb_closed'] = true; - else $_SESSION['WT_sb_closed'] = false; + foreach ($this->record->getSpouseFamilies() as $family) { + return $family; } + } + return parent::getSignifcantFamily(); + } - //-- only get the requested tab and then exit - if (WT_DEBUG_SQL) { - echo WT_DB::getQueryLog(); - } + // Handle AJAX requests - to generate the tab content + public function ajaxRequest() { + global $SEARCH_SPIDER; + + // Search engines should not make AJAX requests + if ($SEARCH_SPIDER) { + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); exit; } - } - /** - * return the title of this page - * @return string the title of the page to go in the <title> tags - */ - function getPageTitle() { - if ($this->indi) { - if ($this->indi->canDisplayDetails()) { - return $this->indi->getFullName().' '.$this->indi->getLifespan(); - } else { - return $this->indi->getFullName(); - } + // Initialise tabs + $tab=safe_GET('module'); + + // A request for a non-existant tab? + if (array_key_exists($tab, $this->tabs)) { + $mod=$this->tabs[$tab]; } else { - return WT_I18N::translate('Individual'); + header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); + exit; + } + + header("Content-Type: text/html; charset=UTF-8"); // AJAX calls do not have the meta tag headers and need this set + header("X-Robots-Tag: noindex,follow"); // AJAX pages should not show up in search results, any links can be followed though + + echo $mod->getTabContent(); + + // Allow the other tabs to modify this one - e.g. lightbox does this. + echo WT_JS_START; + foreach ($this->tabs as $module) { + echo $module->getJSCallback(); + } + echo WT_JS_END; + + if (WT_DEBUG_SQL) { + echo WT_DB::getQueryLog(); } } @@ -158,22 +152,13 @@ class WT_Controller_Individual extends WT_Controller_Base { function canShowHighlightedObject() { global $SHOW_HIGHLIGHT_IMAGES, $USE_SILHOUETTE; - if (($this->indi->canDisplayDetails()) && $SHOW_HIGHLIGHT_IMAGES) { - $firstmediarec = $this->indi->findHighlightedMedia(); + if (($this->record->canDisplayDetails()) && $SHOW_HIGHLIGHT_IMAGES) { + $firstmediarec = $this->record->findHighlightedMedia(); if ($firstmediarec) return true; } if ($USE_SILHOUETTE) { return true; } return false; } - /** - * check if we can show the gedcom record - * @return boolean - */ - function canShowGedcomRecord() { - global $SHOW_GEDCOM_RECORD; - if (WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD && $this->indi->canDisplayDetails()) - return true; - } /** * get the highlighted object HTML @@ -183,7 +168,7 @@ class WT_Controller_Individual extends WT_Controller_Base { global $sex; if ($this->canShowHighlightedObject()) { - $firstmediarec=$this->indi->findHighlightedMedia(); + $firstmediarec=$this->record->findHighlightedMedia(); if (!empty($firstmediarec)) { $mediaobject=WT_Media::getInstance($firstmediarec['mid']); $result=$mediaobject->displayMedia(array('uselightbox_fallback'=>false,'clearbox'=>'general_1')); @@ -191,7 +176,7 @@ class WT_Controller_Individual extends WT_Controller_Base { } } - $sex=$this->indi->getSex(); + $sex=$this->record->getSex(); return display_silhouette(array('sex'=>$sex)); // may return '' } @@ -232,16 +217,16 @@ class WT_Controller_Individual extends WT_Controller_Base { echo '<dd class="field">', $dummy->getFullName(); if ($this->name_count == 1) { if (WT_USER_IS_ADMIN) { - $user_id=get_user_from_gedcom_xref(WT_GED_ID, $this->pid); + $user_id=get_user_from_gedcom_xref(WT_GED_ID, $this->record->getXref()); if ($user_id) { $user_name=get_user_name($user_id); echo '<span> - <a class="warning" href="admin_users.php?action=edituser&username='.$user_name.'">'.$user_name.'</span></a>'; } } } - if ($this->indi->canEdit() && !strpos($factrec, "\nWT_OLD")) { - echo "<div class=\"deletelink\"><a class=\"font9 deleteicon\" href=\"javascript:;\" onclick=\"delete_record('".$this->pid."', ".$linenum."); return false;\" title=\"".WT_I18N::translate('Delete name')."\"><span class=\"link_text\">".WT_I18N::translate('Delete name')."</span></a></div>"; - echo "<div class=\"editlink\"><a href=\"javascript:;\" class=\"font9 editicon\" onclick=\"edit_name('".$this->pid."', ".$linenum."); return false;\" title=\"".WT_I18N::translate('Edit name')."\"><span class=\"link_text\">".WT_I18N::translate('Edit name')."</span></a></div>"; + if ($this->record->canEdit() && !strpos($factrec, "\nWT_OLD")) { + echo "<div class=\"deletelink\"><a class=\"font9 deleteicon\" href=\"javascript:;\" onclick=\"delete_record('".$this->record->getXref()."', ".$linenum."); return false;\" title=\"".WT_I18N::translate('Delete name')."\"><span class=\"link_text\">".WT_I18N::translate('Delete name')."</span></a></div>"; + echo "<div class=\"editlink\"><a href=\"javascript:;\" class=\"font9 editicon\" onclick=\"edit_name('".$this->record->getXref()."', ".$linenum."); return false;\" title=\"".WT_I18N::translate('Edit name')."\"><span class=\"link_text\">".WT_I18N::translate('Edit name')."</span></a></div>"; } echo '</dd>'; echo '</dl>'; @@ -251,7 +236,7 @@ class WT_Controller_Individual extends WT_Controller_Base { echo '<div>'; $fact = trim($nmatch[$i][1]); if (($fact!="SOUR") && ($fact!="NOTE") && ($fact!="SPFX")) { - echo '<dl><dt class="label">', WT_Gedcom_Tag::getLabel($fact, $this->indi), '</dt>'; + echo '<dl><dt class="label">', WT_Gedcom_Tag::getLabel($fact, $this->record), '</dt>'; echo '<dd class="field">'; if (isset($nmatch[$i][2])) { $name = trim($nmatch[$i][2]); @@ -262,7 +247,7 @@ class WT_Controller_Individual extends WT_Controller_Base { } $name=preg_replace('/(\S*)\*/', '<span class="starredname">\\1</span>', $name); if ($fact=='TYPE') { - echo WT_Gedcom_Code_Name::getValue($name, $this->indi); + echo WT_Gedcom_Code_Name::getValue($name, $this->record); } else { echo PrintReady($name); } @@ -317,12 +302,12 @@ class WT_Controller_Individual extends WT_Controller_Base { } echo '> '; if ($this->SEX_COUNT>1) { - if ($this->indi->canEdit() && strpos($factrec, "\nWT_OLD")===false) { + if ($this->record->canEdit() && strpos($factrec, "\nWT_OLD")===false) { if ($event->getLineNumber()=="new") { - echo "<a class=\"font9\" href=\"javascript:;\" onclick=\"add_new_record('".$this->pid."', 'SEX'); return false;\">".WT_I18N::translate('Edit')."</a>"; + echo "<a class=\"font9\" href=\"javascript:;\" onclick=\"add_new_record('".$this->record->getXref()."', 'SEX'); return false;\">".WT_I18N::translate('Edit')."</a>"; } else { - echo "<a class=\"font9\" href=\"javascript:;\" onclick=\"edit_record('".$this->pid."', ".$event->getLineNumber()."); return false;\">".WT_I18N::translate('Edit')."</a> | "; - echo "<a class=\"font9\" href=\"javascript:;\" onclick=\"delete_record('".$this->pid."', ".$event->getLineNumber()."); return false;\">".WT_I18N::translate('Delete')."</a>"; + echo "<a class=\"font9\" href=\"javascript:;\" onclick=\"edit_record('".$this->record->getXref()."', ".$event->getLineNumber()."); return false;\">".WT_I18N::translate('Edit')."</a> | "; + echo "<a class=\"font9\" href=\"javascript:;\" onclick=\"delete_record('".$this->record->getXref()."', ".$event->getLineNumber()."); return false;\">".WT_I18N::translate('Delete')."</a>"; } } } @@ -338,7 +323,7 @@ class WT_Controller_Individual extends WT_Controller_Base { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->indi || $this->indi->isMarkedDeleted()) { + if (!$this->record || $this->record->isMarkedDeleted()) { return null; } // edit menu @@ -353,7 +338,7 @@ class WT_Controller_Individual extends WT_Controller_Base { // will copy the first submenu - which may be edit-raw or delete. // As a temporary solution, make it edit the name if (WT_USER_CAN_EDIT && $this->NAME_LINENUM) { - $menu->addOnclick("return edit_name('".$this->pid."', ".$this->NAME_LINENUM.");"); + $menu->addOnclick("return edit_name('".$this->record->getXref()."', ".$this->NAME_LINENUM.");"); } else { $menu->addOnclick("return false;"); } @@ -361,7 +346,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if (WT_USER_CAN_EDIT) { //--make sure the totals are correct $submenu = new WT_Menu(WT_I18N::translate('Add new Name'), '#', 'menu-indi-addname'); - $submenu->addOnclick("return add_name('".$this->pid."');"); + $submenu->addOnclick("return add_name('".$this->record->getXref()."');"); $submenu->addIcon('edit_indi'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_indi'); $menu->addSubmenu($submenu); @@ -369,18 +354,18 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($this->SEX_COUNT<2) { $submenu = new WT_Menu(WT_I18N::translate('Edit gender'), '#', 'menu-indi-editsex'); if ($this->SEX_LINENUM=="new") { - $submenu->addOnclick("return add_new_record('".$this->pid."', 'SEX');"); + $submenu->addOnclick("return add_new_record('".$this->record->getXref()."', 'SEX');"); } else { - $submenu->addOnclick("return edit_record('".$this->pid."', ".$this->SEX_LINENUM.");"); + $submenu->addOnclick("return edit_record('".$this->record->getXref()."', ".$this->SEX_LINENUM.");"); } $submenu->addIcon('edit_indi'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_sex'); $menu->addSubmenu($submenu); } - if (count($this->indi->getSpouseFamilies())>1) { + if (count($this->record->getSpouseFamilies())>1) { $submenu = new WT_Menu(WT_I18N::translate('Reorder families'), '#', 'menu-indi-orderfam'); - $submenu->addOnclick("return reorder_families('".$this->pid."');"); + $submenu->addOnclick("return reorder_families('".$this->record->getXref()."');"); $submenu->addIcon('edit_fam'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_fam'); $menu->addSubmenu($submenu); @@ -388,9 +373,9 @@ class WT_Controller_Individual extends WT_Controller_Base { } // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $this->canShowGedcomRecord()) { + if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-indi-editraw'); - $submenu->addOnclick("return edit_raw('".$this->pid."');"); + $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); $submenu->addIcon('gedcom'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_raw'); $menu->addSubmenu($submenu); @@ -409,7 +394,7 @@ class WT_Controller_Individual extends WT_Controller_Base { // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-indi-del'); - $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->indi->getFullName())))."')) jQuery.post('action.php',{action:'delete-individual',xref:'".$this->indi->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName())))."')) jQuery.post('action.php',{action:'delete-individual',xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('remove'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_delete'); $menu->addSubmenu($submenu); @@ -422,7 +407,7 @@ class WT_Controller_Individual extends WT_Controller_Base { '#', 'menu-indi-addfav' ); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->indi->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('favorites'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_fav'); $menu->addSubmenu($submenu); @@ -438,7 +423,7 @@ class WT_Controller_Individual extends WT_Controller_Base { */ function getGlobalFacts() { if ($this->globalfacts==null) { - $this->globalfacts = $this->indi->getGlobalFacts(); + $this->globalfacts = $this->record->getGlobalFacts(); foreach ($this->globalfacts as $key => $value) { $fact = $value->getTag(); if ($fact=="SEX") { @@ -462,7 +447,7 @@ class WT_Controller_Individual extends WT_Controller_Base { * @return array */ function getIndiFacts() { - $indifacts = $this->indi->getIndiFacts(); + $indifacts = $this->record->getIndiFacts(); sort_facts($indifacts); return $indifacts; } @@ -471,7 +456,7 @@ class WT_Controller_Individual extends WT_Controller_Base { * @return array */ function getOtherFacts() { - $otherfacts = $this->indi->getOtherFacts(); + $otherfacts = $this->record->getOtherFacts(); return $otherfacts; } @@ -557,7 +542,7 @@ class WT_Controller_Individual extends WT_Controller_Base { $labels["brother"] = get_relationship_name_from_path('son', null, null); break; case 'step-children': - if ($this->indi->equals($family->getHusband())) { + if ($this->record->equals($family->getHusband())) { $labels["parent"] = ''; $labels["mother"] = ''; $labels["father"] = get_relationship_name_from_path('hus', null, null); @@ -585,7 +570,7 @@ class WT_Controller_Individual extends WT_Controller_Base { } //-- step families : set the label for the common parent if ($type=="step-parents") { - $fams = $this->indi->getChildFamilies(); + $fams = $this->record->getChildFamilies(); foreach ($fams as $key=>$fam) { if ($fam->hasParent($husb)) $labels["father"] = get_relationship_name_from_path('fat', null, null); if ($fam->hasParent($wife)) $labels["mother"] = get_relationship_name_from_path('mot', null, null); @@ -601,7 +586,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["father"]; } - if ($husb->getXref()==$this->pid) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; + if ($husb->getXref()==$this->record->getXref()) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; $husb->setLabel($label); } //-- set the label for the wife @@ -614,7 +599,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["father"]; } - if ($wife->getXref()==$this->pid) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; + if ($wife->getXref()==$this->record->getXref()) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; $wife->setLabel($label); } if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { @@ -631,7 +616,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["father"]; } - if ($newhusb->getXref()==$this->pid) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; + if ($newhusb->getXref()==$this->record->getXref()) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; $newhusb->setLabel($label); } else $newhusb = null; @@ -646,7 +631,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["father"]; } - if ($newwife->getXref()==$this->pid) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; + if ($newwife->getXref()==$this->record->getXref()) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; $newwife->setLabel($label); } else $newwife = null; @@ -699,7 +684,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["brother"]; } - if ($children[$i]->getXref()==$this->pid) { + if ($children[$i]->getXref()==$this->record->getXref()) { $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; } if ($include_pedi==true) { @@ -722,7 +707,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["brother"]; } - if ($newchildren[$i]->getXref()==$this->pid) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; + if ($newchildren[$i]->getXref()==$this->record->getXref()) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; if ($include_pedi==true) { $pedi = $newchildren[$i]->getChildFamilyPedigree($family->getXref()); if ($pedi) { @@ -741,7 +726,7 @@ class WT_Controller_Individual extends WT_Controller_Base { if ($sex=="M") { $label = $labels["brother"]; } - if ($delchildren[$i]->getXref()==$this->pid) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; + if ($delchildren[$i]->getXref()==$this->record->getXref()) $label = "<img src=\"". $WT_IMAGES["selected"]. "\" alt=\"\" />"; if ($include_pedi==true) { $pedi = $delchildren[$i]->getChildFamilyPedigree($family->getXref()); if ($pedi) { diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php index dc60363663..54ab1b114e 100644 --- a/library/WT/Controller/Lifespan.php +++ b/library/WT/Controller/Lifespan.php @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -34,7 +34,7 @@ function compare_people($a, $b) { return WT_Date::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); } -class WT_Controller_Lifespan extends WT_Controller_Base { +class WT_Controller_Lifespan extends WT_Controller_Chart { var $pids = array (); var $people = array(); var $scale = 2; @@ -66,10 +66,7 @@ class WT_Controller_Lifespan extends WT_Controller_Base { var $startDate; var $currentsex; - /** - * Initialization function - */ - function init() { + function __construct() { global $GEDCOM_ID_PREFIX; $this->colorindex = 0; $this->Fcolorindex = 0; @@ -197,6 +194,11 @@ class WT_Controller_Lifespan extends WT_Controller_Base { } } + // What should this page show in the browser's title bar? + public function getPageTitle() { + return WT_I18N::translate('Lifespans'); + } + // Add a person (and optionally their immediate family members) to the pids array function addFamily($person, $add_family) { if ($person) { diff --git a/library/WT/Controller/Media.php b/library/WT/Controller/Media.php index 0068bc9f85..de8d6e1c33 100644 --- a/library/WT/Controller/Media.php +++ b/library/WT/Controller/Media.php @@ -1,5 +1,5 @@ <?php -// Controller for the Media Page +// Controller for the media page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -31,17 +31,15 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; -class WT_Controller_Media extends WT_Controller_Base { - var $mid; - var $mediaobject; +class WT_Controller_Media extends WT_Controller_GedcomRecord { - function init() { + public function __construct() { global $MEDIA_DIRECTORY; $filename = safe_GET('filename'); - $this->mid = safe_GET_xref('mid'); + $xref = safe_GET_xref('mid'); - if (empty($filename) && empty($this->mid)) { + if (empty($filename) && empty($xref)) { // this section used by mediafirewall.php to determine what media file was requested if (isset($_SERVER['REQUEST_URI'])) { @@ -73,45 +71,25 @@ class WT_Controller_Media extends WT_Controller_Base { //Checks to see if the filename ($filename) exists if (!empty($filename)) { - //If the filename ($filename) is set, then it will call the method to get the Media ID ($this->mid) from the filename ($filename) - $this->mid = get_media_id_from_file($filename); - if (!$this->mid) { + //If the filename ($filename) is set, then it will call the method to get the Media ID ($xref) from the filename ($filename) + $xref = get_media_id_from_file($filename); + if (!$xref) { //This will set the Media ID to be false if the File given doesn't match to anything in the database - $this->mid = false; + $xref = false; // create a very basic gedcom record for this file so that the functions of the media object will work // this is used by the media firewall when requesting an object that exists in the media firewall directory but not in the gedcom - $this->mediaobject = new WT_Media("0 @"."0"."@ OBJE\n1 FILE ".$filename); + $this->record = new WT_Media("0 @"."0"."@ OBJE\n1 FILE ".$filename); } } - //checks to see if the Media ID ($this->mid) is set. If the Media ID isn't set then there isn't any information avaliable for that picture the picture doesn't exist. - if ($this->mid) { - //This creates a Media Object from the getInstance method of the Media Class. It takes the Media ID ($this->mid) and creates the object. - $this->mediaobject = WT_Media::getInstance($this->mid); - //This sets the controller ID to be the Media ID - $this->m_pid = $this->mid; + //checks to see if the Media ID ($xref) is set. If the Media ID isn't set then there isn't any information avaliable for that picture the picture doesn't exist. + if ($xref) { + //This creates a Media Object from the getInstance method of the Media Class. It takes the Media ID ($xref) and creates the object. + $this->record = WT_Media::getInstance($xref); } - if (is_null($this->mediaobject)) return false; - $this->mediaobject->ged_id=WT_GED_ID; // This record is from a file - - $this->mid=$this->mediaobject->getXref(); // Correct upper/lower case mismatch - } - - /** - * return the title of this page - * @return string the title of the page to go in the <title> tags - */ - function getPageTitle() { - if ($this->mediaobject) { - return $this->mediaobject->getFullName(); - } else { - return WT_I18N::translate('Media object'); - } - } - - function canDisplayDetails() { - return $this->mediaobject->canDisplayDetails(); + if (is_null($this->record)) return false; + $this->record->ged_id=WT_GED_ID; // This record is from a file } /** @@ -120,11 +98,11 @@ class WT_Controller_Media extends WT_Controller_Base { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->mediaobject || $this->mediaobject->isMarkedDeleted()) { + if (!$this->record || $this->record->isMarkedDeleted()) { return null; } - $links = get_media_relations($this->m_pid); + $links = get_media_relations($this->record->getXref()); $linktoid = "new"; foreach ($links as $linktoid => $type) { break; // we're only interested in the key of the first list entry @@ -137,7 +115,7 @@ class WT_Controller_Media extends WT_Controller_Base { if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Edit media object'), '#', 'menu-obje-edit'); - $submenu->addOnclick("window.open('addmedia.php?action=editmedia&pid={$this->m_pid}', '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1')"); + $submenu->addOnclick("window.open('addmedia.php?action=editmedia&pid={$this->record->getXref()}', '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1')"); $submenu->addIcon('edit_media'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_media'); $menu->addSubmenu($submenu); @@ -153,22 +131,22 @@ class WT_Controller_Media extends WT_Controller_Base { // GEDFact assistant Add Media Links ======================= if (WT_USER_GEDCOM_ADMIN && array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) { - $submenu->addOnclick("return ilinkitem('".$this->m_pid."','manage');"); + $submenu->addOnclick("return ilinkitem('".$this->record->getXref()."','manage');"); } else { $ssubmenu = new WT_Menu(WT_I18N::translate('To Person'), '#', 'menu-obje-link-indi'); - $ssubmenu->addOnclick("return ilinkitem('".$this->m_pid."','person');"); + $ssubmenu->addOnclick("return ilinkitem('".$this->record->getXref()."','person');"); $ssubmenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_indis'); $ssubmenu->addIcon('edit_media'); $submenu->addSubMenu($ssubmenu); $ssubmenu = new WT_Menu(WT_I18N::translate('To Family'), '#', 'menu-obje-link-fam'); - $ssubmenu->addOnclick("return ilinkitem('".$this->m_pid."','family');"); + $ssubmenu->addOnclick("return ilinkitem('".$this->record->getXref()."','family');"); $ssubmenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_cfamily'); $ssubmenu->addIcon('edit_media'); $submenu->addSubMenu($ssubmenu); $ssubmenu = new WT_Menu(WT_I18N::translate('To Source'), '#', 'menu-obje-link-sour'); - $ssubmenu->addOnclick("return ilinkitem('".$this->m_pid."','source');"); + $ssubmenu->addOnclick("return ilinkitem('".$this->record->getXref()."','source');"); $ssubmenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_menu_source'); $ssubmenu->addIcon('edit_media'); $submenu->addSubMenu($ssubmenu); @@ -179,7 +157,7 @@ class WT_Controller_Media extends WT_Controller_Base { // edit/view raw gedcom if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-obje-editraw'); - $submenu->addOnclick("return edit_raw('".$this->m_pid."');"); + $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); $submenu->addIcon('gedcom'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_raw'); $menu->addSubmenu($submenu); @@ -199,7 +177,7 @@ class WT_Controller_Media extends WT_Controller_Base { if (WT_USER_GEDCOM_ADMIN) { $submenu = new WT_Menu( WT_I18N::translate('Remove object'), - "admin_media.php?action=removeobject&xref=".$this->m_pid, + "admin_media.php?action=removeobject&xref=".$this->record->getXref(), 'menu-obje-del' ); $submenu->addOnclick("return confirm('".WT_I18N::translate('Are you sure you want to remove this object from the database?')."')"); @@ -215,7 +193,7 @@ class WT_Controller_Media extends WT_Controller_Base { '#', 'menu-obje-addfav' ); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->mediaobject->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('favorites'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_fav'); $menu->addSubmenu($submenu); @@ -230,34 +208,24 @@ class WT_Controller_Media extends WT_Controller_Base { } /** - * check if we can show the gedcom record - * @return boolean - */ - function canShowGedcomRecord() { - global $SHOW_GEDCOM_RECORD; - if ($SHOW_GEDCOM_RECORD && $this->mediaobject->canDisplayDetails()) - return true; - } - - /** * return a list of facts * @return array */ function getFacts($includeFileName=true) { - $facts = $this->mediaobject->getFacts(array()); + $facts = $this->record->getFacts(array()); sort_facts($facts); - //if ($includeFileName) $facts[] = new WT_Event("1 FILE ".$this->mediaobject->getFilename(), $this->mediaobject, 0); - $mediaType = $this->mediaobject->getMediatype(); - $facts[] = new WT_Event("1 TYPE ".WT_Gedcom_Tag::getFileFormTypeValue($mediaType), $this->mediaobject, 0); + //if ($includeFileName) $facts[] = new WT_Event("1 FILE ".$this->record->getFilename(), $this->record, 0); + $mediaType = $this->record->getMediatype(); + $facts[] = new WT_Event("1 TYPE ".WT_Gedcom_Tag::getFileFormTypeValue($mediaType), $this->record, 0); - if (($newrec=find_updated_record($this->m_pid, WT_GED_ID))!==null) { + if (($newrec=find_updated_record($this->record->getXref(), WT_GED_ID))!==null) { $newmedia = new WT_Media($newrec); $newfacts = $newmedia->getFacts(array()); $newimgsize = $newmedia->getImageAttributes(); - if ($includeFileName) $newfacts[] = new WT_Event("1 TYPE ".WT_Gedcom_Tag::getFileFormTypeValue($mediaType), $this->mediaobject, 0); - $newfacts[] = new WT_Event("1 FORM ".$newimgsize['ext'], $this->mediaobject, 0); + if ($includeFileName) $newfacts[] = new WT_Event("1 TYPE ".WT_Gedcom_Tag::getFileFormTypeValue($mediaType), $this->record, 0); + $newfacts[] = new WT_Event("1 FORM ".$newimgsize['ext'], $this->record, 0); $mediaType = $newmedia->getMediatype(); - $newfacts[] = new WT_Event("1 TYPE ".WT_Gedcom_Tag::getFileFormTypeValue($mediaType), $this->mediaobject, 0); + $newfacts[] = new WT_Event("1 TYPE ".WT_Gedcom_Tag::getFileFormTypeValue($mediaType), $this->record, 0); //-- loop through new facts and add them to the list if they are any changes //-- compare new and old facts of the Personal Fact and Details tab 1 for ($i=0; $i<count($facts); $i++) { @@ -287,14 +255,14 @@ class WT_Controller_Media extends WT_Controller_Base { } } - if ($this->mediaobject->fileExists()) { + if ($this->record->fileExists()) { // get height and width of image, when available - $imgsize = $this->mediaobject->getImageAttributes(); + $imgsize = $this->record->getImageAttributes(); if (!empty($imgsize['WxH'])) { - $facts[] = new WT_Event('1 __IMAGE_SIZE__ '.$imgsize['WxH'], $this->mediaobject, 0); + $facts[] = new WT_Event('1 __IMAGE_SIZE__ '.$imgsize['WxH'], $this->record, 0); } //Prints the file size - $facts[] = new WT_Event('1 __FILE_SIZE__ '.$this->mediaobject->getFilesize(), $this->mediaobject, 0); + $facts[] = new WT_Event('1 __FILE_SIZE__ '.$this->record->getFilesize(), $this->record, 0); } sort_facts($facts); @@ -306,8 +274,8 @@ class WT_Controller_Media extends WT_Controller_Base { * @return string */ function getLocalFilename() { - if ($this->mediaobject) { - return $this->mediaobject->getLocalFilename(); + if ($this->record) { + return $this->record->getLocalFilename(); } else { return false; } @@ -318,8 +286,8 @@ class WT_Controller_Media extends WT_Controller_Base { * @return string */ function getServerFilename() { - if ($this->mediaobject) { - return $this->mediaobject->getServerFilename(); + if ($this->record) { + return $this->record->getServerFilename(); } else { return false; } diff --git a/library/WT/Controller/Note.php b/library/WT/Controller/Note.php index 71082f94c8..360c0057cd 100644 --- a/library/WT/Controller/Note.php +++ b/library/WT/Controller/Note.php @@ -1,5 +1,5 @@ <?php -// Controller for the Shared Note Page +// Controller for the shared note page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -31,17 +31,13 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; -class WT_Controller_Note extends WT_Controller_Base { - var $nid; - var $note = null; - var $diffnote = null; +class WT_Controller_Note extends WT_Controller_GedcomRecord { + public function __construct() { + $xref=safe_GET_xref('nid'); - function init() { - $this->nid = safe_GET_xref('nid'); - - $gedrec=find_other_record($this->nid, WT_GED_ID); + $gedrec=find_other_record($xref, WT_GED_ID); if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($this->nid, WT_GED_ID); + $newrec=find_updated_record($xref, WT_GED_ID); } else { $newrec=null; } @@ -57,26 +53,13 @@ class WT_Controller_Note extends WT_Controller_Base { } } - $this->note = new WT_Note($gedrec); + $this->record = new WT_Note($gedrec); // If there are pending changes, merge them in. if ($newrec!==null) { - $this->diffnote=new WT_Note($newrec); - $this->diffnote->setChanged(true); - $this->note->diffMerge($this->diffnote); - } - $this->nid=$this->note->getXref(); // We may have requested X1234, but found x1234 - } - - /** - * get the title for this page - * @return string - */ - function getPageTitle() { - if ($this->note) { - return $this->note->getFullName(); - } else { - return WT_I18N::translate('Note'); + $diff_record=new WT_Note($newrec); + $diff_record->setChanged(true); + $this->record->diffMerge($diff_record); } } @@ -86,7 +69,7 @@ class WT_Controller_Note extends WT_Controller_Base { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->note || $this->note->isMarkedDeleted()) { + if (!$this->record || $this->record->isMarkedDeleted()) { return null; } @@ -97,7 +80,7 @@ class WT_Controller_Note extends WT_Controller_Base { if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Edit note'), '#', 'menu-note-edit'); - $submenu->addOnclick('return edit_note(\''.$this->nid.'\');'); + $submenu->addOnclick('return edit_note(\''.$this->record->getXref().'\');'); $submenu->addIcon('edit_note'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_notes'); $menu->addSubmenu($submenu); @@ -106,7 +89,7 @@ class WT_Controller_Note extends WT_Controller_Base { // edit/view raw gedcom if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-note-editraw'); - $submenu->addOnclick("return edit_raw('".$this->nid."');"); + $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); $submenu->addIcon('gedcom'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_raw'); $menu->addSubmenu($submenu); @@ -125,7 +108,7 @@ class WT_Controller_Note extends WT_Controller_Base { // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-note-del'); - $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', $this->note->getFullName()))."')) jQuery.post('action.php',{action:'delete-note',xref:'".$this->note->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', $this->record->getFullName()))."')) jQuery.post('action.php',{action:'delete-note',xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('remove'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_delete'); $menu->addSubmenu($submenu); @@ -138,7 +121,7 @@ class WT_Controller_Note extends WT_Controller_Base { '#', 'menu-note-addfav' ); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->note->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('favorites'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_fav'); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Pedigree.php b/library/WT/Controller/Pedigree.php index 5c92f87b10..9a47c3e2b0 100644 --- a/library/WT/Controller/Pedigree.php +++ b/library/WT/Controller/Pedigree.php @@ -1,4 +1,6 @@ <?php +// Controller for the pedigree chart +// // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. // @@ -19,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -28,7 +30,7 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_charts.php'; -class WT_Controller_Pedigree extends WT_Controller_Base { +class WT_Controller_Pedigree extends WT_Controller_Chart { var $log2; var $rootid; var $name; @@ -48,10 +50,7 @@ class WT_Controller_Pedigree extends WT_Controller_Base { var $offsetarray; var $minyoffset; - /** - * Initialization function - */ - function init() { + public function __construct() { global $PEDIGREE_FULL_DETAILS, $PEDIGREE_LAYOUT, $MAX_PEDIGREE_GENERATIONS; global $DEFAULT_PEDIGREE_GENERATIONS, $SHOW_EMPTY_BOXES; global $bwidth, $bheight, $baseyoffset, $basexoffset, $byspacing, $bxspacing; @@ -246,6 +245,11 @@ class WT_Controller_Pedigree extends WT_Controller_Base { $this->adjust_subtree(0, $ydiff); } + // What should this page show in the browser's title bar? + public function getPageTitle() { + return /* I18N: %s is a person's name */ WT_I18N::translate('Pedigree tree of %s', $this->name); + } + function getPersonName() { if (is_null($this->rootPerson)) { return WT_I18N::translate('unknown'); diff --git a/library/WT/Controller/Repository.php b/library/WT/Controller/Repository.php index 171ceee1d5..5c69dbfaa6 100644 --- a/library/WT/Controller/Repository.php +++ b/library/WT/Controller/Repository.php @@ -1,5 +1,5 @@ <?php -// Controller for the Repository Page +// Controller for the repository page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -31,17 +31,13 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; -class WT_Controller_Repository extends WT_Controller_Base { - var $rid; - var $repository = null; - var $diffrepository = null; +class WT_Controller_Repository extends WT_Controller_GedcomRecord { + public function __construct() { + $xref = safe_GET_xref('rid'); - function init() { - $this->rid = safe_GET_xref('rid'); - - $gedrec=find_other_record($this->rid, WT_GED_ID); + $gedrec=find_other_record($xref, WT_GED_ID); if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($this->rid, WT_GED_ID); + $newrec=find_updated_record($xref, WT_GED_ID); } else { $newrec=null; } @@ -57,26 +53,13 @@ class WT_Controller_Repository extends WT_Controller_Base { } } - $this->repository = new WT_Repository($gedrec); + $this->record = new WT_Repository($gedrec); // If there are pending changes, merge them in. if ($newrec!==null) { - $this->diffrepository=new WT_Repository($newrec); - $this->diffrepository->setChanged(true); - $this->repository->diffMerge($this->diffrepository); - } - $this->rid=$this->repository->getXref(); // We may have requested X1234, but found x1234 - } - - /** - * get the title for this page - * @return string - */ - function getPageTitle() { - if ($this->repository) { - return $this->repository->getFullName(); - } else { - return WT_I18N::translate('Repository'); + $diff_record=new WT_Repository($newrec); + $diff_record->setChanged(true); + $this->record->diffMerge($diff_record); } } @@ -86,7 +69,7 @@ class WT_Controller_Repository extends WT_Controller_Base { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->repository || $this->repository->isMarkedDeleted()) { + if (!$this->record || $this->record->isMarkedDeleted()) { return null; } @@ -97,7 +80,7 @@ class WT_Controller_Repository extends WT_Controller_Base { if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Edit repository'), '#', 'menu-repo-edit'); - $submenu->addOnclick('return edit_source(\''.$this->rid.'\');'); + $submenu->addOnclick('return edit_source(\''.$this->record->getXref().'\');'); $submenu->addIcon('edit_repo'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_repo'); $menu->addSubmenu($submenu); @@ -106,7 +89,7 @@ class WT_Controller_Repository extends WT_Controller_Base { // edit/view raw gedcom if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-repo-editraw'); - $submenu->addOnclick("return edit_raw('".$this->rid."');"); + $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); $submenu->addIcon('gedcom'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_raw'); $menu->addSubmenu($submenu); @@ -125,7 +108,7 @@ class WT_Controller_Repository extends WT_Controller_Base { // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-repo-del'); - $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', $this->repository->getFullName()))."')) jQuery.post('action.php',{action:'delete-repository',xref:'".$this->repository->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', $this->record->getFullName()))."')) jQuery.post('action.php',{action:'delete-repository',xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('remove'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_delete'); $menu->addSubmenu($submenu); @@ -138,7 +121,7 @@ class WT_Controller_Repository extends WT_Controller_Base { '#', 'menu-repo-addfav' ); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->repository->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('favorites'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_fav'); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Search.php b/library/WT/Controller/Search.php index d90d47adb0..a5777a380b 100644 --- a/library/WT/Controller/Search.php +++ b/library/WT/Controller/Search.php @@ -1,5 +1,5 @@ <?php -// Controller for the Search Page +// Controller for the search page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -21,7 +21,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// // $Id$ if (!defined('WT_WEBTREES')) { @@ -30,6 +29,7 @@ if (!defined('WT_WEBTREES')) { } class WT_Controller_Search extends WT_Controller_Base { + var $action; var $isPostBack = false; var $topsearch; var $srfams; @@ -84,10 +84,7 @@ class WT_Controller_Search extends WT_Controller_Base { var $replacePlacesWord = false; var $printplace = array(); - /** - * Initialization function - */ - function init() { + function __construct() { global $GEDCOM; if ($this->action=='') { diff --git a/library/WT/Controller/Simple.php b/library/WT/Controller/Simple.php new file mode 100644 index 0000000000..35e4802297 --- /dev/null +++ b/library/WT/Controller/Simple.php @@ -0,0 +1,29 @@ +<?php +// Base controller for all popup pages +// +// webtrees: Web based Family History software +// Copyright (C) 2011 webtrees development team. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ + +if (!defined('WT_WEBTREES')) { + header('HTTP/1.0 403 Forbidden'); + exit; +} + +class WT_Controller_Simple extends WT_Controller_Base { +} diff --git a/library/WT/Controller/Source.php b/library/WT/Controller/Source.php index 3856bb4740..41f632ad47 100644 --- a/library/WT/Controller/Source.php +++ b/library/WT/Controller/Source.php @@ -1,5 +1,5 @@ <?php -// Controller for the Source Page +// Controller for the source page // // webtrees: Web based Family History software // Copyright (C) 2011 webtrees development team. @@ -31,17 +31,13 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; -class WT_Controller_Source extends WT_Controller_Base { - var $sid; - var $source = null; - var $diffsource = null; +class WT_Controller_Source extends WT_Controller_GedcomRecord { + public function __construct() { + $xref=safe_GET_xref('sid'); - function init() { - $this->sid=safe_GET_xref('sid'); - - $gedrec=find_source_record($this->sid, WT_GED_ID); + $gedrec=find_source_record($xref, WT_GED_ID); if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($this->sid, WT_GED_ID); + $newrec=find_updated_record($xref, WT_GED_ID); } else { $newrec=null; } @@ -57,26 +53,13 @@ class WT_Controller_Source extends WT_Controller_Base { } } - $this->source = new WT_Source($gedrec); + $this->record = new WT_Source($gedrec); // If there are pending changes, merge them in. if ($newrec!==null) { - $this->diffsource=new WT_Source($newrec); - $this->diffsource->setChanged(true); - $this->source->diffMerge($this->diffsource); - } - $this->sid=$this->source->getXref(); // We may have requested X1234, but found x1234 - } - - /** - * get the title for this page - * @return string - */ - function getPageTitle() { - if ($this->source) { - return $this->source->getFullName(); - } else { - return WT_I18N::translate('Source'); + $diff_record=new WT_Source($newrec); + $diff_record->setChanged(true); + $this->record->diffMerge($this->diff_record); } } @@ -86,7 +69,7 @@ class WT_Controller_Source extends WT_Controller_Base { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->source || $this->source->isMarkedDeleted()) { + if (!$this->record || $this->record->isMarkedDeleted()) { return null; } @@ -97,7 +80,7 @@ class WT_Controller_Source extends WT_Controller_Base { if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Edit source'), '#', 'menu-sour-edit'); - $submenu->addOnclick('return edit_source(\''.$this->sid.'\');'); + $submenu->addOnclick('return edit_source(\''.$this->record->getXref().'\');'); $submenu->addIcon('edit_sour'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_source'); $menu->addSubmenu($submenu); @@ -106,7 +89,7 @@ class WT_Controller_Source extends WT_Controller_Base { // edit/view raw gedcom if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-sour-editraw'); - $submenu->addOnclick("return edit_raw('".$this->sid."');"); + $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); $submenu->addIcon('gedcom'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_edit_raw'); $menu->addSubmenu($submenu); @@ -125,7 +108,7 @@ class WT_Controller_Source extends WT_Controller_Base { // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-sour-del'); - $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', $this->source->getFullName()))."')) jQuery.post('action.php',{action:'delete-source',xref:'".$this->source->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("if (confirm('".addslashes(WT_I18N::translate('Are you sure you want to delete “%s”?', $this->record->getFullName()))."')) jQuery.post('action.php',{action:'delete-source',xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('remove'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_delete'); $menu->addSubmenu($submenu); @@ -138,7 +121,7 @@ class WT_Controller_Source extends WT_Controller_Base { '#', 'menu-sour-addfav' ); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->source->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})"); $submenu->addIcon('favorites'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_fav'); $menu->addSubmenu($submenu); diff --git a/library/WT/Controller/Timeline.php b/library/WT/Controller/Timeline.php index 7a1e71c375..e22ee94159 100644 --- a/library/WT/Controller/Timeline.php +++ b/library/WT/Controller/Timeline.php @@ -30,7 +30,7 @@ if (!defined('WT_WEBTREES')) { require_once WT_ROOT.'includes/functions/functions_charts.php'; -class WT_Controller_Timeline extends WT_Controller_Base { +class WT_Controller_Timeline extends WT_Controller_Chart { var $bheight = 30; var $placements = array(); var $familyfacts = array(); @@ -47,10 +47,7 @@ class WT_Controller_Timeline extends WT_Controller_Base { // GEDCOM elements that may have DATE data, but should not be displayed var $nonfacts = array("BAPL","ENDL","SLGC","SLGS","_TODO","CHAN"); - /** - * Initialization function - */ - function init() { + function __construct() { $this->baseyear = date("Y"); //-- new pid $newpid=safe_GET_xref('newpid'); @@ -136,6 +133,12 @@ class WT_Controller_Timeline extends WT_Controller_Base { $this->baseyear -= 5; $this->topyear += 5; } + + // What should this page show in the browser's title bar? + public function getPageTitle() { + return WT_I18N::translate('Timeline'); + } + /** * check the privacy of the incoming people to make sure they can be shown */ diff --git a/library/WT/MenuBar.php b/library/WT/MenuBar.php index 7aeca16e14..9f5faeed0f 100644 --- a/library/WT/MenuBar.php +++ b/library/WT/MenuBar.php @@ -99,7 +99,7 @@ class WT_MenuBar { $submenu->addClass('submenuitem', 'submenuitem_hover', '', 'icon_small_pedigree'); $menu->addSubmenu($submenu); //-- my_indi submenu - $submenu = new WT_Menu(WT_I18N::translate('My individual record'), 'individual.php?ged='.WT_GEDURL.'&pid='.WT_USER_GEDCOM_ID, 'menu-myrecord'); + $submenu = new WT_Menu(WT_I18N::translate('My individual record'), 'individual.php?pid='.WT_USER_GEDCOM_ID.'&ged='.WT_GEDURL, 'menu-myrecord'); $submenu->addIcon('indis'); $submenu->addClass('submenuitem', 'submenuitem_hover', '', 'icon_small_indis'); $menu->addSubmenu($submenu); @@ -114,18 +114,17 @@ class WT_MenuBar { return $menu; } - public static function getChartsMenu($rootid='') { + public static function getChartsMenu() { global $WT_IMAGES, $SEARCH_SPIDER, $PEDIGREE_FULL_DETAILS, $PEDIGREE_LAYOUT, $controller; - if (isset($controller)) { - if (!$rootid) { - if (isset($controller->pid)) $rootid = $controller->pid; - if (isset($controller->rootid)) $rootid = $controller->rootid; - } + if ($SEARCH_SPIDER) { + return null; } - if (!empty($SEARCH_SPIDER)) { - return null; + if ($controller) { + $rootid=$controller->getSignificantIndividual()->getXref(); + } else { + $rootid=''; } $showFull = ($PEDIGREE_FULL_DETAILS) ? 1 : 0; @@ -389,15 +388,10 @@ class WT_MenuBar { public static function getListsMenu() { global $SEARCH_SPIDER, $controller; - $surname=''; - if (isset($controller)) { - if (isset($controller->indi)) { - list($surname)=explode(',', $controller->indi->getSortName()); - } - if (isset($controller->rootid)) { - $person = WT_Person::getInstance($controller->rootid); - list($surname)=explode(',', $person->getSortName()); - } + if ($controller) { + list($surname)=explode(',', $controller->getSignificantIndividual()->getSortName()); + } else { + $surname=''; } // The top level menu shows the individual list @@ -536,7 +530,7 @@ class WT_MenuBar { * @return WT_Menu the menu item */ public static function getReportsMenu($pid='', $famid='') { - global $SEARCH_SPIDER, $controller; + global $SEARCH_SPIDER; $active_reports=WT_Module::getActiveReports(); if ($SEARCH_SPIDER || !$active_reports) { @@ -754,34 +748,9 @@ class WT_MenuBar { } if ($show_user_favs) { - if ($controller instanceof WT_Controller_Individual && $controller->indi) { - $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#'); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->indi->getXref()."'},function(){location.reload();})"); - $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover'); - $menu->addSubMenu($submenu); - } else if ($controller instanceof WT_Controller_Family && $controller->family) { - $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#'); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->family->getXref()."'},function(){location.reload();})"); - $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover'); - $menu->addSubMenu($submenu); - } else if ($controller instanceof WT_Controller_Source && $controller->source) { - $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#'); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->source->getXref()."'},function(){location.reload();})"); - $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover'); - $menu->addSubMenu($submenu); - } else if ($controller instanceof WT_Controller_Repository && $controller->repository) { - $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#'); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->repository->getXref()."'},function(){location.reload();})"); - $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover'); - $menu->addSubMenu($submenu); - } else if ($controller instanceof WT_Controller_Media && $controller->mediaobject) { - $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#'); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->mediaobject->getXref()."'},function(){location.reload();})"); - $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover'); - $menu->addSubMenu($submenu); - } else if ($controller instanceof WT_Controller_Note && $controller->note) { + if (isset($controller->record) && $controller->record instanceof WT_GedcomRecord) { $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#'); - $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->note->getXref()."'},function(){location.reload();})"); + $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'".$controller->record->getXref()."'},function(){location.reload();})"); $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover'); $menu->addSubMenu($submenu); } diff --git a/library/WT/Module.php b/library/WT/Module.php index 71c584e8df..b7592b8e69 100644 --- a/library/WT/Module.php +++ b/library/WT/Module.php @@ -105,11 +105,6 @@ abstract class WT_Module { return str_replace('_WT_Module', '', get_class($this)); } - // Some modules may use the page's controller - protected $controller; - public function &getController() { return $this->controller; } - public function setController(&$c) { $this->controller=$c; } - // Run an action specified on the URL through module.php?mod=FOO&mod_action=BAR public function modAction($mod_action) { } diff --git a/lifespan.php b/lifespan.php index ea4dc0e683..921dc9249f 100644 --- a/lifespan.php +++ b/lifespan.php @@ -23,22 +23,19 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ define('WT_SCRIPT_NAME', 'lifespan.php'); require './includes/session.php'; // GEDCOM elements that will be found but should not be displayed -$nonfacts = array("FAMS", "FAMC", "MAY", "BLOB", "OBJE", "SEX", "NAME", "SOUR", "NOTE", "BAPL", "ENDL", "SLGC", "SLGS", "_TODO", "_WT_OBJE_SORT", "CHAN", "HUSB", "WIFE", "CHIL", "BIRT", "DEAT", "BURI");// DEATH OF SIBLING: DEATH OF HALF SIBLING DEATH OF MOTHER DEATH OF FATHER DEATH OF CHILD -$nonfamfacts = array("CHAN", "HUSB", "WIFE", "CHIL"); +$nonfacts=array("FAMS", "FAMC", "MAY", "BLOB", "OBJE", "SEX", "NAME", "SOUR", "NOTE", "BAPL", "ENDL", "SLGC", "SLGS", "_TODO", "_WT_OBJE_SORT", "CHAN", "HUSB", "WIFE", "CHIL", "BIRT", "DEAT", "BURI");// DEATH OF SIBLING: DEATH OF HALF SIBLING DEATH OF MOTHER DEATH OF FATHER DEATH OF CHILD +$nonfamfacts=array("CHAN", "HUSB", "WIFE", "CHIL"); -$controller = new WT_Controller_Lifespan(); -$controller->init(); +$zoomfactor=10; -$zoomfactor = 10; -//if peeps !null then pass new array for zooming - -print_header(WT_I18N::translate('Lifespans')); +$controller=new WT_Controller_Lifespan(); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; ?> @@ -358,5 +355,3 @@ var maxX = <?php if (!isset($maxX)) $maxX = 0; echo $maxX; ?>; // Sets the boun //--> </script> - -<?php print_footer(); diff --git a/mediafirewall.php b/mediafirewall.php index 5160c2168d..a7f5514448 100644 --- a/mediafirewall.php +++ b/mediafirewall.php @@ -23,16 +23,12 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ define('WT_SCRIPT_NAME', 'mediafirewall.php'); require './includes/session.php'; -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - -$controller = new WT_Controller_Media(); -$controller->init(); +$controller=new WT_Controller_Media(); $debug_mediafirewall = 0; // set to 1 if you want to see media firewall values displayed instead of images $debug_watermark = 0; // set to 1 if you want to see error messages from the watermark module instead of broken images @@ -315,7 +311,7 @@ if (!$serverFilename) { $exp = explode("?", $requestedfile); $pathinfo = pathinfo($exp[0]); $ext = @strtolower($pathinfo['extension']); - // have to exit even if debug_mediafirewall is enabled because $controller->mediaobject doesn't exist and is required below + // have to exit even if debug_mediafirewall is enabled because $controller->record doesn't exist and is required below sendErrorAndExit($ext, WT_I18N::translate('The media file was not found in this family tree'), $requestedfile); } @@ -325,11 +321,11 @@ if (strpos($_SERVER['REQUEST_URI'], '/thumbs/') || safe_GET_bool('thumb')) { // display the thumbnail file instead of the main file // NOTE: since this script was called when a 404 error occured, we know the requested file // does not exist in the main media directory. just check the media firewall directory - $serverFilename = $controller->mediaobject->getServerFilename('thumb'); + $serverFilename = $controller->record->getServerFilename('thumb'); $which = 'thumb'; } -$imgsize = $controller->mediaobject->getImageAttributes($which); +$imgsize = $controller->record->getImageAttributes($which); if (!file_exists($serverFilename)) { // the requested file MAY be in the gedcom, but it does NOT exist on the server. bail. // Note: the 404 error status is still in effect. @@ -347,14 +343,14 @@ if (empty($controller->pid)) { } // check PGV permissions -if (!$controller->mediaobject->canDisplayDetails()) { +if (!$controller->record->canDisplayDetails()) { // if no permissions, bail // Note: the 404 error status is still in effect if (!$debug_mediafirewall) sendErrorAndExit($imgsize['ext'], WT_I18N::translate('The media file was not found in this family tree')); } $protocol = $_SERVER["SERVER_PROTOCOL"]; // determine if we are using HTTP/1.0 or HTTP/1.1 -$filetime = $controller->mediaobject->getFiletime($which); +$filetime = $controller->record->getFiletime($which); $filetimeHeader = gmdate("D, d M Y H:i:s", $filetime).' GMT'; $expireOffset = 3600 * 24; // tell browser to cache this image for 24 hours if (safe_GET('cb')) $expireOffset = $expireOffset * 7; // if cb parameter was sent, cache for 7 days @@ -401,7 +397,7 @@ if ($usewatermark) { } } -$etag = $controller->mediaobject->getEtag($which); +$etag = $controller->record->getEtag($which); $mimetype = $imgsize['mime']; $disposition = 'inline'; if (safe_GET('dl')) { @@ -433,17 +429,17 @@ if ($debug_mediafirewall) { echo '<tr><td>$controller->pid</td><td>', $controller->pid, '</td><td> </td></tr>'; echo '<tr><td>Requested URL</td><td>', urldecode($_SERVER['REQUEST_URI']), '</td><td> </td></tr>'; echo '<tr><td>serverFilename</td><td>', $serverFilename, '</td><td> </td></tr>'; - echo '<tr><td>controller->mediaobject->getFilename()</td><td>', $controller->mediaobject->getFilename(), '</td><td>this is direct from the gedcom</td></tr>'; - echo '<tr><td>controller->mediaobject->getLocalFilename()</td><td>', $controller->mediaobject->getLocalFilename(), '</td><td></td></tr>'; - echo '<tr><td>controller->mediaobject->getServerFilename()</td><td>', $controller->mediaobject->getServerFilename(), '</td><td></td></tr>'; - echo '<tr><td>controller->mediaobject->fileExists()</td><td>', $controller->mediaobject->fileExists(), '</td><td></td></tr>'; + echo '<tr><td>controller->record->getFilename()</td><td>', $controller->record->getFilename(), '</td><td>this is direct from the gedcom</td></tr>'; + echo '<tr><td>controller->record->getLocalFilename()</td><td>', $controller->record->getLocalFilename(), '</td><td></td></tr>'; + echo '<tr><td>controller->record->getServerFilename()</td><td>', $controller->record->getServerFilename(), '</td><td></td></tr>'; + echo '<tr><td>controller->record->fileExists()</td><td>', $controller->record->fileExists(), '</td><td></td></tr>'; echo '<tr><td>mimetype</td><td>', $mimetype, '</td><td> </td></tr>'; echo '<tr><td>disposition</td><td>', $disposition, '</td><td> </td></tr>'; - echo '<tr><td>controller->mediaobject->getFilesize()</td><td>', $controller->mediaobject->getFilesize(), '</td><td>cannot use this</td></tr>'; + echo '<tr><td>controller->record->getFilesize()</td><td>', $controller->record->getFilesize(), '</td><td>cannot use this</td></tr>'; echo '<tr><td>filesize</td><td>', @filesize($serverFilename), '</td><td>this is right</td></tr>'; - echo '<tr><td>controller->mediaobject->getThumbnail()</td><td>', $controller->mediaobject->getThumbnail(), '</td><td> </td></tr>'; - echo '<tr><td>controller->mediaobject->canDisplayDetails()</td><td>', $controller->mediaobject->canDisplayDetails(), '</td><td> </td></tr>'; - echo '<tr><td>controller->mediaobject->getFullName()</td><td>', $controller->mediaobject->getFullName(), '</td><td> </td></tr>'; + echo '<tr><td>controller->record->getThumbnail()</td><td>', $controller->record->getThumbnail(), '</td><td> </td></tr>'; + echo '<tr><td>controller->record->canDisplayDetails()</td><td>', $controller->record->canDisplayDetails(), '</td><td> </td></tr>'; + echo '<tr><td>controller->record->getFullName()</td><td>', $controller->record->getFullName(), '</td><td> </td></tr>'; echo '<tr><td>basename($serverFilename)</td><td>', basename($serverFilename), '</td><td> </td></tr>'; echo '<tr><td>filetime</td><td>', $filetime, '</td><td> </td></tr>'; echo '<tr><td>filetimeHeader</td><td>', $filetimeHeader, '</td><td> </td></tr>'; @@ -465,7 +461,7 @@ if ($debug_mediafirewall) { echo '<pre>'; print_r (@getimagesize($serverFilename)); - print_r ($controller->mediaobject); + print_r ($controller->record); print_r (WT_GEDCOM); echo '</pre>'; @@ -566,4 +562,3 @@ if (function_exists('readfile')) { } fclose($fp); } - diff --git a/mediaviewer.php b/mediaviewer.php index 20cf974d29..f065a66f04 100644 --- a/mediaviewer.php +++ b/mediaviewer.php @@ -29,19 +29,18 @@ define('WT_SCRIPT_NAME', 'mediaviewer.php'); require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_print_lists.php'; -$controller = new WT_Controller_Media(); -$controller->init(); +$controller=new WT_Controller_Media(); -if ($controller->mediaobject && $controller->mediaobject->canDisplayDetails()) { - print_header($controller->getPageTitle()); - if ($controller->mediaobject->isMarkedDeleted()) { +if ($controller->record && $controller->record->canDisplayDetails()) { + $controller->pageHeader(); + if ($controller->record->isMarkedDeleted()) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This media object has been deleted. You should review the deletion and then %1$s or %2$s it.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->mediaobject->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->mediaobject->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -52,14 +51,14 @@ if ($controller->mediaobject && $controller->mediaobject->canDisplayDetails()) { ' ', help_link('pending_changes'), '</p>'; } - } elseif (find_updated_record($controller->mediaobject->getXref(), WT_GED_ID)!==null) { + } elseif (find_updated_record($controller->record->getXref(), WT_GED_ID)!==null) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This media object has been edited. You should review the changes and then %1$s or %2$s them.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->mediaobject->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->mediaobject->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -72,25 +71,21 @@ if ($controller->mediaobject && $controller->mediaobject->canDisplayDetails()) { } } } else { - header('HTTP/1.0 403 Forbidden'); - print_header(WT_I18N::translate('Media object')); + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); + $controller->pageHeader(); echo '<p class="ui-state-error">', WT_I18N::translate('This media object does not exist or you do not have permission to view it.'), '</p>'; - print_footer(); exit; } -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - if (WT_USE_LIGHTBOX) { require WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_call_js.php'; } echo WT_JS_START; echo 'function show_gedcom_record() {'; -echo ' var recwin=window.open("gedrecord.php?pid=', $controller->mediaobject->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; +echo ' var recwin=window.open("gedrecord.php?pid=', $controller->record->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; echo '}'; -echo 'function showchanges() { window.location="'.$controller->mediaobject->getRawUrl().'"; }'; +echo 'function showchanges() { window.location="'.$controller->record->getRawUrl().'"; }'; ?> jQuery(document).ready(function() { jQuery("#media-tabs").tabs(); jQuery("#media-tabs").css('visibility', 'visible'); @@ -108,23 +103,23 @@ $filename = $controller->getLocalFilename(); global $tmb; echo '<div id="media-details">'; -echo '<h2>', $controller->mediaobject->getFullName(), ' ', $controller->mediaobject->getAddName(), '</h2>'; +echo '<h2>', $controller->record->getFullName(), ' ', $controller->record->getAddName(), '</h2>'; echo '<div id="media-tabs"> <ul> <li><a href="#media-edit"><span>', WT_I18N::translate('Details'), '</span></a></li>'; - if ($controller->mediaobject->countLinkedIndividuals()) { + if ($controller->record->countLinkedIndividuals()) { echo '<li><a href="#indi-media"><span id="indimedia">', WT_I18N::translate('Individuals'), '</span></a></li>'; } - if ($controller->mediaobject->countLinkedFamilies()) { + if ($controller->record->countLinkedFamilies()) { echo '<li><a href="#fam-media"><span id="fammedia">', WT_I18N::translate('Families'), '</span></a></li>'; } - if ($controller->mediaobject->countLinkedSources()) { + if ($controller->record->countLinkedSources()) { echo '<li><a href="#sources-media"><span id="sourcemedia">', WT_I18N::translate('Sources'), '</span></a></li>'; } - if ($controller->mediaobject->countLinkedRepositories()) { + if ($controller->record->countLinkedRepositories()) { echo '<li><a href="#repo-media"><span id="repomedia">', WT_I18N::translate('Repositories'), '</span></a></li>'; } - if ($controller->mediaobject->countLinkedNotes()) { + if ($controller->record->countLinkedNotes()) { echo '<li><a href="#notes-media"><span id="notemedia">', WT_I18N::translate('Notes'), '</span></a></li>'; } echo '</ul>'; @@ -135,8 +130,8 @@ echo '</ul>'; <tr> <td align="center" width="150">'; // display image - if ($controller->canDisplayDetails()) { - echo $controller->mediaobject->displayMedia(array('download'=>true, 'align'=>'none', 'alertnotfound'=>true)); + if ($controller->record->canDisplayDetails()) { + echo $controller->record->displayMedia(array('download'=>true, 'align'=>'none', 'alertnotfound'=>true)); } echo '</td> <td valign="top"> @@ -146,7 +141,7 @@ echo '</ul>'; <table class="facts_table', $TEXT_DIRECTION=='ltr'?'':'_rtl', '">'; $facts = $controller->getFacts(WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT); foreach ($facts as $f=>$fact) { - print_fact($fact, $controller->mediaobject); + print_fact($fact, $controller->record); } echo '</table> </td> @@ -158,37 +153,37 @@ echo '</ul>'; </div>'; // close "media-edit" // Individuals linked to this media object - if ($controller->mediaobject->countLinkedIndividuals()) { + if ($controller->record->countLinkedIndividuals()) { echo '<div id="indi-media">'; - print_indi_table($controller->mediaobject->fetchLinkedIndividuals(), $controller->mediaobject->getFullName()); + print_indi_table($controller->record->fetchLinkedIndividuals(), $controller->record->getFullName()); echo '</div>'; //close "indi-media" } // Families linked to this media object - if ($controller->mediaobject->countLinkedFamilies()) { + if ($controller->record->countLinkedFamilies()) { echo '<div id="fam-media">'; - print_fam_table($controller->mediaobject->fetchLinkedFamilies(), $controller->mediaobject->getFullName()); + print_fam_table($controller->record->fetchLinkedFamilies(), $controller->record->getFullName()); echo '</div>'; //close "fam-media" } // Sources linked to this media object - if ($controller->mediaobject->countLinkedSources()) { + if ($controller->record->countLinkedSources()) { echo '<div id="sources-media">'; - print_sour_table($controller->mediaobject->fetchLinkedSources(), $controller->mediaobject->getFullName()); + print_sour_table($controller->record->fetchLinkedSources(), $controller->record->getFullName()); echo '</div>'; //close "source-media" } // Repositories linked to this media object - if ($controller->mediaobject->countLinkedRepositories()) { + if ($controller->record->countLinkedRepositories()) { echo '<div id="repo-media">'; - print_repo_table($controller->mediaobject->fetchLinkedRepositories(), $controller->mediaobject->getFullName()); + print_repo_table($controller->record->fetchLinkedRepositories(), $controller->record->getFullName()); echo '</div>'; //close "repo-media" } // medias linked to this media object - if ($controller->mediaobject->countLinkedNotes()) { + if ($controller->record->countLinkedNotes()) { echo '<div id="notes-media">'; - print_note_table($controller->mediaobject->fetchLinkedNotes(), $controller->mediaobject->getFullName()); + print_note_table($controller->record->fetchLinkedNotes(), $controller->record->getFullName()); echo '</div>'; //close "notes-media" } echo '</div>'; //close div "media-tabs" @@ -227,6 +222,3 @@ function ilinkitem(mediaid, type) { } //--> </script> - -<?php -print_footer(); diff --git a/modules_v3/GEDFact_assistant/CENS_ctrl.php b/modules_v3/GEDFact_assistant/CENS_ctrl.php index 0e0b7a63af..cf5fb08ca8 100644 --- a/modules_v3/GEDFact_assistant/CENS_ctrl.php +++ b/modules_v3/GEDFact_assistant/CENS_ctrl.php @@ -25,25 +25,22 @@ // // $Id$ -$controller = new WT_Controller_Individual(); -$controller->init(); +$controller=new WT_Controller_Individual(); global $tabno, $linkToID, $SEARCH_SPIDER, $GOOGLEMAP_PH_CONTROLS; global $WT_IMAGES, $SHOW_AGE_DIFF, $GEDCOM, $ABBREVIATE_CHART_LABELS; global $show_full, $famid; echo '<link type="text/css" href="', WT_STATIC_URL, WT_MODULES_DIR, 'GEDFact_assistant/css/cens_style.css" rel="stylesheet" />'; -$summary=$controller->indi->format_first_major_fact(WT_EVENTS_BIRT, 2); -if (!($controller->indi->isDead())) { +$summary=$controller->record->format_first_major_fact(WT_EVENTS_BIRT, 2); +if (!($controller->record->isDead())) { // If alive display age - $bdate=$controller->indi->getBirthDate(); + $bdate=$controller->record->getBirthDate(); $age = WT_Date::GetAgeGedcom($bdate); if ($age!="") { $summary.= "<span class=\"label\">".WT_I18N::translate('Age').":</span><span class=\"field\"> ".get_age_at_event($age, true)."</span>"; } } -$summary.=$controller->indi->format_first_major_fact(WT_EVENTS_DEAT, 2); +$summary.=$controller->record->format_first_major_fact(WT_EVENTS_DEAT, 2); $controller->census_assistant(); - -// print_footer(); diff --git a/modules_v3/GEDFact_assistant/MEDIA_ctrl.php b/modules_v3/GEDFact_assistant/MEDIA_ctrl.php index c2bc5e19ce..02ef06d7da 100644 --- a/modules_v3/GEDFact_assistant/MEDIA_ctrl.php +++ b/modules_v3/GEDFact_assistant/MEDIA_ctrl.php @@ -25,8 +25,8 @@ // // $Id$ -$controller = new WT_Controller_Individual(); -$controller->init(); +$controller=new WT_Controller_Individual(); + echo '<link href="'.WT_STATIC_URL.WT_MODULES_DIR.'GEDFact_assistant/css/gf_styles.css" rel="stylesheet" type="text/css" media="screen" />'; global $tabno, $linkToID, $SEARCH_SPIDER, $GOOGLEMAP_PH_CONTROLS; @@ -37,17 +37,15 @@ global $famid, $censyear, $censdate; // print_simple_header("Census"); -$summary=$controller->indi->format_first_major_fact(WT_EVENTS_BIRT, 2); -if (!($controller->indi->isDead())) { +$summary=$controller->record->format_first_major_fact(WT_EVENTS_BIRT, 2); +if (!($controller->record->isDead())) { // If alive display age - $bdate=$controller->indi->getBirthDate(); + $bdate=$controller->record->getBirthDate(); $age = WT_Date::GetAgeGedcom($bdate); //if ($age!="") { //$summary.= "<span class=\"label\">".WT_I18N::translate('Age').":</span><span class=\"field\"> ".get_age_at_event($age, true)."</span>"; //} } -$summary.=$controller->indi->format_first_major_fact(WT_EVENTS_DEAT, 2); +$summary.=$controller->record->format_first_major_fact(WT_EVENTS_DEAT, 2); $controller->medialink_assistant(); - -// print_footer(); diff --git a/modules_v3/ahnentafel_report/module.php b/modules_v3/ahnentafel_report/module.php index 53db375ff6..4c3340bb86 100644 --- a/modules_v3/ahnentafel_report/module.php +++ b/modules_v3/ahnentafel_report/module.php @@ -50,12 +50,12 @@ class ahnentafel_report_WT_Module extends WT_Module implements WT_Module_Report public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/charts/module.php b/modules_v3/charts/module.php index cd99588454..11346b6977 100644 --- a/modules_v3/charts/module.php +++ b/modules_v3/charts/module.php @@ -68,8 +68,7 @@ class charts_WT_Module extends WT_Module implements WT_Module_Block { $PEDIGREE_FULL_DETAILS = $show_full; if ($type!='treenav') { - $controller = new WT_Controller_Hourglass(); - $controller->init($pid,0,3); + $controller=new WT_Controller_Hourglass($pid,0,3); $controller->setupJavascript(); } diff --git a/modules_v3/clippings/clippings_ctrl.php b/modules_v3/clippings/clippings_ctrl.php index c4f2e8c42f..f03612e029 100644 --- a/modules_v3/clippings/clippings_ctrl.php +++ b/modules_v3/clippings/clippings_ctrl.php @@ -49,7 +49,7 @@ function same_group($a, $b) { /** * Main controller class for the Clippings page. */ -class WT_Controller_Clippings extends WT_Controller_Base { +class WT_Controller_Clippings { var $download_data; var $media_list = array(); @@ -66,14 +66,8 @@ class WT_Controller_Clippings extends WT_Controller_Base { var $level2; var $level3; // number of levels of descendents - /** - * @param string $thing the id of the person - */ - function __construct() { + public function __construct() { parent::__construct(); - } - //----------------beginning of function definitions for WT_Controller_Clippings - function init() { global $SCRIPT_NAME, $MEDIA_DIRECTORY, $MEDIA_FIREWALL_ROOTDIR, $GEDCOM, $cart; if (!isset($_SESSION['exportConvPath'])) $_SESSION['exportConvPath'] = $MEDIA_DIRECTORY; @@ -299,6 +293,11 @@ class WT_Controller_Clippings extends WT_Controller_Base { } return false; } + // + // What should this page show in the browser's title bar? + public function getPageTitle() { + return WT_I18N::translate('Clippings cart'); + } /** * Loads everything in the clippings cart into a zip file. diff --git a/modules_v3/clippings/index.php b/modules_v3/clippings/index.php index a7708fc009..d453b80ac3 100644 --- a/modules_v3/clippings/index.php +++ b/modules_v3/clippings/index.php @@ -25,15 +25,17 @@ // // $Id$ +if (!defined('WT_WEBTREES')) { + header('HTTP/1.0 403 Forbidden'); + exit; +} + global $ENABLE_AUTOCOMPLETE, $cart, $MAX_PEDIGREE_GENERATIONS, $TEXT_DIRECTION, $GEDCOM, $WT_IMAGES; require_once WT_ROOT.WT_MODULES_DIR.'clippings/clippings_ctrl.php'; -$controller = new WT_Controller_Clippings(); -$controller->init(); - -// -- print html header information -print_header(WT_I18N::translate('Clippings cart')); +$controller=new WT_Controller_Clippings(); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; @@ -307,5 +309,3 @@ if ($ct==0) { </td></tr></table> <?php } -if (isset($_SESSION["cart"])) $_SESSION["cart"]=$cart; -print_footer(); diff --git a/modules_v3/clippings/module.php b/modules_v3/clippings/module.php index 687e565705..19b457bfaf 100644 --- a/modules_v3/clippings/module.php +++ b/modules_v3/clippings/module.php @@ -77,34 +77,8 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module $submenu->addIcon('clippings'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_clippings'); $menu->addSubmenu($submenu); - if (isset($controller->indi) && $controller->indi->canDisplayDetails()) { - $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), "module.php?mod=clippings&mod_action=index&action=add&id={$controller->pid}&type=indi", 'menu-clippingsadd'); - $submenu->addIcon('clippings'); - $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip'); - - $menu->addSubmenu($submenu); - } elseif (isset($controller->family) && $controller->family->canDisplayDetails()) { - $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), "module.php?mod=clippings&mod_action=index&action=add&id={$controller->famid}&type=fam", 'menu-clippingsadd'); - $submenu->addIcon('clippings'); - $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip'); - $menu->addSubmenu($submenu); - } elseif (isset($controller->mediaobject) && $controller->mediaobject->canDisplayDetails()) { - $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), "module.php?mod=clippings&mod_action=index&action=add&id={$controller->mid}&type=obje", 'menu-clippingsadd'); - $submenu->addIcon('clippings'); - $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip'); - $menu->addSubmenu($submenu); - } elseif (isset($controller->source) && $controller->source->canDisplayDetails()) { - $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), "module.php?mod=clippings&mod_action=index&action=add&id={$controller->sid}&type=sour", 'menu-clippingsadd'); - $submenu->addIcon('clippings'); - $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip'); - $menu->addSubmenu($submenu); - } elseif (isset($controller->note) && $controller->note->canDisplayDetails()) { - $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), "module.php?mod=clippings&mod_action=index&action=add&id={$controller->nid}&type=note", 'menu-clippingsadd'); - $submenu->addIcon('clippings'); - $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip'); - $menu->addSubmenu($submenu); - } elseif (isset($controller->repository) && $controller->repository->canDisplayDetails()) { - $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), "module.php?mod=clippings&mod_action=index&action=add&id={$controller->rid}&type=repo", 'menu-clippingsadd'); + if (!empty($controller->record) && $controller->record->canDisplayDetails()) { + $submenu = new WT_Menu(WT_I18N::translate('Add to clippings cart'), 'module.php?mod=clippings&mod_action=index&action=add&id='.$controller->record->getXref(), 'menu-clippingsadd'); $submenu->addIcon('clippings'); $submenu->addClass('submenuitem', 'submenuitem_hover', 'submenu', 'icon_small_add_clip'); $menu->addSubmenu($submenu); @@ -125,11 +99,12 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module // Impelement WT_Module_Sidebar public function getSidebarContent() { require_once WT_ROOT.WT_MODULES_DIR.'clippings/clippings_ctrl.php'; - global $WT_IMAGES, $cart; + + global $WT_IMAGES, $cart, $controller; $out = ''; - if ($this->controller) { + if ($controller) { $out .= '<script type="text/javascript"> <!-- jQuery(document).ready(function() { @@ -142,12 +117,8 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module </script> <div id="sb_clippings_content">'; $out .= $this->getCartList(); - $root = null; - if ($this->controller->pid && !WT_Controller_Clippings::id_in_cart($this->controller->pid)) { - $root = WT_GedcomRecord::getInstance($this->controller->pid); - if ($root && $root->canDisplayDetails()) - $out .= '<a href="sidebar.php?sb_action=clippings&add='.$root->getXref().'" class="add_cart"> - <img src="'.$WT_IMAGES['clippings'].'" width="20" /> '.WT_I18N::translate('Add %s to cart', $root->getFullName()).'</a>'; + if (!WT_Controller_Clippings::id_in_cart($controller->record->getXref())) { + $out .= '<a href="sidebar.php?sb_action=clippings&add='.$controller->record->getXref().'" class="add_cart"><img src="'.$WT_IMAGES['clippings'].'" width="20" /> '.WT_I18N::translate('Add %s to cart', $controller->record->getFullName()).'</a>'; } $out .= '</div>'; } @@ -157,9 +128,10 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module // Impelement WT_Module_Sidebar public function getSidebarAjaxContent() { require_once WT_ROOT.WT_MODULES_DIR.'clippings/clippings_ctrl.php'; - global $cart; + + global $cart, $controller; + $controller = new WT_Controller_Clippings(); - $this->controller = $controller; $add = safe_GET_xref('add',''); $add1 = safe_GET_xref('add1',''); $remove = safe_GET('remove', WT_REGEX_INTEGER, -1); @@ -341,8 +313,9 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module } public function downloadForm() { - global $TEXT_DIRECTION; - $controller = $this->controller; + global $TEXT_DIRECTION, $controller; + + $controller = $controller; $out = WT_JS_START; $out .= 'function cancelDownload() { var link = "sidebar.php?sb_action=clippings"; diff --git a/modules_v3/descendancy/module.php b/modules_v3/descendancy/module.php index 0dd35ae74a..1149577afa 100644 --- a/modules_v3/descendancy/module.php +++ b/modules_v3/descendancy/module.php @@ -65,7 +65,7 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { // Implement WT_Module_Sidebar public function getSidebarContent() { - global $WT_IMAGES; + global $WT_IMAGES, $controller; $out = '<script type="text/javascript"> <!-- @@ -112,25 +112,9 @@ class descendancy_WT_Module extends WT_Module implements WT_Module_Sidebar { </script> <form method="post" action="sidebar.php" onsubmit="return false;"> <input type="text" name="sb_desc_name" id="sb_desc_name" value="'.WT_I18N::translate('Search').'" />'; - $out .= '</form><div id="sb_desc_content">'; - - if ($this->controller) { - $root = null; - if ($this->controller->pid) { - $root = WT_Person::getInstance($this->controller->pid); - } elseif ($this->controller->famid) { - $fam = WT_Family::getInstance($this->controller->famid); - if ($fam) { - $root = $fam->getHusband(); - } - if (!$root) { - $root = $fam->getWife(); - } - } - if ($root) { - $out .= '<ul>'.$this->getPersonLi($root, 1).'</ul>'; - } - } + $out .= '</form>'; + $out .= '<div id="sb_desc_content">'; + $out .= '<ul>'.$this->getPersonLi($controller->record, 1).'</ul>'; $out .= '</div>'; return $out; } diff --git a/modules_v3/descendancy_report/module.php b/modules_v3/descendancy_report/module.php index 77488531d8..0d765ef81a 100644 --- a/modules_v3/descendancy_report/module.php +++ b/modules_v3/descendancy_report/module.php @@ -50,12 +50,12 @@ class descendancy_report_WT_Module extends WT_Module implements WT_Module_Report public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/extra_info/module.php b/modules_v3/extra_info/module.php index 4a7897b4c9..b47f41b248 100644 --- a/modules_v3/extra_info/module.php +++ b/modules_v3/extra_info/module.php @@ -50,31 +50,17 @@ class extra_info_WT_Module extends WT_Module implements WT_Module_Sidebar { // Implement WT_Module_Sidebar
public function getSidebarContent() {
- global $WT_IMAGES, $FACT_COUNT, $SHOW_COUNTER;
+ global $WT_IMAGES, $FACT_COUNT, $SHOW_COUNTER, $controller;
- //$reftags = array ('CHAN', 'IDNO', 'RFN', 'AFN', 'REFN', 'RIN', '_UID');// list of tags that can be displayed in this sidebar block
-
- $root = WT_Person::getInstance($this->controller->pid);
- if ($root!=null) {
- $this->controller = new WT_Controller_Individual();
- $this->controller->indi=$root;
- $this->controller->pid=$root->getXref();
- $this->setController($this->controller);
+ $indifacts = $controller->getIndiFacts();
+ if (count($indifacts)==0) {
+ echo WT_I18N::translate('There are no Facts for this individual.');
}
-
- if (!$this->controller->indi->canDisplayDetails()) {
- print_privacy_error();
- } else {
- $indifacts = $this->controller->getIndiFacts();
- if (count($indifacts)==0) {
- echo WT_I18N::translate('There are no Facts for this individual.');
- }
- foreach ($indifacts as $fact) {
- if (in_array($fact->getTag(), WT_Gedcom_Tag::getReferenceFacts())) {
- print_fact($fact, $this->controller->indi);
- }
- $FACT_COUNT++;
+ foreach ($indifacts as $fact) {
+ if (in_array($fact->getTag(), WT_Gedcom_Tag::getReferenceFacts())) {
+ print_fact($fact, $controller->record);
}
+ $FACT_COUNT++;
}
echo '<tr><td><div id="hitcounter">';
diff --git a/modules_v3/family_group_report/module.php b/modules_v3/family_group_report/module.php index 0e7ef0fdbf..2983201c8b 100644 --- a/modules_v3/family_group_report/module.php +++ b/modules_v3/family_group_report/module.php @@ -50,12 +50,12 @@ class family_group_report_WT_Module extends WT_Module implements WT_Module_Repor public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/family_nav/module.php b/modules_v3/family_nav/module.php index be95e41a5a..8f872c9ce7 100644 --- a/modules_v3/family_nav/module.php +++ b/modules_v3/family_nav/module.php @@ -53,30 +53,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { // Implement WT_Module_Sidebar public function getSidebarContent() { - global $WT_IMAGES; - - $out = '<div id="sb_family_nav_content">'; - - if ($this->controller) { - $root = null; - if ($this->controller->pid) { - $root = WT_Person::getInstance($this->controller->pid); - } - else if ($this->controller->famid) { - $fam = WT_Family::getInstance($this->controller->famid); - if ($fam) $root = $fam->getHusband(); - if (!$root) $root = $fam->getWife(); - } - if ($root!=null) { - $this->controller = new WT_Controller_Individual(); - $this->controller->indi=$root; - $this->controller->pid=$root->getXref(); - $this->setController($this->controller); - $out .= $this->getTabContent(); - } - } - $out .= '</div>'; - return $out; + return '<div id="sb_family_nav_content">'.$this->getTabContent().'</div>'; } // Implement WT_Module_Sidebar @@ -87,6 +64,8 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { // TODO: This function isn't part of the WT_Module_Tab interface, as // this module no longer provides a tab. public function getTabContent() { + global $controller; + $out = ''; ob_start(); // ----------------------------------------------------------------------------- @@ -115,12 +94,12 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { global $WT_IMAGES, $spouselinks, $parentlinks, $TEXT_DIRECTION; $personcount=0; - $families = $this->controller->indi->getChildFamilies(); + $families = $controller->record->getChildFamilies(); //-- parent families ------------------------------------------------------------- foreach ($families as $famid=>$family) { - $label = $this->controller->indi->getChildFamilyLabel($family); - $people = $this->controller->buildFamilyList($family, "parents"); + $label = $controller->record->getChildFamilyLabel($family); + $people = $controller->buildFamilyList($family, "parents"); $styleadd = ""; ?> <tr> @@ -145,7 +124,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["husb"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["husb"]); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$people["husb"]->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$people['husb']->getHtmlUrl()."');\">"; echo $people["husb"]->getFullName(); @@ -169,7 +148,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["wife"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["wife"]); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$people["wife"]->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$people['wife']->getHtmlUrl()."');\">"; echo $people["wife"]->getFullName(); @@ -203,7 +182,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { } ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($child); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($child); ?> nam"> <?php if ($pid == $child->getXref()) { echo "<a class=\"famnav_link\" href=\"#\">"; @@ -226,9 +205,9 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { } //-- step parents ---------------------------------------------------------------- - foreach ($this->controller->indi->getChildStepFamilies() as $famid=>$family) { - $label = $this->controller->indi->getStepFamilyLabel($family); - $people = $this->controller->buildFamilyList($family, "step-parents"); + foreach ($controller->record->getChildStepFamilies() as $famid=>$family) { + $label = $controller->record->getStepFamilyLabel($family); + $people = $controller->buildFamilyList($family, "step-parents"); if ($people) { echo "<tr><td><br /></td><td></td></tr>"; } @@ -264,7 +243,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["husb"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["husb"]); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$people["husb"]->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$people['husb']->getHtmlUrl()."');\">"; echo $people["husb"]->getFullName(); @@ -297,7 +276,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["wife"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["wife"]); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$people["wife"]->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$people['wife']->getHtmlUrl()."');\">"; echo $people["wife"]->getFullName(); @@ -323,7 +302,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($child); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($child); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$child->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$child->getHtmlUrl()."');\">"; echo $child->getFullName(); @@ -339,7 +318,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { } //-- spouse and children -------------------------------------------------- - $families = $this->controller->indi->getSpouseFamilies(); + $families = $controller->record->getSpouseFamilies(); foreach ($families as $family) { echo "<tr><td><br /></td><td></td></tr>"; ?> @@ -354,8 +333,8 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { </tr> <?php //$personcount = 0; - $people = $this->controller->buildFamilyList($family, "spouse"); - if (isset($people["husb"]) && $this->controller->indi->equals($people["husb"])) { + $people = $controller->buildFamilyList($family, "spouse"); + if (isset($people["husb"]) && $controller->record->equals($people["husb"])) { $spousetag = 'WIFE'; } else { $spousetag = 'HUSB'; @@ -373,7 +352,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["husb"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["husb"]); ?> nam"> <?php if ($pid == $people["husb"]->getXref()) { echo "<a class=\"famnav_link\" href=\"#\">"; @@ -404,7 +383,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["wife"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["wife"]); ?> nam"> <?php if ($pid == $people["wife"]->getXref()) { echo "<a class=\"famnav_link\" href=\"#\">"; @@ -437,7 +416,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($child); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($child); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$child->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$child->getHtmlUrl()."');\">"; echo $child->getFullName(); @@ -452,9 +431,9 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { } //-- step children ---------------------------------------------------------------- - foreach ($this->controller->indi->getSpouseStepFamilies() as $famid=>$family) { + foreach ($controller->record->getSpouseStepFamilies() as $famid=>$family) { $label = $family->getFullName(); - $people = $this->controller->buildFamilyList($family, "step-children"); + $people = $controller->buildFamilyList($family, "step-children"); if ($people) { echo "<tr><td><br /></td><td></td></tr>"; } @@ -485,7 +464,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["husb"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["husb"]); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$people["husb"]->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$people['husb']->getHtmlUrl()."');\">"; echo $people["husb"]->getFullName(); @@ -512,7 +491,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($people["wife"]); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($people["wife"]); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$people["wife"]->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$people['wife']->getHtmlUrl()."');\">"; echo $people["wife"]->getFullName(); @@ -538,7 +517,7 @@ class family_nav_WT_Module extends WT_Module implements WT_Module_Sidebar { <td class="facts_label<?php echo $styleadd; ?>" nowrap="nowrap" style="width:75px;"> <?php echo $menu->getMenu(); ?> </td> - <td align="center" class="<?php echo $this->controller->getPersonStyle($child); ?> nam"> + <td align="center" class="<?php echo $controller->getPersonStyle($child); ?> nam"> <?php echo "<a class=\"famnav_link\" href=\"".$child->getHtmlUrl()."\" onclick=\"return familyNavLoad('".$child->getHtmlUrl()."');\">"; echo $child->getFullName(); diff --git a/modules_v3/googlemap/googlemap.php b/modules_v3/googlemap/googlemap.php index ead447ea01..049dfabc8e 100644 --- a/modules_v3/googlemap/googlemap.php +++ b/modules_v3/googlemap/googlemap.php @@ -558,7 +558,7 @@ function build_indiv_map($indifacts, $famids) { $gmarks = $markers; global $controller; - $pid=$controller->indi->getXref(); + $pid=$controller->record->getXref(); // === Include css and js files ============================================================ echo '<link type="text/css" href="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/css/wt_v3_googlemap.css" rel="stylesheet" />'; diff --git a/modules_v3/googlemap/module.php b/modules_v3/googlemap/module.php index 380d4d250a..ceb1b98329 100644 --- a/modules_v3/googlemap/module.php +++ b/modules_v3/googlemap/module.php @@ -98,7 +98,7 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu // Implement WT_Module_Tab public function getTabContent() { - global $SEARCH_SPIDER, $WT_IMAGES; + global $SEARCH_SPIDER, $WT_IMAGES, $controller; global $GOOGLEMAP_MAP_TYPE, $GOOGLEMAP_MIN_ZOOM, $GOOGLEMAP_MAX_ZOOM, $GEDCOM; global $GOOGLEMAP_XSIZE, $GOOGLEMAP_YSIZE, $SHOW_LIVING_NAMES; global $TEXT_DIRECTION, $GM_DEFAULT_TOP_VALUE, $GOOGLEMAP_COORD, $GOOGLEMAP_PH_CONTROLS; @@ -109,7 +109,7 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu require_once WT_ROOT.WT_MODULES_DIR.'googlemap/defaultconfig.php'; echo '<table border="0" width="100%"><tr><td>'; - if (!$this->controller->indi->canDisplayName()) { + if (!$controller->record->canDisplayName()) { echo '<table class="facts_table">'; echo '<tr><td class="facts_value">'; print_privacy_error(); @@ -140,13 +140,12 @@ class googlemap_WT_Module extends WT_Module implements WT_Module_Config, WT_Modu echo '<td valign="top" width="30%">'; echo '<div id="map_content">'; $famids = array(); - $families = $this->controller->indi->getSpouseFamilies(); + $families = $controller->record->getSpouseFamilies(); foreach ($families as $family) { $famids[] = $family->getXref(); } - $this->controller->indi->add_family_facts(false); -// create_indiv_buttons(); - build_indiv_map($this->controller->indi->getIndiFacts(), $famids); + $controller->record->add_family_facts(false); + build_indiv_map($controller->record->getIndiFacts(), $famids); echo '</div>'; echo '</td>'; echo '</tr></table>'; diff --git a/modules_v3/googlemap/pedigree_map.php b/modules_v3/googlemap/pedigree_map.php index ab241fa972..2a36491e43 100644 --- a/modules_v3/googlemap/pedigree_map.php +++ b/modules_v3/googlemap/pedigree_map.php @@ -41,8 +41,7 @@ global $PEDIGREE_GENERATIONS, $MAX_PEDIGREE_GENERATIONS, $ENABLE_AUTOCOMPLETE, $ $hideflags = safe_GET('hideflags'); $hidelines = safe_GET('hidelines'); -$controller = new WT_Controller_Pedigree(); -$controller->init(); +$controller=new WT_Controller_Pedigree(); // Default of 5 $clustersize = 5; @@ -283,5 +282,3 @@ echo "</div>"; <?php echo '<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>'; require_once WT_ROOT.WT_MODULES_DIR.'googlemap/wt_v3_pedigree_map.js.php'; - -print_footer(); diff --git a/modules_v3/individual_ext_report/module.php b/modules_v3/individual_ext_report/module.php index cbdba2a3bc..5af44efaf4 100644 --- a/modules_v3/individual_ext_report/module.php +++ b/modules_v3/individual_ext_report/module.php @@ -50,12 +50,12 @@ class individual_ext_report_WT_Module extends WT_Module implements WT_Module_Rep public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/individual_report/module.php b/modules_v3/individual_report/module.php index 59ac327bc1..3e05d2e993 100644 --- a/modules_v3/individual_report/module.php +++ b/modules_v3/individual_report/module.php @@ -50,12 +50,12 @@ class individual_report_WT_Module extends WT_Module implements WT_Module_Report public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/lightbox/album.php b/modules_v3/lightbox/album.php index 42e919e11a..b216882073 100644 --- a/modules_v3/lightbox/album.php +++ b/modules_v3/lightbox/album.php @@ -33,7 +33,6 @@ if (!defined('WT_WEBTREES')) { global $edit, $sort_i; $reorder=safe_get('reorder', '1', '0'); -$pid=$this->controller->indi->getXref(); require_once WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lightbox_print_media.php'; require_once WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lightbox_print_media_row.php'; @@ -76,12 +75,12 @@ if ($reorder==1) { </script> <form name="reorder_form" method="post" action="edit_interface.php"> <input type="hidden" name="action" value="al_reorder_media_update" /> - <input type="hidden" name="pid" value="<?php echo $pid; ?>" /> + <input type="hidden" name="pid" value="<?php echo $controller->record->getXref(); ?>" /> <input type="hidden" id="ord2" name="order2" value="" /> <center> <button type="submit" title="<?php echo WT_I18N::translate('Saves the sorted media to the database'); ?>" onclick="saveOrder();" ><?php echo WT_I18N::translate('Save'); ?></button> <button type="submit" title="<?php echo WT_I18N::translate('Reset to the original order'); ?>" onclick="document.reorder_form.action.value='al_reset_media_update'; document.reorder_form.submit();"><?php echo WT_I18N::translate('Reset'); ?></button> - <button type="button" title="<?php echo WT_I18N::translate('Quit and return'); ?>" onClick="location.href='<?php echo WT_SCRIPT_NAME, '?pid=', $pid, '#lightbox'; ?>'"><?php echo WT_I18N::translate('Cancel'); ?></button> + <button type="button" title="<?php echo WT_I18N::translate('Quit and return'); ?>" onClick="location.href='<?php echo WT_SCRIPT_NAME, '?pid=', $controller->record->getXref(), '#lightbox'; ?>'"><?php echo WT_I18N::translate('Cancel'); ?></button> <?php /* // Debug --------------------------------------------------------------------------- @@ -96,10 +95,10 @@ if ($reorder==1) { } echo '<table width="100%" cellpadding="0" border="0"><tr>'; echo '<td width="100%" valign="top" >'; -lightbox_print_media($pid, 0, true, 1); // map, painting, photo, tombstone) -lightbox_print_media($pid, 0, true, 2); // card, certificate, document, magazine, manuscript, newspaper -lightbox_print_media($pid, 0, true, 3); // electronic, fiche, film -lightbox_print_media($pid, 0, true, 4); // audio, book, coat, video, other -lightbox_print_media($pid, 0, true, 5); // footnotes +lightbox_print_media($controller->record->getXref(), 0, true, 1); // map, painting, photo, tombstone) +lightbox_print_media($controller->record->getXref(), 0, true, 2); // card, certificate, document, magazine, manuscript, newspaper +lightbox_print_media($controller->record->getXref(), 0, true, 3); // electronic, fiche, film +lightbox_print_media($controller->record->getXref(), 0, true, 4); // audio, book, coat, video, other +lightbox_print_media($controller->record->getXref(), 0, true, 5); // footnotes echo '</td>'; echo '</tr></table>'; diff --git a/modules_v3/lightbox/functions/lb_head.php b/modules_v3/lightbox/functions/lb_head.php index a1ccde80a2..ccdf674c5f 100644 --- a/modules_v3/lightbox/functions/lb_head.php +++ b/modules_v3/lightbox/functions/lb_head.php @@ -37,17 +37,17 @@ $reorder=safe_get('reorder', '1', '0'); <!-- function reorder_media() { var win02 = window.open( - 'edit_interface.php?action=reorder_media&pid=<?php echo $this->controller->indi->getXref(); ?>&currtab=album', 'win02', 'resizable=1, menubar=0, scrollbars=1, top=20, HEIGHT=840, WIDTH=450 '); + 'edit_interface.php?action=reorder_media&pid=<?php echo $controller->record->getXref(); ?>&currtab=album', 'win02', 'resizable=1, menubar=0, scrollbars=1, top=20, HEIGHT=840, WIDTH=450 '); if (window.focus) {win02.focus();} } function album_add() { win03 = window.open( - 'addmedia.php?action=showmediaform&linktoid=<?php echo $this->controller->indi->getXref(); ?>', 'win03', 'resizable=1, scrollbars=1, top=50, HEIGHT=780, WIDTH=600 '); + 'addmedia.php?action=showmediaform&linktoid=<?php echo $controller->record->getXref(); ?>', 'win03', 'resizable=1, scrollbars=1, top=50, HEIGHT=780, WIDTH=600 '); if (window.focus) {win03.focus();} } function album_link() { win04 = window.open( - 'inverselink.php?linktoid=<?php echo $this->controller->indi->getXref(); ?>&linkto=person', 'win04', 'resizable=1, scrollbars=1, top=50, HEIGHT=300, WIDTH=450 '); + 'inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&linkto=person', 'win04', 'resizable=1, scrollbars=1, top=50, HEIGHT=300, WIDTH=450 '); win04.focus() } --> diff --git a/modules_v3/lightbox/module.php b/modules_v3/lightbox/module.php index bf6b6dd0bb..8f3f055932 100644 --- a/modules_v3/lightbox/module.php +++ b/modules_v3/lightbox/module.php @@ -74,11 +74,13 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Config, WT_Modul // Implement WT_Module_Tab public function getTabContent() { + global $controller; + ob_start(); require WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_head.php'; $media_found = false; - if (!$this->controller->indi->canDisplayDetails()) { + if (!$controller->record->canDisplayDetails()) { echo '<table class="facts_table" cellpadding="0">'; echo '<tr><td class="facts_value">'; print_privacy_error(); @@ -112,9 +114,11 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Config, WT_Modul protected $mediaCount = null; private function get_media_count() { + global $controller; + if ($this->mediaCount===null) { - $ct = preg_match("/\d OBJE/", $this->controller->indi->getGedcomRecord()); - foreach ($this->controller->indi->getSpouseFamilies() as $sfam) + $ct = preg_match("/\d OBJE/", $controller->record->getGedcomRecord()); + foreach ($controller->record->getSpouseFamilies() as $sfam) $ct += preg_match("/\d OBJE/", $sfam->getGedcomRecord()); $this->mediaCount = $ct; } diff --git a/modules_v3/media/module.php b/modules_v3/media/module.php index 83c715d143..985e1d7ba1 100644 --- a/modules_v3/media/module.php +++ b/modules_v3/media/module.php @@ -58,7 +58,7 @@ class media_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function getTabContent() { - global $NAV_MEDIA; + global $NAV_MEDIA, $controller; ob_start(); // For Reorder media ------------------------------------ @@ -72,22 +72,22 @@ class media_WT_Module extends WT_Module implements WT_Module_Tab { <table class="facts_table"> <?php $media_found = false; - if (!$this->controller->indi->canDisplayDetails()) { + if (!$controller->record->canDisplayDetails()) { echo "<tr><td class=\"facts_value\">"; print_privacy_error(); echo "</td></tr>"; } else { - $media_found = print_main_media($this->controller->pid, 0, true); + $media_found = print_main_media($controller->record->getXref(), 0, true); if (!$media_found) echo "<tr><td id=\"no_tab4\" colspan=\"2\" class=\"facts_value\">".WT_I18N::translate('There are no media objects for this individual.')."</td></tr>"; //-- New Media link - if (WT_USER_CAN_EDIT && $this->controller->indi->canDisplayDetails() && get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { + if (WT_USER_CAN_EDIT && $controller->record->canDisplayDetails() && get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add media'), help_link('add_media'); ?></td> <td class="facts_value"> - <a href="javascript:;" onclick="window.open('addmedia.php?action=showmediaform&linktoid=<?php echo $this->controller->pid; ?>', '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); return false;"> <?php echo WT_I18N::translate('Add a new media object'); ?></a><br /> - <a href="javascript:;" onclick="window.open('inverselink.php?linktoid=<?php echo $this->controller->pid; ?>&linkto=person', '_blank', 'top=50,left=50,width=400,height=300,resizable=1,scrollbars=1'); return false;"><?php echo WT_I18N::translate('Link to an existing media object'); ?></a> + <a href="javascript:;" onclick="window.open('addmedia.php?action=showmediaform&linktoid=<?php echo $controller->record->getXref(); ?>', '_blank', 'top=50,left=50,width=600,height=500,resizable=1,scrollbars=1'); return false;"> <?php echo WT_I18N::translate('Add a new media object'); ?></a><br /> + <a href="javascript:;" onclick="window.open('inverselink.php?linktoid=<?php echo $controller->record->getXref(); ?>&linkto=person', '_blank', 'top=50,left=50,width=400,height=300,resizable=1,scrollbars=1'); return false;"><?php echo WT_I18N::translate('Link to an existing media object'); ?></a> </td> </tr> <?php @@ -105,9 +105,11 @@ class media_WT_Module extends WT_Module implements WT_Module_Tab { * @return int */ function get_media_count() { + global $controller; + if ($this->mediaCount===null) { - $ct = preg_match("/\d OBJE/", $this->controller->indi->getGedcomRecord()); - foreach ($this->controller->indi->getSpouseFamilies() as $sfam) + $ct = preg_match("/\d OBJE/", $controller->record->getGedcomRecord()); + foreach ($controller->record->getSpouseFamilies() as $sfam) $ct += preg_match("/\d OBJE/", $sfam->getGedcomRecord()); $this->mediaCount = $ct; } diff --git a/modules_v3/notes/module.php b/modules_v3/notes/module.php index 0e0a7dd15a..9b010b9678 100644 --- a/modules_v3/notes/module.php +++ b/modules_v3/notes/module.php @@ -48,13 +48,13 @@ class notes_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function getTabContent() { - global $FACT_COUNT, $SHOW_LEVEL2_NOTES, $NAV_NOTES; + global $FACT_COUNT, $SHOW_LEVEL2_NOTES, $NAV_NOTES, $controller; ob_start(); ?> <table class="facts_table"> <?php - if (!$this->controller->indi->canDisplayDetails()) { + if (!$controller->record->canDisplayDetails()) { echo "<tr><td class=\"facts_value\">"; print_privacy_error(); echo "</td></tr>"; @@ -68,44 +68,44 @@ class notes_WT_Module extends WT_Module implements WT_Module_Tab { </td> </tr> <?php - $globalfacts = $this->controller->getGlobalFacts(); + $globalfacts = $controller->getGlobalFacts(); foreach ($globalfacts as $key => $event) { $fact = $event->getTag(); if ($fact=="NAME") { - print_main_notes($event->getGedcomRecord(), 2, $this->controller->pid, $event->getLineNumber(), true); + print_main_notes($event->getGedcomRecord(), 2, $controller->record->getXref(), $event->getLineNumber(), true); } $FACT_COUNT++; } - $otherfacts = $this->controller->getOtherFacts(); + $otherfacts = $controller->getOtherFacts(); foreach ($otherfacts as $key => $event) { $fact = $event->getTag(); if ($fact=="NOTE") { - print_main_notes($event->getGedcomRecord(), 1, $this->controller->pid, $event->getLineNumber()); + print_main_notes($event->getGedcomRecord(), 1, $controller->record->getXref(), $event->getLineNumber()); } $FACT_COUNT++; } // 2nd to 5th level notes/sources - $this->controller->indi->add_family_facts(false); - foreach ($this->controller->getIndiFacts() as $key => $factrec) { + $controller->record->add_family_facts(false); + foreach ($controller->getIndiFacts() as $key => $factrec) { for ($i=2; $i<6; $i++) { - print_main_notes($factrec->getGedcomRecord(), $i, $this->controller->pid, $factrec->getLineNumber(), true); + print_main_notes($factrec->getGedcomRecord(), $i, $controller->record->getXref(), $factrec->getLineNumber(), true); } } if ($this->get_note_count()==0) echo "<tr><td id=\"no_tab2\" colspan=\"2\" class=\"facts_value\">".WT_I18N::translate('There are no Notes for this individual.')."</td></tr>"; //-- New Note Link - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add Note'), help_link('add_note'); ?></td> <td class="facts_value"><a href="javascript:;" - onclick="add_new_record('<?php echo $this->controller->pid; ?>','NOTE'); return false;"><?php echo WT_I18N::translate('Add a new note'); ?></a> + onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','NOTE'); return false;"><?php echo WT_I18N::translate('Add a new note'); ?></a> <br /> </td> </tr> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add Shared Note'), help_link('add_shared_note'); ?></td> <td class="facts_value"><a href="javascript:;" - onclick="add_new_record('<?php echo $this->controller->pid; ?>','SHARED_NOTE'); return false;"><?php echo WT_I18N::translate('Add a new shared note'); ?></a> + onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','SHARED_NOTE'); return false;"><?php echo WT_I18N::translate('Add a new shared note'); ?></a> <br /> </td> </tr> @@ -123,9 +123,11 @@ class notes_WT_Module extends WT_Module implements WT_Module_Tab { } function get_note_count() { + global $controller; + if ($this->noteCount===null) { - $ct = preg_match_all("/\d NOTE /", $this->controller->indi->getGedcomRecord(), $match, PREG_SET_ORDER); - foreach ($this->controller->indi->getSpouseFamilies() as $sfam) + $ct = preg_match_all("/\d NOTE /", $controller->record->getGedcomRecord(), $match, PREG_SET_ORDER); + foreach ($controller->record->getSpouseFamilies() as $sfam) $ct += preg_match("/\d NOTE /", $sfam->getGedcomRecord()); $this->noteCount = $ct; } diff --git a/modules_v3/pedigree_report/module.php b/modules_v3/pedigree_report/module.php index 0ab20838de..e2296cedb0 100644 --- a/modules_v3/pedigree_report/module.php +++ b/modules_v3/pedigree_report/module.php @@ -50,12 +50,12 @@ class pedigree_report_WT_Module extends WT_Module implements WT_Module_Report { public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/personal_facts/module.php b/modules_v3/personal_facts/module.php index 0ae372e401..ef26a60260 100644 --- a/modules_v3/personal_facts/module.php +++ b/modules_v3/personal_facts/module.php @@ -51,33 +51,33 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab
public function getTabContent() {
- global $FACT_COUNT, $EXPAND_RELATIVES_EVENTS;
+ global $FACT_COUNT, $EXPAND_RELATIVES_EVENTS, $controller;
/*if (isset($_COOKIE['row_rela'])) $EXPAND_RELATIVES_EVENTS = ($_COOKIE['row_rela']);
if (isset($_COOKIE['row_histo'])) $EXPAND_HISTO_EVENTS = ($_COOKIE['row_histo']);
else*/ $EXPAND_HISTO_EVENTS = false;
//-- only need to add family facts on this tab
- if (!isset($this->controller->skipFamilyFacts)) {
- $this->controller->indi->add_family_facts();
+ if (!isset($controller->skipFamilyFacts)) {
+ $controller->record->add_family_facts();
}
ob_start();
?>
<table class="facts_table" style="margin-top:-2px;" cellpadding="0">
- <?php if (!$this->controller->indi->canDisplayDetails()) {
+ <?php if (!$controller->record->canDisplayDetails()) {
echo '<tr><td class="facts_value" colspan="2">';
print_privacy_error();
echo '</td></tr>';
} else {
- $indifacts = $this->controller->getIndiFacts();
+ $indifacts = $controller->getIndiFacts();
if (count($indifacts)==0) { ?>
<tr>
<td id="no_tab1" colspan="2" class="facts_value"><?php echo WT_I18N::translate('There are no Facts for this individual.'); ?>
</td>
</tr>
<?php }
- if (!isset($this->controller->skipFamilyFacts)) {
+ if (!isset($controller->skipFamilyFacts)) {
?>
<tr id="row_top">
<td colspan="2" class="descriptionbox rela">
@@ -93,25 +93,25 @@ class personal_facts_WT_Module extends WT_Module implements WT_Module_Tab { }
$yetdied=false;
foreach ($indifacts as $fact) {
- if (strstr(WT_EVENTS_DEAT, $fact->getTag()) && $fact->getParentObject()->getXref()==$this->controller->indi->getXref()) {
+ if (strstr(WT_EVENTS_DEAT, $fact->getTag()) && $fact->getParentObject()->getXref()==$controller->record->getXref()) {
$yetdied = true;
}
if (!is_null($fact->getFamilyId())) {
if (!$yetdied) {
- print_fact($fact, $this->controller->indi);
+ print_fact($fact, $controller->record);
}
} else {
//$reftags = array ('CHAN', 'IDNO', 'RFN', 'AFN', 'REFN', 'RIN', '_UID');// list of tags used in "Extra information" sidebar module
if (!in_array($fact->getTag(), WT_Gedcom_Tag::getReferenceFacts()) || !array_key_exists('extra_info', WT_Module::getActiveSidebars())) {
- print_fact($fact, $this->controller->indi);
+ print_fact($fact, $controller->record);
}
}
$FACT_COUNT++;
}
}
//-- new fact link
- if ($this->controller->indi->canEdit()) {
- print_add_new_fact($this->controller->pid, $indifacts, 'INDI');
+ if ($controller->record->canEdit()) {
+ print_add_new_fact($controller->record->getXref(), $indifacts, 'INDI');
}
echo '</table><br />';
echo WT_JS_START;
diff --git a/modules_v3/relative_ext_report/module.php b/modules_v3/relative_ext_report/module.php index 9bb61237a6..b371623983 100644 --- a/modules_v3/relative_ext_report/module.php +++ b/modules_v3/relative_ext_report/module.php @@ -50,12 +50,12 @@ class relative_ext_report_WT_Module extends WT_Module implements WT_Module_Repor public function getReportMenus() { global $controller; - if ($controller instanceof WT_Controller_Family) { + if ($controller instanceof WT_Controller_Family && $controller->record instanceof WT_Family) { // We are on a family page - $pid='&famid='.$controller->famid; - } elseif ($controller instanceof WT_Controller_Individual) { + $pid='&famid='.$controller->record->getXref(); + } elseif ($controller instanceof WT_Controller_Individual && $controller->record instanceof WT_Individual) { // We are on an individual page - $pid='&pid='.$controller->pid; + $pid='&pid='.$controller->record->getXref(); } elseif ($controller && isset($controller->rootid)) { // We are on a chart page $pid='&pid='.$controller->rootid; diff --git a/modules_v3/relatives/module.php b/modules_v3/relatives/module.php index c39a51df42..71c977d034 100644 --- a/modules_v3/relatives/module.php +++ b/modules_v3/relatives/module.php @@ -69,7 +69,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { * @return html table rows */ function printParentsRows($family, $people, $type) { - global $personcount, $WT_IMAGES, $SHOW_PEDIGREE_PLACES; + global $personcount, $WT_IMAGES, $SHOW_PEDIGREE_PLACES, $controller; $elderdate = ""; //-- new father/husband @@ -79,7 +79,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_labelblue"><?php echo $people["newhusb"]->getLabel(); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($people["newhusb"]); ?>"> + <td class="<?php echo $controller->getPersonStyle($people["newhusb"]); ?>"> <?php print_pedigree_person($people["newhusb"], 2, 0, $personcount++); ?> </td> </tr> @@ -91,7 +91,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_label<?php echo $styleadd; ?>"><?php echo $people["husb"]->getLabel(); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($people["husb"]); ?>"> + <td class="<?php echo $controller->getPersonStyle($people["husb"]); ?>"> <?php print_pedigree_person($people["husb"], 2, 0, $personcount++); ?> </td> </tr> @@ -100,18 +100,18 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { } //-- missing father if ($type=="parents" && !isset($people["husb"]) && !isset($people["newhusb"])) { - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add a new father'); ?></td> - <td class="facts_value"><a href="javascript <?php echo WT_I18N::translate('Add a new father'); ?>" onclick="return addnewparentfamily('<?php echo $this->controller->pid; ?>', 'HUSB', '<?php echo $family->getXref(); ?>');"><?php echo WT_I18N::translate('Add a new father'); ?></a><?php echo help_link('edit_add_parent'); ?></td> + <td class="facts_value"><a href="javascript <?php echo WT_I18N::translate('Add a new father'); ?>" onclick="return addnewparentfamily('<?php echo $controller->record->getXref(); ?>', 'HUSB', '<?php echo $family->getXref(); ?>');"><?php echo WT_I18N::translate('Add a new father'); ?></a><?php echo help_link('edit_add_parent'); ?></td> </tr> <?php } } //-- missing husband if ($type=="spouse" && !isset($people["husb"]) && !isset($people["newhusb"])) { - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add husband'); ?></td> @@ -127,7 +127,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_labelblue"><?php echo $people["newwife"]->getLabel($elderdate); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($people["newwife"]); ?>"> + <td class="<?php echo $controller->getPersonStyle($people["newwife"]); ?>"> <?php print_pedigree_person($people["newwife"], 2, 0, $personcount++); ?> </td> </tr> @@ -138,7 +138,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_label<?php echo $styleadd; ?>"><?php echo $people["wife"]->getLabel($elderdate); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($people["wife"]); ?>"> + <td class="<?php echo $controller->getPersonStyle($people["wife"]); ?>"> <?php print_pedigree_person($people["wife"], 2, 0, $personcount++); ?> </td> </tr> @@ -146,18 +146,18 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { } //-- missing mother if ($type=="parents" && !isset($people["wife"]) && !isset($people["newwife"])) { - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add a new mother'); ?></td> - <td class="facts_value"><a href="javascript:;" onclick="return addnewparentfamily('<?php echo $this->controller->pid; ?>', 'WIFE', '<?php echo $family->getXref(); ?>');"><?php echo WT_I18N::translate('Add a new mother'); ?></a><?php echo help_link('edit_add_parent'); ?></td> + <td class="facts_value"><a href="javascript:;" onclick="return addnewparentfamily('<?php echo $controller->record->getXref(); ?>', 'WIFE', '<?php echo $family->getXref(); ?>');"><?php echo WT_I18N::translate('Add a new mother'); ?></a><?php echo help_link('edit_add_parent'); ?></td> </tr> <?php } } //-- missing wife if ($type=="spouse" && !isset($people["wife"]) && !isset($people["newwife"])) { - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add wife'); ?></td> @@ -232,7 +232,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { if (empty($wife) && !empty($husb)) echo WT_Gedcom_Tag::getLabel('_NMAR', $husb); else if (empty($husb) && !empty($wife)) echo WT_Gedcom_Tag::getLabel('_NMAR', $wife); else echo WT_Gedcom_Tag::getLabel('_NMAR'); - } else if ($family->getMarriageRecord()=="" && $this->controller->indi->canEdit()) { + } else if ($family->getMarriageRecord()=="" && $controller->record->canEdit()) { echo "<a href=\"#\" onclick=\"return add_new_record('".$famid."', 'MARR');\">".WT_I18N::translate('Add marriage details')."</a>"; } else { $factdetail = explode(' ', trim($family->getMarriageRecord())); @@ -261,7 +261,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { * @return html table rows */ function printChildrenRows($family, $people, $type) { - global $personcount, $WT_IMAGES; + global $personcount, $WT_IMAGES, $controller; $elderdate = $family->getMarriageDate(); $key=0; @@ -271,7 +271,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_label<?php echo $styleadd; ?>"><?php if ($styleadd=="red") echo $child->getLabel(); else echo $child->getLabel($elderdate, $key+1); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($child); ?>"> + <td class="<?php echo $controller->getPersonStyle($child); ?>"> <?php print_pedigree_person($child, 2, 0, $personcount++); ?> @@ -287,7 +287,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_label<?php echo $styleadd; ?>"><?php if ($styleadd=="red") echo $child->getLabel(); else echo $child->getLabel($elderdate, $key+1); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($child); ?>"> + <td class="<?php echo $controller->getPersonStyle($child); ?>"> <?php print_pedigree_person($child, 2, 0, $personcount++); ?> @@ -303,7 +303,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { ?> <tr> <td class="facts_label<?php echo $styleadd; ?>"><?php if ($styleadd=="red") echo $child->getLabel(); else echo $child->getLabel($elderdate, $key+1); ?></td> - <td class="<?php echo $this->controller->getPersonStyle($child); ?>"> + <td class="<?php echo $controller->getPersonStyle($child); ?>"> <?php print_pedigree_person($child, 2, 0, $personcount++); ?> @@ -313,7 +313,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { $elderdate = $child->getBirthDate(); ++$key; } - if (isset($family) && $this->controller->indi->canEdit()) { + if (isset($family) && $controller->record->canEdit()) { if ($type == "spouse") { $child_u = WT_I18N::translate('Add a son or daughter'); $child_m = WT_I18N::translate('son'); @@ -351,7 +351,7 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function getTabContent() { - global $WT_IMAGES, $SHOW_AGE_DIFF, $GEDCOM, $ABBREVIATE_CHART_LABELS, $show_full, $personcount; + global $WT_IMAGES, $SHOW_AGE_DIFF, $GEDCOM, $ABBREVIATE_CHART_LABELS, $show_full, $personcount, $controller; if (isset($show_full)) $saved_show_full = $show_full; // We always want to see full details here $show_full = 1; @@ -367,16 +367,16 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { </td></tr></table> <?php $personcount=0; - $families = $this->controller->indi->getChildFamilies(); + $families = $controller->record->getChildFamilies(); if (count($families)==0) { - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <table class="facts_table"> <tr> - <td class="facts_value"><a href="javascript:;" onclick="return addnewparent('<?php echo $this->controller->pid; ?>', 'HUSB');"><?php echo WT_I18N::translate('Add a new father'); ?></a><?php echo help_link('edit_add_parent'); ?></td> + <td class="facts_value"><a href="javascript:;" onclick="return addnewparent('<?php echo $controller->record->getXref(); ?>', 'HUSB');"><?php echo WT_I18N::translate('Add a new father'); ?></a><?php echo help_link('edit_add_parent'); ?></td> </tr> <tr> - <td class="facts_value"><a href="javascript:;" onclick="return addnewparent('<?php echo $this->controller->pid; ?>', 'WIFE');"><?php echo WT_I18N::translate('Add a new mother'); ?></a><?php echo help_link('edit_add_parent'); ?></td> + <td class="facts_value"><a href="javascript:;" onclick="return addnewparent('<?php echo $controller->record->getXref(); ?>', 'WIFE');"><?php echo WT_I18N::translate('Add a new mother'); ?></a><?php echo help_link('edit_add_parent'); ?></td> </tr> </table> <?php @@ -385,8 +385,8 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { // parents foreach ($families as $family) { - $people = $this->controller->buildFamilyList($family, "parents"); - $this->printFamilyHeader($family->getHtmlUrl(), $this->controller->indi->getChildFamilyLabel($family)); + $people = $controller->buildFamilyList($family, "parents"); + $this->printFamilyHeader($family->getHtmlUrl(), $controller->record->getChildFamilyLabel($family)); echo '<table class="facts_table">'; $this->printParentsRows($family, $people, "parents"); $this->printChildrenRows($family, $people, "parents"); @@ -394,9 +394,9 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { } // step-parents - foreach ($this->controller->indi->getChildStepFamilies() as $family) { - $people = $this->controller->buildFamilyList($family, "step-parents"); - $this->printFamilyHeader($family->getHtmlUrl(), $this->controller->indi->getStepFamilyLabel($family)); + foreach ($controller->record->getChildStepFamilies() as $family) { + $people = $controller->buildFamilyList($family, "step-parents"); + $this->printFamilyHeader($family->getHtmlUrl(), $controller->record->getStepFamilyLabel($family)); echo '<table class="facts_table">'; $this->printParentsRows($family, $people, "parents"); $this->printChildrenRows($family, $people, "parents"); @@ -404,10 +404,10 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { } // spouses - $families = $this->controller->indi->getSpouseFamilies(); + $families = $controller->record->getSpouseFamilies(); foreach ($families as $family) { - $people = $this->controller->buildFamilyList($family, "spouse"); - $this->printFamilyHeader($family->getHtmlUrl(), $this->controller->indi->getSpouseFamilyLabel($family)); + $people = $controller->buildFamilyList($family, "spouse"); + $this->printFamilyHeader($family->getHtmlUrl(), $controller->record->getSpouseFamilyLabel($family)); echo '<table class="facts_table">'; $this->printParentsRows($family, $people, "spouse"); $this->printChildrenRows($family, $people, "spouse"); @@ -415,8 +415,8 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { } // step-children - foreach ($this->controller->indi->getSpouseStepFamilies() as $family) { - $people = $this->controller->buildFamilyList($family, "step-children"); + foreach ($controller->record->getSpouseStepFamilies() as $family) { + $people = $controller->buildFamilyList($family, "step-children"); $this->printFamilyHeader($family->getHtmlUrl(), $family->getFullName()); echo '<table class="facts_table">'; $this->printParentsRows($family, $people, "spouse"); @@ -428,67 +428,67 @@ class relatives_WT_Module extends WT_Module implements WT_Module_Tab { echo WT_JS_START, "jQuery('DIV.elderdate').toggle();", WT_JS_END; } - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <br/><table class="facts_table"> <?php if (count($families)>1) { ?> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return reorder_families('<?php echo $this->controller->pid; ?>');"><?php echo WT_I18N::translate('Reorder families'); ?></a> + <a href="javascript:;" onclick="return reorder_families('<?php echo $controller->record->getXref(); ?>');"><?php echo WT_I18N::translate('Reorder families'); ?></a> <?php echo help_link('reorder_families'); ?> </td> </tr> <?php } ?> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return add_famc('<?php echo $this->controller->pid; ?>');"><?php echo WT_I18N::translate('Link this person to an existing family as a child'); ?></a> + <a href="javascript:;" onclick="return add_famc('<?php echo $controller->record->getXref(); ?>');"><?php echo WT_I18N::translate('Link this person to an existing family as a child'); ?></a> <?php echo help_link('link_child'); ?> </td> </tr> - <?php if ($this->controller->indi->getSex()!="F") { ?> + <?php if ($controller->record->getSex()!="F") { ?> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return addspouse('<?php echo $this->controller->pid; ?>','WIFE');"><?php echo WT_I18N::translate('Add a new wife'); ?></a> + <a href="javascript:;" onclick="return addspouse('<?php echo $controller->record->getXref(); ?>','WIFE');"><?php echo WT_I18N::translate('Add a new wife'); ?></a> <?php echo help_link('add_wife'); ?> </td> </tr> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return linkspouse('<?php echo $this->controller->pid; ?>','WIFE');"><?php echo WT_I18N::translate('Add a wife using an existing person'); ?></a> + <a href="javascript:;" onclick="return linkspouse('<?php echo $controller->record->getXref(); ?>','WIFE');"><?php echo WT_I18N::translate('Add a wife using an existing person'); ?></a> <?php echo help_link('link_new_wife'); ?> </td> </tr> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return add_fams('<?php echo $this->controller->pid; ?>','HUSB');"><?php echo WT_I18N::translate('Link this person to an existing family as a husband'); ?></a> + <a href="javascript:;" onclick="return add_fams('<?php echo $controller->record->getXref(); ?>','HUSB');"><?php echo WT_I18N::translate('Link this person to an existing family as a husband'); ?></a> <?php echo help_link('link_new_husb'); ?> </td> </tr> <?php } - if ($this->controller->indi->getSex()!="M") { ?> + if ($controller->record->getSex()!="M") { ?> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return addspouse('<?php echo $this->controller->pid; ?>','HUSB');"><?php echo WT_I18N::translate('Add a new husband'); ?></a> + <a href="javascript:;" onclick="return addspouse('<?php echo $controller->record->getXref(); ?>','HUSB');"><?php echo WT_I18N::translate('Add a new husband'); ?></a> <?php echo help_link('add_husband'); ?> </td> </tr> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return linkspouse('<?php echo $this->controller->pid; ?>','HUSB');"><?php echo WT_I18N::translate('Add a husband using an existing person'); ?></a> + <a href="javascript:;" onclick="return linkspouse('<?php echo $controller->record->getXref(); ?>','HUSB');"><?php echo WT_I18N::translate('Add a husband using an existing person'); ?></a> <?php echo help_link('link_husband'); ?> </td> </tr> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return add_fams('<?php echo $this->controller->pid; ?>','WIFE');"><?php echo WT_I18N::translate('Link this person to an existing family as a wife'); ?></a> + <a href="javascript:;" onclick="return add_fams('<?php echo $controller->record->getXref(); ?>','WIFE');"><?php echo WT_I18N::translate('Link this person to an existing family as a wife'); ?></a> <?php echo help_link('link_wife'); ?> </td> </tr> <?php } ?> <tr> <td class="facts_value"> - <a href="javascript:;" onclick="return addopfchild('<?php echo $this->controller->pid; ?>','U');"><?php echo WT_I18N::translate('Add a child to create a one-parent family'); ?></a> + <a href="javascript:;" onclick="return addopfchild('<?php echo $controller->record->getXref(); ?>','U');"><?php echo WT_I18N::translate('Add a child to create a one-parent family'); ?></a> <?php echo help_link('add_opf_child'); ?> </td> </tr> diff --git a/modules_v3/sources_tab/module.php b/modules_v3/sources_tab/module.php index 4832c6f6d3..7c64deac2f 100644 --- a/modules_v3/sources_tab/module.php +++ b/modules_v3/sources_tab/module.php @@ -48,13 +48,13 @@ class sources_tab_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function getTabContent() { - global $FACT_COUNT, $SHOW_LEVEL2_NOTES, $NAV_SOURCES; + global $FACT_COUNT, $SHOW_LEVEL2_NOTES, $NAV_SOURCES, $controller; ob_start(); ?> <table class="facts_table"> <?php - if (!$this->controller->indi->canDisplayDetails()) { + if (!$controller->record->canDisplayDetails()) { echo "<tr><td class=\"facts_value\">"; print_privacy_error(); echo "</td></tr>"; @@ -67,25 +67,25 @@ class sources_tab_WT_Module extends WT_Module implements WT_Module_Tab { </td> </tr> <?php - $otheritems = $this->controller->getOtherFacts(); + $otheritems = $controller->getOtherFacts(); foreach ($otheritems as $key => $event) { - if ($event->getTag()=="SOUR") print_main_sources($event->getGedcomRecord(), 1, $this->controller->pid, $event->getLineNumber()); + if ($event->getTag()=="SOUR") print_main_sources($event->getGedcomRecord(), 1, $controller->record->getXref(), $event->getLineNumber()); $FACT_COUNT++; } } // 2nd level sources [ 1712181 ] - $this->controller->indi->add_family_facts(false); - foreach ($this->controller->getIndiFacts() as $key => $factrec) { - print_main_sources($factrec->getGedcomRecord(), 2, $this->controller->pid, $factrec->getLineNumber(), true); + $controller->record->add_family_facts(false); + foreach ($controller->getIndiFacts() as $key => $factrec) { + print_main_sources($factrec->getGedcomRecord(), 2, $controller->record->getXref(), $factrec->getLineNumber(), true); } if ($this->get_source_count()==0) echo "<tr><td id=\"no_tab3\" colspan=\"2\" class=\"facts_value\">".WT_I18N::translate('There are no Source citations for this individual.')."</td></tr>"; //-- New Source Link - if ($this->controller->indi->canEdit()) { + if ($controller->record->canEdit()) { ?> <tr> <td class="facts_label"><?php echo WT_I18N::translate('Add Source Citation'), help_link('add_source'); ?></td> <td class="facts_value"> - <a href="javascript:;" onclick="add_new_record('<?php echo $this->controller->pid; ?>','SOUR'); return false;"><?php echo WT_I18N::translate('Add a new source citation'); ?></a> + <a href="javascript:;" onclick="add_new_record('<?php echo $controller->record->getXref(); ?>','SOUR'); return false;"><?php echo WT_I18N::translate('Add a new source citation'); ?></a> <br /> </td> </tr> @@ -102,9 +102,11 @@ class sources_tab_WT_Module extends WT_Module implements WT_Module_Tab { } function get_source_count() { + global $controller; + if ($this->sourceCount===null) { - $ct = preg_match_all("/\d SOUR @(.*)@/", $this->controller->indi->getGedcomRecord(), $match, PREG_SET_ORDER); - foreach ($this->controller->indi->getSpouseFamilies() as $sfam) + $ct = preg_match_all("/\d SOUR @(.*)@/", $controller->record->getGedcomRecord(), $match, PREG_SET_ORDER); + foreach ($controller->record->getSpouseFamilies() as $sfam) $ct += preg_match("/\d SOUR /", $sfam->getGedcomRecord()); $this->sourceCount = $ct; } diff --git a/modules_v3/stories/module.php b/modules_v3/stories/module.php index 6dad53afc9..b7b12e7546 100644 --- a/modules_v3/stories/module.php +++ b/modules_v3/stories/module.php @@ -95,6 +95,8 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ // Implement class WT_Module_Tab public function getTabContent() { + global $controller; + $block_ids= WT_DB::prepare( "SELECT block_id". @@ -104,7 +106,7 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ " AND gedcom_id=?" )->execute(array( $this->getName(), - $xref=$this->controller->indi->getXref(), + $xref=$controller->record->getXref(), WT_GED_ID ))->fetchOneColumn(); @@ -123,7 +125,7 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ } if (WT_USER_GEDCOM_ADMIN && !$html) { $html.='<div class="news_title center">'.$this->getTitle().'</div>'; - $html.='<div><a href="module.php?mod='.$this->getName().'&mod_action=admin_edit&xref='.$this->controller->indi->getXref().'">'; + $html.='<div><a href="module.php?mod='.$this->getName().'&mod_action=admin_edit&xref='.$controller->record->getXref().'">'; $html.=WT_I18N::translate('Add story').'</a>'.help_link('add_story', $this->getName()).'</div><br />'; } return $html; @@ -136,6 +138,8 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ // Implement WT_Module_Tab public function isGrayedOut() { + global $controller; + $count_of_stories= WT_DB::prepare( "SELECT COUNT(block_id)". @@ -145,7 +149,7 @@ class stories_WT_Module extends WT_Module implements WT_Module_Block, WT_Module_ " AND gedcom_id=?" )->execute(array( $this->getName(), - $xref=$this->controller->indi->getXref(), + $xref=$controller->record->getXref(), WT_GED_ID ))->fetchOne(); diff --git a/modules_v3/tree/module.php b/modules_v3/tree/module.php index e33b5f9675..f945aff4f7 100644 --- a/modules_v3/tree/module.php +++ b/modules_v3/tree/module.php @@ -71,9 +71,11 @@ class tree_WT_Module extends WT_Module implements WT_Module_Tab { // Implement WT_Module_Tab public function getTabContent() { + global $controller; + require_once WT_MODULES_DIR.$this->getName().'/class_treeview.php'; $tv = new TreeView('tvTab'); - $r = $tv->drawViewport($this->controller->pid, 3, $this->style); + $r = $tv->drawViewport($controller->record->getXref(), 3, $this->style); return $r; } @@ -29,18 +29,17 @@ require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_print_lists.php'; $controller=new WT_Controller_Note(); -$controller->init(); -if ($controller->note && $controller->note->canDisplayDetails()) { +if ($controller->record && $controller->record->canDisplayDetails()) { print_header($controller->getPageTitle()); - if ($controller->note->isMarkedDeleted()) { + if ($controller->record->isMarkedDeleted()) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This note has been deleted. You should review the deletion and then %1$s or %2$s it.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->note->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->note->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -51,14 +50,14 @@ if ($controller->note && $controller->note->canDisplayDetails()) { ' ', help_link('pending_changes'), '</p>'; } - } elseif (find_updated_record($controller->note->getXref(), WT_GED_ID)!==null) { + } elseif (find_updated_record($controller->record->getXref(), WT_GED_ID)!==null) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This note has been edited. You should review the changes and then %1$s or %2$s them.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->note->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->note->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -71,27 +70,24 @@ if ($controller->note && $controller->note->canDisplayDetails()) { } } } else { - header('HTTP/1.0 403 Forbidden'); - print_header(WT_I18N::translate('Note')); + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); + print_header($controller->getPageTitle()); echo '<p class="ui-state-error">', WT_I18N::translate('This note does not exist or you do not have permission to view it.'), '</p>'; print_footer(); exit; } -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - if (WT_USE_LIGHTBOX) { require WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_call_js.php'; } -$linkToID=$controller->nid; // Tell addmedia.php what to link to +$linkToID=$controller->record->getXref(); // Tell addmedia.php what to link to echo WT_JS_START; echo 'function show_gedcom_record() {'; -echo ' var recwin=window.open("gedrecord.php?pid=', $controller->note->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; +echo ' var recwin=window.open("gedrecord.php?pid=', $controller->record->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; echo '}'; -echo 'function showchanges() { window.location="', $controller->note->getRawUrl(), '"; }'; +echo 'function showchanges() { window.location="', $controller->record->getRawUrl(), '"; }'; echo 'function edit_note() {'; echo ' var win04 = window.open("edit_interface.php?action=editnote&pid=', $linkToID, '", "win04", "top=70, left=70, width=620, height=500, resizable=1, scrollbars=1");'; echo ' if (window.focus) {win04.focus();}'; @@ -104,27 +100,27 @@ echo '}'; echo WT_JS_END; echo '<div id="note-details">'; -echo '<h2>', $controller->note->getFullName(), '</h2>'; +echo '<h2>', $controller->record->getFullName(), '</h2>'; echo '<div id="note-tabs"> <ul> <li><a href="#note-edit"><span>', WT_I18N::translate('Details'), '</span></a></li>'; - if ($controller->note->countLinkedIndividuals()) { + if ($controller->record->countLinkedIndividuals()) { echo '<li><a href="#indi-note"><span id="indisource">', WT_I18N::translate('Individuals'), '</span></a></li>'; } - if ($controller->note->countLinkedFamilies()) { + if ($controller->record->countLinkedFamilies()) { echo '<li><a href="#fam-note"><span id="famsource">', WT_I18N::translate('Families'), '</span></a></li>'; } - if ($controller->note->countLinkedMedia()) { + if ($controller->record->countLinkedMedia()) { echo '<li><a href="#media-note"><span id="mediasource">', WT_I18N::translate('Media objects'), '</span></a></li>'; } - if ($controller->note->countLinkedSources()) { + if ($controller->record->countLinkedSources()) { echo '<li><a href="#source-note"><span id="notesource">', WT_I18N::translate('Sources'), '</span></a></li>'; } echo '</ul>'; // Shared Note details --------------------- - $noterec=$controller->note->getGedcomRecord(); - preg_match("/0 @{$controller->nid}@ NOTE(.*)/", $noterec, $n1match); + $noterec=$controller->record->getGedcomRecord(); + preg_match("/0 @".$controller->record->getXref()."@ NOTE(.*)/", $noterec, $n1match); $note = print_note_record("<br />".$n1match[1], 1, $noterec, false, true, true); echo '<div id="note-edit">'; @@ -146,43 +142,43 @@ echo '<div id="note-tabs"> echo "<br />"; echo "</td></tr>"; - $notefacts=$controller->note->getFacts(); + $notefacts=$controller->record->getFacts(); foreach ($notefacts as $fact) { if ($fact->getTag()!='CONT') { - print_fact($fact, $controller->note); + print_fact($fact, $controller->record); } } // Print media - print_main_media($controller->nid); + print_main_media($controller->record->getXref()); // new fact link - if ($controller->note->canEdit()) { - print_add_new_fact($controller->nid, $notefacts, 'NOTE'); + if ($controller->record->canEdit()) { + print_add_new_fact($controller->record->getXref(), $notefacts, 'NOTE'); } echo '</table> </div>'; // close "note-edit" // Individuals linked to this shared note - if ($controller->note->countLinkedIndividuals()) { + if ($controller->record->countLinkedIndividuals()) { echo '<div id="indi-note">'; - print_indi_table($controller->note->fetchLinkedIndividuals(), $controller->note->getFullName()); + print_indi_table($controller->record->fetchLinkedIndividuals(), $controller->record->getFullName()); echo '</div>'; //close "indi-note" } // Families linked to this shared note - if ($controller->note->countLinkedFamilies()) { + if ($controller->record->countLinkedFamilies()) { echo '<div id="fam-note">'; - print_fam_table($controller->note->fetchLinkedFamilies(), $controller->note->getFullName()); + print_fam_table($controller->record->fetchLinkedFamilies(), $controller->record->getFullName()); echo '</div>'; //close "fam-note" } // Media Items linked to this shared note - if ($controller->note->countLinkedMedia()) { + if ($controller->record->countLinkedMedia()) { echo '<div id="media-note">'; - print_media_table($controller->note->fetchLinkedMedia(), $controller->note->getFullName()); + print_media_table($controller->record->fetchLinkedMedia(), $controller->record->getFullName()); echo '</div>'; //close "media-note" } // Sources linked to this shared note - if ($controller->note->countLinkedSources()) { + if ($controller->record->countLinkedSources()) { echo '<div id="source-note">'; - print_sour_table($controller->note->fetchLinkedSources(), $controller->note->getFullName()); + print_sour_table($controller->record->fetchLinkedSources(), $controller->record->getFullName()); echo '</div>'; //close "source-note" } echo '</div>'; //close div "note-tabs" diff --git a/notelist.php b/notelist.php index 895db106ba..c4046817df 100644 --- a/notelist.php +++ b/notelist.php @@ -1,31 +1,27 @@ <?php -/** - * Parses gedcom file and displays a list of the shared notes in the file. - * - * webtrees: Web based Family History software - * Copyright (C) 2010 webtrees development team. - * - * Derived from PhpGedView - * Copyright (C) 2009 PGV Development Team. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @version $Id$ - * @package webtrees - * @subpackage Lists - */ +// Parses gedcom file and displays a list of the shared notes in the file. +// +// webtrees: Web based Family History software +// Copyright (C) 2011 webtrees development team. +// +// Derived from PhpGedView +// Copyright (C) 2009 PGV Development Team. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ define('WT_SCRIPT_NAME', 'notelist.php'); require './includes/session.php'; @@ -36,4 +32,3 @@ echo '<div class="center"><h2>', WT_I18N::translate('Shared notes'), '</h2>'; print_note_table(get_note_list(WT_GED_ID)); echo '</div>'; print_footer(); -?> diff --git a/pedigree.php b/pedigree.php index 2854696905..8c826d62c4 100644 --- a/pedigree.php +++ b/pedigree.php @@ -30,10 +30,8 @@ define('WT_SCRIPT_NAME', 'pedigree.php'); require './includes/session.php'; require WT_ROOT.'includes/functions/functions_edit.php'; -$controller = new WT_Controller_Pedigree(); -$controller->init(); - -print_header(/* I18N: %s is a person's name */ WT_I18N::translate('Pedigree tree of %s', $controller->name)); +$controller=new WT_Controller_Pedigree(); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; @@ -428,5 +426,3 @@ $maxyoffset+=30; content_div.style.height = <?php echo $maxyoffset; ?> + "px"; } </script> -<?php -print_footer(); @@ -29,18 +29,17 @@ require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_print_lists.php'; $controller=new WT_Controller_Repository(); -$controller->init(); -if ($controller->repository && $controller->repository->canDisplayDetails()) { +if ($controller->record && $controller->record->canDisplayDetails()) { print_header($controller->getPageTitle()); - if ($controller->repository->isMarkedDeleted()) { + if ($controller->record->isMarkedDeleted()) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This repository has been deleted. You should review the deletion and then %1$s or %2$s it.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->repository->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->repository->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -51,14 +50,14 @@ if ($controller->repository && $controller->repository->canDisplayDetails()) { ' ', help_link('pending_changes'), '</p>'; } - } elseif (find_updated_record($controller->repository->getXref(), WT_GED_ID)!==null) { + } elseif (find_updated_record($controller->record->getXref(), WT_GED_ID)!==null) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This repository has been edited. You should review the changes and then %1$s or %2$s them.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->repository->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->repository->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -71,27 +70,24 @@ if ($controller->repository && $controller->repository->canDisplayDetails()) { } } } else { - header('HTTP/1.0 403 Forbidden'); - print_header(WT_I18N::translate('Repository')); + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); + print_header($controller->getPageTitle()); echo '<p class="ui-state-error">', WT_I18N::translate('This repository does not exist or you do not have permission to view it.'), '</p>'; print_footer(); exit; } -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - if (WT_USE_LIGHTBOX) { require WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_call_js.php'; } -$linkToID=$controller->rid; // Tell addmedia.php what to link to +$linkToID=$controller->record->getXref(); // Tell addmedia.php what to link to echo WT_JS_START; echo 'function show_gedcom_record() {'; -echo ' var recwin=window.open("gedrecord.php?pid=', $controller->repository->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; +echo ' var recwin=window.open("gedrecord.php?pid=', $controller->record->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; echo '}'; -echo 'function showchanges() { window.location="', $controller->repository->getRawUrl(), '"; }'; +echo 'function showchanges() { window.location="', $controller->record->getRawUrl(), '"; }'; ?> jQuery(document).ready(function() { jQuery("#repo-tabs").tabs(); jQuery("#repo-tabs").css('visibility', 'visible'); @@ -100,11 +96,11 @@ echo 'function showchanges() { window.location="', $controller->repository->getR echo WT_JS_END; echo '<div id="repo-details">'; -echo '<h2>', $controller->repository->getFullName(), '</h2>'; +echo '<h2>', $controller->record->getFullName(), '</h2>'; echo '<div id="repo-tabs"> <ul> <li><a href="#repo-edit"><span>', WT_I18N::translate('Details'), '</span></a></li>'; - if ($controller->repository->countLinkedSources()) { + if ($controller->record->countLinkedSources()) { echo '<li><a href="#source-repo"><span id="reposource">', WT_I18N::translate('Sources'), '</span></a></li>'; } echo '</ul>'; @@ -112,25 +108,25 @@ echo '<div id="repo-tabs"> // Shared Note details --------------------- echo '<div id="repo-edit">'; echo '<table class="facts_table">'; - $repositoryfacts=$controller->repository->getFacts(); + $repositoryfacts=$controller->record->getFacts(); foreach ($repositoryfacts as $fact) { - print_fact($fact, $controller->repository); + print_fact($fact, $controller->record); } // Print media - print_main_media($controller->rid); + print_main_media($controller->record->getXref()); // new fact link - if ($controller->repository->canEdit()) { - print_add_new_fact($controller->rid, $repositoryfacts, 'REPO'); + if ($controller->record->canEdit()) { + print_add_new_fact($controller->record->getXref(), $repositoryfacts, 'REPO'); // new media if (get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { echo '<tr><td class="descriptionbox">'; echo WT_I18N::translate('Add media'), help_link('add_media'); echo '</td><td class="optionbox">'; - echo '<a href="javascript:;" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=', $controller->rid, '\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Add a new media object'), '</a>'; + echo '<a href="javascript:;" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=', $controller->record->getXref(), '\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Add a new media object'), '</a>'; echo '<br />'; - echo '<a href="javascript:;" onclick="window.open(\'inverselink.php?linktoid=', $controller->rid, '&linkto=repository\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Link to an existing media object'), '</a>'; + echo '<a href="javascript:;" onclick="window.open(\'inverselink.php?linktoid=', $controller->record->getXref(), '&linkto=repository\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Link to an existing media object'), '</a>'; echo '</td></tr>'; }} echo '</table> @@ -138,9 +134,9 @@ echo '<div id="repo-tabs"> // Sources linked to this repository - if ($controller->repository->countLinkedSources()) { + if ($controller->record->countLinkedSources()) { echo '<div id="source-repo">'; - print_sour_table($controller->repository->fetchLinkedSources(), $controller->repository->getFullName()); + print_sour_table($controller->record->fetchLinkedSources(), $controller->record->getFullName()); echo '</div>'; //close "source-repo" } diff --git a/repolist.php b/repolist.php index fe1a059cbf..b5d37eb260 100644 --- a/repolist.php +++ b/repolist.php @@ -1,31 +1,27 @@ <?php -/** - * Repositories List - * - * webtrees: Web based Family History software - * Copyright (C) 2010 webtrees development team. - * - * Derived from PhpGedView - * Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package webtrees - * @subpackage Lists - * @version $Id$ - */ +// Repositories List +// +// webtrees: Web based Family History software +// Copyright (C) 2011 webtrees development team. +// +// Derived from PhpGedView +// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ define('WT_SCRIPT_NAME', 'repolist.php'); require './includes/session.php'; @@ -36,4 +32,3 @@ echo '<div class="center"><h2>', WT_I18N::translate('Repositories'), '</h2>'; print_repo_table(get_repo_list(WT_GED_ID)); echo '</div>'; print_footer(); -?> @@ -1,5 +1,4 @@ <?php -// // Callback function for inline editing. // // webtrees: Web based Family History software @@ -19,7 +18,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ define('WT_SCRIPT_NAME', 'save.php'); require './includes/session.php'; diff --git a/search.php b/search.php index ead9ff4056..0f78e8bb30 100644 --- a/search.php +++ b/search.php @@ -27,11 +27,8 @@ define('WT_SCRIPT_NAME', 'search.php'); require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_print_lists.php'; -$controller = new WT_Controller_Search(); -$controller->init(); - -// Print the top header -print_header(WT_I18N::translate('Search')); +$controller=new WT_Controller_Search(); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; ?> @@ -418,5 +415,3 @@ if (!$somethingPrinted) { </script> <?php } - -print_footer(); diff --git a/search_advanced.php b/search_advanced.php index e6a55fdeec..e77dc899bd 100644 --- a/search_advanced.php +++ b/search_advanced.php @@ -28,10 +28,8 @@ require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_print_lists.php'; $controller=new WT_Controller_AdvancedSearch(); -$controller->init(); +$controller->pageHeader(); -// Print the top header -print_header(WT_I18N::translate('Advanced search')); echo WT_JS_START; ?> function checknames(frm) { @@ -312,6 +310,3 @@ if (!$somethingPrinted ) { </script> <?php } -//-- somewhere the session gedcom gets changed, so we will change it back -$_SESSION['GEDCOM'] = $GEDCOM; -print_footer(); diff --git a/sidebar.php b/sidebar.php index 7552483044..4952c2d425 100644 --- a/sidebar.php +++ b/sidebar.php @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_SCRIPT_NAME')) define('WT_SCRIPT_NAME', 'sidebar.php'); require_once('includes/session.php'); @@ -35,38 +35,10 @@ $sb_action = safe_GET('sb_action', WT_REGEX_ALPHANUM, 'none'); //-- handle ajax calls if ($sb_action!='none') { header('Content-type: text/html; charset=UTF-8'); - class tempController { - var $pid; - var $famid; - } - - $controller = new tempController(); - - $pid = safe_GET_xref('pid', ''); - if (empty($pid)) $pid = safe_POST_xref('pid', ''); - if (!empty($pid)) { - $controller->pid = $pid; - } - $pid = safe_GET_xref('rootid', ''); - if (empty($pid)) $pid = safe_POST_xref('rootid', ''); - if (!empty($pid)) { - $controller->pid = $pid; - } - $famid = safe_GET('famid', WT_REGEX_XREF, ''); - if (empty($famid)) $famid = safe_POST('famid', WT_REGEX_XREF, ''); - if (!empty($famid)) { - $controller->famid = $famid; - } - $sid = safe_GET('sid', WT_REGEX_XREF, ''); - if (empty($sid)) $sid = safe_POST('sid', WT_REGEX_XREF, ''); - if (!empty($sid)) { - $controller->sid = $sid; - } if ($sb_action=='loadMods') { $counter = 0; foreach ($sidebarmods as $mod) { - if (isset($controller)) $mod->setController($controller); if ($mod->hasSidebarContent()) { echo '<h3 id="', $mod->getName(), '"><a href="#">', $mod->getTitle(), '</a></h3>', '<div id="sb_content_', $mod->getName(), '">'; @@ -85,7 +57,6 @@ if ($sb_action!='none') { $modName = safe_GET('mod', WT_REGEX_URL, ''); if (isset($sidebarmods[$modName])) { $mod = $sidebarmods[$modName]; - if (isset($controller)) $mod->setController($controller); echo $mod->getSidebarContent(); } exit; @@ -97,26 +68,6 @@ if ($sb_action!='none') { exit; } -global $controller; -$pid=''; -$famid=''; -if (isset($controller)) { - if (isset($controller->pid)) $pid = $controller->pid; - if (isset($controller->rootid)) $pid = $controller->rootid; - if (isset($controller->famid)) $famid = $controller->famid; - if (isset($controller->sid)) $pid = $controller->sid; -} else { - $pid = safe_GET_xref('pid', ''); - if (empty($pid)) $pid = safe_POST_xref('pid', ''); - if (empty($pid)) $pid = safe_GET_xref('rootid', ''); - if (empty($pid)) $pid = safe_POST_xref('rootid', ''); - if (empty($pid)) $pid = safe_POST_xref('sid', ''); - if (empty($pid)) $pid = safe_GET_xref('sid', ''); - $famid = safe_GET('famid', WT_REGEX_XREF, ''); - if (empty($famid)) $famid = safe_POST('famid', WT_REGEX_XREF, ''); -} - - echo WT_JS_START; //jQuery code to remove table elements from INDI facts ?> jQuery(document).ready(function() { @@ -131,7 +82,6 @@ echo WT_JS_END; $counter = 0; echo '<div id="sidebarAccordion">'; foreach ($sidebarmods as $mod) { - if (isset($controller)) $mod->setController($controller); if ($mod->hasSidebarContent()) { echo '<h3 id="', $mod->getName(), '"><a href="#">', $mod->getTitle(), '</a></h3>', '<div id="sb_content_', $mod->getName(), '">', $mod->getSidebarContent(), '</div>'; diff --git a/source.php b/source.php index 2940c85e7f..46ae6e3be2 100644 --- a/source.php +++ b/source.php @@ -29,18 +29,17 @@ require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_print_lists.php'; $controller=new WT_Controller_Source(); -$controller->init(); -if ($controller->source && $controller->source->canDisplayDetails()) { +if ($controller->record && $controller->record->canDisplayDetails()) { print_header($controller->getPageTitle()); - if ($controller->source->isMarkedDeleted()) { + if ($controller->record->isMarkedDeleted()) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This source has been deleted. You should review the deletion and then %1$s or %2$s it.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->source->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->source->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the deletion and then accept or reject it.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -51,14 +50,14 @@ if ($controller->source && $controller->source->canDisplayDetails()) { ' ', help_link('pending_changes'), '</p>'; } - } elseif (find_updated_record($controller->source->getXref(), WT_GED_ID)!==null) { + } elseif (find_updated_record($controller->record->getXref(), WT_GED_ID)!==null) { if (WT_USER_CAN_ACCEPT) { echo '<p class="ui-state-highlight">', /* I18N: %1$s is "accept", %2$s is "reject". These are links. */ WT_I18N::translate( 'This source has been edited. You should review the changes and then %1$s or %2$s them.', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->source->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', - '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->source->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'accept-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'accept') . '</a>', + '<a href="#" onClick="jQuery.post(\'action.php\',{action:\'reject-changes\',xref:\''.$controller->record->getXref().'\'},function(){location.reload();})">' . WT_I18N::translate_c('You should review the changes and then accept or reject them.', 'reject') . '</a>' ), ' ', help_link('pending_changes'), '</p>'; @@ -71,27 +70,24 @@ if ($controller->source && $controller->source->canDisplayDetails()) { } } } else { - header('HTTP/1.0 403 Forbidden'); + header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); print_header(WT_I18N::translate('Source')); echo '<p class="ui-state-error">', WT_I18N::translate('This source does not exist or you do not have permission to view it.'), '</p>'; print_footer(); exit; } -// We have finished writing session data, so release the lock -Zend_Session::writeClose(); - if (WT_USE_LIGHTBOX) { require WT_ROOT.WT_MODULES_DIR.'lightbox/functions/lb_call_js.php'; } -$linkToID=$controller->sid; // Tell addmedia.php what to link to +$linkToID=$controller->record->getXref(); // Tell addmedia.php what to link to echo WT_JS_START; echo 'function show_gedcom_record() {'; -echo ' var recwin=window.open("gedrecord.php?pid=', $controller->source->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; +echo ' var recwin=window.open("gedrecord.php?pid=', $controller->record->getXref(), '", "_blank", "top=0, left=0, width=600, height=400, scrollbars=1, scrollable=1, resizable=1");'; echo '}'; -echo 'function showchanges() { window.location="', $controller->source->getRawUrl(), '"; }'; +echo 'function showchanges() { window.location="', $controller->record->getRawUrl(), '"; }'; ?> jQuery(document).ready(function() { jQuery("#source-tabs").tabs(); jQuery("#source-tabs").css('visibility', 'visible'); @@ -99,20 +95,20 @@ echo 'function showchanges() { window.location="', $controller->source->getRawUr <?php echo WT_JS_END; echo '<div id="source-details">'; -echo '<h2>', $controller->source->getFullName(), '</h2>'; +echo '<h2>', $controller->record->getFullName(), '</h2>'; echo '<div id="source-tabs"> <ul> <li><a href="#source-edit"><span>', WT_I18N::translate('Details'), '</span></a></li>'; - if ($controller->source->countLinkedIndividuals()) { + if ($controller->record->countLinkedIndividuals()) { echo '<li><a href="#indi-sources"><span id="indisource">', WT_I18N::translate('Individuals'), '</span></a></li>'; } - if ($controller->source->countLinkedFamilies()) { + if ($controller->record->countLinkedFamilies()) { echo '<li><a href="#fam-sources"><span id="famsource">', WT_I18N::translate('Families'), '</span></a></li>'; } - if ($controller->source->countLinkedMedia()) { + if ($controller->record->countLinkedMedia()) { echo '<li><a href="#media-sources"><span id="mediasource">', WT_I18N::translate('Media objects'), '</span></a></li>'; } - if ($controller->source->countLinkedNotes()) { + if ($controller->record->countLinkedNotes()) { echo '<li><a href="#note-sources"><span id="notesource">', WT_I18N::translate('Notes'), '</span></a></li>'; } echo '</ul>'; @@ -120,52 +116,52 @@ echo '<div id="source-tabs"> echo '<div id="source-edit">'; echo '<table class="facts_table">'; - $sourcefacts=$controller->source->getFacts(); + $sourcefacts=$controller->record->getFacts(); foreach ($sourcefacts as $fact) { - print_fact($fact, $controller->source); + print_fact($fact, $controller->record); } // Print media - print_main_media($controller->sid); + print_main_media($controller->record->getXref()); // new fact link - if ($controller->source->canEdit()) { - print_add_new_fact($controller->sid, $sourcefacts, 'SOUR'); + if ($controller->record->canEdit()) { + print_add_new_fact($controller->record->getXref(), $sourcefacts, 'SOUR'); // new media if (get_gedcom_setting(WT_GED_ID, 'MEDIA_UPLOAD') >= WT_USER_ACCESS_LEVEL) { echo '<tr><td class="descriptionbox">'; echo WT_I18N::translate('Add media'), help_link('add_media'); echo '</td><td class="optionbox">'; - echo '<a href="javascript:;" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=', $controller->sid, '\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Add a new media object'), '</a>'; + echo '<a href="javascript:;" onclick="window.open(\'addmedia.php?action=showmediaform&linktoid=', $controller->record->getXref(), '\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Add a new media object'), '</a>'; echo '<br />'; - echo '<a href="javascript:;" onclick="window.open(\'inverselink.php?linktoid=', $controller->sid, '&linkto=source\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Link to an existing media object'), '</a>'; + echo '<a href="javascript:;" onclick="window.open(\'inverselink.php?linktoid=', $controller->record->getXref(), '&linkto=source\', \'_blank\', \'top=50, left=50, width=600, height=500, resizable=1, scrollbars=1\'); return false;">', WT_I18N::translate('Link to an existing media object'), '</a>'; echo '</td></tr>'; } } echo '</table> </div>'; // close "details" // Individuals linked to this source - if ($controller->source->countLinkedIndividuals()) { + if ($controller->record->countLinkedIndividuals()) { echo '<div id="indi-sources">'; - print_indi_table($controller->source->fetchLinkedIndividuals(), $controller->source->getFullName()); + print_indi_table($controller->record->fetchLinkedIndividuals(), $controller->record->getFullName()); echo '</div>'; //close "indi-sources" } // Families linked to this source - if ($controller->source->countLinkedFamilies()) { + if ($controller->record->countLinkedFamilies()) { echo '<div id="fam-sources">'; - print_fam_table($controller->source->fetchLinkedFamilies(), $controller->source->getFullName()); + print_fam_table($controller->record->fetchLinkedFamilies(), $controller->record->getFullName()); echo '</div>'; //close "fam-sources" } // Media Items linked to this source - if ($controller->source->countLinkedMedia()) { + if ($controller->record->countLinkedMedia()) { echo '<div id="media-sources">'; - print_media_table($controller->source->fetchLinkedMedia(), $controller->source->getFullName()); + print_media_table($controller->record->fetchLinkedMedia(), $controller->record->getFullName()); echo '</div>'; //close "media-sources" } // Shared Notes linked to this source - if ($controller->source->countLinkedNotes()) { + if ($controller->record->countLinkedNotes()) { echo '<div id="note-sources">'; - print_note_table($controller->source->fetchLinkedNotes(), $controller->source->getFullName()); + print_note_table($controller->record->fetchLinkedNotes(), $controller->record->getFullName()); echo '</div>'; //close "note-sources" } echo '</div>'; //close div "source-tabs" diff --git a/sourcelist.php b/sourcelist.php index a424d9b301..b312908c8c 100644 --- a/sourcelist.php +++ b/sourcelist.php @@ -1,31 +1,27 @@ <?php -/** - * Parses gedcom file and displays a list of the sources in the file. - * - * webtrees: Web based Family History software - * Copyright (C) 2010 webtrees development team. - * - * Derived from PhpGedView - * Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * @package webtrees - * @subpackage Lists - * @version $Id$ - */ +// Parses gedcom file and displays a list of the sources in the file. +// +// webtrees: Web based Family History software +// Copyright (C) 2011 webtrees development team. +// +// Derived from PhpGedView +// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ define('WT_SCRIPT_NAME', 'sourcelist.php'); require './includes/session.php'; @@ -36,4 +32,3 @@ echo '<div class="center"><h2>', WT_I18N::translate('Sources'), '</h2>'; print_sour_table(get_source_list(WT_GED_ID)); echo '</div>'; print_footer(); -?> diff --git a/timeline.php b/timeline.php index bad0777687..36aa0c6065 100644 --- a/timeline.php +++ b/timeline.php @@ -28,10 +28,8 @@ define('WT_SCRIPT_NAME', 'timeline.php'); require './includes/session.php'; -$controller = new WT_Controller_Timeline(); -$controller->init(); - -print_header(WT_I18N::translate('Timeline')); +$controller=new WT_Controller_Timeline(); +$controller->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; ?> @@ -423,5 +421,3 @@ if (count($controller->people)>0) { if (timeline_chart_div) timeline_chart_div.style.height = '<?php echo $baseyoffset+(($controller->topyear-$controller->baseyear)*$controller->scale*1.1); ?>px'; //--> </script> -<?php -print_footer(); |
