summaryrefslogtreecommitdiff
path: root/library/WT
diff options
context:
space:
mode:
Diffstat (limited to 'library/WT')
-rw-r--r--library/WT/Auth.php6
-rw-r--r--library/WT/Controller/AdvancedSearch.php298
-rw-r--r--library/WT/Controller/Ajax.php9
-rw-r--r--library/WT/Controller/Ancestry.php95
-rw-r--r--library/WT/Controller/Base.php8
-rw-r--r--library/WT/Controller/Branches.php2
-rw-r--r--library/WT/Controller/Chart.php4
-rw-r--r--library/WT/Controller/Compact.php42
-rw-r--r--library/WT/Controller/Descendancy.php136
-rw-r--r--library/WT/Controller/Family.php26
-rw-r--r--library/WT/Controller/Familybook.php55
-rw-r--r--library/WT/Controller/Fanchart.php95
-rw-r--r--library/WT/Controller/GedcomRecord.php2
-rw-r--r--library/WT/Controller/Hourglass.php43
-rw-r--r--library/WT/Controller/Individual.php91
-rw-r--r--library/WT/Controller/Lifespan.php10
-rw-r--r--library/WT/Controller/Note.php6
-rw-r--r--library/WT/Controller/Page.php119
-rw-r--r--library/WT/Controller/Pedigree.php229
-rw-r--r--library/WT/Controller/Repository.php6
-rw-r--r--library/WT/Controller/Search.php18
-rw-r--r--library/WT/Controller/Simple.php11
-rw-r--r--library/WT/Controller/Source.php10
-rw-r--r--library/WT/Controller/Timeline.php29
-rw-r--r--library/WT/DB.php4
-rw-r--r--library/WT/DBStatement.php2
-rw-r--r--library/WT/Date.php5
-rw-r--r--library/WT/Date/Calendar.php42
-rw-r--r--library/WT/Date/Jewish.php27
-rw-r--r--library/WT/Date/Julian.php5
-rw-r--r--library/WT/Fact.php23
-rw-r--r--library/WT/Family.php2
-rw-r--r--library/WT/File.php4
-rw-r--r--library/WT/Filter.php44
-rw-r--r--library/WT/FlashMessages.php29
-rw-r--r--library/WT/GedcomRecord.php195
-rw-r--r--library/WT/I18N.php190
-rw-r--r--library/WT/Individual.php18
-rw-r--r--library/WT/Log.php4
-rw-r--r--library/WT/Mail.php16
-rw-r--r--library/WT/Media.php17
-rw-r--r--library/WT/Menu.php55
-rw-r--r--library/WT/MenuBar.php509
-rw-r--r--library/WT/Module.php36
-rw-r--r--library/WT/Place.php76
-rw-r--r--library/WT/Query/Admin.php72
-rw-r--r--library/WT/Query/Media.php2
-rw-r--r--library/WT/Query/Name.php124
-rw-r--r--library/WT/Report/Base.php122
-rw-r--r--library/WT/Report/Base_Cell.php2
-rw-r--r--library/WT/Report/HTML.php8
-rw-r--r--library/WT/Report/HTML_Html.php8
-rw-r--r--library/WT/Report/HTML_Line.php14
-rw-r--r--library/WT/Report/HTML_TextBox.php3
-rw-r--r--library/WT/Report/PDF.php8
-rw-r--r--library/WT/Report/PDF_Footnote.php2
-rw-r--r--library/WT/Report/PDF_Text.php2
-rw-r--r--library/WT/Soundex.php28
-rw-r--r--library/WT/Stats.php240
-rw-r--r--library/WT/Theme.php86
-rw-r--r--library/WT/Theme/Administration.php195
-rw-r--r--library/WT/Theme/BaseTheme.php1704
-rw-r--r--library/WT/Theme/Clouds.php135
-rw-r--r--library/WT/Theme/Colors.php173
-rw-r--r--library/WT/Theme/Fab.php126
-rw-r--r--library/WT/Theme/Minimal.php123
-rw-r--r--library/WT/Theme/Webtrees.php103
-rw-r--r--library/WT/Theme/Xenea.php113
-rw-r--r--library/WT/Tree.php45
-rw-r--r--library/WT/User.php31
70 files changed, 4303 insertions, 1819 deletions
diff --git a/library/WT/Auth.php b/library/WT/Auth.php
index c4981d27b2..5ed052d6bc 100644
--- a/library/WT/Auth.php
+++ b/library/WT/Auth.php
@@ -1,6 +1,4 @@
<?php
-namespace WT;
-
// webtrees: Web based Family History software
// Copyright (C) 2014 webtrees development team
//
@@ -18,6 +16,8 @@ namespace WT;
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+namespace WT;
+
use WT_Tree;
use Zend_Session;
@@ -124,7 +124,7 @@ class Auth {
*
* @return boolean
*/
- public static function isMember(WT_Tree $tree = null, User $user=null) {
+ public static function isMember(WT_Tree $tree = null, User $user = null) {
global $WT_TREE;
if ($tree === null) {
diff --git a/library/WT/Controller/AdvancedSearch.php b/library/WT/Controller/AdvancedSearch.php
index d5ceaeaa07..90f8b9ef92 100644
--- a/library/WT/Controller/AdvancedSearch.php
+++ b/library/WT/Controller/AdvancedSearch.php
@@ -37,9 +37,9 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
$this->setPageTitle(WT_I18N::translate('Advanced search'));
if (empty($_REQUEST['action'])) {
- $this->action="advanced";
+ $this->action = "advanced";
}
- if ($this->action=="advanced") {
+ if ($this->action == "advanced") {
if (isset($_REQUEST['fields'])) {
$this->fields = $_REQUEST['fields'];
ksort($this->fields);
@@ -54,7 +54,7 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
$this->advancedSearch();
}
if (!$this->fields) {
- $this->fields=array(
+ $this->fields = array(
'NAME:GIVN:SDX',
'NAME:SURN:SDX',
'BIRT:DATE',
@@ -151,9 +151,9 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
* @return int
*/
public static function tagSort($x, $y) {
- list($x1)=explode(':', $x.':');
- list($y1)=explode(':', $y.':');
- $tmp=WT_I18N::strcasecmp(WT_Gedcom_Tag::getLabel($x1), WT_Gedcom_Tag::getLabel($y1));
+ list($x1) = explode(':', $x . ':');
+ list($y1) = explode(':', $y . ':');
+ $tmp = WT_I18N::strcasecmp(WT_Gedcom_Tag::getLabel($x1), WT_Gedcom_Tag::getLabel($y1));
if ($tmp) {
return $tmp;
} else {
@@ -168,7 +168,9 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
*/
function getValue($i) {
$val = '';
- if (isset($this->values[$i])) $val = $this->values[$i];
+ if (isset($this->values[$i])) {
+ $val = $this->values[$i];
+ }
return $val;
}
@@ -214,13 +216,17 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
$newplus = array();
$rels = array();
foreach ($this->fields as $j=>$field) {
- if (strpos($this->fields[$j], "FAMC:HUSB:NAME")===0 || strpos($this->fields[$j], "FAMC:WIFE:NAME")===0) {
+ if (strpos($this->fields[$j], "FAMC:HUSB:NAME") === 0 || strpos($this->fields[$j], "FAMC:WIFE:NAME") === 0) {
$rels[$this->fields[$j]] = $this->values[$j];
continue;
}
$newfields[$i] = $this->fields[$j];
- if (isset($this->values[$j])) $newvalues[$i] = $this->values[$j];
- if (isset($this->plusminus[$j])) $newplus[$i] = $this->plusminus[$j];
+ if (isset($this->values[$j])) {
+ $newvalues[$i] = $this->values[$j];
+ }
+ if (isset($this->plusminus[$j])) {
+ $newplus[$i] = $this->plusminus[$j];
+ }
$i++;
}
$this->fields = $newfields;
@@ -238,46 +244,46 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
* @return void
*/
function advancedSearch() {
- $this->myindilist = array ();
+ $this->myindilist = array();
$fct = count($this->fields);
- if ($fct==0) {
+ if ($fct == 0) {
return;
}
// Dynamic SQL query, plus bind variables
- $sql="SELECT DISTINCT ind.i_id AS xref, ind.i_file AS gedcom_id, ind.i_gedcom AS gedcom FROM `##individuals` ind";
- $bind=array();
+ $sql = "SELECT DISTINCT ind.i_id AS xref, ind.i_file AS gedcom_id, ind.i_gedcom AS gedcom FROM `##individuals` ind";
+ $bind = array();
// Join the following tables
- $father_name =false;
- $mother_name =false;
- $spouse_family =false;
- $indi_name =false;
- $indi_date =false;
- $fam_date =false;
- $indi_plac =false;
- $fam_plac =false;
+ $father_name = false;
+ $mother_name = false;
+ $spouse_family = false;
+ $indi_name = false;
+ $indi_date = false;
+ $fam_date = false;
+ $indi_plac = false;
+ $fam_plac = false;
foreach ($this->fields as $n=>$field) {
if ($this->values[$n]) {
- if (substr($field, 0, 14)=='FAMC:HUSB:NAME') {
- $father_name=true;
- } elseif (substr($field, 0, 14)=='FAMC:WIFE:NAME') {
- $mother_name=true;
- } elseif (substr($field, 0, 4)=='NAME') {
- $indi_name=true;
- } elseif (strpos($field, ':DATE')!==false) {
- if (substr($field, 0, 4)=='FAMS') {
- $fam_date=true;
- $spouse_family=true;
+ if (substr($field, 0, 14) == 'FAMC:HUSB:NAME') {
+ $father_name = true;
+ } elseif (substr($field, 0, 14) == 'FAMC:WIFE:NAME') {
+ $mother_name = true;
+ } elseif (substr($field, 0, 4) == 'NAME') {
+ $indi_name = true;
+ } elseif (strpos($field, ':DATE') !== false) {
+ if (substr($field, 0, 4) == 'FAMS') {
+ $fam_date = true;
+ $spouse_family = true;
} else {
- $indi_date=true;
+ $indi_date = true;
}
- } elseif (strpos($field, ':PLAC')!==false) {
- if (substr($field, 0, 4)=='FAMS') {
- $fam_plac=true;
- $spouse_family=true;
+ } elseif (strpos($field, ':PLAC') !== false) {
+ if (substr($field, 0, 4) == 'FAMS') {
+ $fam_plac = true;
+ $spouse_family = true;
} else {
- $indi_plac=true;
+ $indi_plac = true;
}
} elseif ($field == 'FAMS:NOTE') {
$spouse_family = true;
@@ -286,83 +292,85 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
}
if ($father_name || $mother_name) {
- $sql.=" JOIN `##link` l_1 ON (l_1.l_file=ind.i_file AND l_1.l_from=ind.i_id AND l_1.l_type='FAMC')";
+ $sql .= " JOIN `##link` l_1 ON (l_1.l_file=ind.i_file AND l_1.l_from=ind.i_id AND l_1.l_type='FAMC')";
}
if ($father_name) {
- $sql.=" JOIN `##link` l_2 ON (l_2.l_file=ind.i_file AND l_2.l_from=l_1.l_to AND l_2.l_type='HUSB')";
- $sql.=" JOIN `##name` f_n ON (f_n.n_file=ind.i_file AND f_n.n_id =l_2.l_to)";
+ $sql .= " JOIN `##link` l_2 ON (l_2.l_file=ind.i_file AND l_2.l_from=l_1.l_to AND l_2.l_type='HUSB')";
+ $sql .= " JOIN `##name` f_n ON (f_n.n_file=ind.i_file AND f_n.n_id =l_2.l_to)";
}
if ($mother_name) {
- $sql.=" JOIN `##link` l_3 ON (l_3.l_file=ind.i_file AND l_3.l_from=l_1.l_to AND l_3.l_type='WIFE')";
- $sql.=" JOIN `##name` m_n ON (m_n.n_file=ind.i_file AND m_n.n_id =l_3.l_to)";
+ $sql .= " JOIN `##link` l_3 ON (l_3.l_file=ind.i_file AND l_3.l_from=l_1.l_to AND l_3.l_type='WIFE')";
+ $sql .= " JOIN `##name` m_n ON (m_n.n_file=ind.i_file AND m_n.n_id =l_3.l_to)";
}
if ($spouse_family) {
- $sql.=" JOIN `##link` l_4 ON (l_4.l_file=ind.i_file AND l_4.l_from=ind.i_id AND l_4.l_type='FAMS')";
- $sql.=" JOIN `##families` fam ON (fam.f_file=ind.i_file AND fam.f_id =l_4.l_to)";
+ $sql .= " JOIN `##link` l_4 ON (l_4.l_file=ind.i_file AND l_4.l_from=ind.i_id AND l_4.l_type='FAMS')";
+ $sql .= " JOIN `##families` fam ON (fam.f_file=ind.i_file AND fam.f_id =l_4.l_to)";
}
if ($indi_name) {
- $sql.=" JOIN `##name` i_n ON (i_n.n_file=ind.i_file AND i_n.n_id=ind.i_id)";
+ $sql .= " JOIN `##name` i_n ON (i_n.n_file=ind.i_file AND i_n.n_id=ind.i_id)";
}
if ($indi_date) {
- $sql.=" JOIN `##dates` i_d ON (i_d.d_file=ind.i_file AND i_d.d_gid=ind.i_id)";
+ $sql .= " JOIN `##dates` i_d ON (i_d.d_file=ind.i_file AND i_d.d_gid=ind.i_id)";
}
if ($fam_date) {
- $sql.=" JOIN `##dates` f_d ON (f_d.d_file=ind.i_file AND f_d.d_gid=fam.f_id)";
+ $sql .= " JOIN `##dates` f_d ON (f_d.d_file=ind.i_file AND f_d.d_gid=fam.f_id)";
}
if ($indi_plac) {
- $sql.=" JOIN `##placelinks` i_pl ON (i_pl.pl_file=ind.i_file AND i_pl.pl_gid =ind.i_id)";
- $sql.=" JOIN (".
- "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file".
- " FROM `##places` AS p1".
- " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)".
- " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)".
- " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)".
- " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)".
- " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)".
- " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)".
- " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)".
- " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)".
+ $sql .= " JOIN `##placelinks` i_pl ON (i_pl.pl_file=ind.i_file AND i_pl.pl_gid =ind.i_id)";
+ $sql .= " JOIN (" .
+ "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file" .
+ " FROM `##places` AS p1" .
+ " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" .
+ " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" .
+ " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" .
+ " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" .
+ " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" .
+ " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" .
+ " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" .
+ " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" .
") AS i_p ON (i_p.file =ind.i_file AND i_pl.pl_p_id= i_p.id)";
}
if ($fam_plac) {
- $sql.=" JOIN `##placelinks` f_pl ON (f_pl.pl_file=ind.i_file AND f_pl.pl_gid =fam.f_id)";
- $sql.=" JOIN (".
- "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file".
- " FROM `##places` AS p1".
- " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)".
- " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)".
- " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)".
- " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)".
- " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)".
- " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)".
- " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)".
- " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)".
+ $sql .= " JOIN `##placelinks` f_pl ON (f_pl.pl_file=ind.i_file AND f_pl.pl_gid =fam.f_id)";
+ $sql .= " JOIN (" .
+ "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file" .
+ " FROM `##places` AS p1" .
+ " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" .
+ " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" .
+ " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" .
+ " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" .
+ " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" .
+ " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" .
+ " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" .
+ " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" .
") AS f_p ON (f_p.file =ind.i_file AND f_pl.pl_p_id= f_p.id)";
}
// Add the where clause
- $sql.=" WHERE ind.i_file=?";
- $bind[]=WT_GED_ID;
- for ($i=0; $i<$fct; $i++) {
+ $sql .= " WHERE ind.i_file=?";
+ $bind[] = WT_GED_ID;
+ for ($i = 0; $i < $fct; $i++) {
$field = $this->fields[$i];
$value = $this->values[$i];
- if ($value==='') continue;
- $parts = preg_split("/:/", $field.'::::');
- if ($parts[0]=='NAME') {
+ if ($value === '') {
+ continue;
+ }
+ $parts = preg_split("/:/", $field . '::::');
+ if ($parts[0] == 'NAME') {
// NAME:*
switch ($parts[1]) {
case 'GIVN':
switch ($parts[2]) {
case 'EXACT':
- $sql.=" AND i_n.n_givn=?";
- $bind[]=$value;
+ $sql .= " AND i_n.n_givn=?";
+ $bind[] = $value;
break;
case 'BEGINS':
- $sql.=" AND i_n.n_givn LIKE CONCAT(?, '%')";
- $bind[]=$value;
+ $sql .= " AND i_n.n_givn LIKE CONCAT(?, '%')";
+ $bind[] = $value;
break;
case 'CONTAINS':
- $sql.=" AND i_n.n_givn LIKE CONCAT('%', ?, '%')";
- $bind[]=$value;
+ $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')";
+ $bind[] = $value;
break;
case 'SDX_STD':
$sdx = WT_Soundex::russell($value);
@@ -400,16 +408,16 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
case 'SURN':
switch ($parts[2]) {
case 'EXACT':
- $sql.=" AND i_n.n_surname=?";
- $bind[]=$value;
+ $sql .= " AND i_n.n_surname=?";
+ $bind[] = $value;
break;
case 'BEGINS':
- $sql.=" AND i_n.n_surname LIKE CONCAT(?, '%')";
- $bind[]=$value;
+ $sql .= " AND i_n.n_surname LIKE CONCAT(?, '%')";
+ $bind[] = $value;
break;
case 'CONTAINS':
- $sql.=" AND i_n.n_surname LIKE CONCAT('%', ?, '%')";
- $bind[]=$value;
+ $sql .= " AND i_n.n_surname LIKE CONCAT('%', ?, '%')";
+ $bind[] = $value;
break;
case 'SDX_STD':
$sdx = WT_Soundex::russell($value);
@@ -448,72 +456,78 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
case '_MARNM':
case '_HEB':
case '_AKA':
- $sql.=" AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')";
- $bind[]=$parts[1];
- $bind[]=$value;
+ $sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')";
+ $bind[] = $parts[1];
+ $bind[] = $value;
break;
}
- } elseif ($parts[1]=='DATE') {
+ } elseif ($parts[1] == 'DATE') {
// *:DATE
$date = new WT_Date($value);
if ($date->isOK()) {
$jd1 = $date->date1->minJD;
- if ($date->date2) $jd2 = $date->date2->maxJD;
- else $jd2 = $date->date1->maxJD;
+ if ($date->date2) {
+ $jd2 = $date->date2->maxJD;
+ } else {
+ $jd2 = $date->date1->maxJD;
+ }
if (!empty($this->plusminus[$i])) {
- $adjd = $this->plusminus[$i]*365;
+ $adjd = $this->plusminus[$i] * 365;
$jd1 = $jd1 - $adjd;
$jd2 = $jd2 + $adjd;
}
- $sql.=" AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?";
- $bind[]=$parts[0];
- $bind[]=$jd1;
- $bind[]=$jd2;
+ $sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?";
+ $bind[] = $parts[0];
+ $bind[] = $jd1;
+ $bind[] = $jd2;
}
- } elseif ($parts[0]=='FAMS' && $parts[2]=='DATE') {
+ } elseif ($parts[0] == 'FAMS' && $parts[2] == 'DATE') {
// FAMS:*:DATE
$date = new WT_Date($value);
if ($date->isOK()) {
$jd1 = $date->date1->minJD;
- if ($date->date2) $jd2 = $date->date2->maxJD;
- else $jd2 = $date->date1->maxJD;
+ if ($date->date2) {
+ $jd2 = $date->date2->maxJD;
+ } else {
+ $jd2 = $date->date1->maxJD;
+ }
if (!empty($this->plusminus[$i])) {
- $adjd = $this->plusminus[$i]*365;
+ $adjd = $this->plusminus[$i] * 365;
$jd1 = $jd1 - $adjd;
$jd2 = $jd2 + $adjd;
}
- $sql.=" AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?";
- $bind[]=$parts[1];
- $bind[]=$jd1;
- $bind[]=$jd2;
+ $sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?";
+ $bind[] = $parts[1];
+ $bind[] = $jd1;
+ $bind[] = $jd2;
}
- } elseif ($parts[1]=='PLAC') {
+ } elseif ($parts[1] == 'PLAC') {
// *:PLAC
// SQL can only link a place to a person/family, not to an event.
- $sql.=" AND i_p.place LIKE CONCAT('%', ?, '%')";
- $bind[]=$value;
- } elseif ($parts[0]=='FAMS' && $parts[2]=='PLAC') {
+ $sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')";
+ $bind[] = $value;
+ } elseif ($parts[0] == 'FAMS' && $parts[2] == 'PLAC') {
// FAMS:*:PLAC
// SQL can only link a place to a person/family, not to an event.
- $sql.=" AND f_p.place LIKE CONCAT('%', ?, '%')";
- $bind[]=$value;
- } elseif ($parts[0]=='FAMC' && $parts[2]=='NAME') {
- $table=$parts[1]=='HUSB' ? 'f_n' : 'm_n';
+ $sql .= " AND f_p.place LIKE CONCAT('%', ?, '%')";
+ $bind[] = $value;
+ } elseif ($parts[0] == 'FAMC' && $parts[2] == 'NAME') {
+ $table = $parts[1] == 'HUSB' ? 'f_n' : 'm_n';
// NAME:*
switch ($parts[3]) {
case 'GIVN':
switch ($parts[4]) {
case 'EXACT':
- $sql.=" AND {$table}.n_givn=?";
- $bind[]=$value;
+ $sql .= " AND {$table}.n_givn=?";
+ $bind[] = $value;
break;
case 'BEGINS':
- $sql.=" AND {$table}.n_givn LIKE CONCAT(?, '%')";
- $bind[]=$value;
+ $sql .= " AND {$table}.n_givn LIKE CONCAT(?, '%')";
+ $bind[] = $value;
break;
case 'CONTAINS':
- $sql.=" AND {$table}.n_givn LIKE CONCAT('%', ?, '%')";
- $bind[]=$value;
+ $sql .= " AND {$table}.n_givn LIKE CONCAT('%', ?, '%')";
+ $bind[] = $value;
break;
case 'SDX_STD':
$sdx = WT_Soundex::russell($value);
@@ -551,16 +565,16 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
case 'SURN':
switch ($parts[4]) {
case 'EXACT':
- $sql.=" AND {$table}.n_surname=?";
- $bind[]=$value;
+ $sql .= " AND {$table}.n_surname=?";
+ $bind[] = $value;
break;
case 'BEGINS':
- $sql.=" AND {$table}.n_surname LIKE CONCAT(?, '%')";
- $bind[]=$value;
+ $sql .= " AND {$table}.n_surname LIKE CONCAT(?, '%')";
+ $bind[] = $value;
break;
case 'CONTAINS':
- $sql.=" AND {$table}.n_surname LIKE CONCAT('%', ?, '%')";
- $bind[]=$value;
+ $sql .= " AND {$table}.n_surname LIKE CONCAT('%', ?, '%')";
+ $bind[] = $value;
break;
case 'SDX_STD':
$sdx = WT_Soundex::russell($value);
@@ -596,30 +610,30 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
}
break;
}
- } elseif ($parts[0]=='FAMS') {
+ } elseif ($parts[0] == 'FAMS') {
// e.g. searches for occupation, religion, note, etc.
- $sql.=" AND fam.f_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)";
- $bind[]=$parts[1];
- $bind[]=$value;
+ $sql .= " AND fam.f_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)";
+ $bind[] = $parts[1];
+ $bind[] = $value;
} else {
// e.g. searches for occupation, religion, note, etc.
- $sql.=" AND ind.i_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)";
- $bind[]=$parts[0];
- $bind[]=$value;
+ $sql .= " AND ind.i_gedcom REGEXP CONCAT('\n[0-9] ', ?, '(.*\n[0-9] CONT)* [^\n]*', ?)";
+ $bind[] = $parts[0];
+ $bind[] = $value;
}
}
- $rows=WT_DB::prepare($sql)->execute($bind)->fetchAll();
+ $rows = WT_DB::prepare($sql)->execute($bind)->fetchAll();
foreach ($rows as $row) {
- $person=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
+ $person = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
// Check for XXXX:PLAC fields, which were only partially matched by SQL
foreach ($this->fields as $n=>$field) {
- if ($this->values[$n] && preg_match('/^('.WT_REGEX_TAG.'):PLAC$/', $field, $match)) {
- if (!preg_match('/\n1 '.$match[1].'(\n[2-9].*)*\n2 PLAC .*'.preg_quote($this->values[$n], '/').'/i', $person->getGedcom())) {
+ if ($this->values[$n] && preg_match('/^(' . WT_REGEX_TAG . '):PLAC$/', $field, $match)) {
+ if (!preg_match('/\n1 ' . $match[1] . '(\n[2-9].*)*\n2 PLAC .*' . preg_quote($this->values[$n], '/') . '/i', $person->getGedcom())) {
continue 2;
}
}
}
- $this->myindilist[]=$person;
+ $this->myindilist[] = $person;
}
}
@@ -627,7 +641,7 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search {
* @return bool
*/
function printResults() {
- require_once WT_ROOT.'includes/functions/functions_print_lists.php';
+ require_once WT_ROOT . 'includes/functions/functions_print_lists.php';
if ($this->myindilist) {
uasort($this->myindilist, array('WT_GedcomRecord', 'compare'));
echo format_indi_table($this->myindilist);
diff --git a/library/WT/Controller/Ajax.php b/library/WT/Controller/Ajax.php
index b78659ae7e..ab2387c001 100644
--- a/library/WT/Controller/Ajax.php
+++ b/library/WT/Controller/Ajax.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 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
@@ -29,17 +29,16 @@ class WT_Controller_Ajax extends WT_Controller_Base {
Zend_Session::writeClose();
// Ajax responses are always UTF8
header('Content-Type: text/html; charset=UTF-8');
- $this->page_header=true;
+ $this->page_header = true;
return $this;
}
/**
- * @return $this
+ * @return string
*/
public function pageFooter() {
// Ajax responses may have Javascript
- echo $this->getJavascript();
- return $this;
+ return $this->getJavascript();
}
/**
diff --git a/library/WT/Controller/Ancestry.php b/library/WT/Controller/Ancestry.php
index 060de274c3..736a2a43d6 100644
--- a/library/WT/Controller/Ancestry.php
+++ b/library/WT/Controller/Ancestry.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -18,6 +18,7 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Ancestry - Controller for the ancestry chart
@@ -38,38 +39,38 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
* Startup activity
*/
function __construct() {
- global $bwidth, $bheight, $cbwidth, $cbheight, $pbwidth, $pbheight, $PEDIGREE_FULL_DETAILS;
+ global $bwidth, $bheight, $pbwidth, $pbheight, $PEDIGREE_FULL_DETAILS;
global $DEFAULT_PEDIGREE_GENERATIONS, $PEDIGREE_GENERATIONS, $MAX_PEDIGREE_GENERATIONS, $OLD_PGENS, $box_width, $Dbwidth, $Dbheight;
global $show_full;
parent::__construct();
// Extract form parameters
- $this->show_full = WT_Filter::getInteger('show_full', 0, 1, $PEDIGREE_FULL_DETAILS);
- $this->show_cousins = WT_Filter::getInteger('show_cousins', 0, 1);
- $this->chart_style = WT_Filter::getInteger('chart_style', 0, 3);
- $box_width = WT_Filter::getInteger('box_width', 50, 300, 100);
+ $this->show_full = WT_Filter::getInteger('show_full', 0, 1, $PEDIGREE_FULL_DETAILS);
+ $this->show_cousins = WT_Filter::getInteger('show_cousins', 0, 1);
+ $this->chart_style = WT_Filter::getInteger('chart_style', 0, 3);
+ $box_width = WT_Filter::getInteger('box_width', 50, 300, 100);
$PEDIGREE_GENERATIONS = WT_Filter::getInteger('PEDIGREE_GENERATIONS', 2, $MAX_PEDIGREE_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS);
// This is passed as a global. A parameter would be better...
- $show_full=$this->show_full;
+ $show_full = $this->show_full;
$OLD_PGENS = $PEDIGREE_GENERATIONS;
// -- size of the detailed boxes based upon optional width parameter
- $Dbwidth=($box_width*$bwidth)/100;
- $Dbheight=($box_width*$bheight)/100;
- $bwidth=$Dbwidth;
- $bheight=$Dbheight;
+ $Dbwidth = ($box_width * $bwidth) / 100;
+ $Dbheight = ($box_width * $bheight) / 100;
+ $bwidth = $Dbwidth;
+ $bheight = $Dbheight;
// -- adjust size of the compact box
if (!$this->show_full) {
- $bwidth = $cbwidth;
- $bheight = $cbheight;
+ $bwidth = Theme::theme()->parameter('compact-chart-box-x');
+ $bheight = Theme::theme()->parameter('compact-chart-box-y');
}
- $pbwidth = $bwidth+12;
- $pbheight = $bheight+14;
+ $pbwidth = $bwidth + 12;
+ $pbheight = $bheight + 14;
if ($this->root && $this->root->canShowName()) {
$this->setPageTitle(
@@ -80,8 +81,11 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
$this->setPageTitle(WT_I18N::translate('Ancestors'));
}
- 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);
+ }
}
/**
@@ -92,38 +96,41 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
* @param integer $depth the ascendancy depth to show
*/
public function printChildAscendancy($person, $sosa, $depth) {
- global $OLD_PGENS, $WT_IMAGES, $Dindent, $pidarr, $box_width;
+ global $OLD_PGENS, $pidarr, $box_width;
if ($person) {
- $pid=$person->getXref();
- $label=WT_I18N::translate('Ancestors of %s', $person->getFullName());
+ $pid = $person->getXref();
+ $label = WT_I18N::translate('Ancestors of %s', $person->getFullName());
} else {
- $pid='';
- $label='';
+ $pid = '';
+ $label = '';
}
// child
echo '<li>';
- echo '<table border="0" cellpadding="0" cellspacing="0"><tr><td><a name="sosa', $sosa, '"></a>';
- if ($sosa==1) {
- echo '<img src="', $WT_IMAGES['spacer'], '" height="3" width="', $Dindent, '" alt=""></td><td>';
+ echo '<table><tr><td>';
+ if ($sosa == 1) {
+ echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="3" width="', Theme::theme()->parameter('chart-descendancy-indent'), '"></td><td>';
} else {
- echo '<img src="', $WT_IMAGES['spacer'], '" height="3" width="2" alt="">';
- echo '<img src="', $WT_IMAGES['hline'], '" height="3" width="', ($Dindent-2), '" alt=""></td><td>';
+ echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="3" width="2" alt="">';
+ echo '<img src="', Theme::theme()->parameter('image-hline'), '" height="3" width="', Theme::theme()->parameter('chart-descendancy-indent') - 2, '"></td><td>';
}
print_pedigree_person($person);
echo '</td>';
echo '<td>';
- if ($sosa>1) {
- print_url_arrow('?rootid='.$pid.'&amp;PEDIGREE_GENERATIONS='.$OLD_PGENS.'&amp;show_full='.$this->show_full.'&amp;box_width='.$box_width.'&amp;chart_style='.$this->chart_style.'&amp;ged='.WT_GEDURL, $label, 3);
+ if ($sosa > 1) {
+ print_url_arrow('?rootid=' . $pid . '&amp;PEDIGREE_GENERATIONS=' . $OLD_PGENS . '&amp;show_full=' . $this->show_full . '&amp;box_width=' . $box_width . '&amp;chart_style=' . $this->chart_style . '&amp;ged=' . WT_GEDURL, $label, 3);
}
echo '</td>';
- echo '<td class="details1">&nbsp;<span dir="ltr" class="person_box'. (($sosa==1)?'NN':(($sosa%2)?'F':'')) . '">&nbsp;', $sosa, '&nbsp;</span>&nbsp;';
+ echo '<td class="details1">&nbsp;<span dir="ltr" class="person_box' . (($sosa == 1) ? 'NN' : (($sosa % 2) ? 'F' : '')) . '">&nbsp;', $sosa, '&nbsp;</span>&nbsp;';
echo '</td><td class="details1">';
- $relation ='';
- $new=($pid=='' or !isset($pidarr[$pid]));
- if (!$new) $relation = '<br>[=<a href="#sosa'.$pidarr[$pid].'">'.$pidarr[$pid].'</a> - '.get_sosa_name($pidarr[$pid]).']';
- else $pidarr[$pid]=$sosa;
- echo get_sosa_name($sosa).$relation;
+ $relation = '';
+ $new = ($pid == '' || !isset($pidarr[$pid]));
+ if (!$new) {
+ $relation = '<br>[=<a href="#sosa' . $pidarr[$pid] . '">' . $pidarr[$pid] . '</a> - ' . get_sosa_name($pidarr[$pid]) . ']';
+ } else {
+ $pidarr[$pid] = $sosa;
+ }
+ echo get_sosa_name($sosa) . $relation;
echo '</td>';
echo '</tr></table>';
@@ -132,14 +139,14 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
return;
}
// parents
- $family=$person->getPrimaryChildFamily();
+ $family = $person->getPrimaryChildFamily();
- if ($family && $new && $depth>0) {
+ if ($family && $new && $depth > 0) {
// print marriage info
- echo '<span class="details1" style="white-space: nowrap;" >';
- echo '<img src="', $WT_IMAGES['spacer'], '" height="2" width="', $Dindent, '" align="middle" alt=""><a href="#" onclick="return expand_layer(\'sosa_', $sosa, '\');" class="top"><i id="sosa_', $sosa, '_img" class="icon-minus" title="', WT_I18N::translate('View family'), '"></i></a>';
- echo '&nbsp;<span dir="ltr" class="person_box">&nbsp;', ($sosa*2), '&nbsp;</span>&nbsp;', WT_I18N::translate('and');
- echo '&nbsp;<span dir="ltr" class="person_boxF">&nbsp;', ($sosa*2+1), '&nbsp;</span>&nbsp;';
+ echo '<span class="details1">';
+ echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="2" width="', Theme::theme()->parameter('chart-descendancy-indent'), '" alt=""><a href="#" onclick="return expand_layer(\'sosa_', $sosa, '\');" class="top"><i id="sosa_', $sosa, '_img" class="icon-minus" title="', WT_I18N::translate('View family'), '"></i></a>';
+ echo '&nbsp;<span dir="ltr" class="person_box">&nbsp;', ($sosa * 2), '&nbsp;</span>&nbsp;', WT_I18N::translate('and');
+ echo '&nbsp;<span dir="ltr" class="person_boxF">&nbsp;', ($sosa * 2 + 1), '&nbsp;</span>&nbsp;';
if ($family->canShow()) {
foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) {
echo ' <a href="', $family->getHtmlUrl(), '" class="details1">', $fact->summary(), '</a>';
@@ -147,9 +154,9 @@ class WT_Controller_Ancestry extends WT_Controller_Chart {
}
echo '</span>';
// display parents recursively - or show empty boxes
- echo '<ul style="list-style: none; display: block;" id="sosa_', $sosa, '">';
- $this->printChildAscendancy($family->getHusband(), $sosa*2, $depth-1);
- $this->printChildAscendancy($family->getWife(), $sosa*2+1, $depth-1);
+ echo '<ul id="sosa_', $sosa, '" class="generation">';
+ $this->printChildAscendancy($family->getHusband(), $sosa * 2, $depth - 1);
+ $this->printChildAscendancy($family->getWife(), $sosa * 2 + 1, $depth - 1);
echo '</ul>';
}
echo '</li>';
diff --git a/library/WT/Controller/Base.php b/library/WT/Controller/Base.php
index bf53a0daa6..2572bfb893 100644
--- a/library/WT/Controller/Base.php
+++ b/library/WT/Controller/Base.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 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
@@ -31,7 +31,7 @@ class WT_Controller_Base {
);
private $external_javascript = array();
- protected $page_header = false; // Have we printed a page header?
+ protected $page_header = false; // Have we printed a page header?
/**
* Startup activity
@@ -45,7 +45,7 @@ class WT_Controller_Base {
public function __destruct() {
// If we printed a header, automatically print a footer
if ($this->page_header) {
- $this->pageFooter();
+ echo $this->pageFooter();
}
}
@@ -78,7 +78,7 @@ class WT_Controller_Base {
$backtrace = debug_backtrace();
$script = '/* ' . $backtrace[0]['file'] . ':' . $backtrace[0]['line'] . ' */' . PHP_EOL . $script;
}
- $tmp =& $this->inline_javascript[$priority];
+ $tmp = & $this->inline_javascript[$priority];
$tmp[] = $script;
return $this;
diff --git a/library/WT/Controller/Branches.php b/library/WT/Controller/Branches.php
index bb42210352..14eae86996 100644
--- a/library/WT/Controller/Branches.php
+++ b/library/WT/Controller/Branches.php
@@ -272,7 +272,7 @@ class WT_Controller_Branches extends WT_Controller_Page {
* @return string
*/
private static function sosaGeneration($sosa) {
- $generation = (int)log($sosa, 2) + 1;
+ $generation = (int) log($sosa, 2) + 1;
return '<sup title="' . WT_I18N::translate('Generation') . '">' . $generation . '</sup>';
}
diff --git a/library/WT/Controller/Chart.php b/library/WT/Controller/Chart.php
index 3301328572..1205aa37d8 100644
--- a/library/WT/Controller/Chart.php
+++ b/library/WT/Controller/Chart.php
@@ -36,11 +36,11 @@ class WT_Controller_Chart extends WT_Controller_Page {
$this->root = WT_Individual::getInstance($rootid);
if (!$this->root) {
// Missing root individual? Show the chart for someone.
- $this->root = $this->getSignificantIndividual();
+ $this->root = $this->getSignificantIndividual();
}
if (!$this->root || !$this->root->canShowName()) {
- header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
+ header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
$this->error_message = WT_I18N::translate('This individual does not exist or you do not have permission to view it.');
}
}
diff --git a/library/WT/Controller/Compact.php b/library/WT/Controller/Compact.php
index 4c63935e5f..5b58818c3e 100644
--- a/library/WT/Controller/Compact.php
+++ b/library/WT/Controller/Compact.php
@@ -24,10 +24,10 @@
*/
class WT_Controller_Compact extends WT_Controller_Chart {
// Data for the view
- public $show_thumbs=false;
+ public $show_thumbs = false;
// Date for the controller
- private $treeid=array();
+ private $treeid = array();
/**
* Startup activity
@@ -60,22 +60,24 @@ class WT_Controller_Compact extends WT_Controller_Chart {
$indi = $this->treeid[$n];
if ($indi && $indi->canShowName()) {
- $name=$indi->getFullName();
- $addname=$indi->getAddName();
+ $name = $indi->getFullName();
+ $addname = $indi->getAddName();
if ($this->show_thumbs && $SHOW_HIGHLIGHT_IMAGES) {
- $html=$indi->displayImage();
+ $html = $indi->displayImage();
} else {
- $html='';
+ $html = '';
}
- $html .= '<a class="name1" href="'.$indi->getHtmlUrl().'">';
+ $html .= '<a class="name1" href="' . $indi->getHtmlUrl() . '">';
$html .= $name;
- if ($addname) $html .= '<br>' . $addname;
+ if ($addname) {
+ $html .= '<br>' . $addname;
+ }
$html .= '</a>';
$html .= '<br>';
if ($indi->canShow()) {
- $html.='<div class="details1">'.$indi->getLifeSpan().'</div>';
+ $html .= '<div class="details1">' . $indi->getLifeSpan() . '</div>';
}
} else {
// Empty box
@@ -83,20 +85,20 @@ class WT_Controller_Compact extends WT_Controller_Chart {
}
// -- box color
- $isF='';
- if ($n==1) {
- if ($indi && $indi->getSex()=='F') {
- $isF='F';
+ $isF = '';
+ if ($n == 1) {
+ if ($indi && $indi->getSex() == 'F') {
+ $isF = 'F';
}
- } elseif ($n%2) {
- $isF='F';
+ } elseif ($n % 2) {
+ $isF = 'F';
}
// -- box size
- if ($n==1) {
- return '<td class="person_box'.$isF.' person_box_template" style="text-align:center; vertical-align:top;">'.$html.'</td>';
+ if ($n == 1) {
+ return '<td class="person_box' . $isF . ' person_box_template" style="text-align:center; vertical-align:top;">' . $html . '</td>';
} else {
- return '<td class="person_box'.$isF.' person_box_template" style="text-align:center; vertical-align:top;" width="15%">'.$html.'</td>';
+ return '<td class="person_box' . $isF . ' person_box_template" style="text-align:center; vertical-align:top;" width="15%">' . $html . '</td>';
}
}
@@ -113,7 +115,7 @@ class WT_Controller_Compact extends WT_Controller_Chart {
$arrow_dir = substr($arrow_dir, 0, 1);
if ($TEXT_DIRECTION == 'rtl') {
- if ($arrow_dir=='l') {
+ if ($arrow_dir == 'l') {
$arrow_dir = 'r';
} elseif ($arrow_dir == 'r') {
$arrow_dir = 'l';
@@ -124,7 +126,7 @@ class WT_Controller_Compact extends WT_Controller_Chart {
$title = WT_I18N::translate('Compact tree of %s', $indi->getFullName());
$text = '<a class="icon-' . $arrow_dir . 'arrow" title="' . strip_tags($title) . '" href="?rootid=' . $indi->getXref();
if ($this->show_thumbs) {
- $text .= "&amp;show_thumbs=".$this->show_thumbs;
+ $text .= "&amp;show_thumbs=" . $this->show_thumbs;
}
$text .= "\"></a>";
} else {
diff --git a/library/WT/Controller/Descendancy.php b/library/WT/Controller/Descendancy.php
index 65e0cd0071..fc635329d0 100644
--- a/library/WT/Controller/Descendancy.php
+++ b/library/WT/Controller/Descendancy.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -20,6 +20,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use Rhumsaa\Uuid\Uuid;
+use WT\Theme;
/**
* Class WT_Controller_Descendancy - Controller for the descendancy chart
@@ -42,8 +43,8 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
var $pbwidth;
var $pbheight;
// d'Aboville numbering system [ http://www.saintclair.org/numbers/numdob.html ]
- var $dabo_num=array();
- var $dabo_sex=array();
+ var $dabo_num = array();
+ var $dabo_sex = array();
var $name;
var $cellwidth;
var $show_cousins;
@@ -52,41 +53,43 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
* Create the descendancy controller
*/
function __construct() {
- global $bwidth, $bheight, $cbwidth, $cbheight, $pbwidth, $pbheight, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS, $show_full;
+ global $bwidth, $bheight, $pbwidth, $pbheight, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS, $show_full;
parent::__construct();
// Extract parameters from form
- $this->show_full = WT_Filter::getInteger('show_full', 0, 1, $PEDIGREE_FULL_DETAILS);
+ $this->show_full = WT_Filter::getInteger('show_full', 0, 1, $PEDIGREE_FULL_DETAILS);
$this->chart_style = WT_Filter::getInteger('chart_style', 0, 3, 0);
$this->generations = WT_Filter::getInteger('generations', 2, $MAX_DESCENDANCY_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS);
- $this->box_width = WT_Filter::getInteger('box_width', 50, 300, 100);
+ $this->box_width = WT_Filter::getInteger('box_width', 50, 300, 100);
// This is passed as a global. A parameter would be better...
- $show_full=$this->show_full;
+ $show_full = $this->show_full;
- if (!isset($this->personcount)) $this->personcount = 1;
+ if (!isset($this->personcount)) {
+ $this->personcount = 1;
+ }
// -- size of the detailed boxes based upon optional width parameter
- $Dbwidth = ($this->box_width*$bwidth)/100;
- $Dbheight = ($this->box_width*$bheight)/100;
+ $Dbwidth = ($this->box_width * $bwidth) / 100;
+ $Dbheight = ($this->box_width * $bheight) / 100;
$bwidth = $Dbwidth;
$bheight = $Dbheight;
// -- adjust size of the compact box
if (!$this->show_full) {
- $bwidth = $cbwidth;
- $bheight = $cbheight;
+ $bwidth = Theme::theme()->parameter('compact-chart-box-x');
+ $bheight = Theme::theme()->parameter('compact-chart-box-y');
}
- $pbwidth = $bwidth+12;
- $pbheight = $bheight+14;
+ $pbwidth = $bwidth + 12;
+ $pbheight = $bheight + 14;
// Validate form variables
- if (strlen($this->name)<30) {
- $this->cellwidth=420;
+ if (strlen($this->name) < 30) {
+ $this->cellwidth = 420;
} else {
- $this->cellwidth=(strlen($this->name)*14);
+ $this->cellwidth = (strlen($this->name) * 14);
}
if ($this->root && $this->root->canShowName()) {
@@ -109,14 +112,16 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
*
* @return void
*/
- public function printChildFamily(WT_Individual $person, $depth, $label='1.', $gpid='') {
+ public function printChildFamily(WT_Individual $person, $depth, $label = '1.', $gpid = '') {
- if ($depth<2) return;
+ if ($depth < 2) {
+ return;
+ }
foreach ($person->getSpouseFamilies() as $family) {
print_sosa_family($family->getXref(), '', -1, $label, $person->getXref(), $gpid);
- $i=1;
+ $i = 1;
foreach ($family->getChildren() as $child) {
- $this->printChildFamily($child, $depth-1, $label.($i++).'.', $person->getXref());
+ $this->printChildFamily($child, $depth - 1, $label . ($i++) . '.', $person->getXref());
}
}
}
@@ -130,43 +135,52 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
* @return void
*/
public function printChildDescendancy(WT_Individual $person, $depth) {
- global $WT_IMAGES, $Dindent;
-
echo "<li>";
- echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>";
- if ($depth==$this->generations) echo "<img src=\"".$WT_IMAGES["spacer"]."\" height=\"3\" width=\"$Dindent\" alt=\"\"></td><td>";
- else {
- echo "<img src=\"".$WT_IMAGES["spacer"]."\" height=\"3\" width=\"3\" alt=\"\">";
- echo "<img src=\"".$WT_IMAGES["hline"]."\" height=\"3\" width=\"".($Dindent-3)."\" alt=\"\"></td><td>";
+ echo "<table><tr><td>";
+ if ($depth == $this->generations) {
+ echo "<img src=\"" . Theme::theme()->parameter('image-spacer') . "\" height=\"3\" width=\"", Theme::theme()->parameter('chart-descendancy-indent'), "\" alt=\"\"></td><td>";
+ } else {
+ echo "<img src=\"" . Theme::theme()->parameter('image-spacer') . "\" height=\"3\" width=\"3\" alt=\"\">";
+ echo "<img src=\"" . Theme::theme()->parameter('image-hline') . "\" height=\"3\" width=\"", Theme::theme()->parameter('chart-descendancy-indent') - 3, "\" alt=\"\"></td><td>";
}
print_pedigree_person($person);
echo '</td>';
// check if child has parents and add an arrow
- echo '<td>&nbsp;</td>';
+ echo '<td></td>';
echo '<td>';
foreach ($person->getChildFamilies() as $cfamily) {
foreach ($cfamily->getSpouses() as $parent) {
- print_url_arrow('?rootid='.$parent->getXref().'&amp;generations='.$this->generations.'&amp;chart_style='.$this->chart_style.'&amp;show_full='.$this->show_full.'&amp;box_width='.$this->box_width.'&amp;ged='.WT_GEDURL, WT_I18N::translate('Start at parents'), 2);
+ print_url_arrow('?rootid=' . $parent->getXref() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->show_full . '&amp;box_width=' . $this->box_width . '&amp;ged=' . WT_GEDURL, WT_I18N::translate('Start at parents'), 2);
// only show the arrow for one of the parents
break;
}
}
// d'Aboville child number
- $level =$this->generations-$depth;
- if ($this->show_full) echo '<br><br>&nbsp;';
+ $level = $this->generations - $depth;
+ if ($this->show_full) {
+ echo '<br><br>&nbsp;';
+ }
echo '<span dir="ltr">'; //needed so that RTL languages will display this properly
- if (!isset($this->dabo_num[$level])) $this->dabo_num[$level]=0;
+ if (!isset($this->dabo_num[$level])) {
+ $this->dabo_num[$level] = 0;
+ }
$this->dabo_num[$level]++;
- $this->dabo_num[$level+1]=0;
- $this->dabo_sex[$level]=$person->getSex();
- for ($i=0; $i<=$level;$i++) {
- $isf=$this->dabo_sex[$i];
- if ($isf=="M") $isf="";
- if ($isf=="U") $isf="NN";
- echo "<span class=\"person_box".$isf."\">&nbsp;".$this->dabo_num[$i]."&nbsp;</span>";
- if ($i<$level) echo ".";
+ $this->dabo_num[$level + 1] = 0;
+ $this->dabo_sex[$level] = $person->getSex();
+ for ($i = 0; $i <= $level; $i++) {
+ $isf = $this->dabo_sex[$i];
+ if ($isf === 'M') {
+ $isf = '';
+ }
+ if ($isf === 'U') {
+ $isf = 'NN';
+ }
+ echo "<span class=\"person_box" . $isf . "\">&nbsp;" . $this->dabo_num[$i] . "&nbsp;</span>";
+ if ($i < $level) {
+ echo '.';
+ }
}
echo "</span>";
echo "</td></tr>";
@@ -189,14 +203,12 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
* @return void
*/
private function printFamilyDescendancy(WT_Individual $person, WT_Family $family, $depth) {
- global $WT_IMAGES, $Dindent;
-
$uid = Uuid::uuid4(); // create a unique ID
// print marriage info
echo '<li>';
- echo '<img src="', $WT_IMAGES['spacer'], '" height="2" width="', ($Dindent+4), '" alt="">';
- echo '<span class="details1" style="white-space:nowrap;">';
- echo "<a href=\"#\" onclick=\"expand_layer('".$uid."'); return false;\" class=\"top\"><i id=\"".$uid."_img\" class=\"icon-minus\" title=\"".WT_I18N::translate('View family')."\"></i></a>";
+ echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="2" width="', Theme::theme()->parameter('chart-descendancy-indent') + 4, '" alt="">';
+ echo '<span class="details1">';
+ echo "<a href=\"#\" onclick=\"expand_layer('" . $uid . "'); return false;\" class=\"top\"><i id=\"" . $uid . "_img\" class=\"icon-minus\" title=\"" . WT_I18N::translate('View family') . "\"></i></a>";
if ($family->canShow()) {
foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) {
echo ' <a href="', $family->getHtmlUrl(), '" class="details1">', $fact->summary(), '</a>';
@@ -205,46 +217,50 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
echo '</span>';
// print spouse
- $spouse=$family->getSpouse($person);
- echo '<ul style="list-style:none; display:block;" id="'.$uid.'">';
+ $spouse = $family->getSpouse($person);
+ echo '<ul id="' . $uid . '" class="generation">';
echo '<li>';
- echo '<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
+ echo '<table><tr><td>';
print_pedigree_person($spouse);
echo '</td>';
// check if spouse has parents and add an arrow
- echo '<td>&nbsp;</td>';
+ echo '<td></td>';
echo '<td>';
if ($spouse) {
foreach ($spouse->getChildFamilies() as $cfamily) {
foreach ($cfamily->getSpouses() as $parent) {
- print_url_arrow('?rootid='.$parent->getXref().'&amp;generations='.$this->generations.'&amp;chart_style='.$this->chart_style.'&amp;show_full='.$this->show_full.'&amp;box_width='.$this->box_width.'&amp;ged='.WT_GEDURL, WT_I18N::translate('Start at parents'), 2);
+ print_url_arrow('?rootid=' . $parent->getXref() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->show_full . '&amp;box_width=' . $this->box_width . '&amp;ged=' . WT_GEDURL, WT_I18N::translate('Start at parents'), 2);
// only show the arrow for one of the parents
break;
}
}
}
- if ($this->show_full) echo '<br><br>&nbsp;';
+ if ($this->show_full) {
+ echo '<br><br>&nbsp;';
+ }
echo '</td></tr>';
// children
$children = $family->getChildren();
echo '<tr><td colspan="3" class="details1" >&nbsp;&nbsp;';
if ($children) {
- echo WT_Gedcom_Tag::getLabel('NCHI').': '.count($children);
+ echo WT_Gedcom_Tag::getLabel('NCHI') . ': ' . count($children);
} else {
// Distinguish between no children (NCHI 0) and no recorded
// children (no CHIL records)
if (strpos($family->getGedcom(), '\n1 NCHI 0')) {
- echo WT_Gedcom_Tag::getLabel('NCHI').': '.count($children);
+ echo WT_Gedcom_Tag::getLabel('NCHI') . ': ' . count($children);
} else {
echo WT_I18N::translate('No children');
}
}
echo '</td></tr></table>';
echo '</li>';
- if ($depth>1) foreach ($children as $child) {
- $this->printChildDescendancy($child, $depth-1);
+ if ($depth > 1) {
+ foreach ($children as $child) {
+ $this->printChildDescendancy($child, $depth - 1);
+ }
}
echo '</ul>';
echo '</li>';
@@ -263,14 +279,14 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
if ($n < 1) {
return $array;
}
- $array[$person->getXref()]=$person;
+ $array[$person->getXref()] = $person;
foreach ($person->getSpouseFamilies() as $family) {
$spouse = $family->getSpouse($person);
if ($spouse) {
$array[$spouse->getXref()] = $spouse;
}
foreach ($family->getChildren() as $child) {
- $array = $this->individualDescendancy($child, $n-1, $array);
+ $array = $this->individualDescendancy($child, $n - 1, $array);
}
}
return $array;
@@ -290,9 +306,9 @@ class WT_Controller_Descendancy extends WT_Controller_Chart {
return $array;
}
foreach ($person->getSpouseFamilies() as $family) {
- $array[$family->getXref()]=$family;
+ $array[$family->getXref()] = $family;
foreach ($family->getChildren() as $child) {
- $array = $this->familyDescendancy($child, $n-1, $array);
+ $array = $this->familyDescendancy($child, $n - 1, $array);
}
}
return $array;
diff --git a/library/WT/Controller/Family.php b/library/WT/Controller/Family.php
index 98404d076c..020b8f49ff 100644
--- a/library/WT/Controller/Family.php
+++ b/library/WT/Controller/Family.php
@@ -21,7 +21,7 @@
use WT\Auth;
-require_once WT_ROOT.'includes/functions/functions_print_facts.php';
+require_once WT_ROOT . 'includes/functions/functions_print_facts.php';
/**
* Class WT_Controller_Family - Controller for the family page
@@ -79,9 +79,9 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
* @return string
*/
function getTimelineIndis($tags) {
- preg_match_all('/\n1 (?:'.implode('|', $tags).') @('.WT_REGEX_XREF.')@/', $this->record->getGedcom(), $matches);
+ preg_match_all('/\n1 (?:' . implode('|', $tags) . ') @(' . WT_REGEX_XREF . ')@/', $this->record->getGedcom(), $matches);
foreach ($matches[1] as &$match) {
- $match='pids%5B%5D='.$match;
+ $match = 'pids%5B%5D=' . $match;
}
return implode('&amp;', $matches[1]);
}
@@ -104,18 +104,18 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
if (WT_USER_CAN_EDIT) {
// edit_fam / members
$submenu = new WT_Menu(WT_I18N::translate('Change family members'), '#', 'menu-fam-change');
- $submenu->setOnclick("return change_family_members('".$this->record->getXref()."');");
+ $submenu->setOnclick("return change_family_members('" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
// edit_fam / add child
$submenu = new WT_Menu(WT_I18N::translate('Add a child to this family'), '#', 'menu-fam-addchil');
- $submenu->setOnclick("return add_child_to_family('".$this->record->getXref()."', 'U');");
+ $submenu->setOnclick("return add_child_to_family('" . $this->record->getXref() . "', 'U');");
$menu->addSubmenu($submenu);
// edit_fam / reorder_children
if ($this->record->getNumberOfChildren() > 1) {
$submenu = new WT_Menu(WT_I18N::translate('Re-order children'), '#', 'menu-fam-orderchil');
- $submenu->setOnclick("return reorder_children('".$this->record->getXref()."');");
+ $submenu->setOnclick("return reorder_children('" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
}
@@ -123,7 +123,7 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
// delete
if (WT_USER_CAN_EDIT) {
$submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-fam-del');
- $submenu->setOnclick("return delete_family('" . 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?') . "', '".$this->record->getXref()."');");
+ $submenu->setOnclick("return delete_family('" . 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?') . "', '" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
@@ -141,7 +141,7 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
'#',
'menu-fam-addfav'
);
- $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})");
+ $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
$menu->addSubmenu($submenu);
}
@@ -194,14 +194,14 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
echo '<tr><td class="descriptionbox">';
echo WT_Gedcom_Tag::getLabel('NOTE');
echo '</td><td class="optionbox">';
- echo "<a href=\"#\" onclick=\"return add_new_record('".$this->record->getXref()."','NOTE');\">", WT_I18N::translate('Add a new note'), '</a>';
+ echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','NOTE');\">", WT_I18N::translate('Add a new note'), '</a>';
echo help_link('add_note');
echo '</td></tr>';
echo '<tr><td class="descriptionbox">';
echo WT_Gedcom_Tag::getLabel('SHARED_NOTE');
echo '</td><td class="optionbox">';
- echo "<a href=\"#\" onclick=\"return add_new_record('".$this->record->getXref()."','SHARED_NOTE');\">", WT_I18N::translate('Add a new shared note'), '</a>';
+ echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SHARED_NOTE');\">", WT_I18N::translate('Add a new shared note'), '</a>';
echo help_link('add_shared_note');
echo '</td></tr>';
@@ -209,17 +209,17 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord {
echo '<tr><td class="descriptionbox">';
echo WT_Gedcom_Tag::getLabel('OBJE');
echo '</td><td class="optionbox">';
- echo "<a href=\"#\" onclick=\"window.open('addmedia.php?action=showmediaform&amp;linktoid=".$this->record->getXref()."', '_blank', edit_window_specs); return false;\">", WT_I18N::translate('Add a new media object'), '</a>';
+ echo "<a href=\"#\" onclick=\"window.open('addmedia.php?action=showmediaform&amp;linktoid=" . $this->record->getXref() . "', '_blank', edit_window_specs); return false;\">", WT_I18N::translate('Add a new media object'), '</a>';
echo help_link('OBJE');
echo '<br>';
- echo "<a href=\"#\" onclick=\"window.open('inverselink.php?linktoid=".$this->record->getXref()."&amp;linkto=family', '_blank', find_window_specs); return false;\">", WT_I18N::translate('Link to an existing media object'), '</a>';
+ echo "<a href=\"#\" onclick=\"window.open('inverselink.php?linktoid=" . $this->record->getXref() . "&amp;linkto=family', '_blank', find_window_specs); return false;\">", WT_I18N::translate('Link to an existing media object'), '</a>';
echo '</td></tr>';
}
echo '<tr><td class="descriptionbox">';
echo WT_Gedcom_Tag::getLabel('SOUR');
echo '</td><td class="optionbox">';
- echo "<a href=\"#\" onclick=\"return add_new_record('".$this->record->getXref()."','SOUR');\">", WT_I18N::translate('Add a new source citation'), '</a>';
+ echo "<a href=\"#\" onclick=\"return add_new_record('" . $this->record->getXref() . "','SOUR');\">", WT_I18N::translate('Add a new source citation'), '</a>';
echo help_link('add_source');
echo '</td></tr>';
}
diff --git a/library/WT/Controller/Familybook.php b/library/WT/Controller/Familybook.php
index 1e541ff8b9..a97074f2fc 100644
--- a/library/WT/Controller/Familybook.php
+++ b/library/WT/Controller/Familybook.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -18,6 +18,7 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Familybook - Controller for the familybook chart
@@ -63,15 +64,15 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
$this->box_width = WT_Filter::getInteger('box_width', 50, 300, 100);
// Box sizes are set globally in the theme. Modify them here.
- global $bwidth, $bheight, $cbwidth, $cbheight, $Dbwidth, $bhalfheight, $Dbheight;
+ global $bwidth, $bheight, $Dbwidth, $bhalfheight, $Dbheight;
$Dbwidth = $this->box_width * $bwidth / 100;
$bwidth = $Dbwidth;
$bheight = $Dbheight;
// -- adjust size of the compact box
if (!$this->show_full) {
- $bwidth = $this->box_width * $cbwidth / 100;
- $bheight = $cbheight;
+ $bwidth = $this->box_width * Theme::theme()->parameter('compact-chart-box-x') / 100;
+ $bheight = Theme::theme()->parameter('compact-chart-box-y');
}
$bhalfheight = $bheight / 2;
if ($this->root && $this->root->canShowName()) {
@@ -98,7 +99,7 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
* @return integer
*/
private function printDescendency(WT_Individual $person = null, $count) {
- global $WT_IMAGES, $bwidth, $bheight, $show_full, $box_width; // print_pedigree_person() requires these globals.
+ global $bwidth, $bheight, $show_full, $box_width; // print_pedigree_person() requires these globals.
if ($count > $this->dgenerations) {
return 0;
@@ -129,14 +130,16 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
$ct = 0; // set to 0 for empty boxes
}
if ($count < $this->dgenerations) {
- if ($ct == 0) { // empty boxes
+ if ($ct == 0) {
+ // empty boxes
echo '<table><tr><td>';
$person2 = null;
$kids = $this->printDescendency($person2, $count + 1);
$numkids += $kids;
echo '</td></tr></table>';
}
- if ($ct > 0) { // real people
+ if ($ct > 0) {
+ // real people
echo '<table>';
for ($i = 0; $i < $ct; $i++) {
$person2 = $children[$i];
@@ -149,13 +152,13 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
if ($ct > 1) {
if ($i == 0) {
//-- adjust for the first column on left
- $h = round(((($bheight) * $kids) + 8) / 2); // Assumes border = 1 and padding = 3
+ $h = round(((($bheight) * $kids) + 8) / 2); // Assumes border = 1 and padding = 3
//-- adjust for other vertical columns
if ($kids > 1) {
$h = ($kids - 1) * 4 + $h;
}
echo '<td class="tdbot">',
- '<img class="tvertline" id="vline_', $chil, '" src="', $WT_IMAGES["vline"], '" height="', $h - 1, '" alt=""></td>';
+ '<img class="tvertline" id="vline_', $chil, '" src="', Theme::theme()->parameter('image-vline'), '" height="', $h - 1, '" alt=""></td>';
} else if ($i == $ct - 1) {
//-- adjust for the first column on left
$h = round(((($bheight) * $kids) + 8) / 2);
@@ -164,10 +167,10 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
$h = ((($kids - 1) * 4) + $h);
}
echo '<td class="tdtop">',
- '<img class="bvertline" id="vline_', $chil, '" src="', $WT_IMAGES["vline"], '" height="', $h + 1, '" alt=""></td>';
+ '<img class="bvertline" id="vline_', $chil, '" src="', Theme::theme()->parameter('image-vline'), '" height="', $h + 1, '" alt=""></td>';
} else {
- echo '<td style="background: url(', $WT_IMAGES["vline"], ');">',
- '<img class="spacer" src="', $WT_IMAGES["spacer"], '" alt=""></td>';
+ echo '<td style="background: url(', Theme::theme()->parameter('image-vline'), ');">',
+ '<img class="spacer" src="', Theme::theme()->parameter('image-spacer'), '" alt=""></td>';
}
}
echo '</tr>';
@@ -185,7 +188,7 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
if ($person) {
print_pedigree_person($person);
echo '</td><td>',
- '<img class="line2" src="', $WT_IMAGES["hline"], '" width="8" height="3" alt="">';
+ '<img class="line2" src="', Theme::theme()->parameter('image-hline'), '" width="8" height="3" alt="">';
} else {
echo '<div style="width:', $bwidth + 19, 'px; height:', $bheight + 8, 'px;"></div>',
'</td><td>';
@@ -223,12 +226,12 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
* @param integer $count
*/
private function printPersonPedigree($person, $count) {
- global $WT_IMAGES, $bheight, $bwidth, $bhalfheight;
+ global $bheight, $bwidth, $bhalfheight;
if ($count >= $this->generations) {
return;
}
- $genoffset = $this->generations; // handle pedigree n generations lines
+ $genoffset = $this->generations; // handle pedigree n generations lines
//-- calculate how tall the lines should be
$lh = ($bhalfheight + 4) * pow(2, ($genoffset - $count - 1));
//
@@ -248,22 +251,22 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
echo '</td><td></tr></table>';
}
- //Empty box section done, now for regular pedigree
+ // Empty box section done, now for regular pedigree
foreach ($person->getChildFamilies() as $family) {
echo '<table><tr><td class="tdbot">';
- //
- //Determine line height for two or more spouces
- //And then adjust the vertical line for the root person only
- //
+ // Determine line height for two or more spouces
+ // And then adjust the vertical line for the root person only
$sfamilies = $person->getSpouseFamilies();
$famcount = 0;
- if ($this->show_spouse) { // count number of spouses
+ if ($this->show_spouse) {
+ // count number of spouses
$famcount += count($sfamilies);
}
$savlh = $lh; // Save current line height
if ($count == 1 && $genoffset <= $famcount) {
$linefactor = 0;
- if ($genoffset > 2) { // genoffset of 2 needs no adjustment
+ // genoffset of 2 needs no adjustment
+ if ($genoffset > 2) {
$tblheight = $bheight + 8;
if ($genoffset == 3) {
if ($famcount == 3) {
@@ -292,9 +295,9 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
$lh = $savlh;
}
}
- echo '<img class="line3 pvline" src="', $WT_IMAGES["vline"], '" height="', $lh - 1, '" alt=""></td>',
+ echo '<img class="line3 pvline" src="', Theme::theme()->parameter('image-vline'), '" height="', $lh - 1, '" alt=""></td>',
'<td>',
- '<img class="line4" src="', $WT_IMAGES["hline"], '" height="3" alt=""></td>',
+ '<img class="line4" src="', Theme::theme()->parameter('image-hline'), '" height="3" alt=""></td>',
'<td>';
$lh = $savlh; // restore original line height
//-- print the father box
@@ -317,8 +320,8 @@ class WT_Controller_Familybook extends WT_Controller_Chart {
}
}
echo '</tr><tr>',
- '<td class="tdtop"><img class="pvline" src="', $WT_IMAGES["vline"], '" height="', $lh + 1, '" alt=""></td>',
- '<td><img class="line4" src="', $WT_IMAGES["hline"], '" height="3" alt=""></td>',
+ '<td class="tdtop"><img class="pvline" src="', Theme::theme()->parameter('image-vline'), '" height="', $lh + 1, '"></td>',
+ '<td><img class="line4" src="', Theme::theme()->parameter('image-hline'), '" height="3"></td>',
'<td>';
//-- print the mother box
print_pedigree_person($family->getWife());
diff --git a/library/WT/Controller/Fanchart.php b/library/WT/Controller/Fanchart.php
index f51f9078d3..d87a9d2975 100644
--- a/library/WT/Controller/Fanchart.php
+++ b/library/WT/Controller/Fanchart.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -18,6 +18,7 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Fanchart Controller for the fan chart
@@ -43,8 +44,8 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
$default_generations = $WT_TREE->getPreference('DEFAULT_PEDIGREE_GENERATIONS');
// Extract the request parameters
- $this->fan_style = WT_Filter::getInteger('fan_style', 2, 4, 3);
- $this->fan_width = WT_Filter::getInteger('fan_width', 50, 300, 100);
+ $this->fan_style = WT_Filter::getInteger('fan_style', 2, 4, 3);
+ $this->fan_width = WT_Filter::getInteger('fan_width', 50, 300, 100);
$this->generations = WT_Filter::getInteger('generations', 2, 9, $default_generations);
if ($this->root && $this->root->canShowName()) {
@@ -79,14 +80,14 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
* @return string $text output string
*/
public function splitAlignText($data, $maxlen) {
- $RTLOrd = array(215,216,217,218,219);
+ $RTLOrd = array(215, 216, 217, 218, 219);
$lines = explode("\n", $data);
// more than 1 line : recursive calls
- if (count($lines)>1) {
+ if (count($lines) > 1) {
$text = '';
foreach ($lines as $line) {
- $text .= $this->splitAlignText($line, $maxlen)."\n";
+ $text .= $this->splitAlignText($line, $maxlen) . "\n";
}
return $text;
}
@@ -98,22 +99,26 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
// do not split hebrew line
$found = false;
foreach ($RTLOrd as $ord) {
- if (strpos($data, chr($ord)) !== false) $found=true;
+ if (strpos($data, chr($ord)) !== false) {
+ $found = true;
+ }
}
if ($found) {
- $line=$data;
+ $line = $data;
} else {
foreach ($split as $word) {
$len = strlen($line);
$wlen = strlen($word);
- if (($len+$wlen)<$maxlen) {
- if (!empty($line)) $line .= " ";
+ if (($len + $wlen) < $maxlen) {
+ if (!empty($line)) {
+ $line .= ' ';
+ }
$line .= "$word";
} else {
- $p = max(0,(int)(($maxlen-$len)/2));
+ $p = max(0, (int) (($maxlen - $len) / 2));
if (!empty($line)) {
$line = str_repeat(' ', $p) . $line; // center alignment using spaces
- $text .= $line. "\n";
+ $text .= $line . "\n";
}
$line = $word;
}
@@ -122,10 +127,10 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
// last line
if (!empty($line)) {
$len = strlen($line);
- if (in_array(ord($line{0}),$RTLOrd)) {
- $len/=2;
+ if (in_array(ord($line{0}), $RTLOrd)) {
+ $len /= 2;
}
- $p = max(0,(int)(($maxlen-$len)/2));
+ $p = max(0, (int) (($maxlen - $len) / 2));
$line = str_repeat(' ', $p) . $line; // center alignment using spaces
$text .= $line;
}
@@ -141,11 +146,10 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
* HTTP requests.
*
* @param string $what "png" or "html"
- * @param string[] $fanChart Presentation parameters, provided by the theme.
*
* @return string
*/
- public function generateFanChart($what, $fanChart) {
+ public function generateFanChart($what) {
$treeid = $this->sosaAncestors($this->generations);
$fanw = 640 * $this->fan_width / 100;
$fandeg = 90 * $this->fan_style;
@@ -182,10 +186,29 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
ImageColorTransparent($image, $white);
- $color = ImageColorAllocate($image, hexdec(substr($fanChart['color'],1,2)), hexdec(substr($fanChart['color'],3,2)), hexdec(substr($fanChart['color'],5,2)));
- $bgcolor = ImageColorAllocate($image, hexdec(substr($fanChart['bgColor'],1,2)), hexdec(substr($fanChart['bgColor'],3,2)), hexdec(substr($fanChart['bgColor'],5,2)));
- $bgcolorM = ImageColorAllocate($image, hexdec(substr($fanChart['bgMColor'],1,2)), hexdec(substr($fanChart['bgMColor'],3,2)), hexdec(substr($fanChart['bgMColor'],5,2)));
- $bgcolorF = ImageColorAllocate($image, hexdec(substr($fanChart['bgFColor'],1,2)), hexdec(substr($fanChart['bgFColor'],3,2)), hexdec(substr($fanChart['bgFColor'],5,2)));
+ $color = ImageColorAllocate(
+ $image,
+ hexdec(substr(Theme::theme()->parameter('chart-font-color'), 0, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-font-color'), 2, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-font-color'), 4, 2)));
+ $bgcolor = ImageColorAllocate(
+ $image,
+ hexdec(substr(Theme::theme()->parameter('chart-background-u'), 0, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-background-u'), 2, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-background-u'), 4, 2))
+ );
+ $bgcolorM = ImageColorAllocate(
+ $image,
+ hexdec(substr(Theme::theme()->parameter('chart-background-m'), 0, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-background-m'), 2, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-background-m'), 4, 2))
+ );
+ $bgcolorF = ImageColorAllocate(
+ $image,
+ hexdec(substr(Theme::theme()->parameter('chart-background-f'), 0, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-background-f'), 2, 2)),
+ hexdec(substr(Theme::theme()->parameter('chart-background-f'), 4, 2))
+ );
// imagemap
$imagemap = '<map id="fanmap" name="fanmap">';
@@ -238,7 +261,7 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
// split and center text by lines
- $wmax = (int)($angle * 7 / $fanChart['size'] * $scale);
+ $wmax = (int) ($angle * 7 / Theme::theme()->parameter('chart-font-size') * $scale);
$wmax = min($wmax, 35 * $scale);
if ($gen == 0) {
$wmax = min($wmax, 17 * $scale);
@@ -277,7 +300,13 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
}
// print text
- ImageTtfText($image, (double)$fanChart['size'], $tangle, $tx, $ty, $color, $fanChart['font'], $text);
+ ImageTtfText(
+ $image,
+ Theme::theme()->parameter('chart-font-size'),
+ $tangle, $tx, $ty,
+ $color, Theme::theme()->parameter('chart-font-name'),
+ $text
+ );
$imagemap .= '<area shape="poly" coords="';
// plot upper points
@@ -319,22 +348,22 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
}
$html .= '</a>';
$html .= '<ul class="charts">';
- $html.= '<li><a href="pedigree.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '" >' . WT_I18N::translate('Pedigree') . '</a></li>';
+ $html .= '<li><a href="pedigree.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '" >' . WT_I18N::translate('Pedigree') . '</a></li>';
if (array_key_exists('googlemap', WT_Module::getActiveModules())) {
- $html.= '<li><a href="module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Pedigree map') . '</a></li>';
+ $html .= '<li><a href="module.php?mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Pedigree map') . '</a></li>';
}
if (WT_USER_GEDCOM_ID && WT_USER_GEDCOM_ID != $pid) {
- $html.= '<li><a href="relationship.php?pid1=' . WT_USER_GEDCOM_ID . '&amp;pid2=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Relationship to me').'</a></li>';
+ $html .= '<li><a href="relationship.php?pid1=' . WT_USER_GEDCOM_ID . '&amp;pid2=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Relationship to me') . '</a></li>';
}
- $html.= '<li><a href="descendancy.php?rootid=' . $pid . '&amp;ged='.WT_GEDURL.'" >' . WT_I18N::translate('Descendants') . '</a></li>';
- $html.= '<li><a href="ancestry.php?rootid=' . $pid . '&amp;ged='.WT_GEDURL . '">' . WT_I18N::translate('Ancestors') . '</a></li>';
- $html.= '<li><a href="compact.php?rootid=' . $pid . '&amp;ged='.WT_GEDURL . '">' . WT_I18N::translate('Compact tree') . '</a></li>';
- $html.= '<li><a href="' . $tempURL . '">' . WT_I18N::translate('Fan chart') . '</a></li>';
- $html.= '<li><a href="hourglass.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Hourglass chart') . '</a></li>';
+ $html .= '<li><a href="descendancy.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '" >' . WT_I18N::translate('Descendants') . '</a></li>';
+ $html .= '<li><a href="ancestry.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Ancestors') . '</a></li>';
+ $html .= '<li><a href="compact.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Compact tree') . '</a></li>';
+ $html .= '<li><a href="' . $tempURL . '">' . WT_I18N::translate('Fan chart') . '</a></li>';
+ $html .= '<li><a href="hourglass.php?rootid=' . $pid . '&amp;ged=' . WT_GEDURL . '">' . WT_I18N::translate('Hourglass chart') . '</a></li>';
if (array_key_exists('tree', WT_Module::getActiveModules())) {
$html .= '<li><a href="module.php?mod=tree&amp;mod_action=treeview&amp;ged=' . WT_GEDURL . '&amp;rootid=' . $pid . '">' . WT_I18N::translate('Interactive tree') . '</a></li>';
}
- $html .='</ul>';
+ $html .= '</ul>';
// spouse(s) and children
foreach ($person->getSpouseFamilies() as $family) {
$spouse = $family->getSpouse($person);
@@ -383,7 +412,7 @@ class WT_Controller_Fanchart extends WT_Controller_Chart {
switch ($what) {
case 'html':
- return $html . $imagemap . '<div id="fan_chart_img"><img src="' . WT_SCRIPT_NAME . '?rootid=' . $this->root->getXref() . '&amp;fan_style=' . $this->fan_style . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width.'&amp;img=1" width="' . $fanw . '" height="' . $fanh . '" alt="' . WT_I18N::translate('Fan chart of %s', strip_tags($person->getFullName())) . '" usemap="#fanmap"></div>';
+ return $html . $imagemap . '<div id="fan_chart_img"><img src="' . WT_SCRIPT_NAME . '?rootid=' . $this->root->getXref() . '&amp;fan_style=' . $this->fan_style . '&amp;generations=' . $this->generations . '&amp;fan_width=' . $this->fan_width . '&amp;img=1" width="' . $fanw . '" height="' . $fanh . '" alt="' . WT_I18N::translate('Fan chart of %s', strip_tags($person->getFullName())) . '" usemap="#fanmap"></div>';
case 'png':
ImageStringUp($image, 1, $fanw - 10, $fanh / 3, WT_SERVER_NAME . WT_SCRIPT_PATH, $color);
diff --git a/library/WT/Controller/GedcomRecord.php b/library/WT/Controller/GedcomRecord.php
index b39d277a13..01be351a73 100644
--- a/library/WT/Controller/GedcomRecord.php
+++ b/library/WT/Controller/GedcomRecord.php
@@ -28,7 +28,7 @@ class WT_Controller_GedcomRecord extends WT_Controller_Page {
public function __construct() {
// Automatically fix broken links
if ($this->record && $this->record->canEdit()) {
- $broken_links=0;
+ $broken_links = 0;
foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
if (!$fact->isPendingDeletion() && $fact->getTarget() === null) {
$this->record->deleteFact($fact->getFactId(), false);
diff --git a/library/WT/Controller/Hourglass.php b/library/WT/Controller/Hourglass.php
index dd3bed8031..562ef13071 100644
--- a/library/WT/Controller/Hourglass.php
+++ b/library/WT/Controller/Hourglass.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -18,6 +18,7 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Hourglass - Controller for the hourglass chart
@@ -52,7 +53,7 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
* @param boolean $loadJS
*/
function __construct($rootid = '', $show_full = 1, $loadJS = true) {
- global $bheight, $bwidth, $cbwidth, $cbheight, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS;
+ global $bheight, $bwidth, $PEDIGREE_FULL_DETAILS, $MAX_DESCENDANCY_GENERATIONS;
global $TEXT_DIRECTION, $show_full;
parent::__construct();
@@ -89,11 +90,11 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
// -- adjust size of the compact box
if (!$this->show_full) {
- $bwidth = $this->box_width * $cbwidth / 100;
- $bheight = $cbheight;
+ $bwidth = $this->box_width * Theme::theme()->parameter('compact-chart-box-x') / 100;
+ $bheight = Theme::theme()->parameter('compact-chart-box-y');
}
- $this->bhalfheight = (int)($bheight / 2);
+ $this->bhalfheight = (int) ($bheight / 2);
// Validate parameters
$this->hourPerson = WT_Individual::getInstance($this->pid);
@@ -120,13 +121,13 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
* @param integer $count generation count, so it recursively calls itself
*/
public function printPersonPedigree(WT_Individual $person, $count) {
- global $WT_IMAGES, $bheight, $bwidth;
+ global $bheight, $bwidth;
if ($count >= $this->generations) {
return;
}
- $genoffset = $this->generations; // handle pedigree n generations lines
+ $genoffset = $this->generations; // handle pedigree n generations lines
//
//Prints empty table columns for children w/o parents up to the max generation
@@ -143,11 +144,11 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
echo '</td><td></tr></table>';
}
foreach ($person->getChildFamilies() as $family) {
- echo "<table class='hourglassChart'>";
- echo "<tr>";
- echo "<td style='vertical-align:bottom'><img class='line3 pvline' src='{$WT_IMAGES["vline"]}' width='3' alt=''></td>";
- echo "<td><img class='line4' src='{$WT_IMAGES["hline"]}' width='7' height='3' alt=''></td>";
- echo "<td>";
+ echo '<table class="hourglassChart">';
+ echo '<tr>';
+ echo '<td style="vertical-align:bottom;"><img class="line3 pvline" src="' . Theme::theme()->parameter('image-vline') . '" width="3"></td>';
+ echo '<td><img class="line4" src="' . Theme::theme()->parameter('image-hline') . '" width="7" height="3"></td>';
+ echo '<td>';
//-- print the father box
print_pedigree_person($family->getHusband());
echo "</td>";
@@ -177,8 +178,8 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
}
echo
'</tr><tr>',
- "<td style='vertical-align:top'><img class='pvline' src='{$WT_IMAGES["vline"]}' width='3' alt=''></td>",
- '<td><img class="line4" src="' . $WT_IMAGES["hline"] . '" width="7" height="3" alt=""></td>',
+ "<td style='vertical-align:top'><img class='pvline' src='" . Theme::theme()->parameter('image-vline') . "' width='3' alt=''></td>",
+ '<td><img class="line4" src="' . Theme::theme()->parameter('image-hline') . '" width="7" height="3" alt=""></td>',
'<td>';
//-- print the mother box
print_pedigree_person($family->getWife());
@@ -226,7 +227,7 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
* @return integer
*/
public function printDescendency($person, $count, $showNav = true) {
- global $TEXT_DIRECTION, $WT_IMAGES, $bheight, $bwidth, $lastGenSecondFam;
+ global $TEXT_DIRECTION, $bheight, $bwidth, $lastGenSecondFam;
if ($count > $this->dgenerations) {
return;
@@ -279,13 +280,13 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
if ($ct > 1) {
if ($i == 0) {
// First child
- echo "<td style='vertical-align:bottom'><img alt='' class='line1 tvertline' id='vline_$chil' src='{$WT_IMAGES["vline"]}' width='3'></td>";
+ echo "<td style='vertical-align:bottom'><img alt='' class='line1 tvertline' id='vline_$chil' src='" . Theme::theme()->parameter('image-vline') . "' width='3'></td>";
} elseif ($i == $ct - 1) {
// Last child
- echo "<td style='vertical-align:top'><img alt='' class='bvertline' id='vline_$chil' src='{$WT_IMAGES["vline"]}' width='3'></td>";
+ echo "<td style='vertical-align:top'><img alt='' class='bvertline' id='vline_$chil' src='" . Theme::theme()->parameter('image-vline') . "' width='3'></td>";
} else {
// Middle child
- echo '<td style="background: url(\'' . $WT_IMAGES['vline'] . '\');"><img src=\'' . $WT_IMAGES['spacer'] . '\' width="3" alt=""></td>';
+ echo '<td style="background: url(\'' . Theme::theme()->parameter('image-vline') . '\');"><img src=\'' . Theme::theme()->parameter('image-spacer') . '\' width="3" alt=""></td>';
}
}
echo '</tr>';
@@ -319,9 +320,9 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
}
}
- echo "<table id='table2_$pid'><tr><td>";
+ echo '<table id="table2_' . $pid . '"><tr><td>';
print_pedigree_person($person);
- echo "</td><td><img class='line2' src='{$WT_IMAGES["hline"]}' width='7' height='3' alt=''>";
+ echo '</td><td><img class="line2" src="' . Theme::theme()->parameter('image-hline') . '" width="7" height="3">';
//----- Print the spouse
if ($this->show_spouse) {
@@ -389,7 +390,7 @@ class WT_Controller_Hourglass extends WT_Controller_Chart {
}
// filter out root person from children array so only siblings remain
- $siblings = array_filter($family->getChildren(), function (WT_Individual $item) use ($pid) {
+ $siblings = array_filter($family->getChildren(), function(WT_Individual $item) use ($pid) {
return $item->getXref() != $pid;
});
$num = count($siblings);
diff --git a/library/WT/Controller/Individual.php b/library/WT/Controller/Individual.php
index 89788d2471..41ff7c9891 100644
--- a/library/WT/Controller/Individual.php
+++ b/library/WT/Controller/Individual.php
@@ -22,7 +22,7 @@
use WT\Auth;
use WT\User;
-require_once WT_ROOT.'includes/functions/functions_print_facts.php';
+require_once WT_ROOT . 'includes/functions/functions_print_facts.php';
/**
* Class WT_Controller_Individual - Controller for the individual page
@@ -96,18 +96,18 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
// Search engines should not make AJAX requests
if ($SEARCH_SPIDER) {
- header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
+ header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
}
// Initialise tabs
- $tab=WT_Filter::get('module');
+ $tab = WT_Filter::get('module');
// A request for a non-existant tab?
if (array_key_exists($tab, $this->tabs)) {
- $mod=$this->tabs[$tab];
+ $mod = $this->tabs[$tab];
} else {
- header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
+ header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit;
}
@@ -134,17 +134,17 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
$factrec = $event->getGedcom();
// Create a dummy record, so we can extract the formatted NAME value from the event.
- $dummy=new WT_Individual(
+ $dummy = new WT_Individual(
'xref',
- "0 @xref@ INDI\n1 DEAT Y\n".$factrec,
+ "0 @xref@ INDI\n1 DEAT Y\n" . $factrec,
null,
WT_GED_ID
);
- $all_names=$dummy->getAllNames();
- $primary_name=$all_names[0];
+ $all_names = $dummy->getAllNames();
+ $primary_name = $all_names[0];
$this->name_count++;
- if ($this->name_count >1) { echo '<h3 class="name_two">',$dummy->getFullName(), '</h3>'; } //Other names accordion element
+ if ($this->name_count > 1) { echo '<h3 class="name_two">', $dummy->getFullName(), '</h3>'; } //Other names accordion element
echo '<div class="indi_name_details';
if ($event->isPendingDeletion()) {
echo ' old';
@@ -167,17 +167,17 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
}
}
if ($this->record->canEdit() && !$event->isPendingDeletion()) {
- echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('".WT_I18N::translate('Are you sure you want to delete this fact?')."', '".$this->record->getXref()."', '".$event->getFactId()."');\" title=\"".WT_I18N::translate('Delete this name')."\"><span class=\"link_text\">".WT_I18N::translate('Delete this name')."</span></a></div>";
- echo "<div class=\"editlink\"><a href=\"#\" class=\"editicon\" onclick=\"edit_name('".$this->record->getXref()."', '".$event->getFactId()."'); return false;\" title=\"".WT_I18N::translate('Edit name')."\"><span class=\"link_text\">".WT_I18N::translate('Edit name')."</span></a></div>";
+ echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('" . WT_I18N::translate('Are you sure you want to delete this fact?') . "', '" . $this->record->getXref() . "', '" . $event->getFactId() . "');\" title=\"" . WT_I18N::translate('Delete this name') . "\"><span class=\"link_text\">" . WT_I18N::translate('Delete this name') . "</span></a></div>";
+ echo "<div class=\"editlink\"><a href=\"#\" class=\"editicon\" onclick=\"edit_name('" . $this->record->getXref() . "', '" . $event->getFactId() . "'); return false;\" title=\"" . WT_I18N::translate('Edit name') . "\"><span class=\"link_text\">" . WT_I18N::translate('Edit name') . "</span></a></div>";
}
echo '</dd>';
echo '</dl>';
echo '</div>';
$ct = preg_match_all('/\n2 (\w+) (.*)/', $factrec, $nmatch, PREG_SET_ORDER);
- for ($i=0; $i<$ct; $i++) {
+ for ($i = 0; $i < $ct; $i++) {
echo '<div>';
$fact = $nmatch[$i][1];
- if ($fact!='SOUR' && $fact!='NOTE' && $fact!='SPFX') {
+ if ($fact != 'SOUR' && $fact != 'NOTE' && $fact != 'SPFX') {
echo '<dl><dt class="label">', WT_Gedcom_Tag::getLabel($fact, $this->record), '</dt>';
echo '<dd class="field">'; // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element
if (isset($nmatch[$i][2])) {
@@ -192,7 +192,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
// The SURN field is not necessarily the surname.
// Where it is not a substring of the real surname, show it after the real surname.
$surname = WT_Filter::escapeHtml($primary_name['surname']);
- if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2]))!==false) {
+ if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2])) !== false) {
echo '<span dir="auto">' . $surname . '</span>';
} else {
echo WT_I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $surname . '</span>', '<span dir="auto">' . $name . '</span>');
@@ -224,7 +224,9 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
*/
public function printSexRecord(WT_Fact $event) {
$sex = $event->getValue();
- if (empty($sex)) $sex = 'U';
+ if (empty($sex)) {
+ $sex = 'U';
+ }
echo '<span id="sex" class="';
if ($event->isPendingDeletion()) {
echo 'old ';
@@ -237,7 +239,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
echo 'male_gender"';
if ($event->canEdit()) {
echo ' title="', WT_I18N::translate('Male'), ' - ', WT_I18N::translate('Edit'), '"';
- echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">';
+ echo ' onclick="edit_record(\'' . $this->record->getXref() . '\', \'' . $event->getFactId() . '\'); return false;">';
} else {
echo ' title="', WT_I18N::translate('Male'), '">';
}
@@ -246,7 +248,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
echo 'female_gender"';
if ($event->canEdit()) {
echo ' title="', WT_I18N::translate('Female'), ' - ', WT_I18N::translate('Edit'), '"';
- echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">';
+ echo ' onclick="edit_record(\'' . $this->record->getXref() . '\', \'' . $event->getFactId() . '\'); return false;">';
} else {
echo ' title="', WT_I18N::translate('Female'), '">';
}
@@ -255,7 +257,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
echo 'unknown_gender"';
if ($event->canEdit()) {
echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), ' - ', WT_I18N::translate('Edit'), '"';
- echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">';
+ echo ' onclick="edit_record(\'' . $this->record->getXref() . '\', \'' . $event->getFactId() . '\'); return false;">';
} else {
echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), '">';
}
@@ -283,19 +285,20 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
$menu->setOnclick("return false;");
if (WT_USER_CAN_EDIT) {
foreach ($this->record->getFacts() as $fact) {
- if ($fact->getTag()=='NAME' && $fact->canEdit())
- $menu->setOnclick("return edit_name('".$this->record->getXref() . "', '" . $fact->getFactId() . "');");
+ if ($fact->getTag() === 'NAME' && $fact->canEdit()) {
+ $menu->setOnclick("return edit_name('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');");
break;
+ }
}
$submenu = new WT_Menu(WT_I18N::translate('Add a new name'), '#', 'menu-indi-addname');
- $submenu->setOnclick("return add_name('".$this->record->getXref()."');");
+ $submenu->setOnclick("return add_name('" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
$has_sex_record = false;
$submenu = new WT_Menu(WT_I18N::translate('Edit gender'), '#', 'menu-indi-editsex');
foreach ($this->record->getFacts() as $fact) {
- if ($fact->getTag()=='SEX' && $fact->canEdit()) {
+ if ($fact->getTag() == 'SEX' && $fact->canEdit()) {
$submenu->setOnclick("return edit_record('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');");
$has_sex_record = true;
break;
@@ -306,9 +309,9 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
}
$menu->addSubmenu($submenu);
- if (count($this->record->getSpouseFamilies())>1) {
+ if (count($this->record->getSpouseFamilies()) > 1) {
$submenu = new WT_Menu(WT_I18N::translate('Re-order families'), '#', 'menu-indi-orderfam');
- $submenu->setOnclick("return reorder_families('".$this->record->getXref()."');");
+ $submenu->setOnclick("return reorder_families('" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
}
@@ -316,7 +319,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
// delete
if (WT_USER_CAN_EDIT) {
$submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-indi-del');
- $submenu->setOnclick("return delete_individual('".WT_I18N::translate('Are you sure you want to delete “%s”?', WT_Filter::escapeJs(strip_tags($this->record->getFullName())))."', '".$this->record->getXref()."');");
+ $submenu->setOnclick("return delete_individual('" . WT_I18N::translate('Are you sure you want to delete “%s”?', WT_Filter::escapeJs(strip_tags($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
@@ -334,7 +337,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
'#',
'menu-indi-addfav'
);
- $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})");
+ $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
$menu->addSubmenu($submenu);
}
@@ -349,16 +352,16 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
* @return string returns 'person_box', 'person_boxF', or 'person_boxNN'
*/
function getPersonStyle($person) {
- switch($person->getSex()) {
- case 'M':
- $class = 'person_box';
- break;
- case 'F':
- $class = 'person_boxF';
- break;
- default:
- $class = 'person_boxNN';
- break;
+ switch ($person->getSex()) {
+ case 'M':
+ $class = 'person_box';
+ break;
+ case 'F':
+ $class = 'person_boxF';
+ break;
+ default:
+ $class = 'person_boxNN';
+ break;
}
if ($person->isPendingDeletion()) {
$class .= ' old';
@@ -391,16 +394,16 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord {
public function getSideBarContent() {
global $controller;
- $html='';
- $active=0;
- $n=0;
+ $html = '';
+ $active = 0;
+ $n = 0;
foreach (WT_Module::getActiveSidebars() as $mod) {
if ($mod->hasSidebarContent()) {
- $html.='<h3 id="'.$mod->getName().'"><a href="#">'.$mod->getTitle().'</a></h3>';
- $html.='<div id="sb_content_'.$mod->getName().'">'.$mod->getSidebarContent().'</div>';
+ $html .= '<h3 id="' . $mod->getName() . '"><a href="#">' . $mod->getTitle() . '</a></h3>';
+ $html .= '<div id="sb_content_' . $mod->getName() . '">' . $mod->getSidebarContent() . '</div>';
// The family navigator should be opened by default
- if ($mod->getName()=='family_nav') {
- $active=$n;
+ if ($mod->getName() == 'family_nav') {
+ $active = $n;
}
++$n;
}
diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php
index b9f905179f..229291106a 100644
--- a/library/WT/Controller/Lifespan.php
+++ b/library/WT/Controller/Lifespan.php
@@ -77,7 +77,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page {
$this->Mcolorindex = 0;
$this->zoomfactor = 10;
$this->color = '#0000FF';
- $this->currentYear = (int)date('Y');
+ $this->currentYear = (int) date('Y');
$this->deathMod = 0;
$this->endDate = $this->currentYear;
@@ -131,7 +131,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page {
$this->endYear = $endYear;
if ($beginYear == 0 || $endYear == 0) {
//-- cleanup user input
- $this->pids = array_unique($this->pids); //removes duplicates
+ $this->pids = array_unique($this->pids); //removes duplicates
foreach ($this->pids as $key => $value) {
if ($value != $remove) {
$this->pids[$key] = $value;
@@ -169,7 +169,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page {
}
// Sort the array in order of birth year
- uasort($this->people, function (WT_Individual $a, WT_Individual $b) {
+ uasort($this->people, function(WT_Individual $a, WT_Individual $b) {
return WT_Date::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate());
});
//If there is people in the array posted back this if occurs
@@ -279,8 +279,8 @@ class WT_Controller_Lifespan extends WT_Controller_Page {
$totalYears = $newEndYear - $newStartYear; //length of timeline
$timelineTick = $totalYears / $yearSpan; //calculates the length of the timeline
- for ($i = 0; $i < $timelineTick; $i++) { //prints the timeline
- echo "<div class=\"sublinks_cell\" style=\"text-align: left; position: absolute; top: ", $top, "px; left: ", $leftPosition, "px; width: ", $tickDistance, "px;\">$newStartYear<i class=\"icon-lifespan-chunk\"></i></div>"; //onclick="zoomToggle('100px', '100px', '200px', '200px', this);"
+ for ($i = 0; $i < $timelineTick; $i++) {
+ echo "<div class=\"sublinks_cell\" style=\"text-align: left; position: absolute; top: ", $top, "px; left: ", $leftPosition, "px; width: ", $tickDistance, "px;\">$newStartYear<i class=\"icon-lifespan-chunk\"></i></div>"; //onclick="zoomToggle('100px', '100px', '200px', '200px', this);"
$leftPosition += $tickDistance;
$newStartYear += $yearSpan;
}
diff --git a/library/WT/Controller/Note.php b/library/WT/Controller/Note.php
index 80a8a1734e..47f57cc51f 100644
--- a/library/WT/Controller/Note.php
+++ b/library/WT/Controller/Note.php
@@ -19,7 +19,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-require_once WT_ROOT.'includes/functions/functions_print_facts.php';
+require_once WT_ROOT . 'includes/functions/functions_print_facts.php';
/**
* Class WT_Controller_Note - Controller for the shared note page
@@ -48,7 +48,7 @@ class WT_Controller_Note extends WT_Controller_GedcomRecord {
if (WT_USER_CAN_EDIT) {
$submenu = new WT_Menu(WT_I18N::translate('Edit note'), '#', 'menu-note-edit');
- $submenu->setOnclick('return edit_note(\''.$this->record->getXref().'\');');
+ $submenu->setOnclick('return edit_note(\'' . $this->record->getXref() . '\');');
$menu->addSubmenu($submenu);
}
@@ -66,7 +66,7 @@ class WT_Controller_Note extends WT_Controller_GedcomRecord {
'#',
'menu-note-addfav'
);
- $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})");
+ $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
$menu->addSubmenu($submenu);
}
diff --git a/library/WT/Controller/Page.php b/library/WT/Controller/Page.php
index 5794a2fa41..0357cd2cf1 100644
--- a/library/WT/Controller/Page.php
+++ b/library/WT/Controller/Page.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 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
@@ -15,16 +15,16 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Page Controller for full-page, themed HTML responses
*/
class WT_Controller_Page extends WT_Controller_Base {
// Page header information
- const DOCTYPE = '<!DOCTYPE html>'; // HTML5
private $canonical_url = '';
private $meta_robots = 'noindex,nofollow'; // Most pages are not intended for robots
- private $page_title = WT_WEBTREES; // <head><title> $page_title </title></head>
+ private $page_title = WT_WEBTREES; // <head><title> $page_title </title></head>
/**
* Startup activity
@@ -33,8 +33,8 @@ class WT_Controller_Page extends WT_Controller_Base {
parent::__construct();
// Every page uses these scripts
$this
- ->addExternalJavascript(WT_JQUERY_URL)
- ->addExternalJavascript(WT_JQUERYUI_URL)
+ ->addExternalJavascript(WT_JQUERY_JS_URL)
+ ->addExternalJavascript(WT_JQUERYUI_JS_URL)
->addExternalJavascript(WT_WEBTREES_JS_URL);
}
@@ -44,7 +44,7 @@ class WT_Controller_Page extends WT_Controller_Base {
public function __destruct() {
// If we printed a header, automatically print a footer
if ($this->page_header) {
- $this->pageFooter();
+ echo $this->pageFooter();
}
}
@@ -84,6 +84,15 @@ class WT_Controller_Page extends WT_Controller_Base {
}
/**
+ * What is the preferred URL for this page?
+ *
+ * @return string
+ */
+ public function getCanonicalUrl() {
+ return $this->canonical_url;
+ }
+
+ /**
* Should robots index this page?
*
* @param string $meta_robots
@@ -97,6 +106,15 @@ class WT_Controller_Page extends WT_Controller_Base {
}
/**
+ * Should robots index this page?
+ *
+ * @return string
+ */
+ public function getMetaRobots() {
+ return $this->meta_robots;
+ }
+
+ /**
* Restrict access
*
* @param boolean $condition
@@ -113,35 +131,36 @@ class WT_Controller_Page extends WT_Controller_Base {
}
/**
+ * Print the page footer, using the theme
+ *
+ * @return string
+ */
+ protected function pageFooter() {
+ return
+ Theme::theme()->footerContainer() .
+ $this->getJavascript() .
+ Theme::theme()->hookFooterExtraJavascript() .
+ '</body>' .
+ '</html>' . PHP_EOL .
+ '<!-- webtrees: ' . WT_VERSION . ' -->' .
+ '<!-- Execution time: ' . WT_I18N::number(microtime(true) - WT_START_TIME, 3) . ' seconds -->' .
+ '<!-- Memory: ' . WT_I18N::number(memory_get_peak_usage(true) / 1024) . ' KB -->' .
+ '<!-- SQL queries: ' . WT_I18N::number(WT_DB::getQueryCount()) . ' -->';
+ }
+
+ /**
* Print the page header, using the theme
*
+ * @param string $view 'simple' or ''
+ *
* @return $this
*/
- public function pageHeader() {
- // Import global variables into the local scope, for the theme’s header.php
- global $WT_TREE, $SEARCH_SPIDER, $TEXT_DIRECTION, $REQUIRE_AUTHENTICATION, $headerfile, $view;
-
- // The title often includes the names of records, which may have markup
- // that cannot be used in the page title.
- $title = html_entity_decode(strip_tags($this->page_title), ENT_QUOTES, 'UTF-8');
-
- // Initialise variables for the theme’s header.php
- $LINK_CANONICAL = $this->canonical_url;
- $META_ROBOTS = $this->meta_robots;
- $META_DESCRIPTION = $WT_TREE ? $WT_TREE->getPreference('META_DESCRIPTION') : '';
- if (!$META_DESCRIPTION) {
- $META_DESCRIPTION = strip_tags(WT_TREE_TITLE);
- }
- $META_GENERATOR = WT_WEBTREES . ' ' . WT_VERSION . ' - ' . WT_WEBTREES_URL;
- $META_TITLE = $WT_TREE ? $WT_TREE->getPreference('META_TITLE') : '';
- if ($META_TITLE) {
- $title .= ' - ' . $META_TITLE;
- }
+ public function pageHeader($view = '') {
+ global $TEXT_DIRECTION;
// Give Javascript access to some PHP constants
$this->addInlineJavascript('
var WT_STATIC_URL = "' . WT_Filter::escapeJs(WT_STATIC_URL) . '";
- var WT_THEME_DIR = "' . WT_Filter::escapeJs(WT_THEME_DIR) . '";
var WT_MODULES_DIR = "' . WT_Filter::escapeJs(WT_MODULES_DIR) . '";
var WT_GEDCOM = "' . WT_Filter::escapeJs(WT_GEDCOM) . '";
var WT_GED_ID = "' . WT_Filter::escapeJs(WT_GED_ID) . '";
@@ -154,13 +173,30 @@ class WT_Controller_Page extends WT_Controller_Base {
// Temporary fix for access to main menu hover elements on android/blackberry touch devices
$this->addInlineJavascript('
if(navigator.userAgent.match(/Android|PlayBook/i)) {
- jQuery("#main-menu > li > a").attr("href", "#");
- jQuery("a.icon_arrow").attr("href", "#");
+ jQuery(".primary-menu > li > a").attr("href", "#");
}
');
- header('Content-Type: text/html; charset=UTF-8');
- require WT_ROOT . $headerfile;
+ Theme::theme()->sendHeaders();
+ echo Theme::theme()->doctype();
+ echo Theme::theme()->html();
+ echo Theme::theme()->head($this);
+
+ switch ($view) {
+ case 'simple':
+ echo Theme::theme()->bodyHeaderPopupWindow();
+ break;
+ default:
+ echo Theme::theme()->bodyHeader();
+ break;
+ }
+
+ // Flush the output, so the browser can render the header and load javascript
+ // while we are preparing data for the page
+ if (ini_get('output_buffering')) {
+ ob_flush();
+ }
+ flush();
// Once we've displayed the header, we should no longer write session data.
Zend_Session::writeClose();
@@ -172,27 +208,6 @@ class WT_Controller_Page extends WT_Controller_Base {
}
/**
- * Print the page footer, using the theme
- *
- * @return $this
- */
- protected function pageFooter() {
- global $footerfile, $WT_TREE, $TEXT_DIRECTION, $view;
-
- if (WT_GED_ID) {
- require WT_ROOT . $footerfile;
- }
-
- if (WT_DEBUG_SQL) {
- echo WT_DB::getQueryLog();
- }
- echo $this->getJavascript();
- echo '</body></html>';
-
- return $this;
- }
-
- /**
* Get significant information from this page, to allow other pages such as
* charts and reports to initialise with the same records
*
diff --git a/library/WT/Controller/Pedigree.php b/library/WT/Controller/Pedigree.php
index 4caf85bf01..df77a55ca7 100644
--- a/library/WT/Controller/Pedigree.php
+++ b/library/WT/Controller/Pedigree.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -18,6 +18,7 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Pedigree - Controller for the pedigree chart
@@ -46,40 +47,40 @@ class WT_Controller_Pedigree extends WT_Controller_Chart {
public function __construct() {
global $PEDIGREE_FULL_DETAILS, $PEDIGREE_LAYOUT, $MAX_PEDIGREE_GENERATIONS;
global $DEFAULT_PEDIGREE_GENERATIONS;
- global $bwidth, $bheight, $cbwidth, $cbheight, $baseyoffset, $basexoffset, $byspacing, $bxspacing;
- global $linewidth, $shadowcolor, $shadowblur, $shadowoffsetX, $shadowoffsetY;
+ global $bwidth, $bheight, $baseyoffset, $basexoffset, $byspacing, $bxspacing;
global $show_full, $talloffset;
parent::__construct();
-
- $this->linewidth = $linewidth;
- $this->shadowcolor = $shadowcolor;
- $this->shadowblur = $shadowblur;
- $this->shadowoffsetX = $shadowoffsetX;
- $this->shadowoffsetY = $shadowoffsetY;
+ $this->linewidth = Theme::theme()->parameter('line-width');
+ $this->shadowcolor = Theme::theme()->parameter('shadow-color');
+ $this->shadowblur = Theme::theme()->parameter('shadow-blur');
+ $this->shadowoffsetX = Theme::theme()->parameter('shadow-offset-x');
+ $this->shadowoffsetY = Theme::theme()->parameter('shadow-offset-y');
$this->show_full = WT_Filter::getInteger('show_full', 0, 1, $PEDIGREE_FULL_DETAILS);
$this->talloffset = WT_Filter::getInteger('talloffset', 0, 3, $PEDIGREE_LAYOUT);
$this->box_width = WT_Filter::getInteger('box_width', 50, 300, 100);
$this->PEDIGREE_GENERATIONS = WT_Filter::getInteger('PEDIGREE_GENERATIONS', 2, $MAX_PEDIGREE_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS);
- if ($this->talloffset==1) $this->talloffset=1; // Make SURE this is an integer
- if ($this->talloffset>1 && $this->PEDIGREE_GENERATIONS>8) $this->PEDIGREE_GENERATIONS=8;
+ // With more than 8 generations, we run out of pixels on the <canvas>
+ if ($this->PEDIGREE_GENERATIONS > 8) {
+ $this->PEDIGREE_GENERATIONS = 8;
+ }
// TODO: some library functions expect this as a global.
// Passing a function parameter would be much better.
global $PEDIGREE_GENERATIONS;
- $PEDIGREE_GENERATIONS=$this->PEDIGREE_GENERATIONS;
+ $PEDIGREE_GENERATIONS = $this->PEDIGREE_GENERATIONS;
// This is passed as a global. A parameter would be better...
$this->show_full = ($this->show_full) ? 1 : 0; // Make SURE this is an integer
- if ($this->talloffset>3) {
- $this->talloffset=3;
- } elseif ($this->talloffset<0) {
- $this->talloffset=0;
+ if ($this->talloffset > 3) {
+ $this->talloffset = 3;
+ } elseif ($this->talloffset < 0) {
+ $this->talloffset = 0;
}
- $show_full = $this->show_full;
+ $show_full = $this->show_full;
$talloffset = $this->talloffset;
if ($this->root && $this->root->canShowName()) {
@@ -91,47 +92,48 @@ class WT_Controller_Pedigree extends WT_Controller_Chart {
$this->setPageTitle(WT_I18N::translate('Pedigree'));
}
- // -- adjust size of the compact box
- if (!$this->show_full) {
- $bwidth = $cbwidth;
- $bheight = $cbheight;
+ if ($this->show_full) {
+ $this->pbwidth = Theme::theme()->parameter('chart-box-x') + 6;
+ $this->pbheight = Theme::theme()->parameter('chart-box-y') + 5;
+ } else {
+ $this->pbwidth = Theme::theme()->parameter('compact-chart-box-x') + 6;
+ $this->pbheight = Theme::theme()->parameter('compact-chart-box-y') + 5;
}
+
//-- adjustments for portrait mode
- if ($this->talloffset==0) {
- $bxspacing+=12;
- $baseyoffset -= 20*($this->PEDIGREE_GENERATIONS-1);
+ if ($this->talloffset == 0) {
+ $bxspacing += 12;
+ $baseyoffset -= 20 * ($this->PEDIGREE_GENERATIONS - 1);
}
- $this->pbwidth = $bwidth+6;
- $this->pbheight = $bheight+5;
$this->ancestors = $this->sosaAncestors($PEDIGREE_GENERATIONS);
- $this->treesize = pow(2, (int)($this->PEDIGREE_GENERATIONS))-1;
+ $this->treesize = pow(2, (int) ($this->PEDIGREE_GENERATIONS)) - 1;
// sosaAncestors() puts everyone at $i+1
- for ($i=0; $i<$this->treesize; $i++) {
- $this->ancestors[$i] = $this->ancestors[$i+1];
+ for ($i = 0; $i < $this->treesize; $i++) {
+ $this->ancestors[$i] = $this->ancestors[$i + 1];
}
if (!$this->show_full) {
- if ($this->talloffset==0) {
- $baseyoffset = 160+$bheight*2;
- } elseif ($this->talloffset==1) {
- $baseyoffset = 180+$bheight*2;
- } elseif ($this->talloffset>1) {
- if ($this->PEDIGREE_GENERATIONS==3) {
+ if ($this->talloffset == 0) {
+ $baseyoffset = 160 + $bheight * 2;
+ } elseif ($this->talloffset == 1) {
+ $baseyoffset = 180 + $bheight * 2;
+ } elseif ($this->talloffset > 1) {
+ if ($this->PEDIGREE_GENERATIONS == 3) {
$baseyoffset = 30;
} else {
$baseyoffset = -85;
}
}
} else {
- if ($this->talloffset==0) {
- $baseyoffset = 100+$bheight/2;
- } elseif ($this->talloffset==1) {
- $baseyoffset = 160+$bheight/2;
- } elseif ($this->talloffset>1) {
- if ($this->PEDIGREE_GENERATIONS==3) {
+ if ($this->talloffset == 0) {
+ $baseyoffset = 100 + $bheight / 2;
+ } elseif ($this->talloffset == 1) {
+ $baseyoffset = 160 + $bheight / 2;
+ } elseif ($this->talloffset > 1) {
+ if ($this->PEDIGREE_GENERATIONS == 3) {
$baseyoffset = 30;
} else {
$baseyoffset = -85;
@@ -139,94 +141,121 @@ class WT_Controller_Pedigree extends WT_Controller_Chart {
}
}
// -- this next section will create and position the DIV layers for the pedigree tree
- $this->curgen = 1; // -- variable to track which generation the algorithm is currently working on
- $this->yoffset=0; // -- used to offset the position of each box as it is generated
- $this->xoffset=0;
- $this->prevyoffset=0; // -- used to track the y position of the previous box
+ $this->curgen = 1; // -- variable to track which generation the algorithm is currently working on
+ $this->yoffset = 0; // -- used to offset the position of each box as it is generated
+ $this->xoffset = 0;
+ $this->prevyoffset = 0; // -- used to track the y position of the previous box
$this->offsetarray = array();
$this->minyoffset = 0;
- if ($this->treesize<3) $this->treesize=3;
+ if ($this->treesize < 3) {
+ $this->treesize = 3;
+ }
// -- loop through all of IDs in the array starting at the last and working to the first
//-- calculation the box positions
- for ($i=($this->treesize-1); $i>=0; $i--) {
+ for ($i = ($this->treesize - 1); $i >= 0; $i--) {
// -- check to see if we have moved to the next generation
- if ($i < (int)($this->treesize / (pow(2, $this->curgen)))) {
+ if ($i < (int) ($this->treesize / (pow(2, $this->curgen)))) {
$this->curgen++;
}
//-- box position in current generation
- $boxpos = $i-pow(2, $this->PEDIGREE_GENERATIONS-$this->curgen);
+ $boxpos = $i - pow(2, $this->PEDIGREE_GENERATIONS - $this->curgen);
//-- offset multiple for current generation
if ($this->talloffset < 2) {
- $genoffset = pow(2, $this->curgen-$this->talloffset);
- $boxspacing = $this->pbheight+$byspacing;
- }
- else {
- $genoffset = pow(2, $this->curgen-1);
- $boxspacing = $this->pbwidth+$byspacing;
+ $genoffset = pow(2, $this->curgen - $this->talloffset);
+ $boxspacing = $this->pbheight + $byspacing;
+ } else {
+ $genoffset = pow(2, $this->curgen - 1);
+ $boxspacing = $this->pbwidth + $byspacing;
}
// -- calculate the yoffset Position in the generation Spacing between boxes put child between parents
- $this->yoffset = $baseyoffset+($boxpos * ($boxspacing * $genoffset))+(($boxspacing/2)*$genoffset)+($boxspacing * $genoffset);
+ $this->yoffset = $baseyoffset + ($boxpos * ($boxspacing * $genoffset)) + (($boxspacing / 2) * $genoffset) + ($boxspacing * $genoffset);
// -- calculate the xoffset
- if ($this->talloffset==0) {
- if ($this->PEDIGREE_GENERATIONS<6) {
- $addxoffset = $basexoffset+(10+60*(5-$this->PEDIGREE_GENERATIONS));
- $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth+$bxspacing) / 2)+$addxoffset;
- }
- else {
- $addxoffset = $basexoffset+10;
- $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth+$bxspacing) / 2)+$addxoffset;
+ if ($this->talloffset == 0) {
+ if ($this->PEDIGREE_GENERATIONS < 6) {
+ $addxoffset = $basexoffset + (10 + 60 * (5 - $this->PEDIGREE_GENERATIONS));
+ $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth + $bxspacing) / 2) + $addxoffset;
+ } else {
+ $addxoffset = $basexoffset + 10;
+ $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth + $bxspacing) / 2) + $addxoffset;
}
//-- compact the tree
- if ($this->curgen<$this->PEDIGREE_GENERATIONS) {
- $parent = (int)(($i-1)/2);
- if ($i%2 == 0) $this->yoffset=$this->yoffset - (($boxspacing/2) * ($this->curgen-1));
- else $this->yoffset=$this->yoffset + (($boxspacing/2) * ($this->curgen-1));
+ if ($this->curgen < $this->PEDIGREE_GENERATIONS) {
+ $parent = (int) (($i - 1) / 2);
+ if ($i % 2 == 0) {
+ $this->yoffset = $this->yoffset - (($boxspacing / 2) * ($this->curgen - 1));
+ } else {
+ $this->yoffset = $this->yoffset + (($boxspacing / 2) * ($this->curgen - 1));
+ }
$pgen = $this->curgen;
- while ($parent>0) {
- if ($parent%2 == 0) $this->yoffset=$this->yoffset - (($boxspacing/2) * $pgen);
- else $this->yoffset=$this->yoffset + (($boxspacing/2) * $pgen);
+ while ($parent > 0) {
+ if ($parent % 2 == 0) {
+ $this->yoffset = $this->yoffset - (($boxspacing / 2) * $pgen);
+ } else {
+ $this->yoffset = $this->yoffset + (($boxspacing / 2) * $pgen);
+ }
$pgen++;
- if ($pgen>3) {
- $temp=0;
- for ($j=1; $j<($pgen-2); $j++) $temp += (pow(2, $j)-1);
- if ($parent%2 == 0) $this->yoffset=$this->yoffset - (($boxspacing/2) * $temp);
- else $this->yoffset=$this->yoffset + (($boxspacing/2) * $temp);
+ if ($pgen > 3) {
+ $temp = 0;
+ for ($j = 1; $j < ($pgen - 2); $j++) {
+ $temp += (pow(2, $j) - 1);
+ }
+ if ($parent % 2 == 0) {
+ $this->yoffset = $this->yoffset - (($boxspacing / 2) * $temp);
+ } else {
+ $this->yoffset = $this->yoffset + (($boxspacing / 2) * $temp);
+ }
}
- $parent = (int)(($parent-1)/2);
+ $parent = (int) (($parent - 1) / 2);
}
- if ($this->curgen>3) {
- $temp=0;
- for ($j=1; $j<($this->curgen-2); $j++) $temp += (pow(2, $j)-1);
- if ($i%2 == 0) $this->yoffset=$this->yoffset - (($boxspacing/2) * $temp);
- else $this->yoffset=$this->yoffset + (($boxspacing/2) * $temp);
+ if ($this->curgen > 3) {
+ $temp = 0;
+ for ($j = 1; $j < ($this->curgen - 2); $j++) {
+ $temp += (pow(2, $j) - 1);
+ }
+ if ($i % 2 == 0) {
+ $this->yoffset = $this->yoffset - (($boxspacing / 2) * $temp);
+ } else {
+ $this->yoffset = $this->yoffset + (($boxspacing / 2) * $temp);
+ }
}
}
- $this->yoffset-=(($boxspacing/2)*pow(2,($this->PEDIGREE_GENERATIONS-2))-($boxspacing/2));
- }
- else if ($this->talloffset==1) {
- $this->xoffset = 22 + $basexoffset + (($this->PEDIGREE_GENERATIONS - $this->curgen) * ($this->pbwidth+$bxspacing));
- if ($this->curgen == $this->PEDIGREE_GENERATIONS) $this->xoffset;
- if ($this->PEDIGREE_GENERATIONS<4) $this->xoffset += 60;
- }
- else if ($this->talloffset==2) {
- if ($this->show_full) $this->xoffset = ($this->curgen) * (($this->pbwidth+$bxspacing) / 2)+($this->curgen)*10+136.5;
- else $this->xoffset = ($this->curgen) * (($this->pbwidth+$bxspacing) / 4)+($this->curgen)*10+215.75;
+ $this->yoffset -= (($boxspacing / 2) * pow(2, ($this->PEDIGREE_GENERATIONS - 2)) - ($boxspacing / 2));
+ } else if ($this->talloffset == 1) {
+ $this->xoffset = 22 + $basexoffset + (($this->PEDIGREE_GENERATIONS - $this->curgen) * ($this->pbwidth + $bxspacing));
+ if ($this->curgen == $this->PEDIGREE_GENERATIONS) {
+ $this->xoffset;
+ }
+ if ($this->PEDIGREE_GENERATIONS < 4) {
+ $this->xoffset += 60;
+ }
+ } else if ($this->talloffset == 2) {
+ if ($this->show_full) {
+ $this->xoffset = ($this->curgen) * (($this->pbwidth + $bxspacing) / 2) + ($this->curgen) * 10 + 136.5;
+ } else {
+ $this->xoffset = ($this->curgen) * (($this->pbwidth + $bxspacing) / 4) + ($this->curgen) * 10 + 215.75;
+ }
+ } else {
+ if ($this->show_full) {
+ $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth + $bxspacing) / 2) + 260;
+ } else {
+ $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth + $bxspacing) / 4) + 270;
+ }
}
- else {
- if ($this->show_full) $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth+$bxspacing) / 2)+260;
- else $this->xoffset = ($this->PEDIGREE_GENERATIONS - $this->curgen) * (($this->pbwidth+$bxspacing) / 4)+270;
+ if ($this->curgen == 1 && $this->talloffset == 1) {
+ $this->xoffset += 10;
}
- if ($this->curgen == 1 && $this->talloffset==1) $this->xoffset += 10;
- $this->offsetarray[$i]["x"]=$this->xoffset;
- $this->offsetarray[$i]["y"]=$this->yoffset;
+ $this->offsetarray[$i]["x"] = $this->xoffset;
+ $this->offsetarray[$i]["y"] = $this->yoffset;
}
//-- calculate the smallest yoffset and adjust the tree to that offset
$minyoffset = 0;
- for ($i=0; $i<count($this->ancestors); $i++) {
+ for ($i = 0; $i < count($this->ancestors); $i++) {
if (!empty($offsetarray[$i])) {
- if (($minyoffset==0)||($minyoffset>$this->offsetarray[$i]["y"])) $minyoffset = $this->offsetarray[$i]["y"];
+ if (($minyoffset == 0) || ($minyoffset > $this->offsetarray[$i]["y"])) {
+ $minyoffset = $this->offsetarray[$i]["y"];
+ }
}
}
}
diff --git a/library/WT/Controller/Repository.php b/library/WT/Controller/Repository.php
index 1c8d2f8a52..5f2afc3d88 100644
--- a/library/WT/Controller/Repository.php
+++ b/library/WT/Controller/Repository.php
@@ -21,7 +21,7 @@
use WT\Auth;
-require_once WT_ROOT.'includes/functions/functions_print_facts.php';
+require_once WT_ROOT . 'includes/functions/functions_print_facts.php';
/**
* Class WT_Controller_Repository - Controller for the repository page
@@ -68,7 +68,7 @@ class WT_Controller_Repository extends WT_Controller_GedcomRecord {
// delete
if (WT_USER_CAN_EDIT) {
$submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-repo-del');
- $submenu->setOnclick("return delete_repository('" . WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName()))."', '".$this->record->getXref()."');");
+ $submenu->setOnclick("return delete_repository('" . WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName())) . "', '" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
@@ -86,7 +86,7 @@ class WT_Controller_Repository extends WT_Controller_GedcomRecord {
'#',
'menu-repo-addfav'
);
- $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})");
+ $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
$menu->addSubmenu($submenu);
}
diff --git a/library/WT/Controller/Search.php b/library/WT/Controller/Search.php
index 6cd1f2be44..9fba135793 100644
--- a/library/WT/Controller/Search.php
+++ b/library/WT/Controller/Search.php
@@ -136,7 +136,7 @@ class WT_Controller_Search extends WT_Controller_Page {
$str = str_replace(array(".", "-", " "), array("_", "_", "_"), $search_tree->tree_name);
if (isset ($_REQUEST["$str"]) || $topsearch) {
$this->search_trees[$search_tree->tree_id] = $search_tree;
- $_REQUEST["$str"] = 'yes';
+ $_REQUEST["$str"] = 'yes';
}
}
} else {
@@ -386,7 +386,7 @@ class WT_Controller_Search extends WT_Controller_Page {
private function searchAndReplace() {
global $STANDARD_NAME_FACTS, $ADVANCED_NAME_FACTS, $WT_TREE;
- $this->search_trees = array(WT_GED_ID => $WT_TREE);
+ $this->search_trees = array(WT_GED_ID => $WT_TREE);
$this->srindi = 'yes';
$this->srfams = 'yes';
$this->srsour = 'yes';
@@ -618,7 +618,7 @@ class WT_Controller_Search extends WT_Controller_Page {
echo '<h3 class="indi-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3>
<div class="indi-acc_content">',
format_indi_table($datalist);
- echo '</div>';//indi-acc_content
+ echo '</div>'; //indi-acc_content
}
}
echo '</div>';
@@ -641,10 +641,10 @@ class WT_Controller_Search extends WT_Controller_Page {
echo '<h3 class="fam-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3>
<div class="fam-acc_content">',
format_fam_table($datalist);
- echo '</div>';//fam-acc_content
+ echo '</div>'; //fam-acc_content
}
}
- echo '</div>';//#searchAccordion-fam
+ echo '</div>'; //#searchAccordion-fam
$this->addInlineJavascript('jQuery("#searchAccordion-fam").accordion({heightStyle: "content", collapsible: true});');
// source results
@@ -664,10 +664,10 @@ class WT_Controller_Search extends WT_Controller_Page {
echo '<h3 class="source-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3>
<div class="source-acc_content">',
format_sour_table($datalist);
- echo '</div>';//fam-acc_content
+ echo '</div>'; //fam-acc_content
}
}
- echo '</div>';//#searchAccordion-source
+ echo '</div>'; //#searchAccordion-source
$this->addInlineJavascript('jQuery("#searchAccordion-source").accordion({heightStyle: "content", collapsible: true});');
// note results
@@ -687,10 +687,10 @@ class WT_Controller_Search extends WT_Controller_Page {
echo '<h3 class="note-acc-header"><a href="#"><span class="search_item" dir="auto">', $this->myquery, '</span> @ <span>', $search_tree->tree_title_html, '</span></a></h3>
<div class="note-acc_content">',
format_note_table($datalist);
- echo '</div>';//note-acc_content
+ echo '</div>'; //note-acc_content
}
}
- echo '</div>';//#searchAccordion-note
+ echo '</div>'; //#searchAccordion-note
$this->addInlineJavascript('jQuery("#searchAccordion-note").accordion({heightStyle: "content", collapsible: true});');
$GEDCOM = WT_GEDCOM;
diff --git a/library/WT/Controller/Simple.php b/library/WT/Controller/Simple.php
index 1b94ee445d..e1bea0fd25 100644
--- a/library/WT/Controller/Simple.php
+++ b/library/WT/Controller/Simple.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 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
@@ -34,13 +34,8 @@ class WT_Controller_Simple extends WT_Controller_Page {
*
* @return $this
*/
- public function pageHeader() {
- global $view;
-
- $view = 'simple';
- parent::pageHeader();
-
- return $this;
+ public function pageHeader($view = 'simple') {
+ return parent::pageHeader($view);
}
/**
diff --git a/library/WT/Controller/Source.php b/library/WT/Controller/Source.php
index 4a8325bb3e..45e8883a12 100644
--- a/library/WT/Controller/Source.php
+++ b/library/WT/Controller/Source.php
@@ -21,7 +21,7 @@
use WT\Auth;
-require_once WT_ROOT.'includes/functions/functions_print_facts.php';
+require_once WT_ROOT . 'includes/functions/functions_print_facts.php';
/**
* Class WT_Controller_Source - Controller for the source page
@@ -57,10 +57,10 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord {
$submenu = new WT_Menu(WT_I18N::translate('Edit source'), '#', 'menu-sour-edit');
if ($fact) {
// Edit existing name
- $submenu->setOnclick('return edit_record(\''.$this->record->getXref().'\', \'' . $fact->getFactId() . '\');');
+ $submenu->setOnclick('return edit_record(\'' . $this->record->getXref() . '\', \'' . $fact->getFactId() . '\');');
} else {
// Add new name
- $submenu->setOnclick('return add_fact(\''.$this->record->getXref().'\', \'TITL\');');
+ $submenu->setOnclick('return add_fact(\'' . $this->record->getXref() . '\', \'TITL\');');
}
$menu->addSubmenu($submenu);
}
@@ -68,7 +68,7 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord {
// delete
if (WT_USER_CAN_EDIT) {
$submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-sour-del');
- $submenu->setOnclick("return delete_source('".WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName()))."', '".$this->record->getXref()."');");
+ $submenu->setOnclick("return delete_source('" . WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName())) . "', '" . $this->record->getXref() . "');");
$menu->addSubmenu($submenu);
}
@@ -86,7 +86,7 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord {
'#',
'menu-sour-addfav'
);
- $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'".$this->record->getXref()."'},function(){location.reload();})");
+ $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
$menu->addSubmenu($submenu);
}
diff --git a/library/WT/Controller/Timeline.php b/library/WT/Controller/Timeline.php
index 17bc2f0d35..895852821f 100644
--- a/library/WT/Controller/Timeline.php
+++ b/library/WT/Controller/Timeline.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -18,6 +18,7 @@
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+use WT\Theme;
/**
* Class WT_Controller_Timeline - Controller for the timeline chart
@@ -67,7 +68,7 @@ class WT_Controller_Timeline extends WT_Controller_Page {
$this->setPageTitle(WT_I18N::translate('Timeline'));
- $this->baseyear = (int)date('Y');
+ $this->baseyear = (int) date('Y');
// new pid
$newpid = WT_Filter::get('newpid', WT_REGEX_XREF);
@@ -126,7 +127,7 @@ class WT_Controller_Timeline extends WT_Controller_Page {
$this->topyear = max($this->topyear, $date->y);
if (!$indi->isDead()) {
- $this->topyear = max($this->topyear, (int)date('Y'));
+ $this->topyear = max($this->topyear, (int) date('Y'));
}
// do not add the same fact twice (prevents marriages from being added multiple times)
@@ -140,7 +141,7 @@ class WT_Controller_Timeline extends WT_Controller_Page {
}
$scale = WT_Filter::getInteger('scale', 0, 200);
if ($scale === 0) {
- $this->scale = (int)(($this->topyear - $this->baseyear) / 20 * count($this->indifacts) / 4);
+ $this->scale = (int) (($this->topyear - $this->baseyear) / 20 * count($this->indifacts) / 4);
if ($this->scale < 6) {
$this->scale = 6;
}
@@ -158,7 +159,7 @@ class WT_Controller_Timeline extends WT_Controller_Page {
* @param WT_Fact $event
*/
function print_time_fact(WT_Fact $event) {
- global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION, $WT_IMAGES, $placements;
+ global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION, $placements;
$desc = $event->getValue();
// check if this is a family fact
@@ -172,8 +173,8 @@ class WT_Controller_Timeline extends WT_Controller_Page {
$yoffset = $baseyoffset + (($year - $this->baseyear) * $this->scale) - ($this->scale);
$yoffset = $yoffset + (($month / 12) * $this->scale);
$yoffset = $yoffset + (($day / 30) * ($this->scale / 12));
- $yoffset = (int)($yoffset);
- $place = (int)($yoffset / $this->bheight);
+ $yoffset = (int) ($yoffset);
+ $place = (int) ($yoffset / $this->bheight);
$i = 1;
$j = 0;
$tyoffset = 0;
@@ -185,7 +186,7 @@ class WT_Controller_Timeline extends WT_Controller_Page {
$tyoffset = -1 * $this->bheight * $j;
$j++;
}
- $place = (int)(($yoffset + $tyoffset) / ($this->bheight));
+ $place = (int) (($yoffset + $tyoffset) / ($this->bheight));
}
$yoffset += $tyoffset;
$xoffset += abs($tyoffset);
@@ -193,7 +194,7 @@ class WT_Controller_Timeline extends WT_Controller_Page {
echo "<div id=\"fact$factcount\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . ($xoffset) : "right: " . ($xoffset)) . "px; top:" . ($yoffset) . "px; font-size: 8pt; height: " . ($this->bheight) . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">";
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"cursor: hand;\"><tr><td>";
- echo "<img src=\"" . $WT_IMAGES["hline"] . "\" name=\"boxline$factcount\" id=\"boxline$factcount\" height=\"3\" align=\"left\" width=\"10\" alt=\"\" style=\"padding-";
+ echo "<img src=\"" . Theme::theme()->parameter('image-hline') . "\" name=\"boxline$factcount\" id=\"boxline$factcount\" height=\"3\" align=\"left\" width=\"10\" alt=\"\" style=\"padding-";
if ($TEXT_DIRECTION == 'ltr') {
echo 'left: 3px;">';
} else {
@@ -250,26 +251,26 @@ class WT_Controller_Timeline extends WT_Controller_Page {
echo '</td></tr></table>';
echo '</div>';
if ($TEXT_DIRECTION === 'ltr') {
- $img = 'dline2';
+ $img = 'image-dline2';
$ypos = '0%';
} else {
- $img = 'dline';
+ $img = 'image-dline';
$ypos = '100%';
}
$dyoffset = ($yoffset - $tyoffset) + $this->bheight / 3;
if ($tyoffset < 0) {
$dyoffset = $yoffset + $this->bheight / 3;
if ($TEXT_DIRECTION === 'ltr') {
- $img = 'dline';
+ $img = 'image-dline';
$ypos = '100%';
} else {
- $img = 'dline2';
+ $img = 'image-dline2';
$ypos = '0%';
}
}
// Print the diagonal line
echo '<div id="dbox' . $factcount . '" style="position:absolute; ' . ($TEXT_DIRECTION == 'ltr' ? 'left: ' . ($basexoffset + 25) : 'right: ' . ($basexoffset + 25)) . 'px; top:' . ($dyoffset) . 'px; font-size: 8pt; height: ' . abs($tyoffset) . 'px; width: ' . abs($tyoffset) . 'px;';
- echo ' background-image: url(\'' . $WT_IMAGES[$img] . '\');';
+ echo ' background-image: url(\'' . Theme::theme()->parameter($img) . '\');';
echo ' background-position: 0% ' . $ypos . ';">';
echo '</div>';
}
diff --git a/library/WT/DB.php b/library/WT/DB.php
index e87306ee40..8104ee322b 100644
--- a/library/WT/DB.php
+++ b/library/WT/DB.php
@@ -308,7 +308,7 @@ class WT_DB {
*/
public static function updateSchema($schema_dir, $schema_name, $target_version) {
try {
- $current_version = (int)WT_Site::getPreference($schema_name);
+ $current_version = (int) WT_Site::getPreference($schema_name);
} catch (PDOException $e) {
// During initial installation, this table won’t exist.
// It will only be a problem if we can’t subsequently create it.
@@ -337,7 +337,7 @@ class WT_DB {
$next_version = $current_version + 1;
require $schema_dir . 'db_schema_' . $current_version . '_' . $next_version . '.php';
// The updatescript should update the version or throw an exception
- $current_version = (int)WT_Site::getPreference($schema_name);
+ $current_version = (int) WT_Site::getPreference($schema_name);
if ($current_version != $next_version) {
throw new Exception("Internal error while updating {$schema_name} to {$next_version}");
}
diff --git a/library/WT/DBStatement.php b/library/WT/DBStatement.php
index a6de7638cd..712c46008d 100644
--- a/library/WT/DBStatement.php
+++ b/library/WT/DBStatement.php
@@ -68,7 +68,7 @@ class WT_DBStatement {
$this->pdo_statement->bindValue($key, $bind_variable, PDO::PARAM_NULL);
break;
case 'boolean':
- $this->pdo_statement->bindValue($key, (int)$bind_variable, PDO::PARAM_INT);
+ $this->pdo_statement->bindValue($key, (int) $bind_variable, PDO::PARAM_INT);
break;
case 'integer':
$this->pdo_statement->bindValue($key, $bind_variable, PDO::PARAM_INT);
diff --git a/library/WT/Date.php b/library/WT/Date.php
index 19e0002977..5aa2c38158 100644
--- a/library/WT/Date.php
+++ b/library/WT/Date.php
@@ -158,7 +158,8 @@ class WT_Date {
if (preg_match('/^(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)$/', $m)) {
$cal = '@#DGREGORIAN@';
} else {
- if (preg_match('/^[345]\d\d\d$/', $y)) { // Year 3000-5999
+ if (preg_match('/^[345]\d\d\d$/', $y)) {
+ // Year 3000-5999
$cal = '@#DHEBREW@';
} else {
$cal = '@#DGREGORIAN@';
@@ -377,7 +378,7 @@ class WT_Date {
* @return integer
*/
function JD() {
- return (int)(($this->MinJD() + $this->MaxJD()) / 2);
+ return (int) (($this->MinJD() + $this->MaxJD()) / 2);
}
/**
diff --git a/library/WT/Date/Calendar.php b/library/WT/Date/Calendar.php
index 6630205e61..09e9e9385d 100644
--- a/library/WT/Date/Calendar.php
+++ b/library/WT/Date/Calendar.php
@@ -82,7 +82,7 @@ class WT_Date_Calendar {
// Construct from an array (of three gedcom-style strings: "1900", "FEB", "4")
if (is_array($date)) {
- $this->d = (int)$date[2];
+ $this->d = (int) $date[2];
if (array_key_exists($date[1], static::$MONTH_ABBREV)) {
$this->m = static::$MONTH_ABBREV[$date[1]];
} else {
@@ -119,7 +119,7 @@ class WT_Date_Calendar {
$jd = $date->calendar->ymdToJd($today[0], $date->m, $date->d == 0 ? $today[2] : $date->d);
} else {
// Complete date
- $jd = (int)(($date->maxJD + $date->minJD) / 2);
+ $jd = (int) (($date->maxJD + $date->minJD) / 2);
}
list($this->y, $this->m, $this->d) = $this->calendar->jdToYmd($jd);
// New date has same precision as original date
@@ -410,7 +410,7 @@ class WT_Date_Calendar {
* @return integer
*/
protected function extractYear($year) {
- return (int)$year;
+ return (int) $year;
}
/**
@@ -649,7 +649,7 @@ class WT_Date_Calendar {
$format = str_replace($match, $this->daysInMonth(), $format);
break;
case '%L':
- $format = str_replace($match, (int)$this->isLeapYear(), $format);
+ $format = str_replace($match, (int) $this->isLeapYear(), $format);
break;
case '%Y':
$format = str_replace($match, $this->formatLongYear(), $format);
@@ -892,7 +892,7 @@ class WT_Date_Calendar {
protected static function numberToRomanNumerals($number) {
if ($number < 1) {
// Cannot convert zero/negative numbers
- return (string)$number;
+ return (string) $number;
}
$roman = '';
foreach (self::$roman_numerals as $key => $value) {
@@ -957,24 +957,22 @@ class WT_Date_Calendar {
* @return string
*/
public function calendarUrl($date_format) {
- $URL = 'calendar.php?cal=' . rawurlencode(static::CALENDAR_ESCAPE);
- $action = 'year';
- if (strpos($date_format, 'Y') !== false || strpos($date_format, 'y') !== false) {
- $URL .= '&amp;year=' . $this->formatGedcomYear();
- }
- if (strpos($date_format, 'F') !== false || strpos($date_format, 'M') !== false || strpos($date_format, 'm') !== false || strpos($date_format, 'n') !== false) {
- $URL .= '&amp;month=' . $this->formatGedcomMonth();
- if ($this->m > 0) {
- $action = 'calendar';
- }
- }
- if (strpos($date_format, 'd') !== false || strpos($date_format, 'D') !== false || strpos($date_format, 'j') !== false) {
- $URL .= '&amp;day=' . $this->formatGedcomDay();
- if ($this->d > 0) {
- $action = 'today';
- }
+ if (strpbrk($date_format, 'dDj') && $this->d) {
+ // If the format includes a day, and the date also includes a day, then use the day view
+ $view = 'day';
+ } elseif (strpbrk($date_format, 'FMmn') && $this->m) {
+ // If the format includes a month, and the date also includes a month, then use the month view
+ $view = 'month';
+ } else {
+ // Use the year view
+ $view = 'year';
}
- return $URL . '&amp;action=' . $action;
+ return
+ 'calendar.php?cal=' . rawurlencode(static::CALENDAR_ESCAPE) .
+ '&amp;year=' . $this->formatGedcomYear() .
+ '&amp;month=' . $this->formatGedcomMonth() .
+ '&amp;day=' . $this->formatGedcomDay() .
+ '&amp;view=' . $view;
}
}
diff --git a/library/WT/Date/Jewish.php b/library/WT/Date/Jewish.php
index 8fba7faa06..9837918e97 100644
--- a/library/WT/Date/Jewish.php
+++ b/library/WT/Date/Jewish.php
@@ -237,30 +237,32 @@ class WT_Date_Jewish extends WT_Date_Calendar {
$shortYear = $num % 1000; //discard thousands
//next check for all possible single Hebrew digit years
$singleDigitYear = ($shortYear < 11 || ($shortYear < 100 && $shortYear % 10 == 0) || ($shortYear <= 400 && $shortYear % 100 == 0));
- $thousands = (int)($num / 1000); //get # thousands
+ $thousands = (int) ($num / 1000); //get # thousands
$sb = "";
//append thousands to String
- if ($num % 1000 == 0) { // in year is 5000, 4000 etc
+ if ($num % 1000 == 0) {
+ // in year is 5000, 4000 etc
$sb .= $jOnes[$thousands];
$sb .= self::GERSH;
$sb .= " ";
$sb .= self::ALAFIM; //add # of thousands plus word thousand (overide alafim boolean)
- } else if ($DISPLAY_JEWISH_THOUSANDS) { // if alafim boolean display thousands
+ } elseif ($DISPLAY_JEWISH_THOUSANDS) {
+ // if alafim boolean display thousands
$sb .= $jOnes[$thousands];
$sb .= self::GERSH; //append thousands quote
$sb .= " ";
}
$num = $num % 1000; //remove 1000s
- $hundreds = (int)($num / 100); // # of hundreds
+ $hundreds = (int) ($num / 100); // # of hundreds
$sb .= $jHundreds[$hundreds]; //add hundreds to String
$num = $num % 100; //remove 100s
- if ($num == 15) { //special case 15
+ if ($num == 15) {
$sb .= $tavTaz[0];
- } else if ($num == 16) { //special case 16
+ } else if ($num == 16) {
$sb .= $tavTaz[1];
} else {
- $tens = (int)($num / 10);
- if ($num % 10 == 0) { // if evenly divisable by 10
+ $tens = (int) ($num / 10);
+ if ($num % 10 == 0) {
if ($singleDigitYear == false) {
$sb .= $jTenEnds[$tens]; // use end letters so that for example 5750 will end with an end nun
} else {
@@ -273,11 +275,14 @@ class WT_Date_Jewish extends WT_Date_Calendar {
}
}
if ($singleDigitYear == true) {
- $sb .= self::GERSH; //append single quote
- } else { // append double quote before last digit
+ // Append single quote
+ $sb .= self::GERSH;
+ } else {
+ // Append double quote before last digit
$pos1 = strlen($sb) - 2;
$sb = substr($sb, 0, $pos1) . self::GERSHAYIM . substr($sb, $pos1);
- $sb = str_replace(self::GERSHAYIM . self::GERSHAYIM, self::GERSHAYIM, $sb); //replace double gershayim with single instance
+ // Replace double gershayim with single instance
+ $sb = str_replace(self::GERSHAYIM . self::GERSHAYIM, self::GERSHAYIM, $sb);
}
return $sb;
diff --git a/library/WT/Date/Julian.php b/library/WT/Date/Julian.php
index bd31e1bee3..068a12c33e 100644
--- a/library/WT/Date/Julian.php
+++ b/library/WT/Date/Julian.php
@@ -55,14 +55,15 @@ class WT_Date_Julian extends WT_Date_Calendar {
* {@inheritdoc}
*/
protected function extractYear($year) {
- if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) { // Assume the first year is correct
+ if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) {
+ // Assume the first year is correct
$this->new_old_style = true;
return $match[1] + 1;
} else if (preg_match('/^(\d+) B\.C\.$/', $year, $match)) {
return -$match[1];
} else {
- return (int)$year;
+ return (int) $year;
}
}
diff --git a/library/WT/Fact.php b/library/WT/Fact.php
index 508b5df85e..2769abd8eb 100644
--- a/library/WT/Fact.php
+++ b/library/WT/Fact.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2008 PGV Development Team. All rights reserved.
@@ -68,7 +68,7 @@ class WT_Fact {
$this->fact_id = $fact_id;
$this->tag = $match[1];
} else {
- throw new InvalidArgumentException('Invalid GEDCOM data passed to WT_Fact::_construct('.$gedcom.')');
+ throw new InvalidArgumentException('Invalid GEDCOM data passed to WT_Fact::_construct(' . $gedcom . ')');
}
}
@@ -407,25 +407,6 @@ class WT_Fact {
}
/**
- * Display an icon for this fact.
- * Icons are held in a theme subfolder. Not all themes provide icons.
- *
- * @return string
- */
- public function icon() {
- $icon = 'images/facts/' . $this->getTag() . '.png';
- $dir = substr(WT_CSS_URL, strlen(WT_STATIC_URL));
- if (file_exists($dir . $icon)) {
- return '<img src="' . WT_CSS_URL . $icon . '" title="' . WT_Gedcom_Tag::getLabel($this->getTag()) . '">';
- } elseif (file_exists($dir . 'images/facts/NULL.png')) {
- // Spacer image - for alignment - until we move to a sprite.
- return '<img src="' . WT_CSS_URL . 'images/facts/NULL.png">';
- } else {
- return '';
- }
- }
-
- /**
* Static Helper functions to sort events
*
* @param WT_Fact $a Fact one
diff --git a/library/WT/Family.php b/library/WT/Family.php
index a0da029276..c3778ff70f 100644
--- a/library/WT/Family.php
+++ b/library/WT/Family.php
@@ -221,7 +221,7 @@ class WT_Family extends WT_GedcomRecord {
public function getNumberOfChildren() {
$nchi = count($this->getChildren());
foreach ($this->getFacts('NCHI') as $fact) {
- $nchi = max($nchi, (int)$fact->getValue());
+ $nchi = max($nchi, (int) $fact->getValue());
}
return $nchi;
diff --git a/library/WT/File.php b/library/WT/File.php
index 4e2c740a8b..99905d3402 100644
--- a/library/WT/File.php
+++ b/library/WT/File.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (c) 2014 webtrees development team
+// Copyright (c) 2015 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
@@ -121,7 +121,7 @@ class WT_File {
if (is_dir($path)) {
return true;
} else {
- if (!is_dir(dirname($path))) {
+ if (dirname($path) && !is_dir(dirname($path))) {
WT_File::mkdir(dirname($path));
}
@mkdir($path);
diff --git a/library/WT/Filter.php b/library/WT/Filter.php
index fe930576c1..50214161ff 100644
--- a/library/WT/Filter.php
+++ b/library/WT/Filter.php
@@ -2,7 +2,7 @@
// Filter/escape/validate input and output
//
// webtrees: Web based Family History software
-// Copyright (c) 2014 webtrees development team
+// Copyright (c) 2015 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
@@ -30,7 +30,7 @@ class WT_Filter {
// (([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
// This matches far too much while a “precise” regex is several pages long.
// This is a compromise.
- const URL_REGEX='((https?|ftp]):)(//([^\s/?#<>]*))?([^\s?#<>]*)(\?([^\s#<>]*))?(#[^\s?#<>]+)?';
+ const URL_REGEX = '((https?|ftp]):)(//([^\s/?#<>]*))?([^\s?#<>]*)(\?([^\s#<>]*))?(#[^\s?#<>]+)?';
/**
* Escape a string for use in HTML
@@ -136,7 +136,7 @@ class WT_Filter {
public static function expandUrls($text) {
return preg_replace_callback(
'/' . addcslashes('(?!>)' . WT_Filter::URL_REGEX . '(?!</a>)', '/') . '/i',
- function ($m) {
+ function($m) {
return '<a href="' . $m[0] . '" target="_blank">' . $m[0] . '</a>';
},
WT_Filter::escapeHtml($text)
@@ -181,7 +181,7 @@ class WT_Filter {
*
* @return string|null
*/
- private static function input($source, $variable, $regexp=null, $default=null) {
+ private static function input($source, $variable, $regexp = null, $default = null) {
if ($regexp) {
return filter_input(
$source,
@@ -205,7 +205,7 @@ class WT_Filter {
},
)
);
- return ($tmp===null || $tmp===false) ? $default : $tmp;
+ return ($tmp === null || $tmp === false) ? $default : $tmp;
}
}
@@ -219,7 +219,7 @@ class WT_Filter {
*
* @return string[]
*/
- private static function inputArray($source, $variable, $regexp=null, $default=null) {
+ private static function inputArray($source, $variable, $regexp = null, $default = null) {
if ($regexp) {
// PHP5.3 requires the $tmp variable
$tmp = filter_input_array(
@@ -263,7 +263,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function get($variable, $regexp=null, $default=null) {
+ public static function get($variable, $regexp = null, $default = null) {
return self::input(INPUT_GET, $variable, $regexp, $default);
}
@@ -276,7 +276,7 @@ class WT_Filter {
*
* @return string[]
*/
- public static function getArray($variable, $regexp=null, $default=null) {
+ public static function getArray($variable, $regexp = null, $default = null) {
return self::inputArray(INPUT_GET, $variable, $regexp, $default);
}
@@ -288,7 +288,7 @@ class WT_Filter {
* @return boolean
*/
public static function getBool($variable) {
- return (bool)filter_input(INPUT_GET, $variable, FILTER_VALIDATE_BOOLEAN);
+ return (bool) filter_input(INPUT_GET, $variable, FILTER_VALIDATE_BOOLEAN);
}
/**
@@ -301,7 +301,7 @@ class WT_Filter {
*
* @return integer
*/
- public static function getInteger($variable, $min=0, $max=PHP_INT_MAX, $default=0) {
+ public static function getInteger($variable, $min = 0, $max = PHP_INT_MAX, $default = 0) {
return filter_input(INPUT_GET, $variable, FILTER_VALIDATE_INT, array('options'=>array('min_range'=>$min, 'max_range'=>$max, 'default'=>$default)));
}
@@ -313,7 +313,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function getEmail($variable, $default=null) {
+ public static function getEmail($variable, $default = null) {
return filter_input(INPUT_GET, $variable, FILTER_VALIDATE_EMAIL) ?: $default;
}
@@ -325,7 +325,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function getUrl($variable, $default=null) {
+ public static function getUrl($variable, $default = null) {
return filter_input(INPUT_GET, $variable, FILTER_VALIDATE_URL) ?: $default;
}
@@ -338,7 +338,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function post($variable, $regexp=null, $default=null) {
+ public static function post($variable, $regexp = null, $default = null) {
return self::input(INPUT_POST, $variable, $regexp, $default);
}
@@ -351,7 +351,7 @@ class WT_Filter {
*
* @return string[]
*/
- public static function postArray($variable, $regexp=null, $default=null) {
+ public static function postArray($variable, $regexp = null, $default = null) {
return self::inputArray(INPUT_POST, $variable, $regexp, $default);
}
@@ -363,7 +363,7 @@ class WT_Filter {
* @return boolean
*/
public static function postBool($variable) {
- return (bool)filter_input(INPUT_POST, $variable, FILTER_VALIDATE_BOOLEAN);
+ return (bool) filter_input(INPUT_POST, $variable, FILTER_VALIDATE_BOOLEAN);
}
/**
@@ -376,7 +376,7 @@ class WT_Filter {
*
* @return integer
*/
- public static function postInteger($variable, $min=0, $max=PHP_INT_MAX, $default=0) {
+ public static function postInteger($variable, $min = 0, $max = PHP_INT_MAX, $default = 0) {
return filter_input(INPUT_POST, $variable, FILTER_VALIDATE_INT, array('options'=>array('min_range'=>$min, 'max_range'=>$max, 'default'=>$default)));
}
@@ -388,7 +388,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function postEmail($variable, $default=null) {
+ public static function postEmail($variable, $default = null) {
return filter_input(INPUT_POST, $variable, FILTER_VALIDATE_EMAIL) ?: $default;
}
@@ -400,7 +400,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function postUrl($variable, $default=null) {
+ public static function postUrl($variable, $default = null) {
return filter_input(INPUT_POST, $variable, FILTER_VALIDATE_URL) ?: $default;
}
@@ -413,7 +413,7 @@ class WT_Filter {
*
* @return null|string
*/
- public static function cookie($variable, $regexp=null, $default=null) {
+ public static function cookie($variable, $regexp = null, $default = null) {
return self::input(INPUT_COOKIE, $variable, $regexp, $default);
}
@@ -428,7 +428,7 @@ class WT_Filter {
if ($WT_SESSION->CSRF_TOKEN === null) {
$charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789';
- for ($n=0; $n<32; ++$n) {
+ for ($n = 0; $n < 32; ++$n) {
$WT_SESSION->CSRF_TOKEN .= substr($charset, mt_rand(0, 61), 1);
}
}
@@ -454,9 +454,11 @@ class WT_Filter {
if (WT_Filter::post('csrf') !== WT_Filter::getCsrfToken()) {
// Oops. Something is not quite right
Log::addAuthenticationLog('CSRF mismatch - session expired or malicious attack');
- WT_FlashMessages::addMessage(WT_I18N::translate('This form has expired. Try again.'));
+ WT_FlashMessages::addMessage(WT_I18N::translate('This form has expired. Try again.'), 'error');
+
return false;
}
+
return true;
}
}
diff --git a/library/WT/FlashMessages.php b/library/WT/FlashMessages.php
index 665450e00d..d216394326 100644
--- a/library/WT/FlashMessages.php
+++ b/library/WT/FlashMessages.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 Greg Roach
+// Copyright (C) 2015 Greg Roach
//
// 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
@@ -24,9 +24,13 @@ class WT_FlashMessages {
/**
* Add a new message to the session storage.
*
- * @param string $message
+ * @param string $text
+ * @param string $status "success", "info", "warning" or "danger"
*/
- public static function addMessage($message) {
+ public static function addMessage($text, $status = 'info') {
+ $message = new stdClass;
+ $message->text = $text;
+ $message->status = $status;
$flash_messenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
$flash_messenger->addMessage($message);
@@ -55,23 +59,4 @@ class WT_FlashMessages {
return $messages;
}
-
- /**
- * Most theres will want a simple block of HTML to display
- *
- * @return string
- */
- public static function getHtmlMessages() {
- $html = '';
-
- foreach (self::getMessages() as $message) {
- $html .= '<p class="ui-state-highlight">' . $message . '</p>';
- }
-
- if ($html) {
- $html = '<div id="flash-messages">' . $html . '</div>';
- }
-
- return $html;
- }
}
diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php
index ba76353c31..ecbc323236 100644
--- a/library/WT/GedcomRecord.php
+++ b/library/WT/GedcomRecord.php
@@ -133,7 +133,7 @@ class WT_GedcomRecord {
* @return WT_GedcomRecord|null
* @throws Exception
*/
- public static function getInstance($xref, $gedcom_id=WT_GED_ID, $gedcom=null) {
+ public static function getInstance($xref, $gedcom_id = WT_GED_ID, $gedcom = null) {
// Is this record already in the cache?
if (isset(self::$gedcom_record_cache[$xref][$gedcom_id])) {
return self::$gedcom_record_cache[$xref][$gedcom_id];
@@ -148,7 +148,7 @@ class WT_GedcomRecord {
if (WT_USER_CAN_EDIT) {
if (!isset(self::$pending_record_cache[$gedcom_id])) {
// Fetch all pending records in one database query
- self::$pending_record_cache[$gedcom_id]=array();
+ self::$pending_record_cache[$gedcom_id] = array();
$rows = WT_DB::prepare(
"SELECT xref, new_gedcom FROM `##change` WHERE status='pending' AND gedcom_id=?"
)->execute(array($gedcom_id))->fetchAll();
@@ -174,20 +174,20 @@ class WT_GedcomRecord {
}
// Create the object
- if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedcom.$pending, $match)) {
+ if (preg_match('/^0 @(' . WT_REGEX_XREF . ')@ (' . WT_REGEX_TAG . ')/', $gedcom . $pending, $match)) {
$xref = $match[1]; // Collation - we may have requested I123 and found i123
$type = $match[2];
- } elseif (preg_match('/^0 (HEAD|TRLR)/', $gedcom.$pending, $match)) {
+ } elseif (preg_match('/^0 (HEAD|TRLR)/', $gedcom . $pending, $match)) {
$xref = $match[1];
$type = $match[1];
- } elseif ($gedcom.$pending) {
+ } elseif ($gedcom . $pending) {
throw new Exception('Unrecognized GEDCOM record: ' . $gedcom);
} else {
// A record with both pending creation and pending deletion
$type = static::RECORD_TYPE;
}
- switch($type) {
+ switch ($type) {
case 'INDI':
$record = new WT_Individual($xref, $gedcom, $pending, $gedcom_id);
break;
@@ -226,7 +226,7 @@ class WT_GedcomRecord {
* @return null|string
*/
protected static function fetchGedcomRecord($xref, $gedcom_id) {
- static $statement=null;
+ static $statement = null;
// We don't know what type of object this is. Try each one in turn.
$data = WT_Individual::fetchGedcomRecord($xref, $gedcom_id);
@@ -255,7 +255,7 @@ class WT_GedcomRecord {
}
// Some other type of record...
if (is_null($statement)) {
- $statement=WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_id=? AND o_file=?");
+ $statement = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_id=? AND o_file=?");
}
return $statement->execute(array($xref, $gedcom_id))->fetchOne();
@@ -372,16 +372,16 @@ class WT_GedcomRecord {
}
// We should always be able to see our own record (unless an admin is applying download restrictions)
- if ($this->getXref()==WT_USER_GEDCOM_ID && $this->getGedcomId()==WT_GED_ID && $access_level==WT_USER_ACCESS_LEVEL) {
+ if ($this->getXref() == WT_USER_GEDCOM_ID && $this->getGedcomId() == WT_GED_ID && $access_level == WT_USER_ACCESS_LEVEL) {
return true;
}
// Does this record have a RESN?
if (strpos($this->gedcom, "\n1 RESN confidential")) {
- return WT_PRIV_NONE>=$access_level;
+ return WT_PRIV_NONE >= $access_level;
}
if (strpos($this->gedcom, "\n1 RESN privacy")) {
- return WT_PRIV_USER>=$access_level;
+ return WT_PRIV_USER >= $access_level;
}
if (strpos($this->gedcom, "\n1 RESN none")) {
return true;
@@ -389,11 +389,11 @@ class WT_GedcomRecord {
// Does this record have a default RESN?
if (isset($person_privacy[$this->getXref()])) {
- return $person_privacy[$this->getXref()]>=$access_level;
+ return $person_privacy[$this->getXref()] >= $access_level;
}
// Privacy rules do not apply to admins
- if (WT_PRIV_NONE>=$access_level) {
+ if (WT_PRIV_NONE >= $access_level) {
return true;
}
@@ -413,7 +413,7 @@ class WT_GedcomRecord {
if (isset($global_facts[static::RECORD_TYPE])) {
// Restriction found
- return $global_facts[static::RECORD_TYPE]>=$access_level;
+ return $global_facts[static::RECORD_TYPE] >= $access_level;
} else {
// No restriction found - must be public:
return true;
@@ -427,23 +427,23 @@ class WT_GedcomRecord {
*
* @return boolean
*/
- public function canShow($access_level=WT_USER_ACCESS_LEVEL) {
+ public function canShow($access_level = WT_USER_ACCESS_LEVEL) {
// CACHING: this function can take three different parameters,
// and therefore needs three different caches for the result.
switch ($access_level) {
case WT_PRIV_PUBLIC: // visitor
- if ($this->disp_public===null) {
- $this->disp_public=$this->_canShow(WT_PRIV_PUBLIC);
+ if ($this->disp_public === null) {
+ $this->disp_public = $this->_canShow(WT_PRIV_PUBLIC);
}
return $this->disp_public;
case WT_PRIV_USER: // member
- if ($this->disp_user===null) {
- $this->disp_user=$this->_canShow(WT_PRIV_USER);
+ if ($this->disp_user === null) {
+ $this->disp_user = $this->_canShow(WT_PRIV_USER);
}
return $this->disp_user;
case WT_PRIV_NONE: // admin
- if ($this->disp_none===null) {
- $this->disp_none=$this->_canShow(WT_PRIV_NONE);
+ if ($this->disp_none === null) {
+ $this->disp_none = $this->_canShow(WT_PRIV_NONE);
}
return $this->disp_none;
case WT_PRIV_HIDE: // hidden from admins
@@ -463,7 +463,7 @@ class WT_GedcomRecord {
*
* @return boolean
*/
- public function canShowName($access_level=WT_USER_ACCESS_LEVEL) {
+ public function canShowName($access_level = WT_USER_ACCESS_LEVEL) {
return $this->canShow($access_level);
}
@@ -473,7 +473,7 @@ class WT_GedcomRecord {
* @return boolean
*/
public function canEdit() {
- return WT_USER_GEDCOM_ADMIN || WT_USER_CAN_EDIT && strpos($this->gedcom, "\n1 RESN locked")===false;
+ return WT_USER_GEDCOM_ADMIN || WT_USER_CAN_EDIT && strpos($this->gedcom, "\n1 RESN locked") === false;
}
/**
@@ -485,14 +485,14 @@ class WT_GedcomRecord {
* @return string
*/
public function privatizeGedcom($access_level) {
- if ($access_level==WT_PRIV_HIDE) {
+ if ($access_level == WT_PRIV_HIDE) {
// We may need the original record, for example when downloading a GEDCOM or clippings cart
return $this->gedcom;
} elseif ($this->canShow($access_level)) {
// The record is not private, but the individual facts may be.
// Include the entire first line (for NOTE records)
- list($gedrec)=explode("\n", $this->gedcom, 2);
+ list($gedrec) = explode("\n", $this->gedcom, 2);
// Check each of the facts for access
foreach ($this->getFacts(null, false, $access_level) as $fact) {
@@ -529,7 +529,7 @@ class WT_GedcomRecord {
$this->_getAllNames[] = array(
'type' => $type,
'sort' => preg_replace_callback('/([0-9]+)/', function($matches) { return str_pad($matches[0], 10, '0', STR_PAD_LEFT); }, $value),
- 'full' => '<span dir="auto">'.WT_Filter::escapeHtml($value).'</span>', // This is used for display
+ 'full' => '<span dir="auto">' . WT_Filter::escapeHtml($value) . '</span>', // This is used for display
'fullNN' => $value, // This goes into the database
);
}
@@ -554,7 +554,7 @@ class WT_GedcomRecord {
if (preg_match_all("/^{$level} ({$fact_type}) (.+)((\n[{$sublevel}-9].+)*)/m", $fact->getGedcom(), $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// Treat 1 NAME / 2 TYPE married the same as _MARNM
- if ($match[1]=='NAME' && strpos($match[3], "\n2 TYPE married")!==false) {
+ if ($match[1] == 'NAME' && strpos($match[3], "\n2 TYPE married") !== false) {
$this->addName('_MARNM', $match[2], $fact->getGedcom());
} else {
$this->addName($match[1], $match[2], $fact->getGedcom());
@@ -613,55 +613,26 @@ class WT_GedcomRecord {
* @return integer
*/
public function getPrimaryName() {
- if (is_null($this->_getPrimaryName)) {
+ static $language_script;
+
+ if ($language_script === null) {
+ $language_script = WT_I18N::languageScript(WT_LOCALE);
+ }
+
+ if ($this->_getPrimaryName === null) {
// Generally, the first name is the primary one....
- $this->_getPrimaryName=0;
- // ....except when the language/name use different character sets
- if (count($this->getAllNames())>1) {
- switch (WT_LOCALE) {
- case 'el':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type']!='_MARNM' && WT_I18N::textScript($name['sort'])=='Grek') {
- $this->_getPrimaryName=$n;
- break;
- }
- }
- break;
- case 'ru':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type']!='_MARNM' && WT_I18N::textScript($name['sort'])=='Cyrl') {
- $this->_getPrimaryName=$n;
- break;
- }
- }
- break;
- case 'he':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type']!='_MARNM' && WT_I18N::textScript($name['sort'])=='Hebr') {
- $this->_getPrimaryName=$n;
- break;
- }
- }
- break;
- case 'ar':
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type']!='_MARNM' && WT_I18N::textScript($name['sort'])=='Arab') {
- $this->_getPrimaryName=$n;
- break;
- }
- }
- break;
- default:
- foreach ($this->getAllNames() as $n=>$name) {
- if ($name['type']!='_MARNM' && WT_I18N::textScript($name['sort'])=='Latn') {
- $this->_getPrimaryName=$n;
- break;
- }
+ $this->_getPrimaryName = 0;
+ // ...except when the language/name use different character sets
+ if (count($this->getAllNames()) > 1) {
+ foreach ($this->getAllNames() as $n => $name) {
+ if ($name['type'] !== '_MARNM' && WT_I18N::textScript($name['sort']) === $language_script) {
+ $this->_getPrimaryName = $n;
+ break;
}
- break;
}
}
}
+
return $this->_getPrimaryName;
}
@@ -673,14 +644,14 @@ class WT_GedcomRecord {
public function getSecondaryName() {
if (is_null($this->_getSecondaryName)) {
// Generally, the primary and secondary names are the same
- $this->_getSecondaryName=$this->getPrimaryName();
+ $this->_getSecondaryName = $this->getPrimaryName();
// ....except when there are names with different character sets
- $all_names=$this->getAllNames();
- if (count($all_names)>1) {
- $primary_script=WT_I18N::textScript($all_names[$this->getPrimaryName()]['sort']);
+ $all_names = $this->getAllNames();
+ if (count($all_names) > 1) {
+ $primary_script = WT_I18N::textScript($all_names[$this->getPrimaryName()]['sort']);
foreach ($all_names as $n=>$name) {
- if ($n!=$this->getPrimaryName() && $name['type']!='_MARNM' && WT_I18N::textScript($name['sort'])!=$primary_script) {
- $this->_getSecondaryName=$n;
+ if ($n != $this->getPrimaryName() && $name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) != $primary_script) {
+ $this->_getSecondaryName = $n;
break;
}
}
@@ -764,7 +735,7 @@ class WT_GedcomRecord {
* @return null|string
*/
public function getAddName() {
- if ($this->canShowName() && $this->getPrimaryName()!=$this->getSecondaryName()) {
+ if ($this->canShowName() && $this->getPrimaryName() != $this->getSecondaryName()) {
$all_names = $this->getAllNames();
return $all_names[$this->getSecondaryName()]['full'];
} else {
@@ -783,17 +754,17 @@ class WT_GedcomRecord {
*
* @return string
*/
- public function format_list($tag='li', $find=false, $name=null) {
+ public function format_list($tag = 'li', $find = false, $name = null) {
if (is_null($name)) {
- $name=$this->getFullName();
+ $name = $this->getFullName();
}
- $html='<a href="'.$this->getHtmlUrl().'"';
+ $html = '<a href="' . $this->getHtmlUrl() . '"';
if ($find) {
- $html.=' onclick="pasteid(\''.$this->getXref().'\', \'' . htmlentities($name) . '\');"';
+ $html .= ' onclick="pasteid(\'' . $this->getXref() . '\', \'' . htmlentities($name) . '\');"';
}
- $html.=' class="list_item"><b>'.$name.'</b>';
- $html.=$this->formatListDetails();
- $html='<'.$tag.'>'.$html.'</a></'.$tag.'>';
+ $html .= ' class="list_item"><b>' . $name . '</b>';
+ $html .= $this->formatListDetails();
+ $html = '<' . $tag . '>' . $html . '</a></' . $tag . '>';
return $html;
}
@@ -821,9 +792,9 @@ class WT_GedcomRecord {
if ($event->getDate()->isOK() || !$event->getPlace()->isEmpty()) {
switch ($style) {
case 1:
- return '<br><em>'.$event->getLabel().' '.format_fact_date($event, $this, false, false).' '.format_fact_place($event).'</em>';
+ return '<br><em>' . $event->getLabel() . ' ' . format_fact_date($event, $this, false, false) . ' ' . format_fact_place($event) . '</em>';
case 2:
- return '<dl><dt class="label">'.$event->getLabel().'</dt><dd class="field">'.format_fact_date($event, $this, false, false).' '.format_fact_place($event).'</dd></dl>';
+ return '<dl><dt class="label">' . $event->getLabel() . '</dt><dd class="field">' . format_fact_date($event, $this, false, false) . ' ' . format_fact_place($event) . '</dd></dl>';
}
}
}
@@ -943,13 +914,13 @@ class WT_GedcomRecord {
* @return WT_Note[]
*/
public function linkedNotes($link) {
- $rows=WT_DB::prepare(
- "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom".
- " FROM `##other`".
- " JOIN `##link` ON (o_file=l_file AND o_id=l_from)".
- " LEFT JOIN `##name` ON (o_file=n_file AND o_id=n_id AND n_num=0)".
- " WHERE o_file=? AND o_type='NOTE' AND l_type=? AND l_to=?".
- " ORDER BY n_sort COLLATE '".WT_I18N::$collation."'"
+ $rows = WT_DB::prepare(
+ "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom" .
+ " FROM `##other`" .
+ " JOIN `##link` ON (o_file=l_file AND o_id=l_from)" .
+ " LEFT JOIN `##name` ON (o_file=n_file AND o_id=n_id AND n_num=0)" .
+ " WHERE o_file=? AND o_type='NOTE' AND l_type=? AND l_to=?" .
+ " ORDER BY n_sort COLLATE '" . WT_I18N::$collation . "'"
)->execute(array($this->gedcom_id, $link, $this->xref))->fetchAll();
$list = array();
@@ -970,13 +941,13 @@ class WT_GedcomRecord {
* @return WT_Repository
*/
public function linkedRepositories($link) {
- $rows=WT_DB::prepare(
- "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom".
- " FROM `##other`".
- " JOIN `##link` ON (o_file=l_file AND o_id=l_from)".
- " LEFT JOIN `##name` ON (o_file=n_file AND o_id=n_id AND n_num=0)".
- " WHERE o_file=? AND o_type='REPO' AND l_type=? AND l_to=?".
- " ORDER BY n_sort COLLATE '".WT_I18N::$collation."'"
+ $rows = WT_DB::prepare(
+ "SELECT o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom" .
+ " FROM `##other`" .
+ " JOIN `##link` ON (o_file=l_file AND o_id=l_from)" .
+ " LEFT JOIN `##name` ON (o_file=n_file AND o_id=n_id AND n_num=0)" .
+ " WHERE o_file=? AND o_type='REPO' AND l_type=? AND l_to=?" .
+ " ORDER BY n_sort COLLATE '" . WT_I18N::$collation . "'"
)->execute(array($this->gedcom_id, $link, $this->xref))->fetchAll();
$list = array();
@@ -1058,11 +1029,11 @@ class WT_GedcomRecord {
*
* @return WT_Fact[]
*/
- public function getFacts($filter=null, $sort=false, $access_level=WT_USER_ACCESS_LEVEL, $override=false) {
- $facts=array();
+ public function getFacts($filter = null, $sort = false, $access_level = WT_USER_ACCESS_LEVEL, $override = false) {
+ $facts = array();
if ($this->canShow($access_level) || $override) {
foreach ($this->facts as $fact) {
- if (($filter==null || preg_match('/^' . $filter . '$/', $fact->getTag())) && $fact->canShow($access_level)) {
+ if (($filter == null || preg_match('/^' . $filter . '$/', $fact->getTag())) && $fact->canShow($access_level)) {
$facts[] = $fact;
}
}
@@ -1081,18 +1052,18 @@ class WT_GedcomRecord {
*
* @return string
*/
- public function lastChangeTimestamp($sorting=false) {
+ public function lastChangeTimestamp($sorting = false) {
$chan = $this->getFirstFact('CHAN');
if ($chan) {
// The record does have a CHAN event
$d = $chan->getDate()->MinDate();
if (preg_match('/\n3 TIME (\d\d):(\d\d):(\d\d)/', $chan->getGedcom(), $match)) {
- $t=mktime((int)$match[1], (int)$match[2], (int)$match[3], (int)$d->format('%n'), (int)$d->format('%j'), (int)$d->format('%Y'));
+ $t = mktime((int) $match[1], (int) $match[2], (int) $match[3], (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y'));
} elseif (preg_match('/\n3 TIME (\d\d):(\d\d)/', $chan->getGedcom(), $match)) {
- $t=mktime((int)$match[1], (int)$match[2], 0, (int)$d->format('%n'), (int)$d->format('%j'), (int)$d->format('%Y'));
+ $t = mktime((int) $match[1], (int) $match[2], 0, (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y'));
} else {
- $t=mktime(0, 0, 0, (int)$d->format('%n'), (int)$d->format('%j'), (int)$d->format('%Y'));
+ $t = mktime(0, 0, 0, (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y'));
}
if ($sorting) {
return $t;
@@ -1163,7 +1134,7 @@ class WT_GedcomRecord {
$gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom);
$gedcom = trim($gedcom);
- if ($this->pending==='') {
+ if ($this->pending === '') {
throw new Exception('Cannot edit a deleted record');
}
if ($gedcom && !preg_match('/^1 ' . WT_REGEX_TAG . '/', $gedcom)) {
@@ -1187,7 +1158,7 @@ class WT_GedcomRecord {
$new_gedcom .= "\n" . $gedcom;
}
$fact_id = true; // Only replace/delete one copy of a duplicate fact
- } elseif ($fact->getTag()!='CHAN' || !$update_chan) {
+ } elseif ($fact->getTag() != 'CHAN' || !$update_chan) {
$new_gedcom .= "\n" . $fact->getGedcom();
}
}
@@ -1240,7 +1211,7 @@ class WT_GedcomRecord {
} else {
throw new Exception('Invalid argument to WT_GedcomRecord::createRecord(' . $gedcom . ')');
}
- if (strpos("\r", $gedcom)!==false) {
+ if (strpos("\r", $gedcom) !== false) {
// MSDOS line endings will break things in horrible ways
throw new Exception('Evil line endings found in WT_GedcomRecord::createRecord(' . $gedcom . ')');
}
@@ -1366,7 +1337,7 @@ class WT_GedcomRecord {
foreach ($matches as $match) {
$next_level = $match[1] + 1;
$next_levels = '[' . $next_level . '-9]';
- $gedcom = preg_replace('/' . $match[0] . '(\n' . $next_levels .'.*)*/', '', $gedcom);
+ $gedcom = preg_replace('/' . $match[0] . '(\n' . $next_levels . '.*)*/', '', $gedcom);
}
$this->updateFact($fact->getFactId(), $gedcom, $update_chan);
}
diff --git a/library/WT/I18N.php b/library/WT/I18N.php
index 81360989a7..f771aa0e1b 100644
--- a/library/WT/I18N.php
+++ b/library/WT/I18N.php
@@ -227,16 +227,16 @@ class WT_I18N {
}
$prefs2 = array();
foreach ($prefs as $pref) {
- list($l, $q)=explode(';q=', $pref.';q=1.0');
+ list($l, $q) = explode(';q=', $pref . ';q=1.0');
$l = preg_replace_callback(
'/_[a-z][a-z]$/',
function($x) { return strtoupper($x[0]); },
str_replace('-', '_', $l)
); // en-gb => en_GB
if (array_key_exists($l, $prefs2)) {
- $prefs2[$l] = max((float)$q, $prefs2[$l]);
+ $prefs2[$l] = max((float) $q, $prefs2[$l]);
} else {
- $prefs2[$l] = (float)$q;
+ $prefs2[$l] = (float) $q;
}
}
// Ensure there is a fallback.
@@ -263,10 +263,10 @@ class WT_I18N {
if (is_dir(WT_DATA_DIR . 'language')) {
if (file_exists(WT_DATA_DIR . 'language/' . $locale . '.mo')) {
self::addTranslation(
- new Zend_Translate('gettext', WT_DATA_DIR.'language/' . $locale . '.mo', $locale)
+ new Zend_Translate('gettext', WT_DATA_DIR . 'language/' . $locale . '.mo', $locale)
);
}
- if (file_exists(WT_DATA_DIR.'language/' . $locale . '.php')) {
+ if (file_exists(WT_DATA_DIR . 'language/' . $locale . '.php')) {
self::addTranslation(
new Zend_Translate('array', WT_DATA_DIR . 'language/' . $locale . '.php', $locale)
);
@@ -331,7 +331,7 @@ class WT_I18N {
* @return array
*/
public static function installed_languages() {
- $mo_files = glob(WT_ROOT.'language'.DIRECTORY_SEPARATOR.'*.mo');
+ $mo_files = glob(WT_ROOT . 'language' . DIRECTORY_SEPARATOR . '*.mo');
$cache_key = md5(serialize($mo_files));
if (!($installed_languages = self::$cache->load($cache_key))) {
@@ -349,10 +349,6 @@ class WT_I18N {
$installed_languages[$match[1]] = $tmp2 . '|' . $tmp1;
}
}
- if (empty($installed_languages)) {
- // We cannot translate this
- die('There are no languages installed. You must include at least one xx.mo file in /language/');
- }
// Sort by the combined language/language name...
uasort($installed_languages, array('WT_I18N', 'strcasecmp'));
foreach ($installed_languages as &$value) {
@@ -375,10 +371,10 @@ class WT_I18N {
* @return string
*/
public static function html_markup() {
- $localeData=Zend_Locale_Data::getList(self::$locale, 'layout');
- $dir=$localeData['characterOrder']=='right-to-left' ? 'rtl' : 'ltr';
+ $localeData = Zend_Locale_Data::getList(self::$locale, 'layout');
+ $dir = $localeData['characterOrder'] == 'right-to-left' ? 'rtl' : 'ltr';
list($lang) = preg_split('/[-_@]/', self::$locale);
- return 'lang="'.$lang.'" dir="'.$dir.'"';
+ return 'lang="' . $lang . '" dir="' . $dir . '"';
}
/**
@@ -394,10 +390,10 @@ class WT_I18N {
*
* @return string
*/
- public static function number($n, $precision=0) {
+ public static function number($n, $precision = 0) {
// Add "punctuation" and convert digits
- $n=Zend_Locale_Format::toNumber($n, array('locale'=>WT_LOCALE, 'precision'=>$precision));
- $n=self::digits($n);
+ $n = Zend_Locale_Format::toNumber($n, array('locale'=>WT_LOCALE, 'precision'=>$precision));
+ $n = self::digits($n);
return $n;
}
@@ -431,10 +427,10 @@ class WT_I18N {
*
* @return string
*/
- public static function percentage($n, $precision=0) {
+ public static function percentage($n, $precision = 0) {
return
/* I18N: This is a percentage, such as “32.5%”. “%s” is the number, “%%” is the percent symbol. Some languages require a (non-breaking) space between the two, or a different symbol. */
- self::translate('%s%%', self::number($n*100.0, $precision));
+ self::translate('%s%%', self::number($n * 100.0, $precision));
}
/**
@@ -527,29 +523,29 @@ class WT_I18N {
// I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (in childhood)
return self::translate('(in childhood)');
}
- $age=array();
+ $age = array();
if (preg_match('/(\d+)y/', $string, $match)) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
- $years=$match[1];
- $age[]=self::plural('%s year', '%s years', $years, self::number($years));
+ $years = $match[1];
+ $age[] = self::plural('%s year', '%s years', $years, self::number($years));
} else {
- $years=-1;
+ $years = -1;
}
if (preg_match('/(\d+)m/', $string, $match)) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
- $age[]=self::plural('%s month', '%s months', $match[1], self::number($match[1]));
+ $age[] = self::plural('%s month', '%s months', $match[1], self::number($match[1]));
}
if (preg_match('/(\d+)w/', $string, $match)) {
// I18N: Part of an age string. e.g. 7 weeks and 3 days
- $age[]=self::plural('%s week', '%s weeks', $match[1], self::number($match[1]));
+ $age[] = self::plural('%s week', '%s weeks', $match[1], self::number($match[1]));
}
if (preg_match('/(\d+)d/', $string, $match)) {
// I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
- $age[]=self::plural('%s day', '%s days', $match[1], self::number($match[1]));
+ $age[] = self::plural('%s day', '%s days', $match[1], self::number($match[1]));
}
// If an age is just a number of years, only show the number
- if (count($age)==1 && $years>=0) {
- $age=$years;
+ if (count($age) == 1 && $years >= 0) {
+ $age = $years;
}
if ($age) {
if (!substr_compare($string, '<', 0, 1)) {
@@ -582,20 +578,20 @@ class WT_I18N {
$month = 30 * $day;
$year = 365 * $day;
- if ($seconds>$year) {
- $years=(int)($seconds/$year);
+ if ($seconds > $year) {
+ $years = (int) ($seconds / $year);
return self::plural('%s year ago', '%s years ago', $years, self::number($years));
- } elseif ($seconds>$month) {
- $months=(int)($seconds/$month);
+ } elseif ($seconds > $month) {
+ $months = (int) ($seconds / $month);
return self::plural('%s month ago', '%s months ago', $months, self::number($months));
- } elseif ($seconds>$day) {
- $days=(int)($seconds/$day);
+ } elseif ($seconds > $day) {
+ $days = (int) ($seconds / $day);
return self::plural('%s day ago', '%s days ago', $days, self::number($days));
- } elseif ($seconds>$hour) {
- $hours=(int)($seconds/$hour);
+ } elseif ($seconds > $hour) {
+ $hours = (int) ($seconds / $hour);
return self::plural('%s hour ago', '%s hours ago', $hours, self::number($hours));
- } elseif ($seconds>$minute) {
- $minutes=(int)($seconds/$minute);
+ } elseif ($seconds > $minute) {
+ $minutes = (int) ($seconds / $minute);
return self::plural('%s minute ago', '%s minutes ago', $minutes, self::number($minutes));
} else {
return self::plural('%s second ago', '%s seconds ago', $seconds, self::number($seconds));
@@ -646,8 +642,8 @@ class WT_I18N {
* @return string
*/
public static function textScript($string) {
- $string = strip_tags($string); // otherwise HTML tags show up as latin
- $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); // otherwise HTML entities show up as latin
+ $string = strip_tags($string); // otherwise HTML tags show up as latin
+ $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); // otherwise HTML entities show up as latin
$string = str_replace(array('@N.N.', '@P.N.'), '', $string); // otherwise unknown names show up as latin
$pos = 0;
$strlen = strlen($string);
@@ -761,16 +757,16 @@ class WT_I18N {
$byte1 = ord($string1[$strpos1]);
$byte2 = ord($string2[$strpos2]);
if (($byte1 & 0xE0) == 0xC0) {
- $chr1 = $string1[$strpos1++].$string1[$strpos1++];
+ $chr1 = $string1[$strpos1++] . $string1[$strpos1++];
} elseif (($byte1 & 0xF0) == 0xE0) {
- $chr1 = $string1[$strpos1++].$string1[$strpos1++].$string1[$strpos1++];
+ $chr1 = $string1[$strpos1++] . $string1[$strpos1++] . $string1[$strpos1++];
} else {
$chr1 = $string1[$strpos1++];
}
- if (($byte2 & 0xE0)==0xC0) {
- $chr2 = $string2[$strpos2++].$string2[$strpos2++];
- } elseif (($byte2 & 0xF0)==0xE0) {
- $chr2 = $string2[$strpos2++].$string2[$strpos2++].$string2[$strpos2++];
+ if (($byte2 & 0xE0) == 0xC0) {
+ $chr2 = $string2[$strpos2++] . $string2[$strpos2++];
+ } elseif (($byte2 & 0xF0) == 0xE0) {
+ $chr2 = $string2[$strpos2++] . $string2[$strpos2++] . $string2[$strpos2++];
} else {
$chr2 = $string2[$strpos2++];
}
@@ -865,80 +861,80 @@ class WT_I18N {
*
* @return string
*/
- public static function datatablesI18N(array $lengths=null) {
- if ($lengths===null) {
- $lengths=array(10, 20, 30, 50, 100, -1);
+ public static function datatablesI18N(array $lengths = null) {
+ if ($lengths === null) {
+ $lengths = array(10, 20, 30, 50, 100, -1);
}
- $length_menu='';
+ $length_menu = '';
foreach ($lengths as $length) {
- $length_menu.=
- '<option value="'.$length.'">'.
- ($length==-1 ? /* I18N: listbox option, e.g. “10,25,50,100,all” */ self::translate('All') : self::number($length)).
+ $length_menu .=
+ '<option value="' . $length . '">' .
+ ($length == -1 ? /* I18N: listbox option, e.g. “10,25,50,100,all” */ self::translate('All') : self::number($length)) .
'</option>';
}
- $length_menu='<select>'.$length_menu.'</select>';
- $length_menu=/* I18N: Display %s [records per page], %s is a placeholder for listbox containing numeric options */ self::translate('Display %s', $length_menu);
+ $length_menu = '<select>' . $length_menu . '</select>';
+ $length_menu = /* I18N: Display %s [records per page], %s is a placeholder for listbox containing numeric options */ self::translate('Display %s', $length_menu);
// Which symbol is used for separating numbers into groups
$symbols = Zend_Locale_Data::getList(self::$locale, 'symbols');
// Which digits are used for numbers
$digits = Zend_Locale_Data::getContent(self::$locale, 'numberingsystem', self::$numbering_system);
- if ($digits=='0123456789') {
- $callback='';
+ if ($digits == '0123456789') {
+ $callback = '';
} else {
- $callback=',
+ $callback = ',
"infoCallback": function(oSettings, iStart, iEnd, iMax, iTotal, sPre) {
return sPre
- .replace(/0/g, "'.mb_substr($digits, 0, 1).'")
- .replace(/1/g, "'.mb_substr($digits, 1, 1).'")
- .replace(/2/g, "'.mb_substr($digits, 2, 1).'")
- .replace(/3/g, "'.mb_substr($digits, 3, 1).'")
- .replace(/4/g, "'.mb_substr($digits, 4, 1).'")
- .replace(/5/g, "'.mb_substr($digits, 5, 1).'")
- .replace(/6/g, "'.mb_substr($digits, 6, 1).'")
- .replace(/7/g, "'.mb_substr($digits, 7, 1).'")
- .replace(/8/g, "'.mb_substr($digits, 8, 1).'")
- .replace(/9/g, "'.mb_substr($digits, 9, 1).'");
+ .replace(/0/g, "'.mb_substr($digits, 0, 1) . '")
+ .replace(/1/g, "'.mb_substr($digits, 1, 1) . '")
+ .replace(/2/g, "'.mb_substr($digits, 2, 1) . '")
+ .replace(/3/g, "'.mb_substr($digits, 3, 1) . '")
+ .replace(/4/g, "'.mb_substr($digits, 4, 1) . '")
+ .replace(/5/g, "'.mb_substr($digits, 5, 1) . '")
+ .replace(/6/g, "'.mb_substr($digits, 6, 1) . '")
+ .replace(/7/g, "'.mb_substr($digits, 7, 1) . '")
+ .replace(/8/g, "'.mb_substr($digits, 8, 1) . '")
+ .replace(/9/g, "'.mb_substr($digits, 9, 1) . '");
},
"formatNumber": function(iIn) {
return String(iIn)
- .replace(/0/g, "'.mb_substr($digits, 0, 1).'")
- .replace(/1/g, "'.mb_substr($digits, 1, 1).'")
- .replace(/2/g, "'.mb_substr($digits, 2, 1).'")
- .replace(/3/g, "'.mb_substr($digits, 3, 1).'")
- .replace(/4/g, "'.mb_substr($digits, 4, 1).'")
- .replace(/5/g, "'.mb_substr($digits, 5, 1).'")
- .replace(/6/g, "'.mb_substr($digits, 6, 1).'")
- .replace(/7/g, "'.mb_substr($digits, 7, 1).'")
- .replace(/8/g, "'.mb_substr($digits, 8, 1).'")
- .replace(/9/g, "'.mb_substr($digits, 9, 1).'");
+ .replace(/0/g, "'.mb_substr($digits, 0, 1) . '")
+ .replace(/1/g, "'.mb_substr($digits, 1, 1) . '")
+ .replace(/2/g, "'.mb_substr($digits, 2, 1) . '")
+ .replace(/3/g, "'.mb_substr($digits, 3, 1) . '")
+ .replace(/4/g, "'.mb_substr($digits, 4, 1) . '")
+ .replace(/5/g, "'.mb_substr($digits, 5, 1) . '")
+ .replace(/6/g, "'.mb_substr($digits, 6, 1) . '")
+ .replace(/7/g, "'.mb_substr($digits, 7, 1) . '")
+ .replace(/8/g, "'.mb_substr($digits, 8, 1) . '")
+ .replace(/9/g, "'.mb_substr($digits, 9, 1) . '");
}
';
}
return
- '"language": {'.
- ' "paginate": {'.
- ' "first": "'./* I18N: button label, first page */ self::translate('first').'",'.
- ' "last": "'./* I18N: button label, last page */ self::translate('last').'",'.
- ' "next": "'./* I18N: button label, next page */ self::translate('next').'",'.
- ' "previous": "'./* I18N: button label, previous page */ self::translate('previous').'"'.
- ' },'.
- ' "emptyTable": "'.self::translate('No records to display').'",'.
- ' "info": "'./* I18N: %s are placeholders for numbers */ self::translate('Showing %1$s to %2$s of %3$s', '_START_', '_END_', '_TOTAL_').'",'.
- ' "infoEmpty": "'.self::translate('Showing %1$s to %2$s of %3$s', 0, 0, 0).'",'.
- ' "infoFiltered": "'./* I18N: %s is a placeholder for a number */ self::translate('(filtered from %s total entries)', '_MAX_').'",'.
- ' "infoPostfix": "",'.
- ' "infoThousands": "'.$symbols['group'].'",'.
- ' "lengthMenu": "'.WT_Filter::escapeJs($length_menu).'",'.
- ' "loadingRecords": "'.self::translate('Loading…').'",'.
- ' "processing": "'.self::translate('Loading…').'",'.
- ' "search": "'.self::translate('Filter').'",'.
- ' "url": "",'.
- ' "zeroRecords": "'.self::translate('No records to display').'"'.
- '}'.
+ '"language": {' .
+ ' "paginate": {' .
+ ' "first": "' . /* I18N: button label, first page */ self::translate('first') . '",' .
+ ' "last": "' . /* I18N: button label, last page */ self::translate('last') . '",' .
+ ' "next": "' . /* I18N: button label, next page */ self::translate('next') . '",' .
+ ' "previous": "' . /* I18N: button label, previous page */ self::translate('previous') . '"' .
+ ' },' .
+ ' "emptyTable": "' . self::translate('No records to display') . '",' .
+ ' "info": "' . /* I18N: %s are placeholders for numbers */ self::translate('Showing %1$s to %2$s of %3$s', '_START_', '_END_', '_TOTAL_') . '",' .
+ ' "infoEmpty": "' . self::translate('Showing %1$s to %2$s of %3$s', 0, 0, 0) . '",' .
+ ' "infoFiltered": "' . /* I18N: %s is a placeholder for a number */ self::translate('(filtered from %s total entries)', '_MAX_') . '",' .
+ ' "infoPostfix": "",' .
+ ' "infoThousands": "' . $symbols['group'] . '",' .
+ ' "lengthMenu": "' . WT_Filter::escapeJs($length_menu) . '",' .
+ ' "loadingRecords": "' . self::translate('Loading…') . '",' .
+ ' "processing": "' . self::translate('Loading…') . '",' .
+ ' "search": "' . self::translate('Filter') . '",' .
+ ' "url": "",' .
+ ' "zeroRecords": "' . self::translate('No records to display') . '"' .
+ '}' .
$callback;
}
}
diff --git a/library/WT/Individual.php b/library/WT/Individual.php
index bb98fc1edf..37663f6262 100644
--- a/library/WT/Individual.php
+++ b/library/WT/Individual.php
@@ -660,7 +660,7 @@ class WT_Individual extends WT_GedcomRecord {
if ($min && $max) {
$gregorian_calendar = new GregorianCalendar;
- list($year) = $gregorian_calendar->jdToYmd((int)((max($min) + min($max)) / 2));
+ list($year) = $gregorian_calendar->jdToYmd((int) ((max($min) + min($max)) / 2));
$this->_getEstimatedBirthDate = new WT_Date('EST ' . $year);
} else {
$this->_getEstimatedBirthDate = new WT_Date(''); // always return a date object
@@ -1096,7 +1096,7 @@ class WT_Individual extends WT_GedcomRecord {
// Extract the structured name parts - use for "sortable" names and indexes
////////////////////////////////////////////////////////////////////////////
- $sublevel = 1 + (int)$gedcom[0];
+ $sublevel = 1 + (int) $gedcom[0];
$NPFX = preg_match("/\n{$sublevel} NPFX (.+)/", $gedcom, $match) ? $match[1] : '';
$GIVN = preg_match("/\n{$sublevel} GIVN (.+)/", $gedcom, $match) ? $match[1] : '';
$SURN = preg_match("/\n{$sublevel} SURN (.+)/", $gedcom, $match) ? $match[1] : '';
@@ -1152,9 +1152,9 @@ class WT_Individual extends WT_GedcomRecord {
$GIVN = preg_replace(
array(
'/ ?\/.*\/ ?/', // remove surname
- '/ ?".+"/', // remove nickname
- '/ {2,}/', // multiple spaces, caused by the above
- '/^ | $/', // leading/trailing spaces, caused by the above
+ '/ ?".+"/', // remove nickname
+ '/ {2,}/', // multiple spaces, caused by the above
+ '/^ | $/', // leading/trailing spaces, caused by the above
),
array(
' ',
@@ -1248,11 +1248,11 @@ class WT_Individual extends WT_GedcomRecord {
$this->_getAllNames[] = array(
'type' => $type,
'sort' => $SURN . ',' . $GIVN,
- 'full' => $full, // This is used for display
- 'fullNN' => $fullNN, // This goes into the database
+ 'full' => $full, // This is used for display
+ 'fullNN' => $fullNN, // This goes into the database
'surname' => $surname, // This goes into the database
- 'givn' => $GIVN, // This goes into the database
- 'surn' => $SURN, // This goes into the database
+ 'givn' => $GIVN, // This goes into the database
+ 'surn' => $SURN, // This goes into the database
);
}
}
diff --git a/library/WT/Log.php b/library/WT/Log.php
index 01d8116142..f81515cbf1 100644
--- a/library/WT/Log.php
+++ b/library/WT/Log.php
@@ -1,6 +1,4 @@
<?php
-namespace WT;
-
// webtrees: Web based Family History software
// Copyright (C) 2014 webtrees development team
//
@@ -18,6 +16,8 @@ namespace WT;
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+namespace WT;
+
use WT_DB;
use WT_Tree;
diff --git a/library/WT/Mail.php b/library/WT/Mail.php
index 9ca023a8e6..8a0a0e76c6 100644
--- a/library/WT/Mail.php
+++ b/library/WT/Mail.php
@@ -58,13 +58,13 @@ class WT_Mail {
try {
$mail = new Zend_Mail('UTF-8');
$mail
- ->setSubject ($subject)
+ ->setSubject($subject)
->setBodyHtml($message)
->setBodyText(WT_Filter::unescapeHtml($message))
- ->setFrom (WT_Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'))
- ->addTo ($to_email, $to_name)
- ->setReplyTo ($replyto_email, $replyto_name)
- ->send (WT_Mail::transport());
+ ->setFrom(WT_Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'))
+ ->addTo($to_email, $to_name)
+ ->setReplyTo($replyto_email, $replyto_name)
+ ->send(WT_Mail::transport());
} catch (Exception $ex) {
Log::addErrorLog('Mail: ' . $ex->getMessage());
@@ -87,7 +87,7 @@ class WT_Mail {
public static function systemMessage(WT_Tree $tree, User $user, $subject, $message) {
return self::send(
$tree,
- $user->getEmail(), $user->getRealName(),
+ $user->getEmail(), $user->getRealName(),
WT_Site::getPreference('SMTP_FROM_NAME'), $tree->getPreference('title'),
$subject,
$message
@@ -102,7 +102,7 @@ class WT_Mail {
public static function transport() {
switch (WT_Site::getPreference('SMTP_ACTIVE')) {
case 'internal':
- return new Zend_Mail_Transport_Sendmail();
+ return new Zend_Mail_Transport_Sendmail;
case 'external':
$config = array(
'name' => WT_Site::getPreference('SMTP_HELO'),
@@ -120,7 +120,7 @@ class WT_Mail {
return new Zend_Mail_Transport_Smtp(WT_Site::getPreference('SMTP_HOST'), $config);
default:
// For testing
- return new Zend_Mail_Transport_File();
+ return new Zend_Mail_Transport_File;
}
}
}
diff --git a/library/WT/Media.php b/library/WT/Media.php
index 971760bd47..c37ff8dd32 100644
--- a/library/WT/Media.php
+++ b/library/WT/Media.php
@@ -259,7 +259,7 @@ class WT_Media extends WT_GedcomRecord {
public function getFilesize($which = 'main') {
$size = $this->getFilesizeraw($which);
if ($size) {
- $size = (int)(($size + 1023) / 1024);
+ $size = (int) (($size + 1023) / 1024);
} // add some bytes to be sure we never return “0 KB”
return /* I18N: size of file in KB */
WT_I18N::translate('%s KB', WT_I18N::number($size));
@@ -404,9 +404,18 @@ class WT_Media extends WT_GedcomRecord {
$pathinfo = pathinfo($exp[0]);
$imgsize['ext'] = @strtoupper($pathinfo['extension']);
// all mimetypes we wish to serve with the media firewall must be added to this array.
- $mime = array('DOC' => 'application/msword', 'MOV' => 'video/quicktime', 'MP3' => 'audio/mpeg', 'PDF' => 'application/pdf',
- 'PPT' => 'application/vnd.ms-powerpoint', 'RTF' => 'text/rtf', 'SID' => 'image/x-mrsid', 'TXT' => 'text/plain', 'XLS' => 'application/vnd.ms-excel',
- 'WMV' => 'video/x-ms-wmv');
+ $mime = array(
+ 'DOC' => 'application/msword',
+ 'MOV' => 'video/quicktime',
+ 'MP3' => 'audio/mpeg',
+ 'PDF' => 'application/pdf',
+ 'PPT' => 'application/vnd.ms-powerpoint',
+ 'RTF' => 'text/rtf',
+ 'SID' => 'image/x-mrsid',
+ 'TXT' => 'text/plain',
+ 'XLS' => 'application/vnd.ms-excel',
+ 'WMV' => 'video/x-ms-wmv',
+ );
if (empty($mime[$imgsize['ext']])) {
// if we don’t know what the mimetype is, use something ambiguous
$imgsize['mime'] = 'application/octet-stream';
diff --git a/library/WT/Menu.php b/library/WT/Menu.php
index e2da292a60..20a40da1eb 100644
--- a/library/WT/Menu.php
+++ b/library/WT/Menu.php
@@ -1,6 +1,6 @@
<?php
// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
+// Copyright (C) 2015 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
@@ -59,7 +59,7 @@ class WT_Menu {
* @param string $onclick A javascript onclick handler
* @param WT_Menu[] $submenus Any submenus
*/
- function __construct($label, $link = '#', $id = '', $onclick = '', $submenus = array()) {
+ public function __construct($label, $link = '#', $id = '', $onclick = '', $submenus = array()) {
$this
->setLabel($label)
->setLink($link)
@@ -79,13 +79,56 @@ class WT_Menu {
}
/**
+ * Render this menu using Bootstrap markup
+ *
+ * @return string
+ */
+ public function bootstrap() {
+ if ($this->iconclass) {
+ $class = ' class="' . $this->iconclass . '"';
+ } else {
+ $class = '';
+ }
+ if ($this->id) {
+ $id = ' id="' . $this->id . '"';
+ } else {
+ $id = '';
+ }
+
+ if ($this->submenus) {
+ $submenus = '';
+ foreach ($this->submenus as $submenu) {
+ $submenus .= $submenu->bootstrap();
+ }
+
+ return
+ '<li' . $id . ' class="dropdown">' .
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' .
+ $this->label .
+ ' <span class="caret"></span></a>' .
+ '<ul class="dropdown-menu" role="menu">' .
+ $submenus .
+ '</ul>' .
+ '</li>';
+ } else {
+ if ($this->onclick) {
+ $onclick = ' onclick="' . $this->onclick . '"';
+ } else {
+ $onclick = '';
+ }
+
+ return '<li' . $id . $class . '><a href="' . $this->link . '"' . $onclick . '>' . $this->label . '</a></li>';
+ }
+ }
+
+ /**
* Set the CSS classes for this menu
*
* @param string $class
* @param string $submenuclass
* @param string $iconclass
*/
- function addClass($class, $submenuclass = '', $iconclass = 'icon_general') {
+ public function addClass($class, $submenuclass = '', $iconclass = '') {
$this->class = $class;
$this->submenuclass = $submenuclass;
$this->iconclass = $iconclass;
@@ -168,7 +211,7 @@ class WT_Menu {
*
* @param WT_Menu[]
*/
- function addSubmenu($menu) {
+ public function addSubmenu($menu) {
$this->submenus[] = $menu;
}
@@ -177,7 +220,7 @@ class WT_Menu {
*
* @return string
*/
- function getMenu() {
+ public function getMenu() {
global $menucount, $TEXT_DIRECTION;
if (!isset($menucount)) {
@@ -229,7 +272,7 @@ class WT_Menu {
*
* @return string
*/
- function getMenuAsList() {
+ public function getMenuAsList() {
if ($this->iconclass) {
$class = ' class="' . $this->iconclass . '"';
} else {
diff --git a/library/WT/MenuBar.php b/library/WT/MenuBar.php
deleted file mode 100644
index e57bda0cd6..0000000000
--- a/library/WT/MenuBar.php
+++ /dev/null
@@ -1,509 +0,0 @@
-<?php
-// webtrees: Web based Family History software
-// Copyright (C) 2014 webtrees development team.
-//
-// Derived from PhpGedView
-// Copyright (C) 2002 to 2010 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-use WT\Auth;
-
-/**
- * Class WT_MenuBar - System for generating menus.
- */
-class WT_MenuBar {
- /**
- * @return WT_Menu
- */
- public static function getGedcomMenu() {
- $menu = new WT_Menu(WT_I18N::translate('Home page'), 'index.php?ctype=gedcom&amp;ged='.WT_GEDURL, 'menu-tree');
- $ALLOW_CHANGE_GEDCOM=WT_Site::getPreference('ALLOW_CHANGE_GEDCOM') && count(WT_Tree::getAll())>1;
- foreach (WT_Tree::getAll() as $tree) {
- if ($tree->tree_id==WT_GED_ID || $ALLOW_CHANGE_GEDCOM) {
- $submenu = new WT_Menu(
- $tree->tree_title_html,
- 'index.php?ctype=gedcom&amp;ged='.$tree->tree_name_url,
- 'menu-tree-'.$tree->tree_id // Cannot use name - it must be a CSS identifier
- );
- $menu->addSubmenu($submenu);
- }
- }
- return $menu;
- }
-
- /**
- * @return WT_Menu
- */
- public static function getMyPageMenu() {
- global $PEDIGREE_FULL_DETAILS, $PEDIGREE_LAYOUT;
-
- $showFull = ($PEDIGREE_FULL_DETAILS) ? 1 : 0;
- $showLayout = ($PEDIGREE_LAYOUT) ? 1 : 0;
-
- if (!Auth::id()) {
- return null;
- }
-
- //-- main menu
- $menu = new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&amp;ged='.WT_GEDURL, 'menu-mymenu');
-
- //-- mypage submenu
- $submenu = new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&amp;ged='.WT_GEDURL, 'menu-mypage');
- $menu->addSubmenu($submenu);
- //-- editaccount submenu
- if (Auth::user()->getPreference('editaccount')) {
- $submenu = new WT_Menu(WT_I18N::translate('My account'), 'edituser.php', 'menu-myaccount');
- $menu->addSubmenu($submenu);
- }
- if (WT_USER_GEDCOM_ID) {
- //-- my_pedigree submenu
- $submenu = new WT_Menu(
- WT_I18N::translate('My pedigree'),
- 'pedigree.php?ged='.WT_GEDURL.'&amp;rootid='.WT_USER_GEDCOM_ID."&amp;show_full={$showFull}&amp;talloffset={$showLayout}",
- 'menu-mypedigree'
- );
- $menu->addSubmenu($submenu);
- //-- my_indi submenu
- $submenu = new WT_Menu(WT_I18N::translate('My individual record'), 'individual.php?pid='.WT_USER_GEDCOM_ID.'&amp;ged='.WT_GEDURL, 'menu-myrecord');
- $menu->addSubmenu($submenu);
- }
- if (WT_USER_GEDCOM_ADMIN) {
- //-- admin submenu
- $submenu = new WT_Menu(WT_I18N::translate('Administration'), 'admin.php', 'menu-admin');
- $menu->addSubmenu($submenu);
- }
- return $menu;
- }
-
- /**
- * @return WT_Menu
- */
- public static function getChartsMenu() {
- global $SEARCH_SPIDER, $controller;
-
- if ($SEARCH_SPIDER || !WT_GED_ID) {
- return null;
- }
-
- $indi_xref=$controller->getSignificantIndividual()->getXref();
-
- $menu = new WT_Menu(WT_I18N::translate('Charts'), 'pedigree.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart');
-
- // Build a sortable list of submenu items and then sort it in localized name order
- $menuList = array(
- 'pedigree' =>WT_I18N::translate('Pedigree'),
- 'descendancy' =>WT_I18N::translate('Descendants'),
- 'ancestry' =>WT_I18N::translate('Ancestors'),
- 'compact' =>WT_I18N::translate('Compact tree'),
- 'hourglass' =>WT_I18N::translate('Hourglass chart'),
- 'familybook' =>WT_I18N::translate('Family book'),
- 'timeline' =>WT_I18N::translate('Timeline'),
- 'lifespan' =>WT_I18N::translate('Lifespans'),
- 'relationship'=>WT_I18N::translate('Relationships'),
- 'statistics' =>WT_I18N::translate('Statistics'),
- );
- if (function_exists('imagettftext')) {
- $menuList['fanchart']=WT_I18N::translate('Fan chart');
- }
- // TODO: Use WT_Module_Chart ??
- if (array_key_exists('tree', WT_Module::getActiveModules())) {
- $menuList['tree']=WT_I18N::translate('Interactive tree');
- }
- if (array_key_exists('googlemap', WT_Module::getActiveModules())) {
- $menuList['pedigree_map']=WT_I18N::translate('Pedigree map');
- }
- asort($menuList);
-
- // Produce the submenus in localized name order
- foreach ($menuList as $menuType => $menuName) {
- switch ($menuType) {
- case 'pedigree':
- $submenu = new WT_Menu($menuName, 'pedigree.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-pedigree');
- $menu->addSubmenu($submenu);
- break;
-
- case 'descendancy':
- $submenu = new WT_Menu($menuName, 'descendancy.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-descendancy');
- $menu->addSubmenu($submenu);
- break;
-
- case 'ancestry':
- $submenu = new WT_Menu($menuName, 'ancestry.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-ancestry');
- $menu->addSubmenu($submenu);
- break;
-
- case 'compact':
- $submenu = new WT_Menu($menuName, 'compact.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-compact');
- $menu->addSubmenu($submenu);
- break;
-
- case 'fanchart':
- $submenu = new WT_Menu($menuName, 'fanchart.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-fanchart');
- $menu->addSubmenu($submenu);
- break;
-
- case 'hourglass':
- $submenu = new WT_Menu($menuName, 'hourglass.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-hourglass');
- $menu->addSubmenu($submenu);
- break;
-
- case 'familybook':
- $submenu = new WT_Menu($menuName, 'familybook.php?rootid='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-familybook');
- $menu->addSubmenu($submenu);
- break;
-
- case 'timeline':
- $submenu = new WT_Menu($menuName, 'timeline.php?pids%5B%5D='.$indi_xref.'&amp;ged='.WT_GEDURL, 'menu-chart-timeline');
- if ($controller instanceof WT_Controller_Family && $controller->record) {
- // Build a sortable list of submenu items and then sort it in localized name order
- $menuList = array();
- $menuList['parentTimeLine'] = WT_I18N::translate('Show couple on timeline chart');
- $menuList['childTimeLine'] = WT_I18N::translate('Show children on timeline chart');
- $menuList['familyTimeLine'] = WT_I18N::translate('Show family on timeline chart');
- asort($menuList);
-
- // Produce the submenus in localized name order
- foreach ($menuList as $submenuType => $submenuName) {
- switch ($submenuType) {
- case 'parentTimeLine':
- // charts / parents_timeline
- $subsubmenu = new WT_Menu(
- $submenuName,
- 'timeline.php?'.$controller->getTimelineIndis(array('HUSB','WIFE')).'&amp;ged='.WT_GEDURL,
- 'menu-chart-timeline-parents'
- );
- $submenu->addSubmenu($subsubmenu);
- break;
-
- case 'childTimeLine':
- // charts / children_timeline
- $subsubmenu = new WT_Menu(
- $submenuName,
- 'timeline.php?'.$controller->getTimelineIndis(array('CHIL')).'&amp;ged='.WT_GEDURL,
- 'menu-chart-timeline-children'
- );
- $submenu->addSubmenu($subsubmenu);
- break;
-
- case 'familyTimeLine':
- // charts / family_timeline
- $subsubmenu = new WT_Menu(
- $submenuName,
- 'timeline.php?'.$controller->getTimelineIndis(array('HUSB','WIFE','CHIL')).'&amp;ged='.WT_GEDURL,
- 'menu-chart-timeline-family'
- );
- $submenu->addSubmenu($subsubmenu);
- break;
-
- }
- }
- }
- $menu->addSubmenu($submenu);
- break;
-
- case 'lifespan':
- $submenu = new WT_Menu($menuName, 'lifespan.php?pids%5B%5D='.$indi_xref.'&amp;addFamily=1&amp;ged='.WT_GEDURL, 'menu-chart-lifespan');
- $menu->addSubmenu($submenu);
- break;
-
- case 'relationship':
- if ($indi_xref) {
- // Pages focused on a specific person - from the person, to me
- $pid1=WT_USER_GEDCOM_ID ? WT_USER_GEDCOM_ID : WT_USER_ROOT_ID;;
- $pid2=$indi_xref;
- if ($pid1==$pid2) {
- $pid2='';
- }
- $submenu = new WT_Menu(
- WT_I18N::translate('Relationships'),
- 'relationship.php?pid1='.$pid1.'&amp;pid2='.$pid2.'&amp;ged='.WT_GEDURL,
- 'menu-chart-relationship'
- );
- } else {
- // Regular pages - from me, to somebody
- $pid1=WT_USER_GEDCOM_ID ? WT_USER_GEDCOM_ID : WT_USER_ROOT_ID;
- $pid2='';
- $submenu = new WT_Menu(
- WT_I18N::translate('Relationships'),
- 'relationship.php?pid1='.$pid1.'&amp;pid2='.$pid2.'&amp;ged='.WT_GEDURL,
- 'menu-chart-relationship'
- );
- }
- $menu->addSubmenu($submenu);
- break;
-
- case 'statistics':
- $submenu = new WT_Menu($menuName, 'statistics.php?ged='.WT_GEDURL, 'menu-chart-statistics');
- $menu->addSubmenu($submenu);
- break;
-
- case 'tree':
- $submenu = new WT_Menu($menuName, 'module.php?mod=tree&amp;mod_action=treeview&amp;ged='.WT_GEDURL.'&amp;rootid='.$indi_xref, 'menu-chart-tree');
- $menu->addSubmenu($submenu);
- break;
-
- case 'pedigree_map':
- $submenu = new WT_Menu($menuName, 'module.php?ged='.WT_GEDURL.'&amp;mod=googlemap&amp;mod_action=pedigree_map&amp;rootid='.$indi_xref, 'menu-chart-pedigree_map');
- $menu->addSubmenu($submenu);
- break;
- }
- }
- return $menu;
- }
-
- /**
- * @return WT_Menu
- * @throws Exception
- */
- public static function getListsMenu() {
- global $SEARCH_SPIDER, $controller;
-
- // The top level menu shows the individual list
- $menu = new WT_Menu(WT_I18N::translate('Lists'), 'indilist.php?ged=' . WT_GEDURL, 'menu-list');
-
- // Do not show empty lists
- $row = WT_DB::prepare(
- "SELECT SQL_CACHE" .
- " EXISTS(SELECT 1 FROM `##sources` WHERE s_file=? ) AS sour," .
- " EXISTS(SELECT 1 FROM `##other` WHERE o_file=? AND o_type='REPO') AS repo," .
- " EXISTS(SELECT 1 FROM `##other` WHERE o_file=? AND o_type='NOTE') AS note," .
- " EXISTS(SELECT 1 FROM `##media` WHERE m_file=? ) AS obje"
- )->execute(array(WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID))->fetchOneRow();
-
- // Build a list of submenu items and then sort it in localized name order
- $surname_url = '&amp;surname=' . rawurlencode($controller->getSignificantSurname()) . '&amp;ged=' . WT_GEDURL;
-
- $menulist = array(
- new WT_Menu(WT_I18N::translate('Individuals'), 'indilist.php?ged=' . WT_GEDURL . $surname_url, 'menu-list-indi'),
- );
-
- if (!$SEARCH_SPIDER) {
- $menulist[] = new WT_Menu(WT_I18N::translate('Families'), 'famlist.php?ged=' . WT_GEDURL . $surname_url, 'menu-list-fam');
- $menulist[] = new WT_Menu(WT_I18N::translate('Branches'), 'branches.php?ged=' . WT_GEDURL . $surname_url, 'menu-branches');
- $menulist[] = new WT_Menu(WT_I18N::translate('Place hierarchy'), 'placelist.php?ged=' . WT_GEDURL, 'menu-list-plac');
- if ($row->obje) {
- $menulist[] = new WT_Menu(WT_I18N::translate('Media objects'), 'medialist.php?ged=' . WT_GEDURL, 'menu-list-obje');
- }
- if ($row->repo) {
- $menulist[] = new WT_Menu(WT_I18N::translate('Repositories'), 'repolist.php?ged=' . WT_GEDURL, 'menu-list-repo');
- }
- if ($row->sour) {
- $menulist[] = new WT_Menu(WT_I18N::translate('Sources'), 'sourcelist.php?ged=' . WT_GEDURL, 'menu-list-sour');
- }
- if ($row->note) {
- $menulist[] = new WT_Menu(WT_I18N::translate('Shared notes'), 'notelist.php?ged=' . WT_GEDURL, 'menu-list-note');
- }
- }
- uasort($menulist, function(WT_Menu $x, WT_Menu $y) { return WT_I18N::strcasecmp($x->getLabel(), $y->getLabel()); });
-
- $menu->setSubmenus($menulist);
-
- return $menu;
- }
-
- /**
- * @return WT_Menu
- */
- public static function getCalendarMenu() {
- global $SEARCH_SPIDER;
-
- if ($SEARCH_SPIDER) {
- return null;
- }
- //-- main calendar menu item
- $menu = new WT_Menu(WT_I18N::translate('Calendar'), 'calendar.php?ged='.WT_GEDURL, 'menu-calendar');
- //-- viewday sub menu
- $submenu = new WT_Menu(WT_I18N::translate('Day'), 'calendar.php?ged='.WT_GEDURL, 'menu-calendar-day');
- $menu->addSubmenu($submenu);
- //-- viewmonth sub menu
- $submenu = new WT_Menu(WT_I18N::translate('Month'), 'calendar.php?ged='.WT_GEDURL.'&amp;action=calendar', 'menu-calendar-month');
- $menu->addSubmenu($submenu);
- //-- viewyear sub menu
- $submenu = new WT_Menu(WT_I18N::translate('Year'), 'calendar.php?ged='.WT_GEDURL.'&amp;action=year', 'menu-calendar-year');
- $menu->addSubmenu($submenu);
- return $menu;
- }
-
- /**
- * get the reports menu
- *
- * @return WT_Menu the menu item
- */
- public static function getReportsMenu() {
- global $SEARCH_SPIDER;
-
- $active_reports=WT_Module::getActiveReports();
- if ($SEARCH_SPIDER || !$active_reports) {
- return null;
- }
-
- $menu = new WT_Menu(WT_I18N::translate('Reports'), 'reportengine.php?ged='.WT_GEDURL, 'menu-report');
-
- foreach ($active_reports as $report) {
- foreach ($report->getReportMenus() as $submenu) {
- $menu->addSubmenu($submenu);
- }
- }
-
- return $menu;
- }
-
- /**
- * @return WT_Menu
- */
- public static function getSearchMenu() {
- global $SEARCH_SPIDER;
-
- if ($SEARCH_SPIDER) {
- return null;
- }
- //-- main search menu item
- $menu = new WT_Menu(WT_I18N::translate('Search'), 'search.php?ged='.WT_GEDURL, 'menu-search');
- //-- search_general sub menu
- $submenu = new WT_Menu(WT_I18N::translate('General search'), 'search.php?ged='.WT_GEDURL, 'menu-search-general');
- $menu->addSubmenu($submenu);
- //-- search_soundex sub menu
- $submenu = new WT_Menu(/* I18N: search using “sounds like”, rather than exact spelling */ WT_I18N::translate('Phonetic search'), 'search.php?ged='.WT_GEDURL.'&amp;action=soundex', 'menu-search-soundex');
- $menu->addSubmenu($submenu);
- //-- advanced search
- $submenu = new WT_Menu(WT_I18N::translate('Advanced search'), 'search_advanced.php?ged='.WT_GEDURL, 'menu-search-advanced');
- $menu->addSubmenu($submenu);
- //-- search_replace sub menu
- if (WT_USER_CAN_EDIT) {
- $submenu = new WT_Menu(WT_I18N::translate('Search and replace'), 'search.php?ged='.WT_GEDURL.'&amp;action=replace', 'menu-search-replace');
- $menu->addSubmenu($submenu);
- }
- return $menu;
- }
-
- /**
- * @return WT_Menu[]
- */
- public static function getModuleMenus() {
- $menus=array();
- foreach (WT_Module::getActiveMenus() as $module) {
- $menu=$module->getMenu();
- if ($menu) {
- $menus[] = $menu;
- }
- }
- return $menus;
- }
-
- /**
- * @return null|WT_Menu
- * @throws Exception
- */
- public static function getThemeMenu() {
- global $SEARCH_SPIDER, $WT_TREE;
-
- if ($WT_TREE && !$SEARCH_SPIDER && WT_Site::getPreference('ALLOW_USER_THEMES') && $WT_TREE->getPreference('ALLOW_THEME_DROPDOWN')) {
- $menu=new WT_Menu(WT_I18N::translate('Theme'), '#', 'menu-theme');
- foreach (get_theme_names() as $themename=>$themedir) {
- $submenu=new WT_Menu($themename, get_query_url(array('theme'=>$themedir), '&amp;'), 'menu-theme-'.$themedir);
- if (WT_THEME_DIR == 'themes/'.$themedir.'/') {$submenu->addClass('','','theme-active');}
- $menu->addSubmenu($submenu);
- }
- return $menu;
- } else {
- return null;
- }
- }
-
- /**
- * @return null|WT_Menu
- */
- public static function getLanguageMenu() {
- global $SEARCH_SPIDER;
-
- if ($SEARCH_SPIDER) {
- return null;
- } else {
- $menu=new WT_Menu(WT_I18N::translate('Language'), '#', 'menu-language');
-
- foreach (WT_I18N::installed_languages() as $lang=>$name) {
- $submenu=new WT_Menu($name, get_query_url(array('lang'=>$lang), '&amp;'), 'menu-language-'.$lang);
- if (WT_LOCALE == $lang) {$submenu->addClass('','','lang-active');}
- $menu->addSubmenu($submenu);
- }
- if (count($menu->getSubmenus())>1) {
- return $menu;
- } else {
- return null;
- }
- }
- }
-
- /**
- * @return WT_Menu
- * @throws Exception
- */
- public static function getFavoritesMenu() {
- global $REQUIRE_AUTHENTICATION, $controller, $SEARCH_SPIDER;
-
- $show_user_favs = Auth::check() && array_key_exists('user_favorites', WT_Module::getActiveModules());
- $show_gedc_favs = !$REQUIRE_AUTHENTICATION && array_key_exists('gedcom_favorites', WT_Module::getActiveModules());
-
- if ($show_user_favs && !$SEARCH_SPIDER) {
- if ($show_gedc_favs && !$SEARCH_SPIDER) {
- $favorites=array_merge(
- gedcom_favorites_WT_Module::getFavorites(WT_GED_ID),
- user_favorites_WT_Module::getFavorites(Auth::id())
- );
- } else {
- $favorites=user_favorites_WT_Module::getFavorites(Auth::id());
- }
- } else {
- if ($show_gedc_favs && !$SEARCH_SPIDER) {
- $favorites=gedcom_favorites_WT_Module::getFavorites(WT_GED_ID);
- } else {
- return null;
- }
- }
- // Sort $favorites alphabetically?
-
- $menu=new WT_Menu(WT_I18N::translate('Favorites'), '#', 'menu-favorites');
-
- foreach ($favorites as $favorite) {
- switch($favorite['type']) {
- case 'URL':
- $submenu=new WT_Menu($favorite['title'], $favorite['url']);
- $menu->addSubmenu($submenu);
- break;
- case 'INDI':
- case 'FAM':
- case 'SOUR':
- case 'OBJE':
- case 'NOTE':
- $obj=WT_GedcomRecord::getInstance($favorite['gid']);
- if ($obj && $obj->canShowName()) {
- $submenu=new WT_Menu($obj->getFullName(), $obj->getHtmlUrl());
- $menu->addSubmenu($submenu);
- }
- break;
- }
- }
-
- if ($show_user_favs) {
- if (isset($controller->record) && $controller->record instanceof WT_GedcomRecord) {
- $submenu=new WT_Menu(WT_I18N::translate('Add to favorites'), '#');
- $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'".$controller->record->getXref()."'},function(){location.reload();})");
- $menu->addSubmenu($submenu);
- }
- }
- return $menu;
- }
-}
diff --git a/library/WT/Module.php b/library/WT/Module.php
index a83cc51981..721b9bf212 100644
--- a/library/WT/Module.php
+++ b/library/WT/Module.php
@@ -160,6 +160,30 @@ abstract class WT_Module {
}
/**
+ * Get a the current access level for a module
+ *
+ * @param WT_Tree $tree
+ * @param string $component - tab, block, menu, etc
+ *
+ * @return integer
+ */
+ public function getAccessLevel(WT_Tree $tree, $component) {
+ $access_level = WT_DB::prepare(
+ "SELECT access_level FROM `##module_privacy` WHERE gedcom_id = :gedcom_id AND module_name = :module_name AND component = :component"
+ )->execute(array(
+ 'gedcom_id' => $tree->tree_id,
+ 'module_name' => $this->getName(),
+ 'component' => $component,
+ ))->fetchOne();
+
+ if ($access_level === null) {
+ return $this->defaultAccessLevel();
+ } else {
+ return (int) $access_level;
+ }
+ }
+
+ /**
* Get a list of all active (enabled) modules.
*
* @param boolean $sort Sort the module by the (localised) name
@@ -193,8 +217,8 @@ abstract class WT_Module {
}
}
if ($sort && !$sorted) {
- $sorted = uasort($modules, function (WT_Module $x, WT_MOdule $y) {
- return WT_I18N::strcasecmp((string)$x, (string)$y);
+ $sorted = uasort($modules, function(WT_Module $x, WT_Module $y) {
+ return WT_I18N::strcasecmp($x->getTitle(), $y->getTitle());
});
}
@@ -244,8 +268,8 @@ abstract class WT_Module {
// The order of some modules is defined by the user. Others are sorted by name.
if ($component !== 'menu' && $component !== 'sidebar' && $component !== 'tab') {
- uasort($array, function (WT_Module $x, WT_Module $y) {
- return WT_I18N::strcasecmp((string)$x, (string)$y);
+ uasort($array, function(WT_Module $x, WT_Module $y) {
+ return WT_I18N::strcasecmp($x->getTitle(), $y->getTitle());
});
}
@@ -460,6 +484,10 @@ abstract class WT_Module {
}
}
+ uasort($modules, function(WT_Module $x, WT_Module $y) {
+ return WT_I18N::strcasecmp($x->getTitle(), $y->getTitle());
+ });
+
return $modules;
}
diff --git a/library/WT/Place.php b/library/WT/Place.php
index 55d8b5fd53..d91e31a4bf 100644
--- a/library/WT/Place.php
+++ b/library/WT/Place.php
@@ -21,8 +21,8 @@
*/
class WT_Place {
const GEDCOM_SEPARATOR = ', ';
- private $gedcom_place; // e.g. array("Westminster", "London", "England")
- private $gedcom_id; // We may have the same place in different trees
+ private $gedcom_place; // e.g. array("Westminster", "London", "England")
+ private $gedcom_id; // We may have the same place in different trees
/**
* @param string $gedcom_place
@@ -30,12 +30,12 @@ class WT_Place {
*/
public function __construct($gedcom_place, $gedcom_id) {
if ($gedcom_place) {
- $this->gedcom_place=explode(self::GEDCOM_SEPARATOR, $gedcom_place);
+ $this->gedcom_place = explode(self::GEDCOM_SEPARATOR, $gedcom_place);
} else {
// Empty => "Top level"
- $this->gedcom_place=array();
+ $this->gedcom_place = array();
}
- $this->gedcom_id=$gedcom_id;
+ $this->gedcom_id = $gedcom_id;
}
/**
@@ -160,13 +160,13 @@ class WT_Place {
// Abbreviate the place name, for lists
if ($SHOW_PEDIGREE_PLACES_SUFFIX) {
// The *last* $SHOW_PEDIGREE_PLACES components
- $short_name=implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, -$SHOW_PEDIGREE_PLACES));
+ $short_name = implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, -$SHOW_PEDIGREE_PLACES));
} else {
// The *first* $SHOW_PEDIGREE_PLACES components
- $short_name=implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, 0, $SHOW_PEDIGREE_PLACES));
+ $short_name = implode(self::GEDCOM_SEPARATOR, array_slice($this->gedcom_place, 0, $SHOW_PEDIGREE_PLACES));
}
// Add a tool-tip showing the full name
- return '<span title="'.WT_Filter::escapeHtml($this->getGedcomName()).'" dir="auto">'.WT_Filter::escapeHtml($short_name).'</span>';
+ return '<span title="' . WT_Filter::escapeHtml($this->getGedcomName()) . '" dir="auto">' . WT_Filter::escapeHtml($short_name) . '</span>';
}
}
@@ -190,26 +190,26 @@ class WT_Place {
* @return string[]
*/
public static function allPlaces($gedcom_id) {
- $places=array();
- $rows=
+ $places = array();
+ $rows =
WT_DB::prepare(
- "SELECT SQL_CACHE CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place)".
- " FROM `##places` AS p1".
- " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)".
- " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)".
- " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)".
- " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)".
- " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)".
- " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)".
- " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)".
- " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)".
- " WHERE p1.p_file=?".
- " ORDER BY CONCAT_WS(', ', p9.p_place, p8.p_place, p7.p_place, p6.p_place, p5.p_place, p4.p_place, p3.p_place, p2.p_place, p1.p_place) COLLATE '".WT_I18N::$collation."'"
+ "SELECT SQL_CACHE CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place)" .
+ " FROM `##places` AS p1" .
+ " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" .
+ " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" .
+ " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" .
+ " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" .
+ " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" .
+ " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" .
+ " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" .
+ " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" .
+ " WHERE p1.p_file=?" .
+ " ORDER BY CONCAT_WS(', ', p9.p_place, p8.p_place, p7.p_place, p6.p_place, p5.p_place, p4.p_place, p3.p_place, p2.p_place, p1.p_place) COLLATE '" . WT_I18N::$collation . "'"
)
->execute(array($gedcom_id))
->fetchOneColumn();
foreach ($rows as $row) {
- $places[]=new WT_Place($row, $gedcom_id);
+ $places[] = new WT_Place($row, $gedcom_id);
}
return $places;
}
@@ -221,26 +221,26 @@ class WT_Place {
* @return WT_Place[]
*/
public static function findPlaces($filter, $gedcom_id) {
- $places=array();
- $rows=
+ $places = array();
+ $rows =
WT_DB::prepare(
- "SELECT SQL_CACHE CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place)".
- " FROM `##places` AS p1".
- " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)".
- " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)".
- " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)".
- " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)".
- " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)".
- " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)".
- " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)".
- " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)".
- " WHERE CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) LIKE CONCAT('%', ?, '%') AND CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) NOT LIKE CONCAT('%,%', ?, '%') AND p1.p_file=?".
- " ORDER BY CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) COLLATE '".WT_I18N::$collation."'"
+ "SELECT SQL_CACHE CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place)" .
+ " FROM `##places` AS p1" .
+ " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" .
+ " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" .
+ " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" .
+ " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" .
+ " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" .
+ " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" .
+ " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" .
+ " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" .
+ " WHERE CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) LIKE CONCAT('%', ?, '%') AND CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) NOT LIKE CONCAT('%,%', ?, '%') AND p1.p_file=?" .
+ " ORDER BY CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) COLLATE '" . WT_I18N::$collation . "'"
)
->execute(array($filter, preg_quote($filter), $gedcom_id))
->fetchOneColumn();
foreach ($rows as $row) {
- $places[]=new WT_Place($row, $gedcom_id);
+ $places[] = new WT_Place($row, $gedcom_id);
}
return $places;
}
diff --git a/library/WT/Query/Admin.php b/library/WT/Query/Admin.php
index 199e365934..1e930f55f0 100644
--- a/library/WT/Query/Admin.php
+++ b/library/WT/Query/Admin.php
@@ -18,8 +18,8 @@ class WT_Query_Admin {
public static function countIndiChangesToday($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##individuals` ON (gedcom_id=i_file AND i_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##individuals` ON (gedcom_id=i_file AND i_id=xref)" .
" WHERE status='accepted' AND DATE(change_time)= DATE(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -37,8 +37,8 @@ class WT_Query_Admin {
public static function countIndiChangesWeek($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##individuals` ON (gedcom_id=i_file AND i_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##individuals` ON (gedcom_id=i_file AND i_id=xref)" .
" WHERE status='accepted' AND WEEK(change_time,2)= WEEK(NOW(),2) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -56,8 +56,8 @@ class WT_Query_Admin {
public static function countIndiChangesMonth($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##individuals` ON (gedcom_id=i_file AND i_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##individuals` ON (gedcom_id=i_file AND i_id=xref)" .
" WHERE status='accepted' AND MONTH(change_time)= MONTH(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -75,8 +75,8 @@ class WT_Query_Admin {
public static function countFamChangesToday($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##families` ON (gedcom_id=f_file AND f_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##families` ON (gedcom_id=f_file AND f_id=xref)" .
" WHERE status='accepted' AND DATE(change_time)= DATE(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -94,8 +94,8 @@ class WT_Query_Admin {
public static function countFamChangesWeek($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##families` ON (gedcom_id=f_file AND f_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##families` ON (gedcom_id=f_file AND f_id=xref)" .
" WHERE status='accepted' AND WEEK(change_time,2)= WEEK(NOW(),2) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -113,8 +113,8 @@ class WT_Query_Admin {
public static function countFamChangesMonth($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##families` ON (gedcom_id=f_file AND f_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##families` ON (gedcom_id=f_file AND f_id=xref)" .
" WHERE status='accepted' AND MONTH(change_time)= MONTH(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -132,8 +132,8 @@ class WT_Query_Admin {
public static function countSourChangesToday($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##sources` ON (gedcom_id=s_file AND s_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##sources` ON (gedcom_id=s_file AND s_id=xref)" .
" WHERE status='accepted' AND DATE(change_time)= DATE(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -151,8 +151,8 @@ class WT_Query_Admin {
public static function countSourChangesWeek($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##sources` ON (gedcom_id=s_file AND s_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##sources` ON (gedcom_id=s_file AND s_id=xref)" .
" WHERE status='accepted' AND WEEK(change_time,2)= WEEK(NOW(),2) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -170,8 +170,8 @@ class WT_Query_Admin {
public static function countSourChangesMonth($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##sources` ON (gedcom_id=s_file AND s_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##sources` ON (gedcom_id=s_file AND s_id=xref)" .
" WHERE status='accepted' AND MONTH(change_time)= MONTH(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -189,8 +189,8 @@ class WT_Query_Admin {
public static function countRepoChangesToday($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='REPO')".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='REPO')" .
" WHERE status='accepted' AND DATE(change_time)= DATE(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -208,8 +208,8 @@ class WT_Query_Admin {
public static function countRepoChangesWeek($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='REPO')".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='REPO')" .
" WHERE status='accepted' AND WEEK(change_time,2)= WEEK(NOW(),2) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -227,8 +227,8 @@ class WT_Query_Admin {
public static function countRepoChangesMonth($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='REPO')".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='REPO')" .
" WHERE status='accepted' AND MONTH(change_time)= MONTH(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -246,8 +246,8 @@ class WT_Query_Admin {
public static function countNoteChangesToday($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='NOTE')".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='NOTE')" .
" WHERE status='accepted' AND DATE(change_time)= DATE(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -265,8 +265,8 @@ class WT_Query_Admin {
public static function countNoteChangesWeek($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='NOTE')".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='NOTE')" .
" WHERE status='accepted' AND WEEK(change_time,2)= WEEK(NOW(),2) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -284,8 +284,8 @@ class WT_Query_Admin {
public static function countNoteChangesMonth($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='NOTE')".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##other` ON (gedcom_id=o_file AND o_id=xref AND o_type='NOTE')" .
" WHERE status='accepted' AND MONTH(change_time)= MONTH(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -303,8 +303,8 @@ class WT_Query_Admin {
public static function countObjeChangesToday($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##media` ON (gedcom_id=m_file AND m_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##media` ON (gedcom_id=m_file AND m_id=xref)" .
" WHERE status='accepted' AND DATE(change_time)= DATE(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -322,8 +322,8 @@ class WT_Query_Admin {
public static function countObjeChangesWeek($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##media` ON (gedcom_id=m_file AND m_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##media` ON (gedcom_id=m_file AND m_id=xref)" .
" WHERE status='accepted' AND WEEK(change_time,2)= WEEK(NOW(),2) AND gedcom_id=?"
)
->execute(array($ged_id))
@@ -341,8 +341,8 @@ class WT_Query_Admin {
public static function countObjeChangesMonth($ged_id) {
return WT_I18N::number(
WT_DB::prepare(
- "SELECT count(change_id) FROM `##change`".
- " JOIN `##media` ON (gedcom_id=m_file AND m_id=xref)".
+ "SELECT count(change_id) FROM `##change`" .
+ " JOIN `##media` ON (gedcom_id=m_file AND m_id=xref)" .
" WHERE status='accepted' AND MONTH(change_time)= MONTH(NOW()) AND gedcom_id=?"
)
->execute(array($ged_id))
diff --git a/library/WT/Query/Media.php b/library/WT/Query/Media.php
index 0d23e1e06d..8842db9c9b 100644
--- a/library/WT/Query/Media.php
+++ b/library/WT/Query/Media.php
@@ -24,7 +24,7 @@ class WT_Query_Media {
" ORDER BY 1"
)->execute(array(WT_GED_ID))->fetchOneColumn();
- if (!$folders || reset($folders)!='') {
+ if (!$folders || reset($folders) != '') {
array_unshift($folders, '');
}
diff --git a/library/WT/Query/Name.php b/library/WT/Query/Name.php
index a87ef50695..12fa2cf018 100644
--- a/library/WT/Query/Name.php
+++ b/library/WT/Query/Name.php
@@ -18,82 +18,82 @@ class WT_Query_Name {
switch ($locale) {
case 'ar':
return array(
- 'ا','ب','ت','ث','ج','ح','خ','د','ذ','ر','ز','س','ش','ص','ض','ط','ظ','ع','غ','ف','ق','ك','ل','م','ن','ه','و','ي','آ','ة','ى','ی'
+ 'ا', 'ب', 'ت', 'ث', 'ج', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ف', 'ق', 'ك', 'ل', 'م', 'ن', 'ه', 'و', 'ي', 'آ', 'ة', 'ى', 'ی'
);
case 'cs':
return array(
- 'A','B','C','D','E','F','G','H','CH','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'CH', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
);
case 'da':
case 'nb':
case 'nn':
return array(
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Æ','Ø','Å'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Æ', 'Ø', 'Å'
);
case 'el':
return array(
- 'Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω'
+ 'Α', 'Β', 'Γ', 'Δ', 'Ε', 'Ζ', 'Η', 'Θ', 'Ι', 'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Π', 'Ρ', 'Σ', 'Τ', 'Υ', 'Φ', 'Χ', 'Ψ', 'Ω'
);
case 'es':
return array(
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','Ñ','O','P','Q','R','S','T','U','V','W','X','Y','Z'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
);
case 'et':
return array(
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','Š','Z','Ž','T','U','V','W','Õ','Ä','Ö','Ü','X','Y'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'Z', 'Ž', 'T', 'U', 'V', 'W', 'Õ', 'Ä', 'Ö', 'Ü', 'X', 'Y'
);
case 'fi':
case 'sv':
return array(
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Å','Ä','Ö'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Å', 'Ä', 'Ö'
);
case 'he':
return array(
- 'א','ב','ג','ד','ה','ו','ז','ח','ט','י','כ','ל','מ','נ','ס','ע','פ','צ','ק','ר','ש','ת'
+ 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק', 'ר', 'ש', 'ת'
);
case 'hu':
return array(
- 'A','B','C','CS','D','DZ','DZS','E','F','G','GY','H','I','J','K','L','LY','M','N','NY','O','Ö','P','Q','R','S','SZ','T','TY','U','Ü','V','W','X','Y','Z','ZS'
+ 'A', 'B', 'C', 'CS', 'D', 'DZ', 'DZS', 'E', 'F', 'G', 'GY', 'H', 'I', 'J', 'K', 'L', 'LY', 'M', 'N', 'NY', 'O', 'Ö', 'P', 'Q', 'R', 'S', 'SZ', 'T', 'TY', 'U', 'Ü', 'V', 'W', 'X', 'Y', 'Z', 'ZS'
);
case 'lt':
return array(
- 'A','Ą','B','C','Č','D','E','Ę','Ė','F','G','H','I','Y','Į','J','K','L','M','N','O','P','R','S','Š','T','U','Ų','Ū','V','Z','Ž'
+ 'A', 'Ą', 'B', 'C', 'Č', 'D', 'E', 'Ę', 'Ė', 'F', 'G', 'H', 'I', 'Y', 'Į', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'Š', 'T', 'U', 'Ų', 'Ū', 'V', 'Z', 'Ž'
);
case 'nl':
return array(
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','IJ'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'IJ'
);
case 'pl':
return array(
- 'A','B','C','Ć','D','E','F','G','H','I','J','K','L','Ł','M','N','O','Ó','P','Q','R','S','Ś','T','U','V','W','X','Y','Z','Ź','Ż'
+ 'A', 'B', 'C', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'Ł', 'M', 'N', 'O', 'Ó', 'P', 'Q', 'R', 'S', 'Ś', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ź', 'Ż'
);
case 'ro':
return array(
- 'A','Ă','Â','B','C','D','E','F','G','H','I','Î','J','K','L','M','N','O','P','Q','R','S','Ş','T','Ţ','U','V','W','X','Y','Z'
+ 'A', 'Ă', 'Â', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Î', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Ş', 'T', 'Ţ', 'U', 'V', 'W', 'X', 'Y', 'Z'
);
case 'ru':
return array(
- 'А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я'
+ 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я'
);
case 'sk':
return array(
- 'A','Á','Ä','B','C','Č','D','Ď','E','É','F','G','H','I','Í','J','K','L','Ľ','Ĺ','M','N','Ň','O','Ó','Ô','P','Q','R','Ŕ','S','Š','T','Ť','U','Ú','V','W','X','Y','Ý','Z','Ž'
+ 'A', 'Á', 'Ä', 'B', 'C', 'Č', 'D', 'Ď', 'E', 'É', 'F', 'G', 'H', 'I', 'Í', 'J', 'K', 'L', 'Ľ', 'Ĺ', 'M', 'N', 'Ň', 'O', 'Ó', 'Ô', 'P', 'Q', 'R', 'Ŕ', 'S', 'Š', 'T', 'Ť', 'U', 'Ú', 'V', 'W', 'X', 'Y', 'Ý', 'Z', 'Ž'
);
case 'sl':
return array(
- 'A','B','C','Č','Ć','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','Š','T','U','V','W','X','Y','Z','Ž'
+ 'A', 'B', 'C', 'Č', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ž'
);
case 'sr':
return array(
- 'A','B','C','Č','Ć','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','Š','T','U','V','W','X','Y','Z','Ž'
+ 'A', 'B', 'C', 'Č', 'Ć', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'Š', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ž'
);
case 'tr':
return array(
- 'A','B','C','Ç','D','E','F','G','Ğ','H','I','İ','J','K','L','M','N','O','Ö','P','R','S','Ş','T','U','Ü','V','Y','Z'
+ 'A', 'B', 'C', 'Ç', 'D', 'E', 'F', 'G', 'Ğ', 'H', 'I', 'İ', 'J', 'K', 'L', 'M', 'N', 'O', 'Ö', 'P', 'R', 'S', 'Ş', 'T', 'U', 'Ü', 'V', 'Y', 'Z'
);
default:
return array(
- 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
);
}
}
@@ -175,7 +175,7 @@ class WT_Query_Name {
switch (WT_LOCALE) {
case 'cs':
switch ($letter) {
- case 'C': return $field." LIKE 'C%' COLLATE ".WT_I18N::$collation." AND ".$field." NOT LIKE 'CH%' COLLATE ".WT_I18N::$collation;
+ case 'C': return $field . " LIKE 'C%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'CH%' COLLATE " . WT_I18N::$collation;
}
break;
case 'da':
@@ -183,31 +183,31 @@ class WT_Query_Name {
case 'nn':
switch ($letter) {
// AA gets listed under Å
- case 'A': return $field." LIKE 'A%' COLLATE ".WT_I18N::$collation." AND ".$field." NOT LIKE 'AA%' COLLATE ".WT_I18N::$collation;
- case 'Å': return "(".$field." LIKE 'Å%' COLLATE ".WT_I18N::$collation." OR ".$field." LIKE 'AA%' COLLATE ".WT_I18N::$collation.")";
+ case 'A': return $field . " LIKE 'A%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'AA%' COLLATE " . WT_I18N::$collation;
+ case 'Å': return "(" . $field . " LIKE 'Å%' COLLATE " . WT_I18N::$collation . " OR " . $field . " LIKE 'AA%' COLLATE " . WT_I18N::$collation . ")";
}
break;
case 'hu':
switch ($letter) {
- case 'C': return $field." LIKE 'C%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'CS%' COLLATE ". WT_I18N::$collation;
- case 'D': return $field." LIKE 'D%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'DZ%' COLLATE ". WT_I18N::$collation;
- case 'DZ': return $field." LIKE 'DZ%' COLLATE ".WT_I18N::$collation." AND ".$field." NOT LIKE 'DZS%' COLLATE ".WT_I18N::$collation;
- case 'G': return $field." LIKE 'G%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'GY%' COLLATE ". WT_I18N::$collation;
- case 'L': return $field." LIKE 'L%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'LY%' COLLATE ". WT_I18N::$collation;
- case 'N': return $field." LIKE 'N%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'NY%' COLLATE ". WT_I18N::$collation;
- case 'S': return $field." LIKE 'S%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'SZ%' COLLATE ". WT_I18N::$collation;
- case 'T': return $field." LIKE 'T%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'TY%' COLLATE ". WT_I18N::$collation;
- case 'Z': return $field." LIKE 'Z%' COLLATE ". WT_I18N::$collation." AND ".$field." NOT LIKE 'ZS%' COLLATE ". WT_I18N::$collation;
+ case 'C': return $field . " LIKE 'C%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'CS%' COLLATE " . WT_I18N::$collation;
+ case 'D': return $field . " LIKE 'D%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'DZ%' COLLATE " . WT_I18N::$collation;
+ case 'DZ': return $field . " LIKE 'DZ%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'DZS%' COLLATE " . WT_I18N::$collation;
+ case 'G': return $field . " LIKE 'G%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'GY%' COLLATE " . WT_I18N::$collation;
+ case 'L': return $field . " LIKE 'L%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'LY%' COLLATE " . WT_I18N::$collation;
+ case 'N': return $field . " LIKE 'N%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'NY%' COLLATE " . WT_I18N::$collation;
+ case 'S': return $field . " LIKE 'S%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'SZ%' COLLATE " . WT_I18N::$collation;
+ case 'T': return $field . " LIKE 'T%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'TY%' COLLATE " . WT_I18N::$collation;
+ case 'Z': return $field . " LIKE 'Z%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'ZS%' COLLATE " . WT_I18N::$collation;
}
break;
case 'nl':
switch ($letter) {
- case 'I': return $field." LIKE 'I%' COLLATE ".WT_I18N::$collation." AND ".$field." NOT LIKE 'IJ%' COLLATE ".WT_I18N::$collation;
+ case 'I': return $field . " LIKE 'I%' COLLATE " . WT_I18N::$collation . " AND " . $field . " NOT LIKE 'IJ%' COLLATE " . WT_I18N::$collation;
}
break;
}
// Easy cases: the MySQL collation rules take care of it
- return "$field LIKE CONCAT('@',".WT_DB::quote($letter).",'%') COLLATE ".WT_I18N::$collation." ESCAPE '@'";
+ return "$field LIKE CONCAT('@'," . WT_DB::quote($letter) . ",'%') COLLATE " . WT_I18N::$collation . " ESCAPE '@'";
}
/**
@@ -286,7 +286,7 @@ class WT_Query_Name {
* @return integer[]
*/
public static function givenAlpha($surn, $salpha, $marnm, $fams, $ged_id) {
- $alphas=array();
+ $alphas = array();
$sql =
"SELECT SQL_CACHE COUNT(DISTINCT n_id)" .
@@ -297,9 +297,9 @@ class WT_Query_Name {
if ($surn) {
$sql .= " AND n_surn=" . WT_DB::quote($surn) . " COLLATE '" . WT_I18N::$collation . "'";
- } elseif ($salpha==',') {
+ } elseif ($salpha == ',') {
$sql .= " AND n_surn=''";
- } elseif ($salpha=='@') {
+ } elseif ($salpha == '@') {
$sql .= " AND n_surn='@N.N.'";
} elseif ($salpha) {
$sql .= " AND " . self::getInitialSql('n_surn', $salpha);
@@ -312,7 +312,7 @@ class WT_Query_Name {
// are any names beginning with that letter. It looks better to
// show the full alphabet, rather than omitting rare letters such as X
foreach (self::getAlphabetForLocale(WT_LOCALE) as $letter) {
- $count=WT_DB::prepare($sql . " AND " . self::getInitialSql('n_givn', $letter))->fetchOne();
+ $count = WT_DB::prepare($sql . " AND " . self::getInitialSql('n_givn', $letter))->fetchOne();
$alphas[$letter] = $count;
}
@@ -327,9 +327,9 @@ class WT_Query_Name {
if ($surn) {
$sql .= " AND n_surn=" . WT_DB::quote($surn) . " COLLATE '" . WT_I18N::$collation . "'";
- } elseif ($salpha==',') {
+ } elseif ($salpha == ',') {
$sql .= " AND n_surn=''";
- } elseif ($salpha=='@') {
+ } elseif ($salpha == '@') {
$sql .= " AND n_surn='@N.N.'";
} elseif ($salpha) {
$sql .= " AND " . self::getInitialSql('n_surn', $salpha);
@@ -361,34 +361,34 @@ class WT_Query_Name {
* @return array
*/
public static function surnames($surn, $salpha, $marnm, $fams, $ged_id) {
- $sql=
- "SELECT SQL_CACHE n2.n_surn, n1.n_surname, n1.n_id".
- " FROM `##name` n1 ".
- ($fams ? " JOIN `##link` ON (n_id=l_from AND n_file=l_file AND l_type='FAMS') " : "").
- " JOIN (SELECT n_surn, n_file FROM `##name`".
- " WHERE n_file={$ged_id}".
+ $sql =
+ "SELECT SQL_CACHE n2.n_surn, n1.n_surname, n1.n_id" .
+ " FROM `##name` n1 " .
+ ($fams ? " JOIN `##link` ON (n_id=l_from AND n_file=l_file AND l_type='FAMS') " : "") .
+ " JOIN (SELECT n_surn, n_file FROM `##name`" .
+ " WHERE n_file={$ged_id}" .
($marnm ? "" : " AND n_type!='_MARNM'");
if ($surn) {
- $sql.=" AND n_surn COLLATE '".WT_I18N::$collation."' =".WT_DB::quote($surn);
- } elseif ($salpha==',') {
- $sql.=" AND n_surn=''";
- } elseif ($salpha=='@') {
- $sql.=" AND n_surn='@N.N.'";
+ $sql .= " AND n_surn COLLATE '" . WT_I18N::$collation . "' =" . WT_DB::quote($surn);
+ } elseif ($salpha == ',') {
+ $sql .= " AND n_surn=''";
+ } elseif ($salpha == '@') {
+ $sql .= " AND n_surn='@N.N.'";
} elseif ($salpha) {
- $sql.=" AND ".self::getInitialSql('n_surn', $salpha);
+ $sql .= " AND " . self::getInitialSql('n_surn', $salpha);
} else {
// All surnames
- $sql.=" AND n_surn NOT IN ('', '@N.N.')";
+ $sql .= " AND n_surn NOT IN ('', '@N.N.')";
}
- $sql.=" GROUP BY n_surn COLLATE '".WT_I18N::$collation."', n_file) n2 ON (n1.n_surn=n2.n_surn COLLATE '".WT_I18N::$collation."' AND n1.n_file=n2.n_file)";
+ $sql .= " GROUP BY n_surn COLLATE '" . WT_I18N::$collation . "', n_file) n2 ON (n1.n_surn=n2.n_surn COLLATE '" . WT_I18N::$collation . "' AND n1.n_file=n2.n_file)";
if (!$marnm) {
- $sql.=" AND n_type!='_MARNM'";
+ $sql .= " AND n_type!='_MARNM'";
}
- $list=array();
+ $list = array();
foreach (WT_DB::prepare($sql)->fetchAll() as $row) {
- $list[WT_I18N::strtoupper($row->n_surn)][$row->n_surname][$row->n_id]=true;
+ $list[WT_I18N::strtoupper($row->n_surn)][$row->n_surname][$row->n_id] = true;
}
return $list;
}
@@ -409,7 +409,7 @@ class WT_Query_Name {
* @return WT_Individual[]
*/
public static function individuals($surn, $salpha, $galpha, $marnm, $fams, $ged_id) {
- $sql=
+ $sql =
"SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, n_full " .
"FROM `##individuals` " .
"JOIN `##name` ON (n_id=i_id AND n_file=i_file) " .
@@ -419,12 +419,12 @@ class WT_Query_Name {
if ($surn) {
$sql .= " AND n_surn COLLATE '" . WT_I18N::$collation . "'=" . WT_DB::quote($surn);
- } elseif ($salpha==',') {
+ } elseif ($salpha == ',') {
$sql .= " AND n_surn=''";
- } elseif ($salpha=='@') {
+ } elseif ($salpha == '@') {
$sql .= " AND n_surn='@N.N.'";
} elseif ($salpha) {
- $sql .= " AND ".self::getInitialSql('n_surn', $salpha);
+ $sql .= " AND " . self::getInitialSql('n_surn', $salpha);
} else {
// All surnames
$sql .= " AND n_surn NOT IN ('', '@N.N.')";
@@ -469,10 +469,10 @@ class WT_Query_Name {
* @return WT_Family[]
*/
public static function families($surn, $salpha, $galpha, $marnm, $ged_id) {
- $list=array();
+ $list = array();
foreach (self::individuals($surn, $salpha, $galpha, $marnm, true, $ged_id) as $indi) {
foreach ($indi->getSpouseFamilies() as $family) {
- $list[$family->getXref()]=$family;
+ $list[$family->getXref()] = $family;
}
}
usort($list, array('WT_GedcomRecord', 'compare'));
diff --git a/library/WT/Report/Base.php b/library/WT/Report/Base.php
index 3c2bc2b853..0d3b4dd9b1 100644
--- a/library/WT/Report/Base.php
+++ b/library/WT/Report/Base.php
@@ -407,10 +407,10 @@ class WT_Report_Base {
$this->pageh = $sizes[1];
} else {
if ($this->pagew < 10) {
- die("<strong>REPORT ERROR WT_Report_Base::setup(): </strong>For custom size pages you must set \"customwidth\" larger then this in the XML file");
+ throw new DomainException('REPORT ERROR WT_Report_Base::setup(): For custom size pages you must set "customwidth" larger then this in the XML file');
}
if ($this->pageh < 10) {
- die("<strong>REPORT ERROR WT_Report_Base::setup(): </strong>For custom size pages you must set \"customheight\" larger then this in the XML file");
+ throw new DomainException('REPORT ERROR WT_Report_Base::setup(): For custom size pages you must set "customheight" larger then this in the XML file');
}
}
@@ -577,7 +577,7 @@ function styleStartHandler($attrs) {
global $wt_report;
if (empty($attrs['name'])) {
- die("<strong>REPORT ERROR Style: </strong> The \"name\" of the style is missing or not set in the XML file.");
+ throw new DomainException('REPORT ERROR Style: The "name" of the style is missing or not set in the XML file.');
}
// array Style that will be passed on
@@ -595,7 +595,7 @@ function styleStartHandler($attrs) {
// int The size of the font in points
$s['size'] = $wt_report->defaultFontSize;
if (!empty($attrs['size'])) {
- $s['size'] = (int)$attrs['size'];
+ $s['size'] = (int) $attrs['size'];
} // Get it as int to ignore all decimal points or text (if any text then int(0))
// string B: bold, I: italic, U: underline, D: line trough, The default value is regular.
@@ -621,11 +621,11 @@ function docStartHandler($attrs) {
// Custom page width
if (!empty($attrs['customwidth'])) {
- $wt_report->pagew = (int)$attrs['customwidth'];
+ $wt_report->pagew = (int) $attrs['customwidth'];
} // Get it as int to ignore all decimal points or text (if any text then int(0))
// Custom Page height
if (!empty($attrs['customheight'])) {
- $wt_report->pageh = (int)$attrs['customheight'];
+ $wt_report->pageh = (int) $attrs['customheight'];
} // Get it as int to ignore all decimal points or text (if any text then int(0))
// Left Margin
@@ -633,7 +633,7 @@ function docStartHandler($attrs) {
if ($attrs['leftmargin'] === "0") {
$wt_report->leftmargin = 0;
} elseif (!empty($attrs['leftmargin'])) {
- $wt_report->leftmargin = (int)$attrs['leftmargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
+ $wt_report->leftmargin = (int) $attrs['leftmargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
}
}
// Right Margin
@@ -641,7 +641,7 @@ function docStartHandler($attrs) {
if ($attrs['rightmargin'] === "0") {
$wt_report->rightmargin = 0;
} elseif (!empty($attrs['rightmargin'])) {
- $wt_report->rightmargin = (int)$attrs['rightmargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
+ $wt_report->rightmargin = (int) $attrs['rightmargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
}
}
// Top Margin
@@ -649,7 +649,7 @@ function docStartHandler($attrs) {
if ($attrs['topmargin'] === "0") {
$wt_report->topmargin = 0;
} elseif (!empty($attrs['topmargin'])) {
- $wt_report->topmargin = (int)$attrs['topmargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
+ $wt_report->topmargin = (int) $attrs['topmargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
}
}
// Bottom Margin
@@ -657,7 +657,7 @@ function docStartHandler($attrs) {
if ($attrs['bottommargin'] === "0") {
$wt_report->bottommargin = 0;
} elseif (!empty($attrs['bottommargin'])) {
- $wt_report->bottommargin = (int)$attrs['bottommargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
+ $wt_report->bottommargin = (int) $attrs['bottommargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
}
}
// Header Margin
@@ -665,7 +665,7 @@ function docStartHandler($attrs) {
if ($attrs['headermargin'] === "0") {
$wt_report->headermargin = 0;
} elseif (!empty($attrs['headermargin'])) {
- $wt_report->headermargin = (int)$attrs['headermargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
+ $wt_report->headermargin = (int) $attrs['headermargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
}
}
// Footer Margin
@@ -673,7 +673,7 @@ function docStartHandler($attrs) {
if ($attrs['footermargin'] === "0") {
$wt_report->footermargin = 0;
} elseif (!empty($attrs['footermargin'])) {
- $wt_report->footermargin = (int)$attrs['footermargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
+ $wt_report->footermargin = (int) $attrs['footermargin']; // Get it as int to ignore all decimal points or text (if any text then int(0))
}
}
@@ -829,18 +829,18 @@ function cellStartHandler($attrs) {
// int Cell height (expressed in points) The starting height of this cell. If the text wraps the height will automatically be adjusted.
$height = 0;
if (!empty($attrs['height'])) {
- $height = (int)$attrs['height'];
+ $height = (int) $attrs['height'];
}
// int Cell width (expressed in points) Setting the width to 0 will make it the width from the current location to the right margin.
$width = 0;
if (!empty($attrs['width'])) {
- $width = (int)$attrs['width'];
+ $width = (int) $attrs['width'];
}
// int Stretch carachter mode
$stretch = 0;
if (!empty($attrs['stretch'])) {
- $stretch = (int)$attrs['stretch'];
+ $stretch = (int) $attrs['stretch'];
}
// mixed Position the left corner of this box on the page. The default is the current position.
@@ -849,7 +849,7 @@ function cellStartHandler($attrs) {
if ($attrs['left'] === ".") {
$left = ".";
} elseif (!empty($attrs['left'])) {
- $left = (int)$attrs['left'];
+ $left = (int) $attrs['left'];
} elseif ($attrs['left'] === "0") {
$left = 0;
}
@@ -860,7 +860,7 @@ function cellStartHandler($attrs) {
if ($attrs['top'] === ".") {
$top = ".";
} elseif (!empty($attrs['top'])) {
- $top = (int)$attrs['top'];
+ $top = (int) $attrs['top'];
} elseif ($attrs['top'] === "0") {
$top = 0;
}
@@ -882,7 +882,7 @@ function cellStartHandler($attrs) {
$ln = 0;
if (isset($attrs['newline'])) {
if (!empty($attrs['newline'])) {
- $ln = (int)$attrs['newline'];
+ $ln = (int) $attrs['newline'];
} elseif ($attrs['newline'] === "0") {
$ln = 0;
}
@@ -1078,12 +1078,12 @@ function textBoxStartHandler($attrs) {
// int The starting height of this cell. If the text wraps the height will automatically be adjusted
$height = 0;
if (!empty($attrs['height'])) {
- $height = (int)$attrs['height'];
+ $height = (int) $attrs['height'];
}
// int Setting the width to 0 will make it the width from the current location to the margin
$width = 0;
if (!empty($attrs['width'])) {
- $width = (int)$attrs['width'];
+ $width = (int) $attrs['width'];
}
// mixed Position the left corner of this box on the page. The default is the current position.
@@ -1092,7 +1092,7 @@ function textBoxStartHandler($attrs) {
if ($attrs['left'] === ".") {
$left = ".";
} elseif (!empty($attrs['left'])) {
- $left = (int)$attrs['left'];
+ $left = (int) $attrs['left'];
} elseif ($attrs['left'] === "0") {
$left = 0;
}
@@ -1103,7 +1103,7 @@ function textBoxStartHandler($attrs) {
if ($attrs['top'] === ".") {
$top = ".";
} elseif (!empty($attrs['top'])) {
- $top = (int)$attrs['top'];
+ $top = (int) $attrs['top'];
} elseif ($attrs['top'] === "0") {
$top = 0;
}
@@ -1429,7 +1429,7 @@ function repeatTagStartHandler($attrs) {
$count = preg_match_all("/$level $t(.*)/", $subrec, $match, PREG_SET_ORDER);
$i = 0;
while ($i < $count) {
- $repeats[] = get_sub_record($level, "$level $t", $subrec, $i + 1);;
+ $repeats[] = get_sub_record($level, "$level $t", $subrec, $i + 1);
$i++;
}
}
@@ -1490,16 +1490,15 @@ function repeatTagEndHandler() {
//-- make sure everything is case sensitive
xml_parser_set_option($repeat_parser, XML_OPTION_CASE_FOLDING, false);
//-- set the main element handler functions
- xml_set_element_handler($repeat_parser, "startElement", "endElement");
+ xml_set_element_handler($repeat_parser, 'startElement', 'endElement');
//-- set the character data handler
- xml_set_character_data_handler($repeat_parser, "characterData");
+ xml_set_character_data_handler($repeat_parser, 'characterData');
if (!xml_parse($repeat_parser, $reportxml, true)) {
- printf(
- $reportxml . "\nRepeatTagEHandler XML error: %s at line %d",
+ throw new DomainException(sprintf(
+ 'RepeatTagEHandler XML error: %s at line %d',
xml_error_string(xml_get_error_code($repeat_parser)),
xml_get_current_line_number($repeat_parser)
- );
- exit;
+ ));
}
xml_parser_free($repeat_parser);
}
@@ -1537,9 +1536,7 @@ function varStartHandler($attrs) {
global $desc, $fact, $vars;
if (empty($attrs['var'])) {
- die("<strong>REPORT ERROR var: </strong> The attribute \"var=\" is missing or not set in the XML file on line: " . xml_get_current_line_number(
- $parser
- ));
+ throw new DomainException('REPORT ERROR var: The attribute "var=" is missing or not set in the XML file on line: ' . xml_get_current_line_number($parser));
}
$var = $attrs['var'];
@@ -1685,12 +1682,12 @@ function factsEndHandler() {
//-- make sure everything is case sensitive
xml_parser_set_option($repeat_parser, XML_OPTION_CASE_FOLDING, false);
//-- set the main element handler functions
- xml_set_element_handler($repeat_parser, "startElement", "endElement");
+ xml_set_element_handler($repeat_parser, 'startElement', 'endElement');
//-- set the character data handler
- xml_set_character_data_handler($repeat_parser, "characterData");
+ xml_set_character_data_handler($repeat_parser, 'characterData');
if (!xml_parse($repeat_parser, $reportxml, true)) {
- die(sprintf(
- $reportxml . "\nFactsEHandler XML error: %s at line %d",
+ throw new DomainException(sprintf(
+ 'FactsEHandler XML error: %s at line %d',
xml_error_string(xml_get_error_code($repeat_parser)),
xml_get_current_line_number($repeat_parser)
));
@@ -1717,7 +1714,7 @@ function setVarStartHandler($attrs) {
global $vars, $gedrec, $fact, $desc, $generation;
if (empty($attrs['name'])) {
- die("<strong>REPORT ERROR var: </strong> The attribute \"name=\" is missing or not set in the XML file");
+ throw new DomainException('REPORT ERROR var: The attribute "name" is missing or not set in the XML file');
}
$name = $attrs['name'];
@@ -1831,13 +1828,14 @@ function ifStartHandler($attrs) {
$level++;
$value = get_gedcom_value($id, $level, $gedrec);
}
+ $value = preg_replace("/^@(" . WT_REGEX_XREF . ")@$/", "$1", $value);
$value = "\"" . addslashes($value) . "\"";
}
$condition = str_replace("@$id", $value, $condition);
$i++;
}
$condition = "if ($condition) return true; else return false;";
- $ret = @eval($condition);
+ $ret = eval($condition);
if (!$ret) {
$processIfs++;
}
@@ -2011,7 +2009,7 @@ function highlightedImageStartHandler($attrs) {
} elseif ($attrs['top'] === '.') {
$top = '.';
} elseif (!empty($attrs['top'])) {
- $top = (int)$attrs['top'];
+ $top = (int) $attrs['top'];
}
}
@@ -2023,7 +2021,7 @@ function highlightedImageStartHandler($attrs) {
} elseif ($attrs['left'] === '.') {
$left = '.';
} elseif (!empty($attrs['left'])) {
- $left = (int)$attrs['left'];
+ $left = (int) $attrs['left'];
}
}
@@ -2042,10 +2040,10 @@ function highlightedImageStartHandler($attrs) {
$width = 0;
$height = 0;
if (!empty($attrs['width'])) {
- $width = (int)$attrs['width'];
+ $width = (int) $attrs['width'];
}
if (!empty($attrs['height'])) {
- $height = (int)$attrs['height'];
+ $height = (int) $attrs['height'];
}
$person = WT_Individual::getInstance($id);
@@ -2104,7 +2102,7 @@ function imageStartHandler($attrs) {
} elseif ($attrs['top'] === '.') {
$top = '.';
} elseif (!empty($attrs['top'])) {
- $top = (int)$attrs['top'];
+ $top = (int) $attrs['top'];
}
}
@@ -2116,7 +2114,7 @@ function imageStartHandler($attrs) {
} elseif ($attrs['left'] === '.') {
$left = '.';
} elseif (!empty($attrs['left'])) {
- $left = (int)$attrs['left'];
+ $left = (int) $attrs['left'];
}
}
@@ -2135,10 +2133,10 @@ function imageStartHandler($attrs) {
$width = 0;
$height = 0;
if (!empty($attrs['width'])) {
- $width = (int)$attrs['width'];
+ $width = (int) $attrs['width'];
}
if (!empty($attrs['height'])) {
- $height = (int)$attrs['height'];
+ $height = (int) $attrs['height'];
}
$file = '';
@@ -2221,7 +2219,7 @@ function lineStartHandler($attrs) {
} elseif ($attrs['x1'] === ".") {
$x1 = ".";
} elseif (!empty($attrs['x1'])) {
- $x1 = (int)$attrs['x1'];
+ $x1 = (int) $attrs['x1'];
}
}
// Start vertical position, current position (default)
@@ -2232,7 +2230,7 @@ function lineStartHandler($attrs) {
} elseif ($attrs['y1'] === ".") {
$y1 = ".";
} elseif (!empty($attrs['y1'])) {
- $y1 = (int)$attrs['y1'];
+ $y1 = (int) $attrs['y1'];
}
}
// End horizontal position, maximum width (default)
@@ -2243,7 +2241,7 @@ function lineStartHandler($attrs) {
} elseif ($attrs['x2'] === ".") {
$x2 = ".";
} elseif (!empty($attrs['x2'])) {
- $x2 = (int)$attrs['x2'];
+ $x2 = (int) $attrs['x2'];
}
}
// End vertical position
@@ -2254,7 +2252,7 @@ function lineStartHandler($attrs) {
} elseif ($attrs['y2'] === ".") {
$y2 = ".";
} elseif (!empty($attrs['y2'])) {
- $y2 = (int)$attrs['y2'];
+ $y2 = (int) $attrs['y2'];
}
}
@@ -2313,7 +2311,7 @@ function listStartHandler($attrs) {
// Substitute global vars
$value = preg_replace_callback(
'/\$(\w+)/',
- function ($matches) use ($vars) {
+ function($matches) use ($vars) {
return $vars[$matches[1]]['id'];
},
$value
@@ -2421,7 +2419,7 @@ function listStartHandler($attrs) {
unset($sql_join, $sql_where, $sql_order_by);
break;
default:
- die("Invalid list name: $listname");
+ throw new DomainException('Invalid list name: ' . $listname);
}
$filters = array();
@@ -2576,7 +2574,7 @@ function listStartHandler($attrs) {
uasort($list, array("WT_GedcomRecord", "compare"));
break;
case "CHAN":
- uasort($list, function (WT_GedcomRecord $x, WT_GedcomRecord $y) {
+ uasort($list, function(WT_GedcomRecord $x, WT_GedcomRecord $y) {
return $y->lastChangeTimestamp(true) - $x->lastChangeTimestamp(true);
});
break;
@@ -2658,12 +2656,11 @@ function listEndHandler() {
//-- set the character data handler
xml_set_character_data_handler($repeat_parser, "characterData");
if (!xml_parse($repeat_parser, $reportxml, true)) {
- printf(
- $reportxml . "\nListEHandler XML error: %s at line %d",
+ throw new DomainException(sprintf(
+ 'ListEHandler XML error: %s at line %d',
xml_error_string(xml_get_error_code($repeat_parser)),
xml_get_current_line_number($repeat_parser)
- );
- exit;
+ ));
}
xml_parser_free($repeat_parser);
} else {
@@ -2824,7 +2821,7 @@ function relativesStartHandler($attrs) {
foreach ($list as $key => $value) {
$generation = $value->generation;
if ($generation == $genCounter) {
- $newarray[$key] = new stdClass();
+ $newarray[$key] = new stdClass;
$newarray[$key]->generation = $generation;
}
}
@@ -2904,12 +2901,7 @@ function relativesEndHandler() {
xml_set_character_data_handler($repeat_parser, "characterData");
if (!xml_parse($repeat_parser, $reportxml, true)) {
- printf(
- $reportxml . "\nRelativesEHandler XML error: %s at line %d",
- xml_error_string(xml_get_error_code($repeat_parser)),
- xml_get_current_line_number($repeat_parser)
- );
- exit;
+ throw new DomainException("RelativesEHandler XML error: %s at line %d", xml_error_string(xml_get_error_code($repeat_parser)), xml_get_current_line_number($repeat_parser));
}
xml_parser_free($repeat_parser);
}
@@ -3035,7 +3027,7 @@ function get_gedcom_value($tag, $level, $gedrec) {
$tags = explode(':', $tag);
$origlevel = $level;
if ($level == 0) {
- $level = $gedrec{0} + 1;
+ $level = $gedrec{0} +1;
}
$subrec = $gedrec;
diff --git a/library/WT/Report/Base_Cell.php b/library/WT/Report/Base_Cell.php
index 8bc762db1a..ea3e410f5a 100644
--- a/library/WT/Report/Base_Cell.php
+++ b/library/WT/Report/Base_Cell.php
@@ -132,8 +132,6 @@ class WT_Report_Base_Cell extends WT_Report_Base_Element {
* @param string $bocolor Border color
* @param string $tcolor Text color
* @param $reseth
- *
- * @return \WT_Report_Base_Cell
*/
function __construct(
$width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth
diff --git a/library/WT/Report/HTML.php b/library/WT/Report/HTML.php
index 99317c043e..f155b6bdaa 100644
--- a/library/WT/Report/HTML.php
+++ b/library/WT/Report/HTML.php
@@ -147,7 +147,7 @@ class WT_Report_HTML extends WT_Report_Base {
$this->pageh = $tmpw;
}
// Store the pagewidth without margins
- $this->noMarginWidth = (int)($this->pagew - $this->leftmargin - $this->rightmargin);
+ $this->noMarginWidth = (int) ($this->pagew - $this->leftmargin - $this->rightmargin);
// If RTL
if ($this->rtl) {
$this->alignRTL = "right";
@@ -211,7 +211,7 @@ class WT_Report_HTML extends WT_Report_Base {
*
*/
function run() {
- $controller = new WT_Controller_Simple();
+ $controller = new WT_Controller_Simple;
$controller
->setPageTitle($this->title)
->pageHeader();
@@ -360,7 +360,7 @@ class WT_Report_HTML extends WT_Report_Base {
* @return WT_Report_HTML_PageHeader
*/
function createPageHeader() {
- return new WT_Report_HTML_PageHeader();
+ return new WT_Report_HTML_PageHeader;
}
/**
@@ -663,7 +663,7 @@ class WT_Report_HTML extends WT_Report_Base {
*/
function textWrap($str, $width) {
// Calculate the line width
- $lw = (int)($width / ($this->getCurrentStyleHeight() / 2));
+ $lw = (int) ($width / ($this->getCurrentStyleHeight() / 2));
// Wordwrap each line
$lines = explode("\n", $str);
// Line Feed counter
diff --git a/library/WT/Report/HTML_Html.php b/library/WT/Report/HTML_Html.php
index 45a6ed73c2..8441b5dbce 100644
--- a/library/WT/Report/HTML_Html.php
+++ b/library/WT/Report/HTML_Html.php
@@ -32,7 +32,9 @@ class WT_Report_HTML_Html extends WT_Report_Base_Html {
* @return string
*/
function render($renderer, $sub = false, $inat = true) {
- if (!empty($this->attrs["wt_style"])) $renderer->setCurrentStyle($this->attrs["wt_style"]);
+ if (!empty($this->attrs["wt_style"])) {
+ $renderer->setCurrentStyle($this->attrs["wt_style"]);
+ }
$this->text = $this->getStart() . $this->text;
foreach ($this->elements as $element) {
@@ -47,7 +49,9 @@ class WT_Report_HTML_Html extends WT_Report_Base_Html {
}
}
$this->text .= $this->getEnd();
- if ($sub) return $this->text;
+ if ($sub) {
+ return $this->text;
+ }
// If not called by an other attribute
if ($inat) {
diff --git a/library/WT/Report/HTML_Line.php b/library/WT/Report/HTML_Line.php
index 4c164c5de1..3f798b3ed8 100644
--- a/library/WT/Report/HTML_Line.php
+++ b/library/WT/Report/HTML_Line.php
@@ -32,12 +32,18 @@ class WT_Report_HTML_Line extends WT_Report_Base_Line {
* @return void
*/
function render($renderer) {
- if ($this->x1 == ".") $this->x1 = $renderer->getX();
- if ($this->y1 == ".") $this->y1 = $renderer->getY();
- if ($this->x2 == ".") {
+ if ($this->x1 == '.') {
+ $this->x1 = $renderer->getX();
+ }
+ if ($this->y1 == '.') {
+ $this->y1 = $renderer->getY();
+ }
+ if ($this->x2 == '.') {
$this->x2 = $renderer->getRemainingWidth();
}
- if ($this->y2 == ".") $this->y2 = $renderer->getY();
+ if ($this->y2 == '.') {
+ $this->y2 = $renderer->getY();
+ }
// TODO Non verticle or horizontal lines can use a series of divs absolutely positioned
// Vertical line
if ($this->x1 == $this->x2) {
diff --git a/library/WT/Report/HTML_TextBox.php b/library/WT/Report/HTML_TextBox.php
index f1460aef28..1d3707eb26 100644
--- a/library/WT/Report/HTML_TextBox.php
+++ b/library/WT/Report/HTML_TextBox.php
@@ -161,8 +161,9 @@ class WT_Report_HTML_TextBox extends WT_Report_Base_TextBox {
for ($i = 0; $i < $cE; $i++) {
if (is_object($this->elements[$i])) {
$ew = $this->elements[$i]->setWrapWidth($cW - $w - 2, $cW);
- if ($ew == $cW)
+ if ($ew == $cW) {
$w = 0;
+ }
$lw = $this->elements[$i]->getWidth($renderer);
// Text is already gets the # LF
$cHT += $lw[2];
diff --git a/library/WT/Report/PDF.php b/library/WT/Report/PDF.php
index 6c32b92553..df7306c6ec 100644
--- a/library/WT/Report/PDF.php
+++ b/library/WT/Report/PDF.php
@@ -35,19 +35,19 @@ class WT_Report_PDF extends WT_Report_Base {
*/
const COMPRESSION = true;
/**
- * If TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower).
+ * If true reduce the RAM memory usage by caching temporary data on filesystem (slower).
*
* @var boolean const
*/
const DISK_CACHE = false;
/**
- * TRUE means that the input text is unicode (PDF)
+ * true means that the input text is unicode (PDF)
*
* @var boolean const
*/
const UNICODE = true;
/**
- * FALSE means that the full font is embedded, TRUE means only the used chars
+ * false means that the full font is embedded, true means only the used chars
* in TCPDF v5.9 font subsetting is a very slow process, this leads to larger files
*
* @var boolean const
@@ -231,7 +231,7 @@ class WT_Report_PDF extends WT_Report_Base {
* @return WT_Report_PDF_PageHeader
*/
function createPageHeader() {
- return new WT_Report_PDF_PageHeader();
+ return new WT_Report_PDF_PageHeader;
}
/**
diff --git a/library/WT/Report/PDF_Footnote.php b/library/WT/Report/PDF_Footnote.php
index e78599bbcc..7be2966392 100644
--- a/library/WT/Report/PDF_Footnote.php
+++ b/library/WT/Report/PDF_Footnote.php
@@ -105,7 +105,7 @@ class WT_Report_PDF_Footnote extends WT_Report_Base_Footnote {
if ($this->wrapWidthRemaining > 0) {
// Check with line counter too!
// but floor the $wrapWidthRemaining first to keep it bugfree!
- $wrapWidthRemaining = (int)($this->wrapWidthRemaining);
+ $wrapWidthRemaining = (int) ($this->wrapWidthRemaining);
if (($lw >= $wrapWidthRemaining) or ($lfct > 1)) {
$newtext = "";
$lines = explode("\n", $this->numText);
diff --git a/library/WT/Report/PDF_Text.php b/library/WT/Report/PDF_Text.php
index 750c19facf..2ddda1517e 100644
--- a/library/WT/Report/PDF_Text.php
+++ b/library/WT/Report/PDF_Text.php
@@ -107,7 +107,7 @@ class WT_Report_PDF_Text extends WT_Report_Base_Text {
if ($this->wrapWidthRemaining > 0) {
// Check with line counter too!
// but floor the $wrapWidthRemaining first to keep it bugfree!
- $wrapWidthRemaining = (int)($this->wrapWidthRemaining);
+ $wrapWidthRemaining = (int) ($this->wrapWidthRemaining);
if (($lw >= ($wrapWidthRemaining)) or ($lfct > 1)) {
$newtext = "";
$lines = explode("\n", $this->text);
diff --git a/library/WT/Soundex.php b/library/WT/Soundex.php
index e796ddd2fc..c259ff81e8 100644
--- a/library/WT/Soundex.php
+++ b/library/WT/Soundex.php
@@ -147,20 +147,20 @@ class WT_Soundex {
*/
private static $transformNameTable = array(
// Force Yiddish ligatures to be treated as separate letters
- array('װ', 'וו'),
- array('ײ', 'יי'),
- array('ױ', 'וי'),
- array('בו', 'בע'),
- array('פו', 'פע'),
- array('ומ', 'עמ'),
- array('ום', 'עם'),
- array('ונ', 'ענ'),
- array('ון', 'ען'),
- array('וו', 'ב'),
+ array('װ', 'וו'),
+ array('ײ', 'יי'),
+ array('ױ', 'וי'),
+ array('בו', 'בע'),
+ array('פו', 'פע'),
+ array('ומ', 'עמ'),
+ array('ום', 'עם'),
+ array('ונ', 'ענ'),
+ array('ון', 'ען'),
+ array('וו', 'ב'),
array("\x01", ''),
array('ייה$', "\x01ה"),
array('ייע$', "\x01ע"),
- array('יי', 'ע'),
+ array('יי', 'ע'),
array("\x01", 'יי'),
);
@@ -739,7 +739,8 @@ class WT_Soundex {
$partialResult = array();
$currPos += strlen($thisEntry);
- if ($state != 1) { // Not at beginning of input string
+ // Not at beginning of input string
+ if ($state != 1) {
if ($currPos <= $lastPos) {
// Determine whether the next chunk is a vowel
$nextEntry = substr($name, $currPos, self::MAXCHAR); // Get maximum length chunk
@@ -761,7 +762,8 @@ class WT_Soundex {
}
while ($state < count($soundTableEntry)) {
- if ($soundTableEntry[$state] == '') { // empty means 'ignore this sound in this state'
+ // empty means 'ignore this sound in this state'
+ if ($soundTableEntry[$state] == '') {
foreach ($workingResult as $workingEntry) {
$tempEntry = $workingEntry;
$tempEntry[count($tempEntry) - 1] .= '!'; // Prevent false 'doubles'
diff --git a/library/WT/Stats.php b/library/WT/Stats.php
index 773d6bd240..22476b72fe 100644
--- a/library/WT/Stats.php
+++ b/library/WT/Stats.php
@@ -28,6 +28,7 @@ require_once WT_ROOT . 'includes/functions/functions_print_lists.php';
use Rhumsaa\Uuid\Uuid;
use WT\Auth;
+use WT\Theme;
use WT\User;
/**
@@ -127,7 +128,7 @@ class WT_Stats {
isset($funcs) or $funcs = get_class_methods($this);
// Extract all tags from the provided text
- preg_match_all("/#([^#]+)(?=#)/", (string)$text, $match);
+ preg_match_all("/#([^#]+)(?=#)/", (string) $text, $match);
$tags = $match[1];
$c = count($tags);
$new_tags = array(); // tag to replace
@@ -326,7 +327,7 @@ class WT_Stats {
*/
private function totalIndividualsQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file = ?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file = ?")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -344,7 +345,7 @@ class WT_Stats {
private function totalIndisWithSourcesQuery() {
$rows = $this->runSql("SELECT SQL_CACHE COUNT(DISTINCT i_id) AS tot FROM `##link`, `##individuals` WHERE i_id=l_from AND i_file=l_file AND l_file=" . $this->tree->tree_id . " AND l_type='SOUR'");
- return (int)$rows[0]['tot'];
+ return (int) $rows[0]['tot'];
}
/**
@@ -360,7 +361,10 @@ class WT_Stats {
* @return string
*/
public function chartIndisWithSources($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
@@ -403,7 +407,7 @@ class WT_Stats {
*/
private function totalFamiliesQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##families` WHERE f_file=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##families` WHERE f_file=?")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -421,7 +425,7 @@ class WT_Stats {
private function totalFamsWithSourcesQuery() {
$rows = $this->runSql("SELECT SQL_CACHE COUNT(DISTINCT f_id) AS tot FROM `##link`, `##families` WHERE f_id=l_from AND f_file=l_file AND l_file=" . $this->tree->tree_id . " AND l_type='SOUR'");
- return (int)$rows[0]['tot'];
+ return (int) $rows[0]['tot'];
}
/**
@@ -437,7 +441,11 @@ class WT_Stats {
* @return string
*/
public function chartFamsWithSources($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
@@ -480,7 +488,7 @@ class WT_Stats {
*/
private function totalSourcesQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##sources` WHERE s_file=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##sources` WHERE s_file=?")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -504,7 +512,7 @@ class WT_Stats {
*/
private function totalNotesQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##other` WHERE o_type='NOTE' AND o_file=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##other` WHERE o_type='NOTE' AND o_file=?")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -528,7 +536,7 @@ class WT_Stats {
*/
private function totalRepositoriesQuery() {
return
- (Int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##other` WHERE o_type='REPO' AND o_file=?")
+ (Int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##other` WHERE o_type='REPO' AND o_file=?")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -706,7 +714,7 @@ class WT_Stats {
*/
private function totalSexMalesQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?")
->execute(array($this->tree->tree_id, 'M'))
->fetchOne();
}
@@ -730,7 +738,7 @@ class WT_Stats {
*/
private function totalSexFemalesQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?")
->execute(array($this->tree->tree_id, 'F'))
->fetchOne();
}
@@ -754,7 +762,7 @@ class WT_Stats {
*/
private function totalSexUnknownQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_sex=?")
->execute(array($this->tree->tree_id, 'U'))
->fetchOne();
}
@@ -846,7 +854,7 @@ class WT_Stats {
*/
private function totalLivingQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -870,7 +878,7 @@ class WT_Stats {
*/
private function totalDeceasedQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_gedcom REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file=? AND i_gedcom REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -941,7 +949,7 @@ class WT_Stats {
*/
public function totalUsers($params = array()) {
if (isset($params[0])) {
- $total = count(User::all()) + (int)$params[0];
+ $total = count(User::all()) + (int) $params[0];
} else {
$total = count(User::all());
}
@@ -990,7 +998,7 @@ class WT_Stats {
}
}
- return (int)WT_DB::prepare($sql)->execute($vars)->fetchOne();
+ return (int) WT_DB::prepare($sql)->execute($vars)->fetchOne();
}
/**
@@ -1139,7 +1147,10 @@ class WT_Stats {
* @return string
*/
public function chartMedia($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
@@ -1253,7 +1264,7 @@ class WT_Stats {
switch ($type) {
default:
case 'full':
- if ($record->canShow()) {
+ if ($record->canShowName()) {
$result = $record->format_list('span', false, $record->getFullName());
} else {
$result = WT_I18N::translate('This information is private and cannot be shown.');
@@ -1373,7 +1384,7 @@ class WT_Stats {
*/
private function totalPlacesQuery() {
return
- (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##places` WHERE p_file=?")
+ (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##places` WHERE p_file=?")
->execute(array($this->tree->tree_id))
->fetchOne();
}
@@ -1391,7 +1402,11 @@ class WT_Stats {
* @return string
*/
public function chartDistribution($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_CHART_COLOR3, $WT_STATS_MAP_X, $WT_STATS_MAP_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_CHART_COLOR3 = Theme::theme()->parameter('distribution-chart-low-values');
+ $WT_STATS_MAP_X = Theme::theme()->parameter('distribution-chart-x');
+ $WT_STATS_MAP_Y = Theme::theme()->parameter('distribution-chart-y');
if (isset($params[0])) {
$chart_shows = $params[0];
@@ -1521,7 +1536,7 @@ class WT_Stats {
$chart_url .= "&amp;chs=" . $WT_STATS_MAP_X . "x" . $WT_STATS_MAP_Y;
$chart_url .= "&amp;chld=" . implode('', array_keys($surn_countries)) . "&amp;chd=s:";
foreach ($surn_countries as $count) {
- $chart_url .= substr(WT_GOOGLE_CHART_ENCODING, (int)($count / max($surn_countries) * 61), 1);
+ $chart_url .= substr(WT_GOOGLE_CHART_ENCODING, (int) ($count / max($surn_countries) * 61), 1);
}
$chart = '<div id="google_charts" class="center">';
$chart .= '<b>' . $chart_title . '</b><br><br>';
@@ -1657,7 +1672,11 @@ class WT_Stats {
* @return array|string
*/
public function statsBirthQuery($simple = true, $sex = false, $year1 = -1, $year2 = -1, $params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if ($simple) {
$sql =
@@ -1745,7 +1764,11 @@ class WT_Stats {
* @return array|string
*/
public function statsDeathQuery($simple = true, $sex = false, $year1 = -1, $year2 = -1, $params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if ($simple) {
$sql =
@@ -2005,7 +2028,7 @@ class WT_Stats {
}
break;
case 'age':
- $result = WT_I18N::number((int)($row['age'] / 365.25));
+ $result = WT_I18N::number((int) ($row['age'] / 365.25));
break;
case 'name':
$result = "<a href=\"" . $person->getHtmlUrl() . "\">" . $person->getFullName() . "</a>";
@@ -2032,7 +2055,7 @@ class WT_Stats {
$sex_search = '';
}
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -2066,10 +2089,10 @@ class WT_Stats {
foreach ($rows as $row) {
$person = WT_Individual::getInstance($row['deathdate']);
$age = $row['age'];
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
@@ -2117,7 +2140,7 @@ class WT_Stats {
$sex_search = '';
}
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -2144,10 +2167,10 @@ class WT_Stats {
foreach ($rows as $row) {
$person = WT_Individual::getInstance($row['id']);
$age = (WT_CLIENT_JD - $row['age']);
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
@@ -2211,10 +2234,10 @@ class WT_Stats {
$row = $rows[0];
$age = $row['age'];
if ($show_years) {
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} elseif (!empty($age)) {
$age = $age . 'd';
}
@@ -2321,7 +2344,7 @@ class WT_Stats {
while ($offset = strpos($title, ' ', $offset + 1)) {
$counter[] = $offset;
}
- $half = (int)(count($counter) / 2);
+ $half = (int) (count($counter) / 2);
$chtt = substr_replace($title, '|', $counter[$half], 1);
}
return '<img src="' . "https://chart.googleapis.com/chart?cht=bvg&amp;chs={$sizes[0]}x{$sizes[1]}&amp;chm=D,FF0000,2,0,3,1|N*f1*,000000,0,-1,11,1|N*f1*,000000,1,-1,11,1&amp;chf=bg,s,ffffff00|c,s,ffffff00&amp;chtt=" . rawurlencode($chtt) . "&amp;chd={$chd}&amp;chco=0000FF,FFA0CB,FF0000&amp;chbh=20,3&amp;chxt=x,x,y,y&amp;chxl=" . rawurlencode($chxl) . "&amp;chdl=" . rawurlencode(WT_I18N::translate('Males') . '|' . WT_I18N::translate('Females') . '|' . WT_I18N::translate('Average age at death')) . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . WT_I18N::translate('Average age related to death century') . "\" title=\"" . WT_I18N::translate('Average age related to death century') . "\" />";
@@ -2787,16 +2810,16 @@ class WT_Stats {
case 'age':
$age = $row['age'];
if ($show_years) {
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
$result = get_age_at_event($age, true);
} else {
- $result = WT_I18N::number((int)($age / 365.25));
+ $result = WT_I18N::number((int) ($age / 365.25));
}
break;
}
@@ -2814,7 +2837,7 @@ class WT_Stats {
global $TEXT_DIRECTION;
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -2897,10 +2920,10 @@ class WT_Stats {
if ($type == 'name') {
return $family->format_list('span', false, $family->getFullName());
}
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
@@ -2948,7 +2971,7 @@ class WT_Stats {
global $TEXT_DIRECTION;
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -2984,10 +3007,10 @@ class WT_Stats {
break;
}
$age = $fam['age'];
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
@@ -3074,16 +3097,16 @@ class WT_Stats {
case 'age':
$age = $row['age'];
if ($show_years) {
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
$result = get_age_at_event($age, true);
} else {
- $result = (int)($age / 365.25);
+ $result = (int) ($age / 365.25);
}
break;
}
@@ -3100,7 +3123,11 @@ class WT_Stats {
* @return string|array
*/
public function statsMarrQuery($simple = true, $first = false, $year1 = -1, $year2 = -1, $params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if ($simple) {
$sql =
@@ -3191,7 +3218,11 @@ class WT_Stats {
* @return string|array
*/
private function statsDivQuery($simple = true, $first = false, $year1 = -1, $year2 = -1, $params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if ($simple) {
$sql =
@@ -3528,7 +3559,7 @@ class WT_Stats {
while ($offset = strpos(WT_I18N::translate('Average age in century of marriage'), ' ', $offset + 1)) {
$counter[] = $offset;
}
- $half = (int)(count($counter) / 2);
+ $half = (int) (count($counter) / 2);
$chtt = substr_replace(WT_I18N::translate('Average age in century of marriage'), '|', $counter[$half], 1);
}
return "<img src=\"" . "https://chart.googleapis.com/chart?cht=bvg&amp;chs={$sizes[0]}x{$sizes[1]}&amp;chm=D,FF0000,2,0,3,1|{$chmm}{$chmf}&amp;chf=bg,s,ffffff00|c,s,ffffff00&amp;chtt=" . rawurlencode($chtt) . "&amp;chd={$chd}&amp;chco=0000FF,FFA0CB,FF0000&amp;chbh=20,3&amp;chxt=x,x,y,y&amp;chxl=" . rawurlencode($chxl) . "&amp;chdl=" . rawurlencode(WT_I18N::translate('Males') . "|" . WT_I18N::translate('Females') . "|" . WT_I18N::translate('Average age')) . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . WT_I18N::translate('Average age in century of marriage') . "\" title=\"" . WT_I18N::translate('Average age in century of marriage') . "\" />";
@@ -3934,7 +3965,7 @@ class WT_Stats {
global $TEXT_DIRECTION;
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -3991,7 +4022,7 @@ class WT_Stats {
global $TEXT_DIRECTION;
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -4046,10 +4077,10 @@ class WT_Stats {
return $return;
}
$age = $fam['age'];
- if ((int)($age / 365.25) > 0) {
- $age = (int)($age / 365.25) . 'y';
- } elseif ((int)($age / 30.4375) > 0) {
- $age = (int)($age / 30.4375) . 'm';
+ if ((int) ($age / 365.25) > 0) {
+ $age = (int) ($age / 365.25) . 'y';
+ } elseif ((int) ($age / 30.4375) > 0) {
+ $age = (int) ($age / 30.4375) . 'm';
} else {
$age = $age . 'd';
}
@@ -4114,7 +4145,11 @@ class WT_Stats {
* @return string|string[][]
*/
public function monthFirstChildQuery($simple = true, $sex = false, $year1 = -1, $year2 = -1, $params = array()) {
- global $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if ($year1 >= 0 && $year2 >= 0) {
$sql_years = " AND (d_year BETWEEN '{$year1}' AND '{$year2}')";
@@ -4281,7 +4316,10 @@ class WT_Stats {
* @return string
*/
public function chartLargestFamilies($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_L_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_L_CHART_X = Theme::theme()->parameter('stats-large-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
@@ -4304,7 +4342,7 @@ class WT_Stats {
$total = 10;
}
$sizes = explode('x', $size);
- $total = (int)$total;
+ $total = (int) $total;
$rows = $this->runSql(
" SELECT SQL_CACHE f_numchil AS tot, f_id AS id" .
" FROM `##families`" .
@@ -4646,13 +4684,13 @@ class WT_Stats {
$chm .= 't' . $unknown . ',000000,0,' . $i . ',11,1';
$chxl .= WT_I18N::translate_c('unknown century', 'Unknown') . "|1:||" . WT_I18N::translate('century') . "|2:|0|";
$step = $max + 1;
- for ($d = (int)($max + 1); $d > 0; $d--) {
+ for ($d = (int) ($max + 1); $d > 0; $d--) {
if (($max + 1) < ($d * 10 + 1) && fmod(($max + 1), $d) == 0) {
$step = $d;
}
}
- if ($step == (int)($max + 1)) {
- for ($d = (int)($max); $d > 0; $d--) {
+ if ($step == (int) ($max + 1)) {
+ for ($d = (int) ($max); $d > 0; $d--) {
if ($max < ($d * 10 + 1) && fmod($max, $d) == 0) {
$step = $d;
}
@@ -4675,7 +4713,7 @@ class WT_Stats {
global $TEXT_DIRECTION;
if (isset($params[0])) {
- $total = (int)$params[0];
+ $total = (int) $params[0];
} else {
$total = 10;
}
@@ -4756,12 +4794,12 @@ class WT_Stats {
*/
private function commonSurnamesQuery($type = 'list', $show_tot = false, $params = array()) {
if (isset($params[0]) && $params[0] > 0) {
- $threshold = (int)$params[0];
+ $threshold = (int) $params[0];
} else {
$threshold = $this->tree->getPreference('COMMON_NAMES_THRESHOLD');
}
if (isset($params[1])) {
- $maxtoshow = (int)$params[1];
+ $maxtoshow = (int) $params[1];
} else {
$maxtoshow = 0;
}
@@ -4850,7 +4888,11 @@ class WT_Stats {
* @return string
*/
public function chartCommonSurnames($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
@@ -4919,7 +4961,6 @@ class WT_Stats {
}
$per = round(100 * $count_per / $tot_indi, 0);
$chd .= $this->arrayToExtendedEncoding(array($per));
- //ToDo: RTL names are often printed LTR when also LTR names are present
$chl[] = $top_name . ' - ' . WT_I18N::number($count_per);
}
@@ -4944,12 +4985,12 @@ class WT_Stats {
global $GEDCOM;
if (isset($params[0]) && $params[0] != '' && $params[0] >= 0) {
- $threshold = (int)$params[0];
+ $threshold = (int) $params[0];
} else {
$threshold = 1;
}
if (isset($params[1]) && $params[1] != '' && $params[1] >= 0) {
- $maxtoshow = (int)$params[1];
+ $maxtoshow = (int) $params[1];
} else {
$maxtoshow = 10;
}
@@ -5029,7 +5070,7 @@ class WT_Stats {
global $controller;
$table_id = Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page
$controller
- ->addExternalJavascript(WT_JQUERY_DATATABLES_URL)
+ ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
->addInlineJavascript('
jQuery("#' . $table_id . '").dataTable({
dom: \'t\',
@@ -5248,7 +5289,11 @@ class WT_Stats {
* @return string
*/
public function chartCommonGiven($params = array()) {
- global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y;
+ $WT_STATS_CHART_COLOR1 = Theme::theme()->parameter('distribution-chart-no-values');
+ $WT_STATS_CHART_COLOR2 = Theme::theme()->parameter('distribution-chart-high-values');
+ $WT_STATS_S_CHART_X = Theme::theme()->parameter('stats-small-chart-x');
+ $WT_STATS_S_CHART_Y = Theme::theme()->parameter('stats-small-chart-y');
+
if (isset($params[0]) && $params[0] != '') {
$size = strtolower($params[0]);
@@ -5293,7 +5338,6 @@ class WT_Stats {
$per = round(100 * $count / $tot_indi, 0);
}
$chd .= $this->arrayToExtendedEncoding(array($per));
- //ToDo: RTL names are often printed LTR when also LTR names are present
$chl[] = $givn . ' - ' . WT_I18N::number($count);
}
$per = round(100 * ($tot_indi - $tot) / $tot_indi, 0);
@@ -5564,14 +5608,26 @@ class WT_Stats {
* @return string
*/
public function contactWebmaster() {
- return user_contact_link($this->tree->getPreference('WEBMASTER_USER_ID'));
+ $user_id = $this->tree->getPreference('WEBMASTER_USER_ID');
+ $user = User::find($user_id);
+ if ($user) {
+ return Theme::theme()->contactLink($user);
+ } else {
+ return $user_id;
+ }
}
/**
* @return string
*/
public function contactGedcom() {
- return user_contact_link($this->tree->getPreference('CONTACT_USER_ID'));
+ $user_id = $this->tree->getPreference('CONTACT_USER_ID');
+ $user = User::find($user_id);
+ if ($user) {
+ return Theme::theme()->contactLink($user);
+ } else {
+ return $user_id;
+ }
}
/**
@@ -5761,9 +5817,9 @@ class WT_Stats {
if ($value < 0) {
$value = 0;
}
- $first = (int)($value / 64);
+ $first = (int) ($value / 64);
$second = $value % 64;
- $encoding .= $xencoding[(int)$first] . $xencoding[(int)$second];
+ $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
}
return $encoding;
}
@@ -5901,7 +5957,7 @@ class WT_Stats {
* @return string
*/
public function totalUserMessages() {
- $total = (int)WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##message` WHERE user_id = ?")
+ $total = (int) WT_DB::prepare("SELECT SQL_CACHE COUNT(*) FROM `##message` WHERE user_id = ?")
->execute(array(Auth::id()))
->fetchOne();
@@ -5915,7 +5971,7 @@ class WT_Stats {
*/
public function totalUserJournal() {
try {
- $number = (int)WT_DB::prepare("SELECT COUNT(*) FROM `##news` WHERE user_id = ?")
+ $number = (int) WT_DB::prepare("SELECT COUNT(*) FROM `##news` WHERE user_id = ?")
->execute(array(Auth::id()))
->fetchOne();
} catch (PDOException $ex) {
@@ -5933,7 +5989,7 @@ class WT_Stats {
*/
public function totalGedcomNews() {
try {
- $number = (int)WT_DB::prepare("SELECT COUNT(*) FROM `##news` WHERE gedcom_id = ?")
+ $number = (int) WT_DB::prepare("SELECT COUNT(*) FROM `##news` WHERE gedcom_id = ?")
->execute(array($this->tree->tree_id))
->fetchOne();
} catch (PDOException $ex) {
diff --git a/library/WT/Theme.php b/library/WT/Theme.php
new file mode 100644
index 0000000000..87199517a2
--- /dev/null
+++ b/library/WT/Theme.php
@@ -0,0 +1,86 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT;
+
+use WT\Theme\BaseTheme;
+
+/**
+ * Class Theme - provide access to the current theme.
+ */
+class Theme {
+ /** @var BaseTheme The current theme*/
+ private static $theme;
+
+ /** @var BaseTheme[] All currently installed themes */
+ private static $installed_themes;
+
+ /**
+ * Create a list of all themes available on the system, including
+ * any custom themes.
+ *
+ * @return BaseTheme[]
+ */
+ public static function installedThemes() {
+ if (self::$installed_themes === null) {
+ self::$installed_themes = array();
+ foreach (glob(WT_ROOT . '/themes/*/theme.php') as $theme_path) {
+ $theme = require $theme_path;
+ // Themes beginning with an underscore are reserved for special use.
+ if (substr_compare($theme->themeId(), '_', 0, 1) !== 0) {
+ self::$installed_themes[] = $theme;
+ }
+ }
+ }
+
+ return self::$installed_themes;
+ }
+
+ /**
+ * An associative array of theme names, for <select> fields, etc.
+ *
+ * @return string[]
+ */
+ public static function themeNames() {
+ $theme_names = array();
+ foreach (self::installedThemes() as $theme) {
+ $theme_names[$theme->themeId()] = $theme->themeName();
+ }
+
+ return $theme_names;
+ }
+
+ /**
+ * The currently active theme
+ *
+ * @param BaseTheme|null $theme
+ *
+ * @return BaseTheme
+ * @throws \LogicException
+ */
+ public static function theme(BaseTheme $theme = null) {
+
+ if ($theme) {
+ self::$theme = $theme;
+ } elseif (!self::$theme) {
+ throw new \LogicException;
+ }
+
+ return self::$theme;
+ }
+}
diff --git a/library/WT/Theme/Administration.php b/library/WT/Theme/Administration.php
new file mode 100644
index 0000000000..47fc4078ed
--- /dev/null
+++ b/library/WT/Theme/Administration.php
@@ -0,0 +1,195 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT_I18N;
+use WT_Menu;
+use WT_Tree;
+
+/**
+ * Class Administration - The admin theme.
+ */
+class Administration extends BaseTheme {
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ WT_FONT_AWESOME_CSS_URL,
+ WT_BOOTSTRAP_CSS_URL,
+ WT_DATATABLES_BOOTSTRAP_CSS_URL,
+ WT_BOOTSTRAP_DATETIMEPICKER_CSS_URL,
+ $this->assetUrl() . 'style.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/_administration/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function footerContent() {
+ return '';
+ }
+
+ /** {@inheritdoc} */
+ protected function headerContent() {
+ return $this->secondaryMenuContainer($this->secondaryMenu());
+ }
+
+ /** {@inheritdoc} */
+ public function hookFooterExtraJavascript() {
+ return
+ '<script src="' . WT_BOOTSTRAP_JS_URL . '"></script>';
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuAdminSite() {
+ return new WT_Menu(/* I18N: Menu entry*/ WT_I18N::translate('webtrees'), '#', '', '', array(
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Site preferences'), 'admin_site_config.php?action=site'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Sending email'), 'admin_site_config.php?action=email'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Login and registration'), 'admin_site_config.php?action=login'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Logs'), 'admin_site_logs.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Site access rules'), 'admin_site_access.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Clean up data folder'), 'admin_site_clean.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Server information'), 'admin_site_info.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('README documentation'), 'admin_site_readme.php'),
+ ));
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuAdminTrees() {
+ $submenus = array(
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Manage family trees'), 'admin_trees_manage.php')
+ );
+
+ if (count(WT_Tree::getAll()) > 1) {
+ $submenus[] = new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Set the default blocks for new family trees'), '#', '', 'return modalDialog(\'index_edit.php?gedcom_id=-1\', \'' . WT_I18N::translate('Set the default blocks for new family trees') . '\')');
+ $submenus[] = new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Merge family trees'), 'admin_trees_merge.php');
+ }
+
+ return new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Family trees'), '#', '', '', $submenus);
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuAdminUsers() {
+ return new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Users'), '#', '', '', array(
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('User administration'), 'admin_users.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Add a new user'), 'admin_users.php?action=edit'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Send broadcast messages'), 'admin_users_bulk.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Delete inactive users'), 'admin_users.php?action=cleanup'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Set the default blocks for new users'), '#', '', 'return modalDialog(\'index_edit.php?user_id=-1\', \'' . WT_I18N::translate('Set the default blocks for new users') . '\')'),
+ ));
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuAdminMedia() {
+ return new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Media'), '#', '', '', array(
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Manage media'), 'admin_media.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Upload media files'), 'admin_media_upload.php'),
+ ));
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuAdminModules() {
+ return new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Modules'), '#', '', '', array(
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Module administration'), 'admin_modules.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Menus'), 'admin_module_menus.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Tabs'), 'admin_module_tabs.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Blocks'), 'admin_module_blocks.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Sidebars'), 'admin_module_sidebar.php'),
+ new WT_Menu(/* I18N: Menu entry */ WT_I18N::translate('Reports'), 'admin_module_reports.php'),
+ ));
+ }
+
+ /** {@inheritdoc} */
+ protected function primaryMenu() {
+ return array(
+ $this->menuAdminSite(),
+ $this->menuAdminTrees(),
+ $this->menuAdminUsers(),
+ $this->menuAdminMedia(),
+ $this->menuAdminModules(),
+ );
+ }
+
+ /** {@inheritdoc} */
+ protected function primaryMenuContainer(array $menus) {
+ $html = '';
+ foreach ($menus as $menu) {
+ $html .= $menu->bootstrap();
+ }
+
+ return
+ '<nav class="navbar navbar-default">' .
+ '<div class="navbar-header">' .
+ '<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#primary-navbar-collapse">' .
+ '<span class="sr-only">Toggle navigation</span>' .
+ '<span class="icon-bar"></span>' .
+ '<span class="icon-bar"></span>' .
+ '<span class="icon-bar"></span>' .
+ '</button>' .
+ //'<a class="navbar-brand" href="index.php">' . WT_WEBTREES . '</a>' .
+ '</div>' .
+ '<div class="collapse navbar-collapse" id="primary-navbar-collapse">' .
+ '<ul class="nav navbar-nav">' .
+ $html .
+ '</ul>' .
+ '</div>' .
+ '</nav>';
+ }
+
+ /** {@inheritdoc} */
+ protected function secondaryMenu() {
+ return array_filter(array(
+ $this->menuMyPage(),
+ $this->menuLanguages(),
+ $this->menuLogout(),
+ ));
+ }
+
+ /** {@inheritdoc} */
+ protected function secondaryMenuContainer(array $menus) {
+ $html = '';
+ foreach ($menus as $menu) {
+ $html .= $menu->bootstrap();
+ }
+
+ return '<div class="clearfix"><ul class="nav nav-pills small pull-right" role="menu">' . $html . '</ul></div>';
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return '_administration';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return 'administration';
+ }
+}
diff --git a/library/WT/Theme/BaseTheme.php b/library/WT/Theme/BaseTheme.php
new file mode 100644
index 0000000000..7bf386222e
--- /dev/null
+++ b/library/WT/Theme/BaseTheme.php
@@ -0,0 +1,1704 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use gedcom_favorites_WT_Module;
+use user_favorites_WT_Module;
+use WT\Auth;
+use WT\Theme;
+use WT\User;
+use WT_Controller_Page;
+use WT_DB;
+use WT_Fact;
+use WT_FlashMessages;
+use WT_Gedcom_Tag;
+use WT_GedcomRecord;
+use WT_I18N;
+use WT_Filter;
+use WT_Individual;
+use WT_Menu;
+use WT_Module;
+use WT_Site;
+use WT_Tree;
+use Zend_Session_Namespace;
+
+/**
+ * Class Base - Common functions and interfaces for all themes.
+ */
+abstract class BaseTheme {
+ /** @var Zend_Session_Namespace */
+ protected $session;
+
+ /** @var WT_Tree The current tree */
+ protected $tree;
+
+ /** @var string An escaped version of the "ged=XXX" URL parameter */
+ protected $tree_url;
+
+ /** @var boolean Are we showing a page to a search engine? */
+ protected $search_engine;
+
+ /**
+ * Custom themes should place their initialization code in the function hookAfterInit(), not in
+ * the constructor, as all themes get constructed - whether they are used or not.
+ */
+ final public function __construct() {
+ }
+
+ /**
+ * Create the top of the <body>.
+ *
+ * @return string
+ */
+ public function bodyHeader() {
+ return
+ '<body class="container">' .
+ '<header>' .
+ $this->headerContent() .
+ $this->primaryMenuContainer($this->primaryMenu()) .
+ '</header>' .
+ '<main id="content" role="main">' .
+ $this->flashMessagesContainer(WT_FlashMessages::getMessages());
+ }
+
+ /**
+ * Create the top of the <body> (for popup windows).
+ *
+ * @return string
+ */
+ public function bodyHeaderPopupWindow() {
+ return
+ '<body class="container container-popup">' .
+ '<main id="content" role="main">' .
+ $this->flashMessagesContainer(WT_FlashMessages::getMessages());
+ }
+
+ /**
+ * Create a contact link for a user.
+ *
+ * @param User $user
+ *
+ * @return string
+ */
+ public function contactLink(User $user) {
+ $method = $user->getPreference('contactmethod');
+
+ switch ($method) {
+ case 'none':
+ return '';
+ case 'mailto':
+ return '<a href="mailto:' . WT_Filter::escapeHtml($user->getEmail()) . '">' . WT_Filter::escapeHtml($user->getRealName()) . '</a>';
+ default:
+ return "<a href='#' onclick='message(\"" . WT_Filter::escapeJs($user->getUserName()) . "\", \"" . $method . "\", \"" . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_Filter::escapeJs(get_query_url()) . "\", \"\");return false;'>" . WT_Filter::escapeHtml($user->getRealName()) . '</a>';
+ }
+ }
+
+ /**
+ * Create contact link for both technical and genealogy support.
+ *
+ * @param User $user
+ *
+ * @return string
+ */
+ protected function contactLinkEverything(User $user) {
+ return WT_I18N::translate('For technical support or genealogy questions, please contact') . ' ' . $this->contactLink($user);
+ }
+
+ /**
+ * Create contact link for genealogy support.
+ *
+ * @param User $user
+ *
+ * @return string
+ */
+ protected function contactLinkGenealogy(User $user) {
+ return WT_I18N::translate('For help with genealogy questions contact') . ' ' . $this->contactLink($user);
+ }
+
+ /**
+ * Create contact link for technical support.
+ *
+ * @param User $user
+ *
+ * @return string
+ */
+ protected function contactLinkTechnical(User $user) {
+ return WT_I18N::translate('For technical support and information contact') . ' ' . $this->contactLink($user);
+ }
+
+ /**
+ * Create contact links for the page footer.
+ *
+ * @return string
+ */
+ protected function contactLinks() {
+ $contact_user = User::find($this->tree->getPreference('CONTACT_USER_ID'));
+ $webmaster_user = User::find($this->tree->getPreference('WEBMASTER_USER_ID'));
+
+ if ($contact_user && $contact_user === $webmaster_user) {
+ return $this->contactLinkEverything($contact_user);
+ } elseif ($contact_user && $webmaster_user) {
+ return $this->contactLinkGenealogy($contact_user) . '<br>' . $this->contactLinkTechnical($webmaster_user);
+ } elseif ($contact_user) {
+ return $this->contactLinkGenealogy($contact_user);
+ } elseif ($webmaster_user) {
+ return $this->contactLinkTechnical($webmaster_user);
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Where are our CSS, JS and other assets?
+ *
+ * @return string A relative path, such as "themes/foo/"
+ */
+ public function assetUrl() {
+ return '';
+ }
+
+ /**
+ * Create the <DOCTYPE> tag.
+ *
+ * @return string
+ */
+ public function doctype() {
+ return '<!DOCTYPE html>';
+ }
+
+ /**
+ * HTML link to a "favorites icon".
+ *
+ * @return string
+ */
+ protected function favicon() {
+ // Use the default webtrees favicon
+ return '<link rel="icon" href="favicon.ico" type="image/x-icon">';
+ }
+
+ /**
+ * Add markup to a flash message.
+ *
+ * @param \stdClass $message
+ *
+ * @return string
+ */
+ protected function flashMessageContainer(\stdClass $message) {
+ return
+ '<div class="alert alert-' . $message->status . ' alert-dismissible" role="alert">' .
+ '<button type="button" class="close" data-dismiss="alert" aria-label="' . /* I18N: button label */ WT_I18N::translate('close') . '">' .
+ '<span aria-hidden="true">&times;</span>' .
+ '</button>' .
+ $message->text .
+ '</div>';
+ }
+
+ /**
+ * Create a container for messages that are "flashed" to the session
+ * on one request, and displayed on another. If there are many messages,
+ * the container may need a max-height and scroll-bar.
+ *
+ * @param \stdClass[] $messages
+ *
+ * @return string
+ */
+ protected function flashMessagesContainer(array $messages) {
+ $html = '';
+ foreach ($messages as $message) {
+ $html .= $this->flashMessageContainer($message);
+ }
+
+ if ($html) {
+ return '<div class="flash-messages">' . $html . '</div>';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create the <footer> tag.
+ *
+ * @return string
+ */
+ public function footerContainer() {
+ return
+ '</main>' .
+ '<footer>' . $this->footerContent() . '</footer>';
+ }
+
+ /**
+ * Create the contents of the <footer> tag.
+ *
+ * @return string
+ */
+ protected function footerContent() {
+ return
+ $this->formatContactLinks() .
+ $this->logoPoweredBy();
+ }
+
+ /**
+ * Format the contents of a variable-height home-page block.
+ *
+ * @param string $id
+ * @param string $title
+ * @param string $class
+ * @param string $content
+ *
+ * @return string
+ */
+ public function formatBlock($id, $title, $class, $content) {
+ return
+ '<div id="' . $id . '" class="block" >' .
+ '<div class="blockheader">' . $title . '</div>' .
+ '<div class="blockcontent ' . $class . '">' . $content . '</div>' .
+ '</div>';
+ }
+
+ /**
+ * Add markup to the contact links.
+ *
+ * @return string
+ */
+ protected function formatContactLinks() {
+ if ($this->tree) {
+ return '<div class="contact-links">' . $this->contactLinks() . '</div>';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create a pending changes link for the page footer.
+ *
+ * @return string
+ */
+ protected function formatPendingChangesLink() {
+ if ($this->pendingChangesExist()) {
+ return '<div class="pending-changes-link">' . $this->pendingChangesLink() . '</div>';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Add markup to the tree title.
+ *
+ * @return string
+ */
+ protected function formatTreeTitle() {
+ if ($this->tree) {
+ return '<h1 class="header-title">' . $this->tree->tree_title_html . '</h1>';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Add markup to the user menu.
+ *
+ * @return string
+ */
+ protected function formatSecondaryMenu() {
+ return
+ '<ul class="secondary-menu">' .
+ implode('', $this->secondaryMenu()) .
+ '</ul>';
+ }
+
+ /**
+ * Add markup to an item in the user menu.
+ *
+ * @param WT_Menu $menu
+ *
+ * @return string
+ */
+ protected function formatUserMenuItem(WT_Menu $menu) {
+ return $menu->getMenuAsList();
+ }
+
+ /**
+ * Create a quick search form for the header.
+ *
+ * @return string
+ */
+ protected function formQuickSearch() {
+ if ($this->tree) {
+ return
+ '<form action="search.php" class="header-search" method="post" role="search">' .
+ '<input type="hidden" name="action" value="general">' .
+ '<input type="hidden" name="ged" value="' . $this->tree->tree_name_html . '">' .
+ '<input type="hidden" name="topsearch" value="yes">' .
+ $this->formQuickSearchFields() .
+ '</form>';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create a search field and submit button for the quick search form in the header.
+ *
+ * @return string
+ */
+ protected function formQuickSearchFields() {
+ return
+ '<input type="search" name="query" size="15" placeholder="' . WT_I18N::translate('Search') . '">' .
+ '<input type="image" src="' . Theme::theme()->parameter('image-search') . '" alt="' . WT_I18N::translate('Search') . '">';
+ }
+
+ /**
+ * Create the <head> tag.
+ *
+ * @param WT_Controller_Page $controller The current controller
+ *
+ * @return string
+ */
+ public function head(WT_Controller_Page $controller) {
+ return
+ '<head>' .
+ $this->headContents($controller) .
+ $this->hookHeaderExtraContent() .
+ '</head>';
+ }
+
+ /**
+ * Create the contents of the <head> tag.
+ *
+ * @param WT_Controller_Page $controller The current controller
+ *
+ * @return string
+ */
+ protected function headContents(WT_Controller_Page $controller) {
+ // The title often includes the names of records, which may include HTML markup.
+ $title = WT_Filter::unescapeHtml($controller->getPageTitle());
+
+ // If an extra (site) title is specified, append it.
+ if ($this->tree && $this->tree->getPreference('META_TITLE')) {
+ $title .= ' - ' . WT_Filter::escapeHtml($this->tree->getPreference('META_TITLE'));
+ }
+
+ $html =
+ // modernizr.js and respond.js need to be loaded before the <body> to avoid FOUC
+ '<!--[if IE 8]><script src="' . WT_MODERNIZR_JS_URL . '"></script><![endif]-->' .
+ '<!--[if IE 8]><script src="' . WT_RESPOND_JS_URL . '"></script><![endif]-->' .
+ $this->metaCharset() .
+ $this->title($title) .
+ $this->favicon() .
+ $this->metaViewport() .
+ $this->metaRobots($controller->getMetaRobots()) .
+ $this->metaUaCompatible() .
+ $this->metaGenerator(WT_WEBTREES . ' ' . WT_VERSION . ' - ' . WT_WEBTREES_URL) .
+ $this->metaCanonicalUrl($controller->getCanonicalUrl());
+
+ if ($this->tree) {
+ $html .= $this->metaDescription($this->tree->getPreference('META_DESCRIPTION', html_entity_decode(strip_tags($this->tree->tree_title_html), ENT_QUOTES)));
+ }
+
+ // CSS files
+ foreach ($this->stylesheets() as $css) {
+ $html .= '<link rel="stylesheet" type="text/css" href="' . $css . '">';
+ }
+
+ return $html;
+ }
+
+ /**
+ * Create the contents of the <header> tag.
+ *
+ * @return string
+ */
+ protected function headerContent() {
+ return
+ $this->logoHeader() .
+ $this->secondaryMenuContainer($this->secondaryMenu()) .
+ $this->formatTreeTitle() .
+ $this->formQuickSearch();
+ }
+
+ /**
+ * Create the <header> tag for a popup window.
+ *
+ * @return string
+ */
+ protected function headerSimple() {
+ return
+ $this->flashMessagesContainer(WT_FlashMessages::getMessages()) .
+ '<div id="content">';
+ }
+
+ /**
+ * Allow themes to do things after initialization (since they cannot use
+ * the constructor).
+ *
+ * @return void
+ */
+ public function hookAfterInit() {
+ }
+
+ /**
+ * Allow themes to add extra scripts to the page footer.
+ *
+ * @return string
+ */
+ public function hookFooterExtraJavascript() {
+ return '';
+ }
+
+ /**
+ * Allow themes to add extra content to the page header.
+ * Typically this will be additional CSS.
+ *
+ * @return string
+ */
+ public function hookHeaderExtraContent() {
+ return '';
+ }
+
+ /**
+ * Create the <html> tag.
+ *
+ * @return string
+ */
+ public function html() {
+ return '<html ' . WT_I18N::html_markup() . '>';
+ }
+
+ /**
+ * Display an icon for this fact.
+ *
+ * @param WT_Fact $fact
+ *
+ * @return string
+ */
+ public function icon(WT_Fact $fact) {
+ $icon = 'images/facts/' . $fact->getTag() . '.png';
+ $dir = substr($this->assetUrl(), strlen(WT_STATIC_URL));
+ if (file_exists($dir . $icon)) {
+ return '<img src="' . $this->assetUrl() . $icon . '" title="' . WT_Gedcom_Tag::getLabel($fact->getTag()) . '">';
+ } elseif (file_exists($dir . 'images/facts/NULL.png')) {
+ // Spacer image - for alignment - until we move to a sprite.
+ return '<img src="' . Theme::theme()->assetUrl() . 'images/facts/NULL.png">';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Display an individual in a box - for charts, etc.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return string
+ */
+ public function individualBox(WT_Individual $individual) {
+ $personBoxClass = array_search($individual->getSex(), array('person_box' => 'M', 'person_boxF' => 'F', 'person_boxNN' => 'U'));
+ if ($this->tree->getPreference('SHOW_HIGHLIGHT_IMAGES')) {
+ $thumbnail = $individual->displayImage();
+ } else {
+ $thumbnail = '';
+ }
+
+ return
+ '<div data-pid="' . $individual->getXref() . '" class="person_box_template ' . $personBoxClass . ' box-style1" style="width: ' . $this->parameter('chart-box-x') . 'px; min-height: ' . $this->parameter('chart-box-y') . 'px">' .
+ '<div class="noprint icons">' .
+ '<span class="iconz icon-zoomin" title="' . WT_I18N::translate('Zoom in/out on this box.') . '"></span>' .
+ '<div class="itr"><i class="icon-pedigree"></i><div class="popup">' .
+ '<ul class="' . $personBoxClass . '">' . implode('', $this->individualBoxMenu($individual)) . '</ul>' .
+ '</div>' .
+ '</div>' .
+ '</div>' .
+ '<div class="chart_textbox" style="max-height:' . $this->parameter('chart-box-y') . 'px;">' .
+ $thumbnail .
+ '<a href="' . $individual->getHtmlUrl() . '">' .
+ '<span class="namedef name1">' . $individual->getFullName() . '</span>' .
+ '</a>' .
+ '<div class="namedef name1">' . $individual->getAddName() . '</div>' .
+ '<div class="inout2 details1">' . $this->individualBoxFacts($individual) . '</div>' .
+ '</div>' .
+ '<div class="inout"></div>' .
+ '</div>';
+ }
+
+ /**
+ * Display an empty box - for a missing individual in a chart.
+ *
+ * @return string
+ */
+ public function individualBoxEmpty() {
+ return '<div class="person_box_template person_boxNN box-style1" style="width: ' . $this->parameter('chart-box-x') . 'px; min-height: ' . $this->parameter('chart-box-y') . 'px"></div>';
+ }
+
+ /**
+ * Display an individual in a box - for charts, etc.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return string
+ */
+ public function individualBoxLarge(WT_Individual $individual) {
+ $personBoxClass = array_search($individual->getSex(), array('person_box' => 'M', 'person_boxF' => 'F', 'person_boxNN' => 'U'));
+ if ($this->tree->getPreference('SHOW_HIGHLIGHT_IMAGES')) {
+ $thumbnail = $individual->displayImage();
+ } else {
+ $thumbnail = '';
+ }
+
+ return
+ '<div data-pid="' . $individual->getXref() . '" class="person_box_template ' . $personBoxClass . ' box-style2">' .
+ '<div class="noprint icons">' .
+ '<span class="iconz icon-zoomin" title="' . WT_I18N::translate('Zoom in/out on this box.') . '"></span>' .
+ '<div class="itr"><i class="icon-pedigree"></i><div class="popup">' .
+ '<ul class="' . $personBoxClass . '">' . implode('', $this->individualBoxMenu($individual)) . '</ul>' .
+ '</div>' .
+ '</div>' .
+ '</div>' .
+ '<div class="chart_textbox" style="max-height:' . $this->parameter('chart-box-y') . 'px;">' .
+ $thumbnail .
+ '<a href="' . $individual->getHtmlUrl() . '">' .
+ '<span class="namedef name2">' . $individual->getFullName() . '</span>' .
+ '</a>' .
+ '<div class="namedef name2">' . $individual->getAddName() . '</div>' .
+ '<div class="inout2 details2">' . $this->individualBoxFacts($individual) . '</div>' .
+ '</div>' .
+ '<div class="inout"></div>' .
+ '</div>';
+ }
+
+ /**
+ * Display an individual in a box - for charts, etc.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return string
+ */
+ public function individualBoxSmall(WT_Individual $individual) {
+ $personBoxClass = array_search($individual->getSex(), array('person_box' => 'M', 'person_boxF' => 'F', 'person_boxNN' => 'U'));
+ if ($this->tree->getPreference('SHOW_HIGHLIGHT_IMAGES')) {
+ $thumbnail = $individual->displayImage();
+ } else {
+ $thumbnail = '';
+ }
+
+
+ return
+ '<div data-pid="' . $individual->getXref() . '" class="person_box_template ' . $personBoxClass . ' box-style0" style="width: ' . $this->parameter('compact-chart-box-x') . 'px; min-height: ' . $this->parameter('compact-chart-box-y') . 'px">' .
+ '<div class="compact_view">' .
+ $thumbnail .
+ '<a href="' . $individual->getHtmlUrl() . '">' .
+ '<span class="namedef name0">' . $individual->getFullName() . '</span>' .
+ '</a>' .
+ '<div class="inout2 details0">' . $individual->getLifeSpan() . '</div>' .
+ '</div>' .
+ '<div class="inout"></div>' .
+ '</div>';
+ }
+
+ /**
+ * Display an individual in a box - for charts, etc.
+ *
+ * @return string
+ */
+ public function individualBoxSmallEmpty() {
+ return '<div class="person_box_template person_boxNN box-style1" style="width: ' . $this->parameter('compact-chart-box-x') . 'px; min-height: ' . $this->parameter('compact-chart-box-y') . 'px"></div>';
+ }
+
+ /**
+ * Generate the facts, for display in charts.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return string
+ */
+ protected function individualBoxFacts(WT_Individual $individual) {
+ $html = '';
+
+ $opt_tags = preg_split('/\W/', $this->tree->getPreference('CHART_BOX_TAGS'), 0, PREG_SPLIT_NO_EMPTY);
+ // Show BIRT or equivalent event
+ foreach (explode('|', WT_EVENTS_BIRT) as $birttag) {
+ if (!in_array($birttag, $opt_tags)) {
+ $event = $individual->getFirstFact($birttag);
+ if ($event) {
+ $html .= $event->summary();
+ break;
+ }
+ }
+ }
+ // Show optional events (before death)
+ foreach ($opt_tags as $key => $tag) {
+ if (!preg_match('/^(' . WT_EVENTS_DEAT . ')$/', $tag)) {
+ $event = $individual->getFirstFact($tag);
+ if (!is_null($event)) {
+ $html .= $event->summary();
+ unset ($opt_tags[$key]);
+ }
+ }
+ }
+ // Show DEAT or equivalent event
+ foreach (explode('|', WT_EVENTS_DEAT) as $deattag) {
+ $event = $individual->getFirstFact($deattag);
+ if ($event) {
+ $html .= $event->summary();
+ if (in_array($deattag, $opt_tags)) {
+ unset ($opt_tags[array_search($deattag, $opt_tags)]);
+ }
+ break;
+ }
+ }
+ // Show remaining optional events (after death)
+ foreach ($opt_tags as $tag) {
+ $event = $individual->getFirstFact($tag);
+ if ($event) {
+ $html .= $event->summary();
+ }
+ }
+
+ return $html;
+ }
+
+ /**
+ * Generate the LDS summary, for display in charts.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return string
+ */
+ protected function individualBoxLdsSummary(WT_Individual $individual) {
+ if ($this->tree->getPreference('SHOW_LDS_AT_GLANCE')) {
+ $BAPL = $individual->getFacts('BAPL') ? 'B' : '_';
+ $ENDL = $individual->getFacts('ENDL') ? 'E' : '_';
+ $SLGC = $individual->getFacts('SLGC') ? 'C' : '_';
+ $SLGS = '_';
+
+ foreach ($individual->getSpouseFamilies() as $family) {
+ if ($family->getFacts('SLGS')) {
+ $SLGS = '';
+ }
+ }
+
+ return $BAPL . $ENDL . $SLGS . $SLGC;
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Links, to show in chart boxes;
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu[]
+ */
+ protected function individualBoxMenu(WT_Individual $individual) {
+ $menus = array_merge(
+ $this->individualBoxMenuCharts($individual),
+ $this->individualBoxMenuFamilyLinks($individual)
+ );
+
+ return $menus;
+ }
+
+ /**
+ * Chart links, to show in chart boxes;
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu[]
+ */
+ protected function individualBoxMenuCharts(WT_Individual $individual) {
+ $menus = array_filter(array(
+ $this->menuChartAncestors($individual),
+ $this->menuChartCompact($individual),
+ $this->menuChartDescendants($individual),
+ $this->menuChartFanChart($individual),
+ $this->menuChartHourglass($individual),
+ $this->menuChartInteractiveTree($individual),
+ $this->menuChartPedigree($individual),
+ $this->menuChartPedigreeMap($individual),
+ $this->menuChartRelationship($individual),
+ $this->menuChartTimeline($individual),
+ ));
+
+ usort($menus, function(WT_Menu $x, WT_Menu $y) {
+ return WT_I18N::strcasecmp($x->getLabel(), $y->getLabel());
+ });
+
+ return $menus;
+ }
+
+ /**
+ * Family links, to show in chart boxes.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu[]
+ */
+ protected function individualBoxMenuFamilyLinks(WT_Individual $individual) {
+ $menus = array();
+
+ foreach ($individual->getSpouseFamilies() as $family) {
+ $menus[] = new WT_Menu('<strong>' . WT_I18N::translate('Family with spouse') . '</strong>', $family->getHtmlUrl());
+ $spouse = $family->getSpouse($individual);
+ if ($spouse && $spouse->canShowName()) {
+ $menus[] = new WT_Menu($spouse->getFullName(), $spouse->getHtmlUrl());
+ }
+ foreach ($family->getChildren() as $child) {
+ if ($child->canShowName()) {
+ $menus[] = new WT_Menu($child->getFullName(), $child->getHtmlUrl());
+ }
+ }
+ }
+
+ return $menus;
+ }
+
+ /**
+ * Create part of an individual box
+ *
+ * @param WT_Individual $individual
+ *
+ * @return string
+ */
+ protected function individualBoxSexSymbol(WT_Individual $individual) {
+ if ($this->tree->getPreference('PEDIGREE_SHOW_GENDER')) {
+ return $individual->sexImage('large');
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Initialise the theme. We cannot pass these in a constructor, as the construction
+ * happens in a theme file, and we need to be able to change it.
+ *
+ * @param Zend_Session_Namespace $session
+ * @param bool $search_engine
+ * @param WT_Tree|null $tree The current tree (if there is one).
+ *
+ * @return void
+ */
+ final public function init(Zend_Session_Namespace $session, $search_engine, WT_Tree $tree = null) {
+ $this->tree = $tree;
+ $this->tree_url = $tree ? 'ged=' . WT_Filter::escapeUrl($tree->tree_name) : null;
+ $this->session = $session;
+ $this->search_engine = $search_engine;
+
+ $this->hookAfterInit();
+ }
+
+ /**
+ * Are we generating a page for a robot (instead of a human being).
+ *
+ * @return boolean
+ */
+ protected function isSearchEngine() {
+ return $this->search_engine;
+ }
+
+ /**
+ * A large webtrees logo, for the footer.
+ *
+ * @return string
+ */
+ protected function logoHeader() {
+ return '<div class="header-logo"></div>';
+ }
+
+ /**
+ * A small "powered by webtrees" logo for the footer.
+ *
+ * @return string
+ */
+ protected function logoPoweredBy() {
+ return '<a href="' . WT_WEBTREES_URL . '" class="powered-by-webtrees" title="' . WT_WEBTREES_URL . '"></a>';
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuCalendar() {
+ if ($this->isSearchEngine()) {
+ return new WT_Menu(WT_I18N::translate('Calendar'), '#', 'menu-calendar');
+ }
+
+ // Default action is the day view.
+ $menu = new WT_Menu(WT_I18N::translate('Calendar'), 'calendar.php?' . $this->tree_url, 'menu-calendar');
+
+ // Day view
+ $submenu = new WT_Menu(WT_I18N::translate('Day'), 'calendar.php?' . $this->tree_url . '&amp;view=day', 'menu-calendar-day');
+ $menu->addSubmenu($submenu);
+
+ // Month view
+ $submenu = new WT_Menu(WT_I18N::translate('Month'), 'calendar.php?' . $this->tree_url . '&amp;view=month', 'menu-calendar-month');
+ $menu->addSubmenu($submenu);
+
+ //Year view
+ $submenu = new WT_Menu(WT_I18N::translate('Year'), 'calendar.php?' . $this->tree_url . '&amp;view=year', 'menu-calendar-year');
+ $menu->addSubmenu($submenu);
+
+ return $menu;
+ }
+
+ /**
+ * Generate a menu for each of the different charts.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChart(WT_Individual $individual) {
+ if ($this->tree && !$this->isSearchEngine()) {
+ // The top level menu is the pedigree chart
+ $menu = $this->menuChartPedigree($individual);
+ $menu->setLabel(WT_I18N::translate('Charts'));
+ $menu->setId('menu-chart');
+
+ $submenus = array_filter(array(
+ $this->menuChartAncestors($individual),
+ $this->menuChartCompact($individual),
+ $this->menuChartDescendants($individual),
+ $this->menuChartFamilyBook($individual),
+ $this->menuChartFanChart($individual),
+ $this->menuChartHourglass($individual),
+ $this->menuChartInteractiveTree($individual),
+ $this->menuChartLifespan($individual),
+ $this->menuChartPedigree($individual),
+ $this->menuChartPedigreeMap($individual),
+ $this->menuChartRelationship($individual),
+ $this->menuChartStatistics(),
+ $this->menuChartTimeline($individual),
+ ));
+
+ usort($submenus, function(WT_Menu $x, WT_Menu $y) {
+ return WT_I18N::strcasecmp($x->getLabel(), $y->getLabel());
+ });
+
+ $menu->setSubmenus($submenus);
+
+ return $menu;
+ } else {
+ return new WT_Menu(WT_I18N::translate('Charts'), '#', 'menu-chart');
+ }
+ }
+
+ /**
+ * Generate a menu item for the ancestors chart (ancestry.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartAncestors(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Ancestors'), 'ancestry.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-pedigree');
+ }
+
+ /**
+ * Generate a menu item for the compact tree (compact.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartCompact(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Compact tree'), 'compact.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-compact');
+ }
+
+ /**
+ * Generate a menu item for the descendants chart (descendancy.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartDescendants(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Descendants'), 'descendancy.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-descendants');
+ }
+
+ /**
+ * Generate a menu item for the family-book chart (familybook.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartFamilyBook(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Family book'), 'familybook.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-familybook');
+ }
+
+ /**
+ * Generate a menu item for the fan chart (fanchart.php).
+ *
+ * We can only do this if the GD2 library is installed with TrueType support.
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuChartFanChart(WT_Individual $individual) {
+ if (function_exists('imagettftext')) {
+ return new WT_Menu(WT_I18N::translate('Fan chart'), 'fanchart.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-fanchart');
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Generate a menu item for the pedigree map (googlemap module).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuChartInteractiveTree(WT_Individual $individual) {
+ if (array_key_exists('tree', WT_Module::getActiveModules())) {
+ return new WT_Menu(WT_I18N::translate('Interactive tree'), 'module.php?mod=tree&amp;mod_action=treeview&amp;' . $this->tree_url . '&amp;rootid=' . $individual->getXref(), 'menu-chart-tree');
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Generate a menu item for the hourglass chart (hourglass.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartHourglass(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Hourglass chart'), 'hourglass.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-hourglass');
+ }
+
+ /**
+ * Generate a menu item for the lifepsan chart (lifespan.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartLifespan(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Lifespans'), 'lifespan.php?pids%5B%5D=' . $individual->getXref() . '&amp;addFamily=1&amp;' . $this->tree_url, 'menu-chart-lifespan');
+ }
+
+ /**
+ * Generate a menu item for the pedigree chart (pedigree.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartPedigree(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Pedigree'), 'pedigree.php?rootid=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-pedigree');
+ }
+
+ /**
+ * Generate a menu item for the pedigree map (googlemap module).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuChartPedigreeMap(WT_Individual $individual) {
+ if (array_key_exists('googlemap', WT_Module::getActiveModules())) {
+ return new WT_Menu(WT_I18N::translate('Pedigree map'), 'module.php?' . $this->tree_url . '&amp;mod=googlemap&amp;mod_action=pedigree_map&amp;rootid=' . $individual->getXref(), 'menu-chart-pedigree_map');
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Generate a menu item for the relationship chart (relationship.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartRelationship(WT_Individual $individual) {
+ if (WT_USER_GEDCOM_ID && $individual->getXref()) {
+ return new WT_Menu(WT_I18N::translate('Relationship to me'), 'relationship.php?pid1=' . WT_USER_GEDCOM_ID . '&amp;pid2=' . $individual->getXref() . '&amp;ged=' . $this->tree_url, 'menu-chart-relationship');
+ } else {
+ return new WT_Menu(WT_I18N::translate('Relationships'), 'relationship.php?pid1=' . $individual->getXref() . '&amp;ged=' . $this->tree_url, 'menu-chart-relationship');
+ }
+ }
+
+ /**
+ * Generate a menu item for the statistics charts (statistics.php).
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartStatistics() {
+ return new WT_Menu(WT_I18N::translate('Statistics'), 'statistics.php?' . $this->tree_url, 'menu-chart-statistics');
+ }
+
+ /**
+ * Generate a menu item for the timeline chart (timeline.php).
+ *
+ * @param WT_Individual $individual
+ *
+ * @return WT_Menu
+ */
+ protected function menuChartTimeline(WT_Individual $individual) {
+ return new WT_Menu(WT_I18N::translate('Timeline'), 'timeline.php?pids%5B%5D=' . $individual->getXref() . '&amp;' . $this->tree_url, 'menu-chart-timeline');
+ }
+
+ /**
+ * Favorites menu.
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuFavorites() {
+ global $controller;
+
+ $show_user_favorites = $this->tree && array_key_exists('user_favorites', WT_Module::getActiveModules()) && Auth::check();
+ $show_tree_favorites = $this->tree && array_key_exists('gedcom_favorites', WT_Module::getActiveModules());
+
+ if ($show_user_favorites && $show_tree_favorites) {
+ $favorites = array_merge(
+ gedcom_favorites_WT_Module::getFavorites(WT_GED_ID),
+ user_favorites_WT_Module::getFavorites(Auth::id())
+ );
+ } elseif ($show_user_favorites) {
+ $favorites = user_favorites_WT_Module::getFavorites(Auth::id());
+ } elseif ($show_tree_favorites) {
+ $favorites = gedcom_favorites_WT_Module::getFavorites(WT_GED_ID);
+ } else {
+ return null;
+ }
+
+ $menu = new WT_Menu(WT_I18N::translate('Favorites'), '#', 'menu-favorites');
+
+ foreach ($favorites as $favorite) {
+ switch ($favorite['type']) {
+ case 'URL':
+ $submenu = new WT_Menu($favorite['title'], $favorite['url']);
+ $menu->addSubmenu($submenu);
+ break;
+ case 'INDI':
+ case 'FAM':
+ case 'SOUR':
+ case 'OBJE':
+ case 'NOTE':
+ $obj = WT_GedcomRecord::getInstance($favorite['gid']);
+ if ($obj && $obj->canShowName()) {
+ $submenu = new WT_Menu($obj->getFullName(), $obj->getHtmlUrl());
+ $menu->addSubmenu($submenu);
+ }
+ break;
+ }
+ }
+
+ if ($show_user_favorites) {
+ if (isset($controller->record) && $controller->record instanceof WT_GedcomRecord) {
+ $submenu = new WT_Menu(WT_I18N::translate('Add to favorites'), '#');
+ $submenu->setOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $controller->record->getXref() . "'},function(){location.reload();})");
+ $menu->addSubmenu($submenu);
+ }
+ }
+
+ return $menu;
+ }
+
+ /**
+ * @return WT_Menu
+ */
+ protected function menuHomePage() {
+ $menu = new WT_Menu(WT_I18N::translate('Home page'), 'index.php?ctype=gedcom&amp;' . $this->tree_url, 'menu-tree');
+ $ALLOW_CHANGE_GEDCOM = WT_Site::getPreference('ALLOW_CHANGE_GEDCOM') && count(WT_Tree::getAll()) > 1;
+ foreach (WT_Tree::getAll() as $tree) {
+ if ($tree->tree_id === WT_GED_ID || $ALLOW_CHANGE_GEDCOM) {
+ $submenu = new WT_Menu(
+ $tree->tree_title_html,
+ 'index.php?ctype=gedcom&amp;ged=' . $tree->tree_name_url,
+ 'menu-tree-' . $tree->tree_id // Cannot use name - it must be a CSS identifier
+ );
+ $menu->addSubmenu($submenu);
+ }
+ }
+
+ return $menu;
+ }
+
+ /**
+ * A menu to show a list of available languages.
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuLanguages() {
+ $menu = new WT_Menu(WT_I18N::translate('Language'), '#', 'menu-language');
+
+ foreach (WT_I18N::installed_languages() as $lang => $name) {
+ $submenu = new WT_Menu($name, get_query_url(array('lang' => $lang), '&amp;'), 'menu-language-' . $lang);
+ if (WT_LOCALE === $lang) {
+ $submenu->addClass('', '', 'active');
+ }
+ $menu->addSubmenu($submenu);
+ }
+
+ if (count($menu->getSubmenus()) > 1 && !$this->isSearchEngine()) {
+ return $menu;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create a menu to show lists of individuals, families, sources, etc.
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuLists() {
+ global $controller;
+
+ // The top level menu shows the individual list
+ $menu = new WT_Menu(WT_I18N::translate('Lists'), 'indilist.php?' . $this->tree_url, 'menu-list');
+
+ // Do not show empty lists
+ $row = WT_DB::prepare(
+ "SELECT SQL_CACHE" .
+ " EXISTS(SELECT 1 FROM `##sources` WHERE s_file=? ) AS sour," .
+ " EXISTS(SELECT 1 FROM `##other` WHERE o_file=? AND o_type='REPO') AS repo," .
+ " EXISTS(SELECT 1 FROM `##other` WHERE o_file=? AND o_type='NOTE') AS note," .
+ " EXISTS(SELECT 1 FROM `##media` WHERE m_file=? ) AS obje"
+ )->execute(array(WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID))->fetchOneRow();
+
+ // Build a list of submenu items and then sort it in localized name order
+ $surname_url = '&amp;surname=' . rawurlencode($controller->getSignificantSurname());
+
+ $menulist = array(
+ new WT_Menu(WT_I18N::translate('Individuals'), 'indilist.php?' . $this->tree_url . $surname_url, 'menu-list-indi'),
+ );
+
+ if (!$this->isSearchEngine()) {
+ $menulist[] = new WT_Menu(WT_I18N::translate('Families'), 'famlist.php?' . $this->tree_url . $surname_url, 'menu-list-fam');
+ $menulist[] = new WT_Menu(WT_I18N::translate('Branches'), 'branches.php?' . $this->tree_url . $surname_url, 'menu-branches');
+ $menulist[] = new WT_Menu(WT_I18N::translate('Place hierarchy'), 'placelist.php?' . $this->tree_url, 'menu-list-plac');
+ if ($row->obje) {
+ $menulist[] = new WT_Menu(WT_I18N::translate('Media objects'), 'medialist.php?' . $this->tree_url, 'menu-list-obje');
+ }
+ if ($row->repo) {
+ $menulist[] = new WT_Menu(WT_I18N::translate('Repositories'), 'repolist.php?' . $this->tree_url, 'menu-list-repo');
+ }
+ if ($row->sour) {
+ $menulist[] = new WT_Menu(WT_I18N::translate('Sources'), 'sourcelist.php?' . $this->tree_url, 'menu-list-sour');
+ }
+ if ($row->note) {
+ $menulist[] = new WT_Menu(WT_I18N::translate('Shared notes'), 'notelist.php?' . $this->tree_url, 'menu-list-note');
+ }
+ }
+ uasort($menulist, function(WT_Menu $x, WT_Menu $y) {
+ return WT_I18N::strcasecmp($x->getLabel(), $y->getLabel());
+ });
+
+ $menu->setSubmenus($menulist);
+
+ return $menu;
+ }
+
+ /**
+ * A login menu option (or null if we are already logged in).
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuLogin() {
+ if (Auth::check() || $this->isSearchEngine() || WT_SCRIPT_NAME === 'login.php') {
+ return null;
+ } else {
+ return new WT_Menu(WT_I18N::translate('Login'), WT_LOGIN_URL . '?url=' . rawurlencode(get_query_url()));
+ }
+ }
+
+ /**
+ * A logout menu option (or null if we are already logged out).
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuLogout() {
+ if (Auth::check()) {
+ return new WT_Menu(WT_I18N::translate('Logout'), 'logout.php');
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get the additional menus created by each of the modules
+ *
+ * @return WT_Menu[]
+ */
+ protected function menuModules() {
+ $menus = array();
+ foreach (WT_Module::getActiveMenus() as $module) {
+ $menu = $module->getMenu();
+ if ($menu) {
+ $menus[] = $menu;
+ }
+ }
+
+ return $menus;
+ }
+
+ /**
+ * A link to allow users to edit their account settings.
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuMyAccount() {
+ if (Auth::check()) {
+ return new WT_Menu(WT_Filter::escapeHtml(Auth::user()->getRealName()), 'edituser.php');
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return WT_Menu|null
+ */
+ protected function menuMyMenu() {
+ $showFull = $this->tree->getPreference('PEDIGREE_FULL_DETAILS') ? 1 : 0;
+ $showLayout = $this->tree->getPreference('PEDIGREE_LAYOUT') ? 1 : 0;
+
+ if (!Auth::id()) {
+ return null;
+ }
+
+ $menu = new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&amp;' . $this->tree_url, 'menu-mymenu');
+
+ $menu->addSubmenu($this->menuMyPage());
+ $menu->addSubmenu(new WT_Menu(WT_I18N::translate('My account'), 'edituser.php', 'menu-myaccount'));
+
+ if (WT_USER_GEDCOM_ID) {
+ $menu->addSubmenu(new WT_Menu(
+ WT_I18N::translate('My pedigree'),
+ 'pedigree.php?' . $this->tree_url . '&amp;rootid=' . WT_USER_GEDCOM_ID . "&amp;show_full={$showFull}&amp;talloffset={$showLayout}",
+ 'menu-mypedigree'
+ ));
+
+ $menu->addSubmenu(new WT_Menu(
+ WT_I18N::translate('My individual record'), 'individual.php?pid=' . WT_USER_GEDCOM_ID . '&amp;' . $this->tree_url, 'menu-myrecord'
+ ));
+ }
+
+ if (WT_USER_GEDCOM_ADMIN) {
+ $menu->addSubmenu(new WT_Menu(WT_I18N::translate('Administration'), 'admin.php', 'menu-admin'));
+ }
+
+ return $menu;
+ }
+
+ /**
+ * A link to the user's personal home page.
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuMyPage()
+ {
+ return new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&amp;' . $this->tree_url, 'menu-mypage');
+ }
+
+ /**
+ * Create a pending changes menu.
+ *
+ * @return WT_Menu|null
+ */
+ protected function menuPendingChanges() {
+ if ($this->pendingChangesExist()) {
+ $menu = new WT_Menu(WT_I18N::translate('Pending changes'), '#', 'menu-pending');
+ $menu->setOnclick('window.open(\'edit_changes.php\', \'_blank\', chan_window_specs); return false;');
+
+ return $menu;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return WT_Menu|null
+ */
+ protected function menuReports() {
+ $active_reports = WT_Module::getActiveReports();
+
+ if ($this->isSearchEngine() || !$active_reports) {
+ return new WT_Menu(WT_I18N::translate('Reports'), '#', 'menu-report');
+ }
+
+ $menu = new WT_Menu(WT_I18N::translate('Reports'), 'reportengine.php?' . $this->tree_url, 'menu-report');
+
+ $sub_menu = false;
+ foreach ($active_reports as $report) {
+ foreach ($report->getReportMenus() as $submenu) {
+ $menu->addSubmenu($submenu);
+ $sub_menu = true;
+ }
+ }
+
+ if ($sub_menu && !$this->isSearchEngine()) {
+ return $menu;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create the search menu
+ *
+ * @return WT_Menu
+ */
+ protected function menuSearch() {
+ if ($this->isSearchEngine()) {
+ return new WT_Menu(WT_I18N::translate('Search'), '#', 'menu-search');
+ }
+ //-- main search menu item
+ $menu = new WT_Menu(WT_I18N::translate('Search'), 'search.php?' . $this->tree_url, 'menu-search');
+ //-- search_general sub menu
+ $submenu = new WT_Menu(WT_I18N::translate('General search'), 'search.php?' . $this->tree_url, 'menu-search-general');
+ $menu->addSubmenu($submenu);
+ //-- search_soundex sub menu
+ $submenu = new WT_Menu(/* I18N: search using “sounds like”, rather than exact spelling */
+ WT_I18N::translate('Phonetic search'), 'search.php?' . $this->tree_url . '&amp;action=soundex', 'menu-search-soundex');
+ $menu->addSubmenu($submenu);
+ //-- advanced search
+ $submenu = new WT_Menu(WT_I18N::translate('Advanced search'), 'search_advanced.php?' . $this->tree_url, 'menu-search-advanced');
+ $menu->addSubmenu($submenu);
+ //-- search_replace sub menu
+ if (WT_USER_CAN_EDIT) {
+ $submenu = new WT_Menu(WT_I18N::translate('Search and replace'), 'search.php?' . $this->tree_url . '&amp;action=replace', 'menu-search-replace');
+ $menu->addSubmenu($submenu);
+ }
+
+ return $menu;
+ }
+
+ /**
+ * Themes menu.
+ *
+ * @return WT_Menu|null
+ */
+ public function menuThemes() {
+ if ($this->tree && !$this->isSearchEngine() && WT_Site::getPreference('ALLOW_USER_THEMES') && $this->tree->getPreference('ALLOW_THEME_DROPDOWN')) {
+ $menu = new WT_Menu(WT_I18N::translate('Theme'), '#', 'menu-theme');
+ foreach (Theme::installedThemes() as $theme) {
+ $submenu = new WT_Menu($theme->themeName(), get_query_url(array('theme' => $theme->themeId()), '&amp;'), 'menu-theme-' . $theme->themeId());
+ if ($theme === $this) {
+ $submenu->addClass('', '', 'active');
+ }
+ $menu->addSubmenu($submenu);
+ }
+
+ return $menu;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Create the <link rel="canonical"> tag.
+ *
+ * @param string $url
+ *
+ * @return string
+ */
+ protected function metaCanonicalUrl($url) {
+ if ($url) {
+ return '<link rel="canonical" href="' . $url . '">';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create the <meta charset=""> tag.
+ *
+ * @return string
+ */
+ protected function metaCharset() {
+ return '<meta charset="UTF-8">';
+ }
+
+ /**
+ * Create the <meta name="description"> tag.
+ *
+ * @param string $description
+ *
+ * @return string
+ */
+ protected function metaDescription($description) {
+ if ($description) {
+ return '<meta name="description" content="' . $description . '">';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create the <meta name="generator"> tag.
+ *
+ * @param string $generator
+ *
+ * @return string
+ */
+ protected function metaGenerator($generator) {
+ if ($generator) {
+ return '<meta name="generator" content="' . $generator . '">';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create the <meta name="robots"> tag.
+ *
+ * @param string $robots
+ *
+ * @return string
+ */
+ protected function metaRobots($robots) {
+ if ($robots) {
+ return '<meta name="robots" content="' . $robots . '">';
+ } else {
+ return '';
+ }
+ }
+
+ /**
+ * Create the <meta http-equiv="X-UA-Compatible"> tag.
+ *
+ * @return string
+ */
+ protected function metaUaCompatible() {
+ return '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
+ }
+
+ /**
+ * Create the <meta name="viewport" content="width=device-width, initial-scale=1"> tag.
+ *
+ * @return string
+ */
+ protected function metaViewport() {
+ return '<meta name="viewport" content="width=device-width, initial-scale=1">';
+ }
+
+ /**
+ * Misecellaneous dimensions, fonts, styles, etc.
+ *
+ * @param string $parameter_name
+ *
+ * @return string|integer|float
+ */
+ public function parameter($parameter_name) {
+ $parameters = array(
+ 'chart-background-f' => 'dddddd',
+ 'chart-background-m' => 'cccccc',
+ 'chart-background-u' => 'eeeeee',
+ 'chart-box-x' => 250,
+ 'chart-box-y' => 80,
+ 'chart-descendancy-box-x' => 260,
+ 'chart-descendancy-box-y' => 80,
+ 'chart-descendancy-indent' => 15,
+ 'chart-font-color' => '000000',
+ 'chart-font-name' => WT_ROOT . 'includes/fonts/DejaVuSans.ttf',
+ 'chart-font-size' => 7,
+ 'chart-offset-x' => 10,
+ 'chart-offset-y' => 10,
+ 'chart-spacing-x' => 1,
+ 'chart-spacing-y' => 5,
+ 'compact-chart-box-x' => 240,
+ 'compact-chart-box-y' => 50,
+ 'distribution-chart-high-values' => '555555',
+ 'distribution-chart-low-values' => 'cccccc',
+ 'distribution-chart-no-values' => 'ffffff',
+ 'distribution-chart-x' => 440,
+ 'distribution-chart-y' => 220,
+ 'line-width' => 1.5,
+ 'shadow-blur' => 0,
+ 'shadow-color' => '',
+ 'shadow-offset-x' => 0,
+ 'shadow-offset-y' => 0,
+ 'stats-small-chart-x' => 440,
+ 'stats-small-chart-y' => 125,
+ 'stats-large-chart-x' => 900,
+ 'image-dline' => $this->assetUrl() . 'images/dline.png',
+ 'image-dline2' => $this->assetUrl() . 'images/dline2.png',
+ 'image-hline' => $this->assetUrl() . 'images/hline.png',
+ 'image-spacer' => $this->assetUrl() . 'images/spacer.png',
+ 'image-vline' => $this->assetUrl() . 'images/vline.png',
+ 'image-add' => $this->assetUrl() . 'images/add.png',
+ 'image-button_family' => $this->assetUrl() . 'images/buttons/family.png',
+ 'image-minus' => $this->assetUrl() . 'images/minus.png',
+ 'image-plus' => $this->assetUrl() . 'images/plus.png',
+ 'image-remove' => $this->assetUrl() . 'images/delete.png',
+ 'image-search' => $this->assetUrl() . 'images/go.png',
+ 'image-default_image_F' => $this->assetUrl() . 'images/silhouette_female.png',
+ 'image-default_image_M' => $this->assetUrl() . 'images/silhouette_male.png',
+ 'image-default_image_U' => $this->assetUrl() . 'images/silhouette_unknown.png',
+ );
+
+ if (array_key_exists($parameter_name, $parameters)) {
+ return $parameters[$parameter_name];
+ } else {
+ throw new \InvalidArgumentException($parameter_name);
+ }
+ }
+
+ /**
+ * Are there any pending changes for us to approve?
+ *
+ * @return bool
+ */
+ protected function pendingChangesExist() {
+ return exists_pending_change(Auth::user(), $this->tree);
+ }
+
+ /**
+ * Create a pending changes link.
+ *
+ * @return string
+ */
+ protected function pendingChangesLink() {
+ return
+ '<a href="#" onclick="window.open(\'edit_changes.php\', \'_blank\', chan_window_specs); return false;">' .
+ $this->pendingChangesLinkText() .
+ '</a>';
+ }
+
+ /**
+ * Text to use in the pending changes link.
+ *
+ * @return string
+ */
+ protected function pendingChangesLinkText() {
+ return WT_I18N::translate('There are pending changes for you to moderate.');
+ }
+
+ /**
+ * Generate a list of items for the main menu.
+ *
+ * @return WT_Menu[]
+ */
+ protected function primaryMenu() {
+ global $controller;
+
+ if ($this->tree) {
+ $individual = $controller->getSignificantIndividual();
+
+ return array_filter(array_merge(array(
+ $this->menuHomePage(),
+ $this->menuMyMenu(),
+ $this->menuChart($individual),
+ $this->menuLists(),
+ $this->menuCalendar(),
+ $this->menuReports(),
+ $this->menuSearch(),
+ ), $this->menuModules()));
+ } else {
+ // No public trees? No genealogy menu!
+ return array();
+ }
+ }
+
+ /**
+ * Add markup to the primary menu.
+ *
+ * @param WT_Menu[] $menus
+ *
+ * @return string
+ */
+ protected function primaryMenuContainer(array $menus) {
+ $html = '';
+ foreach ($menus as $menu) {
+ $html .= $menu->getMenuAsList();
+ }
+
+ return '<nav><ul class="primary-menu">' . $html . '</ul></nav>';
+ }
+
+ /**
+ * Generate a list of items for the user menu.
+ *
+ * @return WT_Menu[]
+ */
+ protected function secondaryMenu() {
+ return array_filter(array(
+ $this->menuPendingChanges(),
+ $this->menuLogin(),
+ $this->menuMyAccount(),
+ $this->menuLogout(),
+ $this->menuFavorites(),
+ $this->menuLanguages(),
+ $this->menuThemes(),
+ ));
+ }
+
+ /**
+ * Add markup to the secondary menu.
+ *
+ * @param WT_Menu[] $menus
+ *
+ * @return string
+ */
+ protected function secondaryMenuContainer(array $menus) {
+ $html = '';
+ foreach ($menus as $menu) {
+ $html .= $menu->getMenuAsList();
+ }
+
+ return '<ul class="nav nav-pills secondary-menu">' . $html . '</ul>';
+ }
+
+ /**
+ * Send any HTTP headers.
+ *
+ * @return void
+ */
+ public function sendHeaders() {
+ header('Content-Type: text/html; charset=UTF-8');
+ }
+
+ /**
+ * A list of CSS files to include for this page.
+ *
+ * @return string[]
+ */
+ protected function stylesheets() {
+ return array();
+ }
+
+ /**
+ * A fixed string to identify this theme, in settings, etc.
+ *
+ * @return string
+ */
+ abstract public function themeId();
+
+ /**
+ * What is this theme called?
+ *
+ * @return string
+ */
+ abstract public function themeName();
+
+ /**
+ * Create the <title> tag.
+ *
+ * @param string $title
+ *
+ * @return string
+ */
+ protected function title($title) {
+ return '<title>' . WT_Filter::escapeHtml($title) . '</title>';
+ }
+}
diff --git a/library/WT/Theme/Clouds.php b/library/WT/Theme/Clouds.php
new file mode 100644
index 0000000000..f6dc84649d
--- /dev/null
+++ b/library/WT/Theme/Clouds.php
@@ -0,0 +1,135 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT\Theme;
+use WT_I18N;
+use WT_Menu;
+
+/**
+ * Class Clouds - The clouds theme.
+ */
+class Clouds extends BaseTheme {
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/clouds/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function favicon() {
+ return '<link rel="icon" href="' . $this->assetUrl() . 'favicon.png" type="image/png">';
+ }
+
+ /** {@inheritdoc} */
+ protected function flashMessageContainer(\stdClass $message) {
+ // This theme uses jQuery markup.
+ return '<p class="ui-state-highlight">' . $message->text . '</p>';
+ }
+
+ /** {@inheritdoc} */
+ public function formatBlock($id, $title, $class, $content) {
+ return
+ '<div id="' . $id . '" class="block" >' .
+ '<table class="blockheader"><tr><td class="blockh1"></td><td class="blockh2">' .
+ '<div class="blockhc"><b>' . $title . '</b></div>' .
+ '</td><td class="blockh3"></td></tr></table>' .
+ '<div class="blockcontent normal_inner_block ' . $class . '">' . $content . '</div>' .
+ '</div>';
+ }
+
+ /** {@inheritdoc} */
+ protected function formQuickSearchFields() {
+ return
+ '<input type="search" name="query" size="15" placeholder="' . WT_I18N::translate('Search') . '">' .
+ '<input class="search-icon" type="image" src="' . Theme::theme()->parameter('image-search') . '" alt="' . WT_I18N::translate('Search') . '" title="' . WT_I18N::translate('Search') . '">';
+ }
+
+ /** {@inheritdoc} */
+ public function hookFooterExtraJavascript() {
+ return
+ '<script src="' . WT_JQUERY_COLORBOX_URL . '"></script>' .
+ '<script src="' . WT_JQUERY_WHEELZOOM_URL . '"></script>' .
+ '<script>' .
+ 'activate_colorbox();' .
+ 'jQuery.extend(jQuery.colorbox.settings, {' .
+ ' width: "85%",' .
+ ' height: "85%",' .
+ ' transition: "none",' .
+ ' slideshowStart: "' . WT_I18N::translate('Play') . '",' .
+ ' slideshowStop: "' . WT_I18N::translate('Stop') . '",' .
+ ' title: function() { return jQuery(this).data("title"); }' .
+ '});' .
+ '</script>';
+ }
+
+ /** {@inheritdoc} */
+ public function parameter($parameter_name) {
+ $parameters = array(
+ 'chart-background-f' => 'e9daf1',
+ 'chart-background-m' => 'b1cff0',
+ 'chart-descendancy-box-x' => 250,
+ 'chart-spacing-x' => 4,
+ 'distribution-chart-high-values' => '95b8e0',
+ 'distribution-chart-low-values' => 'c8e7ff',
+ );
+
+ if (array_key_exists($parameter_name, $parameters)) {
+ return $parameters[$parameter_name];
+ } else {
+ return parent::parameter($parameter_name);
+ }
+ }
+
+ /** {@inheritdoc} */
+ protected function primaryMenuContainer(array $menus) {
+ $html = '';
+
+ foreach ($menus as $menu) {
+ // Create an inert menu - to use as a label
+ $tmp = new WT_Menu(strip_tags($menu->getLabel()), '');
+
+ // Insert the label into the submenu
+ $submenus = $menu->getSubmenus();
+ array_unshift($submenus, $tmp);
+ $menu->setSubmenus($submenus);
+
+ $html .= $menu->getMenuAsList();
+ }
+
+ return '<ul class="primary-menu">' . $html . '</ul>';
+ }
+
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ 'themes/clouds/jquery-ui-1.11.2/jquery-ui.css',
+ $this->assetUrl() . 'style.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return 'clouds';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return /* I18N: Name of a theme. */ WT_I18N::translate('clouds');
+ }
+}
diff --git a/library/WT/Theme/Colors.php b/library/WT/Theme/Colors.php
new file mode 100644
index 0000000000..de7d683a35
--- /dev/null
+++ b/library/WT/Theme/Colors.php
@@ -0,0 +1,173 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT\Auth;
+use WT\Theme;
+use WT_I18N;
+use WT_Menu;
+use WT_Site;
+
+/**
+ * Class Colors - The colors theme.
+ */
+class Colors extends Clouds {
+ /** @var string[] A list of color palettes */
+ protected $sub_colors;
+
+ /** @var string Which of the color palettes to use on this page */
+ protected $sub_color;
+
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/colors/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function formatSecondaryMenu() {
+ return
+ '<ul class="secondary-menu">' .
+ implode('', $this->secondaryMenu()) .
+ '<li>' .
+ $this->formQuickSearch() .
+ '</li>' .
+ '</ul>';
+ }
+
+ /** {@inheritdoc} */
+ protected function headerContent() {
+ return
+ $this->formatTreeTitle() .
+ $this->formatSecondaryMenu();
+ }
+
+ /**
+ * Create resources for the colors theme.
+ *
+ * {@inheritdoc}
+ */
+ public function hookAfterInit() {
+ $this->sub_colors = array(
+ 'aquamarine' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Aqua Marine'),
+ 'ash' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Ash'),
+ 'belgianchocolate'=> /* I18N: The name of a colour-scheme */ WT_I18N::translate('Belgian Chocolate'),
+ 'bluelagoon' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Blue Lagoon'),
+ 'bluemarine' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Blue Marine'),
+ 'coffeeandcream' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Coffee and Cream'),
+ 'coldday' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Cold Day'),
+ 'greenbeam' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Green Beam'),
+ 'mediterranio' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Mediterranio'),
+ 'mercury' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Mercury'),
+ 'nocturnal' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Nocturnal'),
+ 'olivia' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Olivia'),
+ 'pinkplastic' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Pink Plastic'),
+ 'sage' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Sage'),
+ 'shinytomato' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Shiny Tomato'),
+ 'tealtop' => /* I18N: The name of a colour-scheme */ WT_I18N::translate('Teal Top'),
+ );
+ uasort($this->sub_colors, array('WT_I18N', 'strcasecmp'));
+
+ // If we've selected a new palette, and we are logged in, set this value as a default.
+ if (isset($_GET['themecolor']) && array_key_exists($_GET['themecolor'], $this->sub_colors)) {
+ // Request to change color
+ $this->sub_color = $_GET['themecolor'];
+ Auth::user()->setPreference('themecolor', $this->sub_color);
+ if (Auth::isAdmin()) {
+ WT_Site::setPreference('DEFAULT_COLOR_PALETTE', $this->sub_color);
+ }
+ unset($_GET['themecolor']);
+ // Rember that we have selected a value
+ $this->session->subColor = $this->sub_color;
+ }
+ // If we are logged in, use our preference
+ $this->sub_color = Auth::user()->getPreference('themecolor');
+ // If not logged in or no preference, use one we selected earlier in the session?
+ if (!$this->sub_color) {
+ $this->sub_color = $this->session->subColor;
+ }
+ // We haven't selected one this session? Use the site default
+ if (!$this->sub_color) {
+ $this->sub_color = WT_Site::getPreference('DEFAULT_COLOR_PALETTE');
+ }
+ // Make sure our selected palette actually exists
+ if (!array_key_exists($this->sub_color, $this->sub_colors)) {
+ $this->sub_color = 'ash';
+ }
+ }
+
+ /**
+ * Generate a list of items for the user menu.
+ *
+ * @return WT_Menu[]
+ */
+ protected function secondaryMenu() {
+ $menubar = parent::secondaryMenu();
+ $menubar[] = $this->menuPalette();
+
+ return $menubar;
+ }
+
+ /**
+ * Create a menu of palette options
+ *
+ * @return WT_Menu
+ */
+ protected function menuPalette() {
+ $menu = new WT_Menu(/* I18N: A colour scheme */ WT_I18N::translate('Palette'), '#', 'menu-color');
+
+ foreach ($this->sub_colors as $colorChoice => $color_name) {
+ $submenu = new WT_Menu($color_name, get_query_url(array('themecolor' => $colorChoice), '&amp;'), 'menu-color-' . $colorChoice);
+ if ($this->session->subColor) {
+ if ($this->session->subColor === $colorChoice) {
+ $submenu->addClass('', '', 'theme-active');
+ }
+ } elseif (WT_Site::getPreference('DEFAULT_COLOR_PALETTE') === $colorChoice) {
+ // here when visitor changes palette from default
+ $submenu->addClass('', '', 'theme-active');
+ } elseif ($this->sub_color === 'ash') {
+ // here when site has different theme as default and user switches to colors
+ if ($this->sub_color === $colorChoice) {
+ $submenu->addClass('', '', 'theme-active');
+ }
+ }
+ $menu->addSubmenu($submenu);
+ }
+
+ return $menu;
+ }
+
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ 'themes/colors/jquery-ui-1.11.2/jquery-ui.css',
+ $this->assetUrl() . 'style.css',
+ $this->assetUrl() . 'palette/' . $this->sub_color . '.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return 'colors';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return /* I18N: Name of a theme. */ WT_I18N::translate('colors');
+ }
+}
diff --git a/library/WT/Theme/Fab.php b/library/WT/Theme/Fab.php
new file mode 100644
index 0000000000..07e19763e5
--- /dev/null
+++ b/library/WT/Theme/Fab.php
@@ -0,0 +1,126 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT_I18N;
+use WT_Menu;
+
+/**
+ * Class Fab - The F.A.B. theme.
+ */
+class Fab extends BaseTheme {
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/fab/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function favicon() {
+ return '<link rel="icon" href="' . $this->assetUrl() . 'favicon.png" type="image/png">';
+ }
+
+ /** {@inheritdoc} */
+ protected function flashMessageContainer(\stdClass $message) {
+ // This theme uses jQuery markup.
+ return '<p class="ui-state-highlight">' . $message->text . '</p>';
+ }
+
+ /** {@inheritdoc} */
+ protected function formatSecondaryMenu() {
+ return
+ '<ul class="secondary-menu">' .
+ implode('', $this->secondaryMenu()) .
+ '<li>' .
+ $this->formQuickSearch() .
+ '</li>' .
+ '</ul>';
+ }
+ /** {@inheritdoc} */
+ protected function headerContent() {
+ return
+ $this->formatTreeTitle() .
+ $this->formatSecondaryMenu();
+ }
+
+ /** {@inheritdoc} */
+ protected function formatUserMenuItem(WT_Menu $menu) {
+ return $menu->getMenuAsList();
+ }
+
+ /** {@inheritdoc} */
+ protected function formQuickSearchFields() {
+ return
+ '<input type="search" name="query" size="20" placeholder="' . WT_I18N::translate('Search') . '">';
+ }
+
+ /** {@inheritdoc} */
+ public function hookFooterExtraJavascript() {
+ return
+ '<script src="' . WT_JQUERY_COLORBOX_URL . '"></script>' .
+ '<script src="' . WT_JQUERY_WHEELZOOM_URL . '"></script>' .
+ '<script>' .
+ 'activate_colorbox();' .
+ 'jQuery.extend(jQuery.colorbox.settings, {' .
+ ' width: "85%",' .
+ ' height: "85%",' .
+ ' transition: "none",' .
+ ' slideshowStart: "' . WT_I18N::translate('Play') . '",' .
+ ' slideshowStop: "' . WT_I18N::translate('Stop') . '",' .
+ ' title: function() { return jQuery(this).data("title"); }' .
+ '});' .
+ '</script>';
+ }
+
+ /** {@inheritdoc} */
+ public function parameter($parameter_name) {
+ $parameters = array(
+ 'chart-background-f' => 'e9daf1',
+ 'chart-background-m' => 'b1cff0',
+ 'chart-box-x' => 260,
+ 'chart-descendancy-box-x' => 290,
+ 'chart-spacing-x' => 0,
+ 'distribution-chart-high-values' => '9ca3d4',
+ 'distribution-chart-low-values' => 'e5e6ef',
+ );
+
+ if (array_key_exists($parameter_name, $parameters)) {
+ return $parameters[$parameter_name];
+ } else {
+ return parent::parameter($parameter_name);
+ }
+ }
+
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ 'themes/fab/jquery-ui-1.11.2/jquery-ui.css',
+ $this->assetUrl() . 'style.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return 'fab';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return /* I18N: Name of a theme. */ WT_I18N::translate('F.A.B.');
+ }
+}
diff --git a/library/WT/Theme/Minimal.php b/library/WT/Theme/Minimal.php
new file mode 100644
index 0000000000..b1beddf8c4
--- /dev/null
+++ b/library/WT/Theme/Minimal.php
@@ -0,0 +1,123 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT_I18N;
+
+/**
+ * Class Minimal - The Minimal theme.
+ */
+class Minimal extends BaseTheme {
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/minimal/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function favicon() {
+ return '<link rel="icon" href="' . $this->assetUrl() . 'favicon.png" type="image/png">';
+ }
+
+ /** {@inheritdoc} */
+ protected function flashMessageContainer(\stdClass $message) {
+ // This theme uses jQuery markup.
+ return '<p class="ui-state-highlight">' . $message->text . '</p>';
+ }
+
+ /** {@inheritdoc} */
+ protected function formQuickSearchFields() {
+ return
+ '<input type="search" name="query" size="20" placeholder="' . WT_I18N::translate('Search') . '">';
+ }
+
+ /** {@inheritdoc} */
+ protected function formatSecondaryMenu() {
+ return
+ '<ul class="secondary-menu">' .
+ implode('', $this->secondaryMenu()) .
+ '<li>' .
+ $this->formQuickSearch() .
+ '</li>' .
+ '</ul>';
+ }
+ /** {@inheritdoc} */
+ protected function headerContent() {
+ return
+ $this->formatTreeTitle() .
+ $this->formatSecondaryMenu();
+ }
+
+ /** {@inheritdoc} */
+ protected function logoPoweredBy() {
+ return '<a href="' . WT_WEBTREES_URL . '" class="powered-by-webtrees" title="' . WT_WEBTREES_URL . '">' . WT_WEBTREES . '</a>';
+ }
+
+ /** {@inheritdoc} */
+ public function hookFooterExtraJavascript() {
+ return
+ '<script src="' . WT_JQUERY_COLORBOX_URL . '"></script>' .
+ '<script src="' . WT_JQUERY_WHEELZOOM_URL . '"></script>' .
+ '<script>' .
+ 'activate_colorbox();' .
+ 'jQuery.extend(jQuery.colorbox.settings, {' .
+ ' width: "85%",' .
+ ' height: "85%",' .
+ ' transition: "none",' .
+ ' slideshowStart: "' . WT_I18N::translate('Play') . '",' .
+ ' slideshowStop: "' . WT_I18N::translate('Stop') . '"' .
+ ' title: function() { return jQuery(this).data("title"); }' .
+ '});' .
+ '</script>';
+ }
+
+ /** {@inheritdoc} */
+ public function parameter($parameter_name) {
+ $parameters = array(
+ 'chart-background-f' => 'dddddd',
+ 'chart-background-m' => 'cccccc',
+ 'chart-spacing-x' => 0,
+ 'distribution-chart-low-values' => 'cccccc',
+ 'distribution-chart-no-values' => 'ffffff',
+ );
+
+ if (array_key_exists($parameter_name, $parameters)) {
+ return $parameters[$parameter_name];
+ } else {
+ return parent::parameter($parameter_name);
+ }
+ }
+
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ 'themes/minimal/jquery-ui-1.11.2/jquery-ui.css',
+ $this->assetUrl() . 'style.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return 'minimal';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return /* I18N: Name of a theme. */ WT_I18N::translate('minimal');
+ }
+}
diff --git a/library/WT/Theme/Webtrees.php b/library/WT/Theme/Webtrees.php
new file mode 100644
index 0000000000..f6804195b4
--- /dev/null
+++ b/library/WT/Theme/Webtrees.php
@@ -0,0 +1,103 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT\Theme;
+use WT_I18N;
+
+/**
+ * Class Webtrees - The webtrees (default) theme.
+ */
+class Webtrees extends BaseTheme {
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/webtrees/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function favicon() {
+ return '<link rel="icon" href="' . $this->assetUrl() . 'favicon.png" type="image/png">';
+ }
+
+ /** {@inheritdoc} */
+ protected function flashMessageContainer(\stdClass $message) {
+ // This theme uses jQuery markup.
+ return '<p class="ui-state-highlight">' . $message->text . '</p>';
+ }
+
+ /** {@inheritdoc} */
+ protected function formQuickSearchFields() {
+ return
+ '<input type="search" name="query" size="25" placeholder="' . WT_I18N::translate('Search') . '">' .
+ '<input type="image" class="image" src="' . Theme::theme()->parameter('image-search') . '" alt="' . WT_I18N::translate('Search') . '" title="' . WT_I18N::translate('Search') . '">';
+ }
+
+ /** {@inheritdoc} */
+ public function hookFooterExtraJavascript() {
+ return
+ '<script src="' . WT_JQUERY_COLORBOX_URL . '"></script>' .
+ '<script src="' . WT_JQUERY_WHEELZOOM_URL . '"></script>' .
+ '<script>' .
+ 'activate_colorbox();' .
+ 'jQuery.extend(jQuery.colorbox.settings, {' .
+ ' width:"85%",' .
+ ' height:"85%",' .
+ ' transition:"none",' .
+ ' slideshowStart:"' . WT_I18N::translate('Play') . '",' .
+ ' slideshowStop:"' . WT_I18N::translate('Stop') . '",' .
+ ' title: function() { return jQuery(this).data("title"); }' .
+ '});' .
+ '</script>';
+ }
+
+ /** {@inheritdoc} */
+ public function parameter($parameter_name) {
+ $parameters = array(
+ 'chart-background-f' => 'e9daf1',
+ 'chart-background-m' => 'b1cff0',
+ 'distribution-chart-high-values' => '84beff',
+ 'distribution-chart-low-values' => 'c3dfff',
+ 'image-search' => $this->assetUrl() . 'images/search.png',
+ );
+
+ if (array_key_exists($parameter_name, $parameters)) {
+ return $parameters[$parameter_name];
+ } else {
+ return parent::parameter($parameter_name);
+ }
+ }
+
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ 'themes/webtrees/jquery-ui-1.11.2/jquery-ui.css',
+ $this->assetUrl() . 'style.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return 'webtrees';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return WT_I18N::translate('webtrees');
+ }
+}
diff --git a/library/WT/Theme/Xenea.php b/library/WT/Theme/Xenea.php
new file mode 100644
index 0000000000..f15e4eb522
--- /dev/null
+++ b/library/WT/Theme/Xenea.php
@@ -0,0 +1,113 @@
+<?php
+// webtrees: Web based Family History software
+// Copyright (C) 2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+namespace WT\Theme;
+
+use WT_I18N;
+
+/**
+ * Class Xenea - The xenea theme.
+ */
+class Xenea extends BaseTheme {
+ /** {@inheritdoc} */
+ public function assetUrl() {
+ return 'themes/xenea/css-1.7.0/';
+ }
+
+ /** {@inheritdoc} */
+ protected function favicon() {
+ return '<link rel="icon" href="' . $this->assetUrl() . 'favicon.png" type="image/png">';
+ }
+
+ /** {@inheritdoc} */
+ protected function flashMessageContainer(\stdClass $message) {
+ // This theme uses jQuery markup.
+ return '<p class="ui-state-highlight">' . $message->text . '</p>';
+ }
+
+ /** {@inheritdoc} */
+ protected function formQuickSearchFields() {
+ return
+ '<input type="search" name="query" size="12" placeholder="' . WT_I18N::translate('Search') . '">' .
+ '<input type="submit" name="search" value="&gt;">';
+ }
+
+ /** {@inheritdoc} */
+ protected function headerContent() {
+ return
+ '<div class="header-upper">' .
+ $this->formatTreeTitle() .
+ $this->formQuickSearch() .
+ '</div>' .
+ '<div class="header-lower">' .
+ $this->formatSecondaryMenu() .
+ '</div>';
+ }
+
+ /** {@inheritdoc} */
+ public function hookFooterExtraJavascript() {
+ return
+ '<script src="' . WT_JQUERY_COLORBOX_URL . '"></script>' .
+ '<script src="' . WT_JQUERY_WHEELZOOM_URL . '"></script>' .
+ '<script>' .
+ 'activate_colorbox();' .
+ 'jQuery.extend(jQuery.colorbox.settings, {' .
+ ' width: "85%",' .
+ ' height: "85%",' .
+ ' transition: "none",' .
+ ' slideshowStart: "' . WT_I18N::translate('Play') . '",' .
+ ' slideshowStop: "' . WT_I18N::translate('Stop') . '",' .
+ ' title: function() { return jQuery(this).data("title"); }' .
+ '});' .
+ '</script>';
+ }
+
+ /** {@inheritdoc} */
+ public function parameter($parameter_name) {
+ $parameters = array(
+ 'chart-background-f' => 'e9daf1',
+ 'chart-background-m' => 'b1cff0',
+ 'distribution-chart-high-values' => '84beff',
+ 'distribution-chart-low-values' => 'c3dfff',
+ );
+
+ if (array_key_exists($parameter_name, $parameters)) {
+ return $parameters[$parameter_name];
+ } else {
+ return parent::parameter($parameter_name);
+ }
+ }
+
+ /** {@inheritdoc} */
+ protected function stylesheets() {
+ return array(
+ 'themes/xenea/jquery-ui-1.11.2/jquery-ui.css',
+ $this->assetUrl() . 'style.css',
+ );
+ }
+
+ /** {@inheritdoc} */
+ public function themeId() {
+ return 'xenea';
+ }
+
+ /** {@inheritdoc} */
+ public function themeName() {
+ return /* I18N: Name of a theme. */ WT_I18N::translate('xenea');
+ }
+}
diff --git a/library/WT/Tree.php b/library/WT/Tree.php
index 35eb7fb40f..fd21f661a4 100644
--- a/library/WT/Tree.php
+++ b/library/WT/Tree.php
@@ -96,17 +96,17 @@ class WT_Tree {
// Update the database
if ($setting_value === null) {
WT_DB::prepare(
- "DELETE FROM `##gedcom_setting` WHERE gedcom_id = :gedcom_id AND setting_name = :setting_name"
+ "DELETE FROM `##gedcom_setting` WHERE gedcom_id = :tree_id AND setting_name = :setting_name"
)->execute(array(
- 'gedcom_id' => $this->tree_id,
+ 'tree_id' => $this->tree_id,
'setting_name' => $setting_name,
));
} else {
WT_DB::prepare(
"REPLACE INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" .
- " VALUES (:gedcom_id, :setting_name, LEFT(:setting_value, 255))"
+ " VALUES (:tree_id, :setting_name, LEFT(:setting_value, 255))"
)->execute(array(
- 'gedcom_id' => $this->tree_id,
+ 'tree_id' => $this->tree_id,
'setting_name' => $setting_name,
'setting_value' => $setting_value,
));
@@ -157,9 +157,24 @@ class WT_Tree {
public function setUserPreference(User $user, $setting_name, $setting_value) {
if ($this->getUserPreference($user, $setting_name) !== $setting_value) {
// Update the database
- WT_DB::prepare(
- "REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, LEFT(?, 255))"
- )->execute(array($user->getUserId(), $this->tree_id, $setting_name, $setting_value));
+ if ($setting_value === null) {
+ WT_DB::prepare(
+ "DELETE FROM `##user_gedcom_setting` WHERE gedcom_id = :tree_id AND user_id = :user_id AND setting_name = :setting_name"
+ )->execute(array(
+ 'tree_id' => $this->tree_id,
+ 'user_id' => $user->getUserId(),
+ 'setting_name' => $setting_name,
+ ));
+ } else {
+ WT_DB::prepare(
+ "REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (:user_id, :tree_id, :setting_name, LEFT(:setting_value, 255))"
+ )->execute(array(
+ 'user_id' => $user->getUserId(),
+ 'tree_id' => $this->tree_id,
+ 'setting_name' => $setting_name,
+ 'setting_value' => $setting_value
+ ));
+ }
// Update our cache
$this->user_preferences[$user->getUserId()][$setting_name] = $setting_value;
// Audit log of changes
@@ -196,11 +211,11 @@ class WT_Tree {
" LEFT JOIN `##gedcom_setting` gs3 ON (g.gedcom_id=gs3.gedcom_id AND gs3.setting_name='REQUIRE_AUTHENTICATION')" .
" LEFT JOIN `##user_gedcom_setting` ugs ON (g.gedcom_id=ugs.gedcom_id AND ugs.setting_name='canedit' AND ugs.user_id=?)" .
" WHERE " .
- " g.gedcom_id>0 AND (". // exclude the "template" tree
+ " g.gedcom_id>0 AND (" . // exclude the "template" tree
" EXISTS (SELECT 1 FROM `##user_setting` WHERE user_id=? AND setting_name='canadmin' AND setting_value=1)" . // Admin sees all
" ) OR (" .
- " gs2.setting_value = 1 AND (". // Allow imported trees, with either:
- " gs3.setting_value <> 1 OR" . // visitor access
+ " gs2.setting_value = 1 AND (" . // Allow imported trees, with either:
+ " gs3.setting_value <> 1 OR" . // visitor access
" IFNULL(ugs.setting_value, 'none')<>'none'" . // explicit access
" )" .
" )" .
@@ -289,16 +304,20 @@ class WT_Tree {
* Create a new tree
*
* @param string $tree_name
+ * @param string $tree_title
*
* @return void
*/
- public static function create($tree_name) {
+ public static function create($tree_name, $tree_title) {
try {
// Create a new tree
WT_DB::prepare(
"INSERT INTO `##gedcom` (gedcom_name) VALUES (?)"
)->execute(array($tree_name));
$tree_id = WT_DB::prepare("SELECT LAST_INSERT_ID()")->fetchOne();
+ WT_DB::prepare(
+ "INSERT INTO `##gedcom_setting` (gedcom_id, setting_name) VALUES (?, ?)"
+ )->execute(array($tree_id, $tree_title));
} catch (PDOException $ex) {
// A tree with that name already exists?
return;
@@ -422,7 +441,7 @@ class WT_Tree {
$tree->setPreference('WEBTREES_EMAIL', '');
$tree->setPreference('WORD_WRAPPED_NOTES', '0');
$tree->setPreference('imported', '0');
- $tree->setPreference('title', /* I18N: Default title for new family trees */ WT_I18N::translate('My family tree'));
+ $tree->setPreference('title', /* I18N: Default title for new family trees */ WT_I18N::translate('My family tree'));
// Default restriction settings
$statement = WT_DB::prepare(
@@ -436,7 +455,7 @@ class WT_Tree {
// Genealogy data
// It is simpler to create a temporary/unimported GEDCOM than to populate all the tables...
- $john_doe =/* I18N: This should be a common/default/placeholder name of an individual. Put slashes around the surname. */
+ $john_doe = /* I18N: This should be a common/default/placeholder name of an individual. Put slashes around the surname. */
WT_I18N::translate('John /DOE/');
$note = WT_I18N::translate('Edit this individual and replace their details with your own');
WT_DB::prepare("INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data) VALUES (?, ?)")->execute(array(
diff --git a/library/WT/User.php b/library/WT/User.php
index 51d91e1cbf..18fafd8ba6 100644
--- a/library/WT/User.php
+++ b/library/WT/User.php
@@ -8,7 +8,7 @@ use WT_Tree;
/**
* Class User - Provide an interface to the wt_user table.
*
- * @copyright (c) 2014 webtrees development team
+ * @copyright (c) 2015 webtrees development team
* @license 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
@@ -150,7 +150,7 @@ class User {
* @return integer
*/
public static function count() {
- return (int)WT_DB::prepare(
+ return (int) WT_DB::prepare(
"SELECT SQL_CACHE COUNT(*)" .
" FROM `##user`" .
" WHERE user_id > 0"
@@ -203,14 +203,37 @@ class User {
}
/**
+ * Get a list of all verified uses.
+ *
+ * @return User[]
+ */
+ public static function allVerified() {
+ $rows = WT_DB::prepare(
+ "SELECT SQL_CACHE user_id, user_name, real_name, email" .
+ " FROM `##user`" .
+ " JOIN `##user_setting` USING (user_id)" .
+ " WHERE user_id > 0" .
+ " AND setting_name = 'verified'" .
+ " AND setting_value = '1'"
+ )->fetchAll();
+
+ $users = array();
+ foreach ($rows as $row) {
+ $users[] = new User($row);
+ }
+
+ return $users;
+ }
+
+ /**
* Get a list of all users who are currently logged in.
*
* @return User[]
*/
public static function allLoggedIn() {
$rows = WT_DB::prepare(
- "SELECT SQL_NO_CACHE DISTINCT user_id, user_name, real_name, email".
- " FROM `##user`".
+ "SELECT SQL_NO_CACHE DISTINCT user_id, user_name, real_name, email" .
+ " FROM `##user`" .
" JOIN `##session` USING (user_id)"
)->fetchAll();