summaryrefslogtreecommitdiff
path: root/library/WT
diff options
context:
space:
mode:
Diffstat (limited to 'library/WT')
-rw-r--r--library/WT/Controller/AdvancedSearch.php8
-rw-r--r--library/WT/Controller/Ancestry.php16
-rw-r--r--library/WT/Controller/Base.php177
-rw-r--r--library/WT/Controller/Chart.php29
-rw-r--r--library/WT/Controller/Descendancy.php70
-rw-r--r--library/WT/Controller/Family.php86
-rw-r--r--library/WT/Controller/GedcomRecord.php60
-rw-r--r--library/WT/Controller/Hourglass.php16
-rw-r--r--library/WT/Controller/Individual.php237
-rw-r--r--library/WT/Controller/Lifespan.php14
-rw-r--r--library/WT/Controller/Media.php116
-rw-r--r--library/WT/Controller/Note.php47
-rw-r--r--library/WT/Controller/Pedigree.php16
-rw-r--r--library/WT/Controller/Repository.php47
-rw-r--r--library/WT/Controller/Search.php9
-rw-r--r--library/WT/Controller/Simple.php29
-rw-r--r--library/WT/Controller/Source.php47
-rw-r--r--library/WT/Controller/Timeline.php13
-rw-r--r--library/WT/MenuBar.php61
-rw-r--r--library/WT/Module.php5
20 files changed, 629 insertions, 474 deletions
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&amp;mod_action=menu-add-favorite',{xref:'".$this->family->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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&amp;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 '>&nbsp;';
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&amp;mod_action=menu-add-favorite',{xref:'".$this->indi->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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&amp;xref=".$this->m_pid,
+ "admin_media.php?action=removeobject&amp;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&amp;mod_action=menu-add-favorite',{xref:'".$this->mediaobject->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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&amp;mod_action=menu-add-favorite',{xref:'".$this->note->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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&amp;mod_action=menu-add-favorite',{xref:'".$this->repository->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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&amp;mod_action=menu-add-favorite',{xref:'".$this->source->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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.'&amp;pid='.WT_USER_GEDCOM_ID, 'menu-myrecord');
+ $submenu = new WT_Menu(WT_I18N::translate('My individual record'), 'individual.php?pid='.WT_USER_GEDCOM_ID.'&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;mod_action=menu-add-favorite',{xref:'".$controller->note->getXref()."'},function(){location.reload();})");
+ $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;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) {
}