@@ -26,116 +26,116 @@ |
||
26 | 26 | * Class UserJournalModule |
27 | 27 | */ |
28 | 28 | class UserJournalModule extends AbstractModule implements ModuleBlockInterface { |
29 | - /** |
|
30 | - * Create a new module. |
|
31 | - * |
|
32 | - * @param string $directory Where is this module installed |
|
33 | - */ |
|
34 | - public function __construct($directory) { |
|
35 | - parent::__construct($directory); |
|
36 | - |
|
37 | - // Create/update the database tables. |
|
38 | - Database::updateSchema('\Fisharebest\Webtrees\Module\FamilyTreeNews\Schema', 'NB_SCHEMA_VERSION', 3); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * How should this module be labelled on tabs, menus, etc.? |
|
43 | - * |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function getTitle() { |
|
47 | - return /* I18N: Name of a module */ I18N::translate('Journal'); |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * A sentence describing what this module does. |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function getDescription() { |
|
56 | - return /* I18N: Description of the “Journal” module */ I18N::translate('A private area to record notes or keep a journal.'); |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * Generate the HTML content of this block. |
|
61 | - * |
|
62 | - * @param int $block_id |
|
63 | - * @param bool $template |
|
64 | - * @param string[] $cfg |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
69 | - global $ctype, $WT_TREE; |
|
70 | - |
|
71 | - switch (Filter::get('action')) { |
|
72 | - case 'deletenews': |
|
73 | - $news_id = Filter::getInteger('news_id'); |
|
74 | - if ($news_id) { |
|
75 | - Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); |
|
76 | - } |
|
77 | - break; |
|
78 | - } |
|
79 | - |
|
80 | - $articles = Database::prepare( |
|
81 | - "SELECT news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE user_id = :user_id ORDER BY updated DESC" |
|
82 | - )->execute(array( |
|
83 | - 'offset' => WT_TIMESTAMP_OFFSET, |
|
84 | - 'user_id' => Auth::id(), |
|
85 | - ))->fetchAll(); |
|
86 | - |
|
87 | - $id = $this->getName() . $block_id; |
|
88 | - $class = $this->getName() . '_block'; |
|
89 | - $title = $this->getTitle(); |
|
90 | - $content = ''; |
|
91 | - |
|
92 | - if (empty($articles)) { |
|
93 | - $content .= '<p>' . I18N::translate('You have not created any journal items.') . '</p>'; |
|
94 | - } |
|
95 | - |
|
96 | - foreach ($articles as $article) { |
|
97 | - $content .= '<div class="journal_box">'; |
|
98 | - $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>'; |
|
99 | - $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>'; |
|
100 | - if ($article->body == strip_tags($article->body)) { |
|
101 | - $article->body = nl2br($article->body, false); |
|
102 | - } |
|
103 | - $content .= $article->body; |
|
104 | - $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a>'; |
|
105 | - $content .= ' | '; |
|
106 | - $content .= '<a href="index.php?action=deletenews&news_id=' . $article->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>'; |
|
107 | - $content .= '</div><br>'; |
|
108 | - } |
|
109 | - |
|
110 | - $content .= '<p><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a journal entry') . '</a></p>'; |
|
111 | - |
|
112 | - if ($template) { |
|
113 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
114 | - } else { |
|
115 | - return $content; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - /** {@inheritdoc} */ |
|
120 | - public function loadAjax() { |
|
121 | - return false; |
|
122 | - } |
|
123 | - |
|
124 | - /** {@inheritdoc} */ |
|
125 | - public function isUserBlock() { |
|
126 | - return true; |
|
127 | - } |
|
128 | - |
|
129 | - /** {@inheritdoc} */ |
|
130 | - public function isGedcomBlock() { |
|
131 | - return false; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * An HTML form to edit block settings |
|
136 | - * |
|
137 | - * @param int $block_id |
|
138 | - */ |
|
139 | - public function configureBlock($block_id) { |
|
140 | - } |
|
29 | + /** |
|
30 | + * Create a new module. |
|
31 | + * |
|
32 | + * @param string $directory Where is this module installed |
|
33 | + */ |
|
34 | + public function __construct($directory) { |
|
35 | + parent::__construct($directory); |
|
36 | + |
|
37 | + // Create/update the database tables. |
|
38 | + Database::updateSchema('\Fisharebest\Webtrees\Module\FamilyTreeNews\Schema', 'NB_SCHEMA_VERSION', 3); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * How should this module be labelled on tabs, menus, etc.? |
|
43 | + * |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function getTitle() { |
|
47 | + return /* I18N: Name of a module */ I18N::translate('Journal'); |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * A sentence describing what this module does. |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function getDescription() { |
|
56 | + return /* I18N: Description of the “Journal” module */ I18N::translate('A private area to record notes or keep a journal.'); |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * Generate the HTML content of this block. |
|
61 | + * |
|
62 | + * @param int $block_id |
|
63 | + * @param bool $template |
|
64 | + * @param string[] $cfg |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
69 | + global $ctype, $WT_TREE; |
|
70 | + |
|
71 | + switch (Filter::get('action')) { |
|
72 | + case 'deletenews': |
|
73 | + $news_id = Filter::getInteger('news_id'); |
|
74 | + if ($news_id) { |
|
75 | + Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); |
|
76 | + } |
|
77 | + break; |
|
78 | + } |
|
79 | + |
|
80 | + $articles = Database::prepare( |
|
81 | + "SELECT news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE user_id = :user_id ORDER BY updated DESC" |
|
82 | + )->execute(array( |
|
83 | + 'offset' => WT_TIMESTAMP_OFFSET, |
|
84 | + 'user_id' => Auth::id(), |
|
85 | + ))->fetchAll(); |
|
86 | + |
|
87 | + $id = $this->getName() . $block_id; |
|
88 | + $class = $this->getName() . '_block'; |
|
89 | + $title = $this->getTitle(); |
|
90 | + $content = ''; |
|
91 | + |
|
92 | + if (empty($articles)) { |
|
93 | + $content .= '<p>' . I18N::translate('You have not created any journal items.') . '</p>'; |
|
94 | + } |
|
95 | + |
|
96 | + foreach ($articles as $article) { |
|
97 | + $content .= '<div class="journal_box">'; |
|
98 | + $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>'; |
|
99 | + $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>'; |
|
100 | + if ($article->body == strip_tags($article->body)) { |
|
101 | + $article->body = nl2br($article->body, false); |
|
102 | + } |
|
103 | + $content .= $article->body; |
|
104 | + $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a>'; |
|
105 | + $content .= ' | '; |
|
106 | + $content .= '<a href="index.php?action=deletenews&news_id=' . $article->news_id . '&ctype=' . $ctype . '&ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>'; |
|
107 | + $content .= '</div><br>'; |
|
108 | + } |
|
109 | + |
|
110 | + $content .= '<p><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a journal entry') . '</a></p>'; |
|
111 | + |
|
112 | + if ($template) { |
|
113 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
114 | + } else { |
|
115 | + return $content; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + /** {@inheritdoc} */ |
|
120 | + public function loadAjax() { |
|
121 | + return false; |
|
122 | + } |
|
123 | + |
|
124 | + /** {@inheritdoc} */ |
|
125 | + public function isUserBlock() { |
|
126 | + return true; |
|
127 | + } |
|
128 | + |
|
129 | + /** {@inheritdoc} */ |
|
130 | + public function isGedcomBlock() { |
|
131 | + return false; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * An HTML form to edit block settings |
|
136 | + * |
|
137 | + * @param int $block_id |
|
138 | + */ |
|
139 | + public function configureBlock($block_id) { |
|
140 | + } |
|
141 | 141 | } |
@@ -69,12 +69,12 @@ |
||
69 | 69 | global $ctype, $WT_TREE; |
70 | 70 | |
71 | 71 | switch (Filter::get('action')) { |
72 | - case 'deletenews': |
|
73 | - $news_id = Filter::getInteger('news_id'); |
|
74 | - if ($news_id) { |
|
75 | - Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); |
|
76 | - } |
|
77 | - break; |
|
72 | + case 'deletenews': |
|
73 | + $news_id = Filter::getInteger('news_id'); |
|
74 | + if ($news_id) { |
|
75 | + Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id)); |
|
76 | + } |
|
77 | + break; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $articles = Database::prepare( |
@@ -25,13 +25,15 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Class UserJournalModule |
27 | 27 | */ |
28 | -class UserJournalModule extends AbstractModule implements ModuleBlockInterface { |
|
28 | +class UserJournalModule extends AbstractModule implements ModuleBlockInterface |
|
29 | +{ |
|
29 | 30 | /** |
30 | 31 | * Create a new module. |
31 | 32 | * |
32 | 33 | * @param string $directory Where is this module installed |
33 | 34 | */ |
34 | - public function __construct($directory) { |
|
35 | + public function __construct($directory) |
|
36 | + { |
|
35 | 37 | parent::__construct($directory); |
36 | 38 | |
37 | 39 | // Create/update the database tables. |
@@ -43,7 +45,8 @@ discard block |
||
43 | 45 | * |
44 | 46 | * @return string |
45 | 47 | */ |
46 | - public function getTitle() { |
|
48 | + public function getTitle() |
|
49 | + { |
|
47 | 50 | return /* I18N: Name of a module */ I18N::translate('Journal'); |
48 | 51 | } |
49 | 52 | |
@@ -52,7 +55,8 @@ discard block |
||
52 | 55 | * |
53 | 56 | * @return string |
54 | 57 | */ |
55 | - public function getDescription() { |
|
58 | + public function getDescription() |
|
59 | + { |
|
56 | 60 | return /* I18N: Description of the “Journal” module */ I18N::translate('A private area to record notes or keep a journal.'); |
57 | 61 | } |
58 | 62 | |
@@ -65,7 +69,8 @@ discard block |
||
65 | 69 | * |
66 | 70 | * @return string |
67 | 71 | */ |
68 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
72 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
73 | + { |
|
69 | 74 | global $ctype, $WT_TREE; |
70 | 75 | |
71 | 76 | switch (Filter::get('action')) { |
@@ -117,17 +122,20 @@ discard block |
||
117 | 122 | } |
118 | 123 | |
119 | 124 | /** {@inheritdoc} */ |
120 | - public function loadAjax() { |
|
125 | + public function loadAjax() |
|
126 | + { |
|
121 | 127 | return false; |
122 | 128 | } |
123 | 129 | |
124 | 130 | /** {@inheritdoc} */ |
125 | - public function isUserBlock() { |
|
131 | + public function isUserBlock() |
|
132 | + { |
|
126 | 133 | return true; |
127 | 134 | } |
128 | 135 | |
129 | 136 | /** {@inheritdoc} */ |
130 | - public function isGedcomBlock() { |
|
137 | + public function isGedcomBlock() |
|
138 | + { |
|
131 | 139 | return false; |
132 | 140 | } |
133 | 141 | |
@@ -136,6 +144,7 @@ discard block |
||
136 | 144 | * |
137 | 145 | * @param int $block_id |
138 | 146 | */ |
139 | - public function configureBlock($block_id) { |
|
147 | + public function configureBlock($block_id) |
|
148 | + { |
|
140 | 149 | } |
141 | 150 | } |
@@ -23,42 +23,42 @@ |
||
23 | 23 | * Class DeathReportModule |
24 | 24 | */ |
25 | 25 | class DeathReportModule extends AbstractModule implements ModuleReportInterface { |
26 | - /** {@inheritdoc} */ |
|
27 | - public function getTitle() { |
|
28 | - // This text also appears in the .XML file - update both together |
|
29 | - return /* I18N: Name of a module/report */ I18N::translate('Deaths'); |
|
30 | - } |
|
26 | + /** {@inheritdoc} */ |
|
27 | + public function getTitle() { |
|
28 | + // This text also appears in the .XML file - update both together |
|
29 | + return /* I18N: Name of a module/report */ I18N::translate('Deaths'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** {@inheritdoc} */ |
|
33 | - public function getDescription() { |
|
34 | - // This text also appears in the .XML file - update both together |
|
35 | - return /* I18N: Description of the “Deaths” module */ I18N::translate('A report of individuals who died in a given time or place.'); |
|
36 | - } |
|
32 | + /** {@inheritdoc} */ |
|
33 | + public function getDescription() { |
|
34 | + // This text also appears in the .XML file - update both together |
|
35 | + return /* I18N: Description of the “Deaths” module */ I18N::translate('A report of individuals who died in a given time or place.'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * What is the default access level for this module? |
|
40 | - * |
|
41 | - * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function defaultAccessLevel() { |
|
46 | - return Auth::PRIV_PRIVATE; |
|
47 | - } |
|
38 | + /** |
|
39 | + * What is the default access level for this module? |
|
40 | + * |
|
41 | + * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function defaultAccessLevel() { |
|
46 | + return Auth::PRIV_PRIVATE; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Return a menu item for this report. |
|
51 | - * |
|
52 | - * @return Menu |
|
53 | - */ |
|
54 | - public function getReportMenu() { |
|
55 | - global $WT_TREE; |
|
49 | + /** |
|
50 | + * Return a menu item for this report. |
|
51 | + * |
|
52 | + * @return Menu |
|
53 | + */ |
|
54 | + public function getReportMenu() { |
|
55 | + global $WT_TREE; |
|
56 | 56 | |
57 | - return new Menu( |
|
58 | - $this->getTitle(), |
|
59 | - 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', |
|
60 | - 'menu-report-' . $this->getName(), |
|
61 | - array('rel' => 'nofollow') |
|
62 | - ); |
|
63 | - } |
|
57 | + return new Menu( |
|
58 | + $this->getTitle(), |
|
59 | + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml', |
|
60 | + 'menu-report-' . $this->getName(), |
|
61 | + array('rel' => 'nofollow') |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | } |
@@ -22,15 +22,18 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Class DeathReportModule |
24 | 24 | */ |
25 | -class DeathReportModule extends AbstractModule implements ModuleReportInterface { |
|
25 | +class DeathReportModule extends AbstractModule implements ModuleReportInterface |
|
26 | +{ |
|
26 | 27 | /** {@inheritdoc} */ |
27 | - public function getTitle() { |
|
28 | + public function getTitle() |
|
29 | + { |
|
28 | 30 | // This text also appears in the .XML file - update both together |
29 | 31 | return /* I18N: Name of a module/report */ I18N::translate('Deaths'); |
30 | 32 | } |
31 | 33 | |
32 | 34 | /** {@inheritdoc} */ |
33 | - public function getDescription() { |
|
35 | + public function getDescription() |
|
36 | + { |
|
34 | 37 | // This text also appears in the .XML file - update both together |
35 | 38 | return /* I18N: Description of the “Deaths” module */ I18N::translate('A report of individuals who died in a given time or place.'); |
36 | 39 | } |
@@ -42,7 +45,8 @@ discard block |
||
42 | 45 | * |
43 | 46 | * @return int |
44 | 47 | */ |
45 | - public function defaultAccessLevel() { |
|
48 | + public function defaultAccessLevel() |
|
49 | + { |
|
46 | 50 | return Auth::PRIV_PRIVATE; |
47 | 51 | } |
48 | 52 | |
@@ -51,7 +55,8 @@ discard block |
||
51 | 55 | * |
52 | 56 | * @return Menu |
53 | 57 | */ |
54 | - public function getReportMenu() { |
|
58 | + public function getReportMenu() |
|
59 | + { |
|
55 | 60 | global $WT_TREE; |
56 | 61 | |
57 | 62 | return new Menu( |
@@ -28,78 +28,78 @@ discard block |
||
28 | 28 | * Tip : you could change the number of generations loaded before ajax calls both in individual page and in treeview page to optimize speed and server load |
29 | 29 | */ |
30 | 30 | class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface, ModuleChartInterface { |
31 | - /** {@inheritdoc} */ |
|
32 | - public function getTitle() { |
|
33 | - return /* I18N: Name of a module */ I18N::translate('Interactive tree'); |
|
34 | - } |
|
35 | - |
|
36 | - /** {@inheritdoc} */ |
|
37 | - public function getDescription() { |
|
38 | - return /* I18N: Description of the “Interactive tree” module */ I18N::translate('An interactive tree, showing all the ancestors and descendants of an individual.'); |
|
39 | - } |
|
40 | - |
|
41 | - /** {@inheritdoc} */ |
|
42 | - public function defaultTabOrder() { |
|
43 | - return 68; |
|
44 | - } |
|
45 | - |
|
46 | - /** {@inheritdoc} */ |
|
47 | - public function getTabContent() { |
|
48 | - global $controller; |
|
49 | - |
|
50 | - $tv = new TreeView('tvTab'); |
|
51 | - list($html, $js) = $tv->drawViewport($controller->record, 3); |
|
52 | - |
|
53 | - return |
|
54 | - '<script src="' . $this->js() . '"></script>' . |
|
55 | - '<script src="' . WT_JQUERYUI_TOUCH_PUNCH_URL . '"></script>' . |
|
56 | - '<script>' . $js . '</script>' . |
|
57 | - $html; |
|
58 | - } |
|
59 | - |
|
60 | - /** {@inheritdoc} */ |
|
61 | - public function hasTabContent() { |
|
62 | - return !Auth::isSearchEngine(); |
|
63 | - } |
|
64 | - |
|
65 | - /** {@inheritdoc} */ |
|
66 | - public function isGrayedOut() { |
|
67 | - return false; |
|
68 | - } |
|
69 | - |
|
70 | - /** {@inheritdoc} */ |
|
71 | - public function canLoadAjax() { |
|
72 | - return true; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Return a menu item for this chart. |
|
77 | - * |
|
78 | - * @return Menu|null |
|
79 | - */ |
|
80 | - public function getChartMenu(Individual $individual) { |
|
81 | - return new Menu( |
|
82 | - $this->getTitle(), |
|
83 | - 'module.php?mod=tree&mod_action=treeview&rootid=' . $individual->getXref() . '&ged=' . $individual->getTree()->getNameUrl(), |
|
84 | - 'menu-chart-tree', |
|
85 | - array('rel' => 'nofollow') |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Return a menu item for this chart - for use in individual boxes. |
|
91 | - * |
|
92 | - * @return Menu|null |
|
93 | - */ |
|
94 | - public function getBoxChartMenu(Individual $individual) { |
|
95 | - return $this->getChartMenu($individual); |
|
96 | - } |
|
97 | - |
|
98 | - /** {@inheritdoc} */ |
|
99 | - public function getPreLoadContent() { |
|
100 | - // We cannot use jQuery("head").append(<link rel="stylesheet" ...as jQuery is not loaded at this time |
|
101 | - return |
|
102 | - '<script> |
|
31 | + /** {@inheritdoc} */ |
|
32 | + public function getTitle() { |
|
33 | + return /* I18N: Name of a module */ I18N::translate('Interactive tree'); |
|
34 | + } |
|
35 | + |
|
36 | + /** {@inheritdoc} */ |
|
37 | + public function getDescription() { |
|
38 | + return /* I18N: Description of the “Interactive tree” module */ I18N::translate('An interactive tree, showing all the ancestors and descendants of an individual.'); |
|
39 | + } |
|
40 | + |
|
41 | + /** {@inheritdoc} */ |
|
42 | + public function defaultTabOrder() { |
|
43 | + return 68; |
|
44 | + } |
|
45 | + |
|
46 | + /** {@inheritdoc} */ |
|
47 | + public function getTabContent() { |
|
48 | + global $controller; |
|
49 | + |
|
50 | + $tv = new TreeView('tvTab'); |
|
51 | + list($html, $js) = $tv->drawViewport($controller->record, 3); |
|
52 | + |
|
53 | + return |
|
54 | + '<script src="' . $this->js() . '"></script>' . |
|
55 | + '<script src="' . WT_JQUERYUI_TOUCH_PUNCH_URL . '"></script>' . |
|
56 | + '<script>' . $js . '</script>' . |
|
57 | + $html; |
|
58 | + } |
|
59 | + |
|
60 | + /** {@inheritdoc} */ |
|
61 | + public function hasTabContent() { |
|
62 | + return !Auth::isSearchEngine(); |
|
63 | + } |
|
64 | + |
|
65 | + /** {@inheritdoc} */ |
|
66 | + public function isGrayedOut() { |
|
67 | + return false; |
|
68 | + } |
|
69 | + |
|
70 | + /** {@inheritdoc} */ |
|
71 | + public function canLoadAjax() { |
|
72 | + return true; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Return a menu item for this chart. |
|
77 | + * |
|
78 | + * @return Menu|null |
|
79 | + */ |
|
80 | + public function getChartMenu(Individual $individual) { |
|
81 | + return new Menu( |
|
82 | + $this->getTitle(), |
|
83 | + 'module.php?mod=tree&mod_action=treeview&rootid=' . $individual->getXref() . '&ged=' . $individual->getTree()->getNameUrl(), |
|
84 | + 'menu-chart-tree', |
|
85 | + array('rel' => 'nofollow') |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Return a menu item for this chart - for use in individual boxes. |
|
91 | + * |
|
92 | + * @return Menu|null |
|
93 | + */ |
|
94 | + public function getBoxChartMenu(Individual $individual) { |
|
95 | + return $this->getChartMenu($individual); |
|
96 | + } |
|
97 | + |
|
98 | + /** {@inheritdoc} */ |
|
99 | + public function getPreLoadContent() { |
|
100 | + // We cannot use jQuery("head").append(<link rel="stylesheet" ...as jQuery is not loaded at this time |
|
101 | + return |
|
102 | + '<script> |
|
103 | 103 | if (document.createStyleSheet) { |
104 | 104 | document.createStyleSheet("' . $this->css() . '"); // For Internet Explorer |
105 | 105 | } else { |
@@ -110,83 +110,83 @@ discard block |
||
110 | 110 | document.getElementsByTagName("head")[0].appendChild(newSheet); |
111 | 111 | } |
112 | 112 | </script>'; |
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * This is a general purpose hook, allowing modules to respond to routes |
|
117 | - * of the form module.php?mod=FOO&mod_action=BAR |
|
118 | - * |
|
119 | - * @param string $mod_action |
|
120 | - */ |
|
121 | - public function modAction($mod_action) { |
|
122 | - global $controller, $WT_TREE; |
|
123 | - |
|
124 | - switch ($mod_action) { |
|
125 | - case 'treeview': |
|
126 | - $controller = new ChartController; |
|
127 | - $tv = new TreeView('tv'); |
|
128 | - ob_start(); |
|
129 | - |
|
130 | - $person = $controller->getSignificantIndividual(); |
|
131 | - |
|
132 | - list($html, $js) = $tv->drawViewport($person, 4); |
|
133 | - |
|
134 | - $controller |
|
135 | - ->setPageTitle(I18N::translate('Interactive tree of %s', $person->getFullName())) |
|
136 | - ->pageHeader() |
|
137 | - ->addExternalJavascript($this->js()) |
|
138 | - ->addExternalJavascript(WT_JQUERYUI_TOUCH_PUNCH_URL) |
|
139 | - ->addInlineJavascript($js) |
|
140 | - ->addInlineJavascript(' |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * This is a general purpose hook, allowing modules to respond to routes |
|
117 | + * of the form module.php?mod=FOO&mod_action=BAR |
|
118 | + * |
|
119 | + * @param string $mod_action |
|
120 | + */ |
|
121 | + public function modAction($mod_action) { |
|
122 | + global $controller, $WT_TREE; |
|
123 | + |
|
124 | + switch ($mod_action) { |
|
125 | + case 'treeview': |
|
126 | + $controller = new ChartController; |
|
127 | + $tv = new TreeView('tv'); |
|
128 | + ob_start(); |
|
129 | + |
|
130 | + $person = $controller->getSignificantIndividual(); |
|
131 | + |
|
132 | + list($html, $js) = $tv->drawViewport($person, 4); |
|
133 | + |
|
134 | + $controller |
|
135 | + ->setPageTitle(I18N::translate('Interactive tree of %s', $person->getFullName())) |
|
136 | + ->pageHeader() |
|
137 | + ->addExternalJavascript($this->js()) |
|
138 | + ->addExternalJavascript(WT_JQUERYUI_TOUCH_PUNCH_URL) |
|
139 | + ->addInlineJavascript($js) |
|
140 | + ->addInlineJavascript(' |
|
141 | 141 | if (document.createStyleSheet) { |
142 | 142 | document.createStyleSheet("' . $this->css() . '"); // For Internet Explorer |
143 | 143 | } else { |
144 | 144 | jQuery("head").append(\'<link rel="stylesheet" type="text/css" href="' . $this->css() . '">\'); |
145 | 145 | } |
146 | 146 | '); |
147 | - echo $html; |
|
148 | - break; |
|
149 | - |
|
150 | - case 'getDetails': |
|
151 | - header('Content-Type: text/html; charset=UTF-8'); |
|
152 | - $pid = Filter::get('pid', WT_REGEX_XREF); |
|
153 | - $i = Filter::get('instance'); |
|
154 | - $tv = new TreeView($i); |
|
155 | - $individual = Individual::getInstance($pid, $WT_TREE); |
|
156 | - if ($individual) { |
|
157 | - echo $tv->getDetails($individual); |
|
158 | - } |
|
159 | - break; |
|
160 | - |
|
161 | - case 'getPersons': |
|
162 | - header('Content-Type: text/html; charset=UTF-8'); |
|
163 | - $q = Filter::get('q'); |
|
164 | - $i = Filter::get('instance'); |
|
165 | - $tv = new TreeView($i); |
|
166 | - echo $tv->getPersons($q); |
|
167 | - break; |
|
168 | - |
|
169 | - default: |
|
170 | - http_response_code(404); |
|
171 | - break; |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * URL for our style sheet. |
|
177 | - * |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function css() { |
|
181 | - return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/css/treeview.css'; |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * URL for our JavaScript. |
|
186 | - * |
|
187 | - * @return string |
|
188 | - */ |
|
189 | - public function js() { |
|
190 | - return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/js/treeview.js'; |
|
191 | - } |
|
147 | + echo $html; |
|
148 | + break; |
|
149 | + |
|
150 | + case 'getDetails': |
|
151 | + header('Content-Type: text/html; charset=UTF-8'); |
|
152 | + $pid = Filter::get('pid', WT_REGEX_XREF); |
|
153 | + $i = Filter::get('instance'); |
|
154 | + $tv = new TreeView($i); |
|
155 | + $individual = Individual::getInstance($pid, $WT_TREE); |
|
156 | + if ($individual) { |
|
157 | + echo $tv->getDetails($individual); |
|
158 | + } |
|
159 | + break; |
|
160 | + |
|
161 | + case 'getPersons': |
|
162 | + header('Content-Type: text/html; charset=UTF-8'); |
|
163 | + $q = Filter::get('q'); |
|
164 | + $i = Filter::get('instance'); |
|
165 | + $tv = new TreeView($i); |
|
166 | + echo $tv->getPersons($q); |
|
167 | + break; |
|
168 | + |
|
169 | + default: |
|
170 | + http_response_code(404); |
|
171 | + break; |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * URL for our style sheet. |
|
177 | + * |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function css() { |
|
181 | + return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/css/treeview.css'; |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * URL for our JavaScript. |
|
186 | + * |
|
187 | + * @return string |
|
188 | + */ |
|
189 | + public function js() { |
|
190 | + return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/js/treeview.js'; |
|
191 | + } |
|
192 | 192 | } |
@@ -122,53 +122,53 @@ |
||
122 | 122 | global $controller, $WT_TREE; |
123 | 123 | |
124 | 124 | switch ($mod_action) { |
125 | - case 'treeview': |
|
126 | - $controller = new ChartController; |
|
127 | - $tv = new TreeView('tv'); |
|
128 | - ob_start(); |
|
129 | - |
|
130 | - $person = $controller->getSignificantIndividual(); |
|
131 | - |
|
132 | - list($html, $js) = $tv->drawViewport($person, 4); |
|
133 | - |
|
134 | - $controller |
|
135 | - ->setPageTitle(I18N::translate('Interactive tree of %s', $person->getFullName())) |
|
136 | - ->pageHeader() |
|
137 | - ->addExternalJavascript($this->js()) |
|
138 | - ->addExternalJavascript(WT_JQUERYUI_TOUCH_PUNCH_URL) |
|
139 | - ->addInlineJavascript($js) |
|
140 | - ->addInlineJavascript(' |
|
125 | + case 'treeview': |
|
126 | + $controller = new ChartController; |
|
127 | + $tv = new TreeView('tv'); |
|
128 | + ob_start(); |
|
129 | + |
|
130 | + $person = $controller->getSignificantIndividual(); |
|
131 | + |
|
132 | + list($html, $js) = $tv->drawViewport($person, 4); |
|
133 | + |
|
134 | + $controller |
|
135 | + ->setPageTitle(I18N::translate('Interactive tree of %s', $person->getFullName())) |
|
136 | + ->pageHeader() |
|
137 | + ->addExternalJavascript($this->js()) |
|
138 | + ->addExternalJavascript(WT_JQUERYUI_TOUCH_PUNCH_URL) |
|
139 | + ->addInlineJavascript($js) |
|
140 | + ->addInlineJavascript(' |
|
141 | 141 | if (document.createStyleSheet) { |
142 | 142 | document.createStyleSheet("' . $this->css() . '"); // For Internet Explorer |
143 | 143 | } else { |
144 | 144 | jQuery("head").append(\'<link rel="stylesheet" type="text/css" href="' . $this->css() . '">\'); |
145 | 145 | } |
146 | 146 | '); |
147 | - echo $html; |
|
148 | - break; |
|
149 | - |
|
150 | - case 'getDetails': |
|
151 | - header('Content-Type: text/html; charset=UTF-8'); |
|
152 | - $pid = Filter::get('pid', WT_REGEX_XREF); |
|
153 | - $i = Filter::get('instance'); |
|
154 | - $tv = new TreeView($i); |
|
155 | - $individual = Individual::getInstance($pid, $WT_TREE); |
|
156 | - if ($individual) { |
|
157 | - echo $tv->getDetails($individual); |
|
158 | - } |
|
159 | - break; |
|
160 | - |
|
161 | - case 'getPersons': |
|
162 | - header('Content-Type: text/html; charset=UTF-8'); |
|
163 | - $q = Filter::get('q'); |
|
164 | - $i = Filter::get('instance'); |
|
165 | - $tv = new TreeView($i); |
|
166 | - echo $tv->getPersons($q); |
|
167 | - break; |
|
168 | - |
|
169 | - default: |
|
170 | - http_response_code(404); |
|
171 | - break; |
|
147 | + echo $html; |
|
148 | + break; |
|
149 | + |
|
150 | + case 'getDetails': |
|
151 | + header('Content-Type: text/html; charset=UTF-8'); |
|
152 | + $pid = Filter::get('pid', WT_REGEX_XREF); |
|
153 | + $i = Filter::get('instance'); |
|
154 | + $tv = new TreeView($i); |
|
155 | + $individual = Individual::getInstance($pid, $WT_TREE); |
|
156 | + if ($individual) { |
|
157 | + echo $tv->getDetails($individual); |
|
158 | + } |
|
159 | + break; |
|
160 | + |
|
161 | + case 'getPersons': |
|
162 | + header('Content-Type: text/html; charset=UTF-8'); |
|
163 | + $q = Filter::get('q'); |
|
164 | + $i = Filter::get('instance'); |
|
165 | + $tv = new TreeView($i); |
|
166 | + echo $tv->getPersons($q); |
|
167 | + break; |
|
168 | + |
|
169 | + default: |
|
170 | + http_response_code(404); |
|
171 | + break; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 |
@@ -29,22 +29,26 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class InteractiveTreeModule extends AbstractModule implements ModuleTabInterface, ModuleChartInterface { |
31 | 31 | /** {@inheritdoc} */ |
32 | - public function getTitle() { |
|
32 | + public function getTitle() |
|
33 | + { |
|
33 | 34 | return /* I18N: Name of a module */ I18N::translate('Interactive tree'); |
34 | 35 | } |
35 | 36 | |
36 | 37 | /** {@inheritdoc} */ |
37 | - public function getDescription() { |
|
38 | + public function getDescription() |
|
39 | + { |
|
38 | 40 | return /* I18N: Description of the “Interactive tree” module */ I18N::translate('An interactive tree, showing all the ancestors and descendants of an individual.'); |
39 | 41 | } |
40 | 42 | |
41 | 43 | /** {@inheritdoc} */ |
42 | - public function defaultTabOrder() { |
|
44 | + public function defaultTabOrder() |
|
45 | + { |
|
43 | 46 | return 68; |
44 | 47 | } |
45 | 48 | |
46 | 49 | /** {@inheritdoc} */ |
47 | - public function getTabContent() { |
|
50 | + public function getTabContent() |
|
51 | + { |
|
48 | 52 | global $controller; |
49 | 53 | |
50 | 54 | $tv = new TreeView('tvTab'); |
@@ -58,17 +62,20 @@ discard block |
||
58 | 62 | } |
59 | 63 | |
60 | 64 | /** {@inheritdoc} */ |
61 | - public function hasTabContent() { |
|
65 | + public function hasTabContent() |
|
66 | + { |
|
62 | 67 | return !Auth::isSearchEngine(); |
63 | 68 | } |
64 | 69 | |
65 | 70 | /** {@inheritdoc} */ |
66 | - public function isGrayedOut() { |
|
71 | + public function isGrayedOut() |
|
72 | + { |
|
67 | 73 | return false; |
68 | 74 | } |
69 | 75 | |
70 | 76 | /** {@inheritdoc} */ |
71 | - public function canLoadAjax() { |
|
77 | + public function canLoadAjax() |
|
78 | + { |
|
72 | 79 | return true; |
73 | 80 | } |
74 | 81 | |
@@ -77,7 +84,8 @@ discard block |
||
77 | 84 | * |
78 | 85 | * @return Menu|null |
79 | 86 | */ |
80 | - public function getChartMenu(Individual $individual) { |
|
87 | + public function getChartMenu(Individual $individual) |
|
88 | + { |
|
81 | 89 | return new Menu( |
82 | 90 | $this->getTitle(), |
83 | 91 | 'module.php?mod=tree&mod_action=treeview&rootid=' . $individual->getXref() . '&ged=' . $individual->getTree()->getNameUrl(), |
@@ -91,12 +99,14 @@ discard block |
||
91 | 99 | * |
92 | 100 | * @return Menu|null |
93 | 101 | */ |
94 | - public function getBoxChartMenu(Individual $individual) { |
|
102 | + public function getBoxChartMenu(Individual $individual) |
|
103 | + { |
|
95 | 104 | return $this->getChartMenu($individual); |
96 | 105 | } |
97 | 106 | |
98 | 107 | /** {@inheritdoc} */ |
99 | - public function getPreLoadContent() { |
|
108 | + public function getPreLoadContent() |
|
109 | + { |
|
100 | 110 | // We cannot use jQuery("head").append(<link rel="stylesheet" ...as jQuery is not loaded at this time |
101 | 111 | return |
102 | 112 | '<script> |
@@ -118,7 +128,8 @@ discard block |
||
118 | 128 | * |
119 | 129 | * @param string $mod_action |
120 | 130 | */ |
121 | - public function modAction($mod_action) { |
|
131 | + public function modAction($mod_action) |
|
132 | + { |
|
122 | 133 | global $controller, $WT_TREE; |
123 | 134 | |
124 | 135 | switch ($mod_action) { |
@@ -177,7 +188,8 @@ discard block |
||
177 | 188 | * |
178 | 189 | * @return string |
179 | 190 | */ |
180 | - public function css() { |
|
191 | + public function css() |
|
192 | + { |
|
181 | 193 | return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/css/treeview.css'; |
182 | 194 | } |
183 | 195 | |
@@ -186,7 +198,8 @@ discard block |
||
186 | 198 | * |
187 | 199 | * @return string |
188 | 200 | */ |
189 | - public function js() { |
|
201 | + public function js() |
|
202 | + { |
|
190 | 203 | return WT_STATIC_URL . WT_MODULES_DIR . $this->getName() . '/js/treeview.js'; |
191 | 204 | } |
192 | 205 | } |
@@ -31,273 +31,273 @@ discard block |
||
31 | 31 | * Class RecentChangesModule |
32 | 32 | */ |
33 | 33 | class RecentChangesModule extends AbstractModule implements ModuleBlockInterface { |
34 | - const DEFAULT_BLOCK = '1'; |
|
35 | - const DEFAULT_DAYS = 7; |
|
36 | - const DEFAULT_HIDE_EMPTY = '0'; |
|
37 | - const DEFAULT_SHOW_USER = '1'; |
|
38 | - const DEFAULT_SORT_STYLE = 'date_desc'; |
|
39 | - const DEFAULT_INFO_STYLE = 'table'; |
|
40 | - const MAX_DAYS = 90; |
|
41 | - |
|
42 | - /** {@inheritdoc} */ |
|
43 | - public function getTitle() { |
|
44 | - return /* I18N: Name of a module */ I18N::translate('Recent changes'); |
|
45 | - } |
|
46 | - |
|
47 | - /** {@inheritdoc} */ |
|
48 | - public function getDescription() { |
|
49 | - return /* I18N: Description of the “Recent changes” module */ I18N::translate('A list of records that have been updated recently.'); |
|
50 | - } |
|
51 | - |
|
52 | - /** {@inheritdoc} */ |
|
53 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
54 | - global $ctype, $WT_TREE; |
|
55 | - |
|
56 | - $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); |
|
57 | - $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE); |
|
58 | - $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE); |
|
59 | - $show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER); |
|
60 | - $block = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK); |
|
61 | - $hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY); |
|
62 | - |
|
63 | - foreach (array('days', 'infoStyle', 'sortStyle', 'hide_empty', 'show_user', 'block') as $name) { |
|
64 | - if (array_key_exists($name, $cfg)) { |
|
65 | - $$name = $cfg[$name]; |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - $records = $this->getRecentChanges($WT_TREE, WT_CLIENT_JD - $days); |
|
70 | - |
|
71 | - if (empty($records) && $hide_empty) { |
|
72 | - return ''; |
|
73 | - } |
|
74 | - |
|
75 | - // Print block header |
|
76 | - $id = $this->getName() . $block_id; |
|
77 | - $class = $this->getName() . '_block'; |
|
78 | - |
|
79 | - if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
80 | - $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
81 | - } else { |
|
82 | - $title = ''; |
|
83 | - } |
|
84 | - $title .= /* I18N: title for list of recent changes */ I18N::plural('Changes in the last %s day', 'Changes in the last %s days', $days, I18N::number($days)); |
|
85 | - |
|
86 | - $content = ''; |
|
87 | - // Print block content |
|
88 | - if (count($records) == 0) { |
|
89 | - $content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days)); |
|
90 | - } else { |
|
91 | - switch ($infoStyle) { |
|
92 | - case 'list': |
|
93 | - $content .= $this->changesList($records, $sortStyle, $show_user); |
|
94 | - break; |
|
95 | - case 'table': |
|
96 | - $content .= $this->changesTable($records, $sortStyle, $show_user); |
|
97 | - break; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - if ($template) { |
|
102 | - if ($block) { |
|
103 | - $class .= ' small_inner_block'; |
|
104 | - } |
|
105 | - |
|
106 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
107 | - } else { |
|
108 | - return $content; |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - /** {@inheritdoc} */ |
|
113 | - public function loadAjax() { |
|
114 | - return true; |
|
115 | - } |
|
116 | - |
|
117 | - /** {@inheritdoc} */ |
|
118 | - public function isUserBlock() { |
|
119 | - return true; |
|
120 | - } |
|
121 | - |
|
122 | - /** {@inheritdoc} */ |
|
123 | - public function isGedcomBlock() { |
|
124 | - return true; |
|
125 | - } |
|
126 | - |
|
127 | - /** {@inheritdoc} */ |
|
128 | - public function configureBlock($block_id) { |
|
129 | - if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
130 | - $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS)); |
|
131 | - $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table')); |
|
132 | - $this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'name|date_asc|date_desc')); |
|
133 | - $this->setBlockSetting($block_id, 'show_user', Filter::postBool('show_user')); |
|
134 | - $this->setBlockSetting($block_id, 'hide_empty', Filter::postBool('hide_empty')); |
|
135 | - $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); |
|
136 | - } |
|
137 | - |
|
138 | - $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); |
|
139 | - $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE); |
|
140 | - $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE); |
|
141 | - $show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER); |
|
142 | - $block = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK); |
|
143 | - $hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY); |
|
144 | - |
|
145 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
146 | - echo I18N::translate('Number of days to show'); |
|
147 | - echo '</td><td class="optionbox">'; |
|
148 | - echo '<input type="text" name="days" size="2" value="', $days, '">'; |
|
149 | - echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', I18N::number(self::MAX_DAYS), I18N::number(self::MAX_DAYS)), '</em>'; |
|
150 | - echo '</td></tr>'; |
|
151 | - |
|
152 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
153 | - echo I18N::translate('Presentation style'); |
|
154 | - echo '</td><td class="optionbox">'; |
|
155 | - echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); |
|
156 | - echo '</td></tr>'; |
|
157 | - |
|
158 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
159 | - echo I18N::translate('Sort order'); |
|
160 | - echo '</td><td class="optionbox">'; |
|
161 | - echo FunctionsEdit::selectEditControl('sortStyle', array( |
|
162 | - 'name' => /* I18N: An option in a list-box */ I18N::translate('sort by name'), |
|
163 | - 'date_asc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, oldest first'), |
|
164 | - 'date_desc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, newest first'), |
|
165 | - ), null, $sortStyle, ''); |
|
166 | - echo '</td></tr>'; |
|
167 | - |
|
168 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
169 | - echo /* I18N: label for a yes/no option */ I18N::translate('Show the user who made the change'); |
|
170 | - echo '</td><td class="optionbox">'; |
|
171 | - echo FunctionsEdit::editFieldYesNo('show_user', $show_user); |
|
172 | - echo '</td></tr>'; |
|
173 | - |
|
174 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
175 | - echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow'); |
|
176 | - echo '</td><td class="optionbox">'; |
|
177 | - echo FunctionsEdit::editFieldYesNo('block', $block); |
|
178 | - echo '</td></tr>'; |
|
179 | - |
|
180 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
181 | - echo I18N::translate('Should this block be hidden when it is empty'); |
|
182 | - echo '</td><td class="optionbox">'; |
|
183 | - echo FunctionsEdit::editFieldYesNo('hide_empty', $hide_empty); |
|
184 | - echo '</td></tr>'; |
|
185 | - echo '<tr><td colspan="2" class="optionbox wrap">'; |
|
186 | - echo '<span class="error">', I18N::translate('If you hide an empty block, you will not be able to change its configuration until it becomes visible by no longer being empty.'), '</span>'; |
|
187 | - echo '</td></tr>'; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Find records that have changed since a given julian day |
|
192 | - * |
|
193 | - * @param Tree $tree Changes for which tree |
|
194 | - * @param int $jd Julian day |
|
195 | - * |
|
196 | - * @return GedcomRecord[] List of records with changes |
|
197 | - */ |
|
198 | - private function getRecentChanges(Tree $tree, $jd) { |
|
199 | - $sql = |
|
200 | - "SELECT d_gid FROM `##dates`" . |
|
201 | - " WHERE d_fact='CHAN' AND d_julianday1 >= :jd AND d_file = :tree_id"; |
|
202 | - |
|
203 | - $vars = array( |
|
204 | - 'jd' => $jd, |
|
205 | - 'tree_id' => $tree->getTreeId(), |
|
206 | - ); |
|
207 | - |
|
208 | - $xrefs = Database::prepare($sql)->execute($vars)->fetchOneColumn(); |
|
209 | - |
|
210 | - $records = array(); |
|
211 | - foreach ($xrefs as $xref) { |
|
212 | - $record = GedcomRecord::getInstance($xref, $tree); |
|
213 | - if ($record->canShow()) { |
|
214 | - $records[] = $record; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - return $records; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Format a table of events |
|
223 | - * |
|
224 | - * @param GedcomRecord[] $records |
|
225 | - * @param string $sort |
|
226 | - * @param bool $show_user |
|
227 | - * |
|
228 | - * @return string |
|
229 | - */ |
|
230 | - private function changesList(array $records, $sort, $show_user) { |
|
231 | - switch ($sort) { |
|
232 | - case 'name': |
|
233 | - uasort($records, array('self', 'sortByNameAndChangeDate')); |
|
234 | - break; |
|
235 | - case 'date_asc': |
|
236 | - uasort($records, array('self', 'sortByChangeDateAndName')); |
|
237 | - $records = array_reverse($records); |
|
238 | - break; |
|
239 | - case 'date_desc': |
|
240 | - uasort($records, array('self', 'sortByChangeDateAndName')); |
|
241 | - } |
|
242 | - |
|
243 | - $html = ''; |
|
244 | - foreach ($records as $record) { |
|
245 | - $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>'; |
|
246 | - $html .= '<div class="indent" style="margin-bottom: 5px;">'; |
|
247 | - if ($record instanceof Individual) { |
|
248 | - if ($record->getAddName()) { |
|
249 | - $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item">' . $record->getAddName() . '</a>'; |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - // The timestamp may be missing or private. |
|
254 | - $timestamp = $record->lastChangeTimestamp(); |
|
255 | - if ($timestamp !== '') { |
|
256 | - if ($show_user) { |
|
257 | - $html .= /* I18N: [a record was] Changed on <date/time> by <user> */ |
|
258 | - I18N::translate('Changed on %1$s by %2$s', $timestamp, Filter::escapeHtml($record->lastChangeUser())); |
|
259 | - } else { |
|
260 | - $html .= /* I18N: [a record was] Changed on <date/time> */ |
|
261 | - I18N::translate('Changed on %1$s', $timestamp); |
|
262 | - } |
|
263 | - } |
|
264 | - $html .= '</div>'; |
|
265 | - } |
|
266 | - |
|
267 | - return $html; |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * Format a table of events |
|
272 | - * |
|
273 | - * @param GedcomRecord[] $records |
|
274 | - * @param string $sort |
|
275 | - * @param bool $show_user |
|
276 | - * |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - private function changesTable($records, $sort, $show_user) { |
|
280 | - global $controller; |
|
281 | - |
|
282 | - $table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page |
|
283 | - |
|
284 | - switch ($sort) { |
|
285 | - case 'name': |
|
286 | - default: |
|
287 | - $aaSorting = "[1,'asc'], [2,'desc']"; |
|
288 | - break; |
|
289 | - case 'date_asc': |
|
290 | - $aaSorting = "[2,'asc'], [1,'asc']"; |
|
291 | - break; |
|
292 | - case 'date_desc': |
|
293 | - $aaSorting = "[2,'desc'], [1,'asc']"; |
|
294 | - break; |
|
295 | - } |
|
296 | - |
|
297 | - $html = ''; |
|
298 | - $controller |
|
299 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
300 | - ->addInlineJavascript(' |
|
34 | + const DEFAULT_BLOCK = '1'; |
|
35 | + const DEFAULT_DAYS = 7; |
|
36 | + const DEFAULT_HIDE_EMPTY = '0'; |
|
37 | + const DEFAULT_SHOW_USER = '1'; |
|
38 | + const DEFAULT_SORT_STYLE = 'date_desc'; |
|
39 | + const DEFAULT_INFO_STYLE = 'table'; |
|
40 | + const MAX_DAYS = 90; |
|
41 | + |
|
42 | + /** {@inheritdoc} */ |
|
43 | + public function getTitle() { |
|
44 | + return /* I18N: Name of a module */ I18N::translate('Recent changes'); |
|
45 | + } |
|
46 | + |
|
47 | + /** {@inheritdoc} */ |
|
48 | + public function getDescription() { |
|
49 | + return /* I18N: Description of the “Recent changes” module */ I18N::translate('A list of records that have been updated recently.'); |
|
50 | + } |
|
51 | + |
|
52 | + /** {@inheritdoc} */ |
|
53 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
54 | + global $ctype, $WT_TREE; |
|
55 | + |
|
56 | + $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); |
|
57 | + $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE); |
|
58 | + $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE); |
|
59 | + $show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER); |
|
60 | + $block = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK); |
|
61 | + $hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY); |
|
62 | + |
|
63 | + foreach (array('days', 'infoStyle', 'sortStyle', 'hide_empty', 'show_user', 'block') as $name) { |
|
64 | + if (array_key_exists($name, $cfg)) { |
|
65 | + $$name = $cfg[$name]; |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + $records = $this->getRecentChanges($WT_TREE, WT_CLIENT_JD - $days); |
|
70 | + |
|
71 | + if (empty($records) && $hide_empty) { |
|
72 | + return ''; |
|
73 | + } |
|
74 | + |
|
75 | + // Print block header |
|
76 | + $id = $this->getName() . $block_id; |
|
77 | + $class = $this->getName() . '_block'; |
|
78 | + |
|
79 | + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
80 | + $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
81 | + } else { |
|
82 | + $title = ''; |
|
83 | + } |
|
84 | + $title .= /* I18N: title for list of recent changes */ I18N::plural('Changes in the last %s day', 'Changes in the last %s days', $days, I18N::number($days)); |
|
85 | + |
|
86 | + $content = ''; |
|
87 | + // Print block content |
|
88 | + if (count($records) == 0) { |
|
89 | + $content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days)); |
|
90 | + } else { |
|
91 | + switch ($infoStyle) { |
|
92 | + case 'list': |
|
93 | + $content .= $this->changesList($records, $sortStyle, $show_user); |
|
94 | + break; |
|
95 | + case 'table': |
|
96 | + $content .= $this->changesTable($records, $sortStyle, $show_user); |
|
97 | + break; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + if ($template) { |
|
102 | + if ($block) { |
|
103 | + $class .= ' small_inner_block'; |
|
104 | + } |
|
105 | + |
|
106 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
107 | + } else { |
|
108 | + return $content; |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + /** {@inheritdoc} */ |
|
113 | + public function loadAjax() { |
|
114 | + return true; |
|
115 | + } |
|
116 | + |
|
117 | + /** {@inheritdoc} */ |
|
118 | + public function isUserBlock() { |
|
119 | + return true; |
|
120 | + } |
|
121 | + |
|
122 | + /** {@inheritdoc} */ |
|
123 | + public function isGedcomBlock() { |
|
124 | + return true; |
|
125 | + } |
|
126 | + |
|
127 | + /** {@inheritdoc} */ |
|
128 | + public function configureBlock($block_id) { |
|
129 | + if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
130 | + $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS)); |
|
131 | + $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table')); |
|
132 | + $this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'name|date_asc|date_desc')); |
|
133 | + $this->setBlockSetting($block_id, 'show_user', Filter::postBool('show_user')); |
|
134 | + $this->setBlockSetting($block_id, 'hide_empty', Filter::postBool('hide_empty')); |
|
135 | + $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); |
|
136 | + } |
|
137 | + |
|
138 | + $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); |
|
139 | + $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE); |
|
140 | + $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE); |
|
141 | + $show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER); |
|
142 | + $block = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK); |
|
143 | + $hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY); |
|
144 | + |
|
145 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
146 | + echo I18N::translate('Number of days to show'); |
|
147 | + echo '</td><td class="optionbox">'; |
|
148 | + echo '<input type="text" name="days" size="2" value="', $days, '">'; |
|
149 | + echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', I18N::number(self::MAX_DAYS), I18N::number(self::MAX_DAYS)), '</em>'; |
|
150 | + echo '</td></tr>'; |
|
151 | + |
|
152 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
153 | + echo I18N::translate('Presentation style'); |
|
154 | + echo '</td><td class="optionbox">'; |
|
155 | + echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); |
|
156 | + echo '</td></tr>'; |
|
157 | + |
|
158 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
159 | + echo I18N::translate('Sort order'); |
|
160 | + echo '</td><td class="optionbox">'; |
|
161 | + echo FunctionsEdit::selectEditControl('sortStyle', array( |
|
162 | + 'name' => /* I18N: An option in a list-box */ I18N::translate('sort by name'), |
|
163 | + 'date_asc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, oldest first'), |
|
164 | + 'date_desc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, newest first'), |
|
165 | + ), null, $sortStyle, ''); |
|
166 | + echo '</td></tr>'; |
|
167 | + |
|
168 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
169 | + echo /* I18N: label for a yes/no option */ I18N::translate('Show the user who made the change'); |
|
170 | + echo '</td><td class="optionbox">'; |
|
171 | + echo FunctionsEdit::editFieldYesNo('show_user', $show_user); |
|
172 | + echo '</td></tr>'; |
|
173 | + |
|
174 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
175 | + echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow'); |
|
176 | + echo '</td><td class="optionbox">'; |
|
177 | + echo FunctionsEdit::editFieldYesNo('block', $block); |
|
178 | + echo '</td></tr>'; |
|
179 | + |
|
180 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
181 | + echo I18N::translate('Should this block be hidden when it is empty'); |
|
182 | + echo '</td><td class="optionbox">'; |
|
183 | + echo FunctionsEdit::editFieldYesNo('hide_empty', $hide_empty); |
|
184 | + echo '</td></tr>'; |
|
185 | + echo '<tr><td colspan="2" class="optionbox wrap">'; |
|
186 | + echo '<span class="error">', I18N::translate('If you hide an empty block, you will not be able to change its configuration until it becomes visible by no longer being empty.'), '</span>'; |
|
187 | + echo '</td></tr>'; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Find records that have changed since a given julian day |
|
192 | + * |
|
193 | + * @param Tree $tree Changes for which tree |
|
194 | + * @param int $jd Julian day |
|
195 | + * |
|
196 | + * @return GedcomRecord[] List of records with changes |
|
197 | + */ |
|
198 | + private function getRecentChanges(Tree $tree, $jd) { |
|
199 | + $sql = |
|
200 | + "SELECT d_gid FROM `##dates`" . |
|
201 | + " WHERE d_fact='CHAN' AND d_julianday1 >= :jd AND d_file = :tree_id"; |
|
202 | + |
|
203 | + $vars = array( |
|
204 | + 'jd' => $jd, |
|
205 | + 'tree_id' => $tree->getTreeId(), |
|
206 | + ); |
|
207 | + |
|
208 | + $xrefs = Database::prepare($sql)->execute($vars)->fetchOneColumn(); |
|
209 | + |
|
210 | + $records = array(); |
|
211 | + foreach ($xrefs as $xref) { |
|
212 | + $record = GedcomRecord::getInstance($xref, $tree); |
|
213 | + if ($record->canShow()) { |
|
214 | + $records[] = $record; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + return $records; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Format a table of events |
|
223 | + * |
|
224 | + * @param GedcomRecord[] $records |
|
225 | + * @param string $sort |
|
226 | + * @param bool $show_user |
|
227 | + * |
|
228 | + * @return string |
|
229 | + */ |
|
230 | + private function changesList(array $records, $sort, $show_user) { |
|
231 | + switch ($sort) { |
|
232 | + case 'name': |
|
233 | + uasort($records, array('self', 'sortByNameAndChangeDate')); |
|
234 | + break; |
|
235 | + case 'date_asc': |
|
236 | + uasort($records, array('self', 'sortByChangeDateAndName')); |
|
237 | + $records = array_reverse($records); |
|
238 | + break; |
|
239 | + case 'date_desc': |
|
240 | + uasort($records, array('self', 'sortByChangeDateAndName')); |
|
241 | + } |
|
242 | + |
|
243 | + $html = ''; |
|
244 | + foreach ($records as $record) { |
|
245 | + $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>'; |
|
246 | + $html .= '<div class="indent" style="margin-bottom: 5px;">'; |
|
247 | + if ($record instanceof Individual) { |
|
248 | + if ($record->getAddName()) { |
|
249 | + $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item">' . $record->getAddName() . '</a>'; |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + // The timestamp may be missing or private. |
|
254 | + $timestamp = $record->lastChangeTimestamp(); |
|
255 | + if ($timestamp !== '') { |
|
256 | + if ($show_user) { |
|
257 | + $html .= /* I18N: [a record was] Changed on <date/time> by <user> */ |
|
258 | + I18N::translate('Changed on %1$s by %2$s', $timestamp, Filter::escapeHtml($record->lastChangeUser())); |
|
259 | + } else { |
|
260 | + $html .= /* I18N: [a record was] Changed on <date/time> */ |
|
261 | + I18N::translate('Changed on %1$s', $timestamp); |
|
262 | + } |
|
263 | + } |
|
264 | + $html .= '</div>'; |
|
265 | + } |
|
266 | + |
|
267 | + return $html; |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Format a table of events |
|
272 | + * |
|
273 | + * @param GedcomRecord[] $records |
|
274 | + * @param string $sort |
|
275 | + * @param bool $show_user |
|
276 | + * |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + private function changesTable($records, $sort, $show_user) { |
|
280 | + global $controller; |
|
281 | + |
|
282 | + $table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page |
|
283 | + |
|
284 | + switch ($sort) { |
|
285 | + case 'name': |
|
286 | + default: |
|
287 | + $aaSorting = "[1,'asc'], [2,'desc']"; |
|
288 | + break; |
|
289 | + case 'date_asc': |
|
290 | + $aaSorting = "[2,'asc'], [1,'asc']"; |
|
291 | + break; |
|
292 | + case 'date_desc': |
|
293 | + $aaSorting = "[2,'desc'], [1,'asc']"; |
|
294 | + break; |
|
295 | + } |
|
296 | + |
|
297 | + $html = ''; |
|
298 | + $controller |
|
299 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
300 | + ->addInlineJavascript(' |
|
301 | 301 | jQuery("#' . $table_id . '").dataTable({ |
302 | 302 | dom: \'t\', |
303 | 303 | paging: false, |
@@ -316,75 +316,75 @@ discard block |
||
316 | 316 | }); |
317 | 317 | '); |
318 | 318 | |
319 | - $html .= '<table id="' . $table_id . '" class="width100">'; |
|
320 | - $html .= '<thead><tr>'; |
|
321 | - $html .= '<th></th>'; |
|
322 | - $html .= '<th>' . I18N::translate('Record') . '</th>'; |
|
323 | - $html .= '<th>' . GedcomTag::getLabel('CHAN') . '</th>'; |
|
324 | - $html .= '<th>' . GedcomTag::getLabel('_WT_USER') . '</th>'; |
|
325 | - $html .= '</tr></thead><tbody>'; |
|
326 | - |
|
327 | - foreach ($records as $record) { |
|
328 | - $html .= '<tr><td>'; |
|
329 | - switch ($record::RECORD_TYPE) { |
|
330 | - case 'INDI': |
|
331 | - $html .= $record->getSexImage('small'); |
|
332 | - break; |
|
333 | - case 'FAM': |
|
334 | - $html .= '<i class="icon-button_family"></i>'; |
|
335 | - break; |
|
336 | - case 'OBJE': |
|
337 | - $html .= '<i class="icon-button_media"></i>'; |
|
338 | - break; |
|
339 | - case 'NOTE': |
|
340 | - $html .= '<i class="icon-button_note"></i>'; |
|
341 | - break; |
|
342 | - case 'SOUR': |
|
343 | - $html .= '<i class="icon-button_source"></i>'; |
|
344 | - break; |
|
345 | - case 'REPO': |
|
346 | - $html .= '<i class="icon-button_repository"></i>'; |
|
347 | - break; |
|
348 | - } |
|
349 | - $html .= '</td>'; |
|
350 | - $html .= '<td data-sort="' . Filter::escapeHtml($record->getSortName()) . '">'; |
|
351 | - $html .= '<a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a>'; |
|
352 | - $addname = $record->getAddName(); |
|
353 | - if ($addname) { |
|
354 | - $html .= '<div class="indent"><a href="' . $record->getHtmlUrl() . '">' . $addname . '</a></div>'; |
|
355 | - } |
|
356 | - $html .= '</td>'; |
|
357 | - $html .= '<td data-sort="' . $record->lastChangeTimestamp(true) . '">' . $record->lastChangeTimestamp() . '</td>'; |
|
358 | - $html .= '<td>' . Filter::escapeHtml($record->lastChangeUser()) . '</td>'; |
|
359 | - $html .= '</tr>'; |
|
360 | - } |
|
361 | - |
|
362 | - $html .= '</tbody></table>'; |
|
363 | - |
|
364 | - return $html; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * Sort the records by (1) last change date and (2) name |
|
369 | - * |
|
370 | - * @param GedcomRecord $a |
|
371 | - * @param GedcomRecord $b |
|
372 | - * |
|
373 | - * @return int |
|
374 | - */ |
|
375 | - private static function sortByChangeDateAndName(GedcomRecord $a, GedcomRecord $b) { |
|
376 | - return $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true) ?: GedcomRecord::compare($a, $b); |
|
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Sort the records by (1) name and (2) last change date |
|
381 | - * |
|
382 | - * @param GedcomRecord $a |
|
383 | - * @param GedcomRecord $b |
|
384 | - * |
|
385 | - * @return int |
|
386 | - */ |
|
387 | - private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b) { |
|
388 | - return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true); |
|
389 | - } |
|
319 | + $html .= '<table id="' . $table_id . '" class="width100">'; |
|
320 | + $html .= '<thead><tr>'; |
|
321 | + $html .= '<th></th>'; |
|
322 | + $html .= '<th>' . I18N::translate('Record') . '</th>'; |
|
323 | + $html .= '<th>' . GedcomTag::getLabel('CHAN') . '</th>'; |
|
324 | + $html .= '<th>' . GedcomTag::getLabel('_WT_USER') . '</th>'; |
|
325 | + $html .= '</tr></thead><tbody>'; |
|
326 | + |
|
327 | + foreach ($records as $record) { |
|
328 | + $html .= '<tr><td>'; |
|
329 | + switch ($record::RECORD_TYPE) { |
|
330 | + case 'INDI': |
|
331 | + $html .= $record->getSexImage('small'); |
|
332 | + break; |
|
333 | + case 'FAM': |
|
334 | + $html .= '<i class="icon-button_family"></i>'; |
|
335 | + break; |
|
336 | + case 'OBJE': |
|
337 | + $html .= '<i class="icon-button_media"></i>'; |
|
338 | + break; |
|
339 | + case 'NOTE': |
|
340 | + $html .= '<i class="icon-button_note"></i>'; |
|
341 | + break; |
|
342 | + case 'SOUR': |
|
343 | + $html .= '<i class="icon-button_source"></i>'; |
|
344 | + break; |
|
345 | + case 'REPO': |
|
346 | + $html .= '<i class="icon-button_repository"></i>'; |
|
347 | + break; |
|
348 | + } |
|
349 | + $html .= '</td>'; |
|
350 | + $html .= '<td data-sort="' . Filter::escapeHtml($record->getSortName()) . '">'; |
|
351 | + $html .= '<a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a>'; |
|
352 | + $addname = $record->getAddName(); |
|
353 | + if ($addname) { |
|
354 | + $html .= '<div class="indent"><a href="' . $record->getHtmlUrl() . '">' . $addname . '</a></div>'; |
|
355 | + } |
|
356 | + $html .= '</td>'; |
|
357 | + $html .= '<td data-sort="' . $record->lastChangeTimestamp(true) . '">' . $record->lastChangeTimestamp() . '</td>'; |
|
358 | + $html .= '<td>' . Filter::escapeHtml($record->lastChangeUser()) . '</td>'; |
|
359 | + $html .= '</tr>'; |
|
360 | + } |
|
361 | + |
|
362 | + $html .= '</tbody></table>'; |
|
363 | + |
|
364 | + return $html; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * Sort the records by (1) last change date and (2) name |
|
369 | + * |
|
370 | + * @param GedcomRecord $a |
|
371 | + * @param GedcomRecord $b |
|
372 | + * |
|
373 | + * @return int |
|
374 | + */ |
|
375 | + private static function sortByChangeDateAndName(GedcomRecord $a, GedcomRecord $b) { |
|
376 | + return $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true) ?: GedcomRecord::compare($a, $b); |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Sort the records by (1) name and (2) last change date |
|
381 | + * |
|
382 | + * @param GedcomRecord $a |
|
383 | + * @param GedcomRecord $b |
|
384 | + * |
|
385 | + * @return int |
|
386 | + */ |
|
387 | + private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b) { |
|
388 | + return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true); |
|
389 | + } |
|
390 | 390 | } |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | $content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days)); |
90 | 90 | } else { |
91 | 91 | switch ($infoStyle) { |
92 | - case 'list': |
|
93 | - $content .= $this->changesList($records, $sortStyle, $show_user); |
|
94 | - break; |
|
95 | - case 'table': |
|
96 | - $content .= $this->changesTable($records, $sortStyle, $show_user); |
|
97 | - break; |
|
92 | + case 'list': |
|
93 | + $content .= $this->changesList($records, $sortStyle, $show_user); |
|
94 | + break; |
|
95 | + case 'table': |
|
96 | + $content .= $this->changesTable($records, $sortStyle, $show_user); |
|
97 | + break; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | */ |
230 | 230 | private function changesList(array $records, $sort, $show_user) { |
231 | 231 | switch ($sort) { |
232 | - case 'name': |
|
233 | - uasort($records, array('self', 'sortByNameAndChangeDate')); |
|
234 | - break; |
|
235 | - case 'date_asc': |
|
236 | - uasort($records, array('self', 'sortByChangeDateAndName')); |
|
237 | - $records = array_reverse($records); |
|
238 | - break; |
|
239 | - case 'date_desc': |
|
240 | - uasort($records, array('self', 'sortByChangeDateAndName')); |
|
232 | + case 'name': |
|
233 | + uasort($records, array('self', 'sortByNameAndChangeDate')); |
|
234 | + break; |
|
235 | + case 'date_asc': |
|
236 | + uasort($records, array('self', 'sortByChangeDateAndName')); |
|
237 | + $records = array_reverse($records); |
|
238 | + break; |
|
239 | + case 'date_desc': |
|
240 | + uasort($records, array('self', 'sortByChangeDateAndName')); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $html = ''; |
@@ -282,16 +282,16 @@ discard block |
||
282 | 282 | $table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page |
283 | 283 | |
284 | 284 | switch ($sort) { |
285 | - case 'name': |
|
286 | - default: |
|
287 | - $aaSorting = "[1,'asc'], [2,'desc']"; |
|
288 | - break; |
|
289 | - case 'date_asc': |
|
290 | - $aaSorting = "[2,'asc'], [1,'asc']"; |
|
291 | - break; |
|
292 | - case 'date_desc': |
|
293 | - $aaSorting = "[2,'desc'], [1,'asc']"; |
|
294 | - break; |
|
285 | + case 'name': |
|
286 | + default: |
|
287 | + $aaSorting = "[1,'asc'], [2,'desc']"; |
|
288 | + break; |
|
289 | + case 'date_asc': |
|
290 | + $aaSorting = "[2,'asc'], [1,'asc']"; |
|
291 | + break; |
|
292 | + case 'date_desc': |
|
293 | + $aaSorting = "[2,'desc'], [1,'asc']"; |
|
294 | + break; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | $html = ''; |
@@ -327,24 +327,24 @@ discard block |
||
327 | 327 | foreach ($records as $record) { |
328 | 328 | $html .= '<tr><td>'; |
329 | 329 | switch ($record::RECORD_TYPE) { |
330 | - case 'INDI': |
|
331 | - $html .= $record->getSexImage('small'); |
|
332 | - break; |
|
333 | - case 'FAM': |
|
334 | - $html .= '<i class="icon-button_family"></i>'; |
|
335 | - break; |
|
336 | - case 'OBJE': |
|
337 | - $html .= '<i class="icon-button_media"></i>'; |
|
338 | - break; |
|
339 | - case 'NOTE': |
|
340 | - $html .= '<i class="icon-button_note"></i>'; |
|
341 | - break; |
|
342 | - case 'SOUR': |
|
343 | - $html .= '<i class="icon-button_source"></i>'; |
|
344 | - break; |
|
345 | - case 'REPO': |
|
346 | - $html .= '<i class="icon-button_repository"></i>'; |
|
347 | - break; |
|
330 | + case 'INDI': |
|
331 | + $html .= $record->getSexImage('small'); |
|
332 | + break; |
|
333 | + case 'FAM': |
|
334 | + $html .= '<i class="icon-button_family"></i>'; |
|
335 | + break; |
|
336 | + case 'OBJE': |
|
337 | + $html .= '<i class="icon-button_media"></i>'; |
|
338 | + break; |
|
339 | + case 'NOTE': |
|
340 | + $html .= '<i class="icon-button_note"></i>'; |
|
341 | + break; |
|
342 | + case 'SOUR': |
|
343 | + $html .= '<i class="icon-button_source"></i>'; |
|
344 | + break; |
|
345 | + case 'REPO': |
|
346 | + $html .= '<i class="icon-button_repository"></i>'; |
|
347 | + break; |
|
348 | 348 | } |
349 | 349 | $html .= '</td>'; |
350 | 350 | $html .= '<td data-sort="' . Filter::escapeHtml($record->getSortName()) . '">'; |
@@ -30,7 +30,8 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Class RecentChangesModule |
32 | 32 | */ |
33 | -class RecentChangesModule extends AbstractModule implements ModuleBlockInterface { |
|
33 | +class RecentChangesModule extends AbstractModule implements ModuleBlockInterface |
|
34 | +{ |
|
34 | 35 | const DEFAULT_BLOCK = '1'; |
35 | 36 | const DEFAULT_DAYS = 7; |
36 | 37 | const DEFAULT_HIDE_EMPTY = '0'; |
@@ -40,17 +41,20 @@ discard block |
||
40 | 41 | const MAX_DAYS = 90; |
41 | 42 | |
42 | 43 | /** {@inheritdoc} */ |
43 | - public function getTitle() { |
|
44 | + public function getTitle() |
|
45 | + { |
|
44 | 46 | return /* I18N: Name of a module */ I18N::translate('Recent changes'); |
45 | 47 | } |
46 | 48 | |
47 | 49 | /** {@inheritdoc} */ |
48 | - public function getDescription() { |
|
50 | + public function getDescription() |
|
51 | + { |
|
49 | 52 | return /* I18N: Description of the “Recent changes” module */ I18N::translate('A list of records that have been updated recently.'); |
50 | 53 | } |
51 | 54 | |
52 | 55 | /** {@inheritdoc} */ |
53 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
56 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
57 | + { |
|
54 | 58 | global $ctype, $WT_TREE; |
55 | 59 | |
56 | 60 | $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); |
@@ -110,22 +114,26 @@ discard block |
||
110 | 114 | } |
111 | 115 | |
112 | 116 | /** {@inheritdoc} */ |
113 | - public function loadAjax() { |
|
117 | + public function loadAjax() |
|
118 | + { |
|
114 | 119 | return true; |
115 | 120 | } |
116 | 121 | |
117 | 122 | /** {@inheritdoc} */ |
118 | - public function isUserBlock() { |
|
123 | + public function isUserBlock() |
|
124 | + { |
|
119 | 125 | return true; |
120 | 126 | } |
121 | 127 | |
122 | 128 | /** {@inheritdoc} */ |
123 | - public function isGedcomBlock() { |
|
129 | + public function isGedcomBlock() |
|
130 | + { |
|
124 | 131 | return true; |
125 | 132 | } |
126 | 133 | |
127 | 134 | /** {@inheritdoc} */ |
128 | - public function configureBlock($block_id) { |
|
135 | + public function configureBlock($block_id) |
|
136 | + { |
|
129 | 137 | if (Filter::postBool('save') && Filter::checkCsrf()) { |
130 | 138 | $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS)); |
131 | 139 | $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table')); |
@@ -195,7 +203,8 @@ discard block |
||
195 | 203 | * |
196 | 204 | * @return GedcomRecord[] List of records with changes |
197 | 205 | */ |
198 | - private function getRecentChanges(Tree $tree, $jd) { |
|
206 | + private function getRecentChanges(Tree $tree, $jd) |
|
207 | + { |
|
199 | 208 | $sql = |
200 | 209 | "SELECT d_gid FROM `##dates`" . |
201 | 210 | " WHERE d_fact='CHAN' AND d_julianday1 >= :jd AND d_file = :tree_id"; |
@@ -227,7 +236,8 @@ discard block |
||
227 | 236 | * |
228 | 237 | * @return string |
229 | 238 | */ |
230 | - private function changesList(array $records, $sort, $show_user) { |
|
239 | + private function changesList(array $records, $sort, $show_user) |
|
240 | + { |
|
231 | 241 | switch ($sort) { |
232 | 242 | case 'name': |
233 | 243 | uasort($records, array('self', 'sortByNameAndChangeDate')); |
@@ -276,7 +286,8 @@ discard block |
||
276 | 286 | * |
277 | 287 | * @return string |
278 | 288 | */ |
279 | - private function changesTable($records, $sort, $show_user) { |
|
289 | + private function changesTable($records, $sort, $show_user) |
|
290 | + { |
|
280 | 291 | global $controller; |
281 | 292 | |
282 | 293 | $table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page |
@@ -372,7 +383,8 @@ discard block |
||
372 | 383 | * |
373 | 384 | * @return int |
374 | 385 | */ |
375 | - private static function sortByChangeDateAndName(GedcomRecord $a, GedcomRecord $b) { |
|
386 | + private static function sortByChangeDateAndName(GedcomRecord $a, GedcomRecord $b) |
|
387 | + { |
|
376 | 388 | return $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true) ?: GedcomRecord::compare($a, $b); |
377 | 389 | } |
378 | 390 | |
@@ -384,7 +396,8 @@ discard block |
||
384 | 396 | * |
385 | 397 | * @return int |
386 | 398 | */ |
387 | - private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b) { |
|
399 | + private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b) |
|
400 | + { |
|
388 | 401 | return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true); |
389 | 402 | } |
390 | 403 | } |
@@ -26,132 +26,132 @@ |
||
26 | 26 | * Class TopGivenNamesModule |
27 | 27 | */ |
28 | 28 | class TopGivenNamesModule extends AbstractModule implements ModuleBlockInterface { |
29 | - /** {@inheritdoc} */ |
|
30 | - public function getTitle() { |
|
31 | - return /* I18N: Name of a module. Top=Most common */ I18N::translate('Top given names'); |
|
32 | - } |
|
33 | - |
|
34 | - /** {@inheritdoc} */ |
|
35 | - public function getDescription() { |
|
36 | - return /* I18N: Description of the “Top given names” module */ I18N::translate('A list of the most popular given names.'); |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Generate the HTML content of this block. |
|
41 | - * |
|
42 | - * @param int $block_id |
|
43 | - * @param bool $template |
|
44 | - * @param string[] $cfg |
|
45 | - * |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
49 | - global $ctype, $WT_TREE; |
|
50 | - |
|
51 | - $num = $this->getBlockSetting($block_id, 'num', '10'); |
|
52 | - $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
53 | - |
|
54 | - foreach (array('num', 'infoStyle') as $name) { |
|
55 | - if (array_key_exists($name, $cfg)) { |
|
56 | - $$name = $cfg[$name]; |
|
57 | - } |
|
58 | - } |
|
59 | - |
|
60 | - $stats = new Stats($WT_TREE); |
|
61 | - |
|
62 | - $id = $this->getName() . $block_id; |
|
63 | - $class = $this->getName() . '_block'; |
|
64 | - if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
65 | - $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
66 | - } else { |
|
67 | - $title = ''; |
|
68 | - } |
|
69 | - if ($num == 1) { |
|
70 | - // I18N: i.e. most popular given name. |
|
71 | - $title .= I18N::translate('Top given name'); |
|
72 | - } else { |
|
73 | - // I18N: Title for a list of the most common given names, %s is a number. Note that a separate translation exists when %s is 1 |
|
74 | - $title .= I18N::plural('Top %s given name', 'Top %s given names', $num, I18N::number($num)); |
|
75 | - } |
|
76 | - |
|
77 | - $content = '<div class="normal_inner_block">'; |
|
78 | - //Select List or Table |
|
79 | - switch ($infoStyle) { |
|
80 | - case "list": // Output style 1: Simple list style. Better suited to left side of page. |
|
81 | - if (I18N::direction() === 'ltr') { |
|
82 | - $padding = 'padding-left: 15px'; |
|
83 | - } else { |
|
84 | - $padding = 'padding-right: 15px'; |
|
85 | - } |
|
86 | - $params = array(1, $num, 'rcount'); |
|
87 | - // List Female names |
|
88 | - $totals = $stats->commonGivenFemaleTotals($params); |
|
89 | - if ($totals) { |
|
90 | - $content .= '<b>' . I18N::translate('Females') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
91 | - } |
|
92 | - // List Male names |
|
93 | - $totals = $stats->commonGivenMaleTotals($params); |
|
94 | - if ($totals) { |
|
95 | - $content .= '<b>' . I18N::translate('Males') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
96 | - } |
|
97 | - break; |
|
98 | - case "table": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page |
|
99 | - $params = array(1, $num, 'rcount'); |
|
100 | - $content .= '<table style="margin:auto;"> |
|
29 | + /** {@inheritdoc} */ |
|
30 | + public function getTitle() { |
|
31 | + return /* I18N: Name of a module. Top=Most common */ I18N::translate('Top given names'); |
|
32 | + } |
|
33 | + |
|
34 | + /** {@inheritdoc} */ |
|
35 | + public function getDescription() { |
|
36 | + return /* I18N: Description of the “Top given names” module */ I18N::translate('A list of the most popular given names.'); |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Generate the HTML content of this block. |
|
41 | + * |
|
42 | + * @param int $block_id |
|
43 | + * @param bool $template |
|
44 | + * @param string[] $cfg |
|
45 | + * |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
49 | + global $ctype, $WT_TREE; |
|
50 | + |
|
51 | + $num = $this->getBlockSetting($block_id, 'num', '10'); |
|
52 | + $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
53 | + |
|
54 | + foreach (array('num', 'infoStyle') as $name) { |
|
55 | + if (array_key_exists($name, $cfg)) { |
|
56 | + $$name = $cfg[$name]; |
|
57 | + } |
|
58 | + } |
|
59 | + |
|
60 | + $stats = new Stats($WT_TREE); |
|
61 | + |
|
62 | + $id = $this->getName() . $block_id; |
|
63 | + $class = $this->getName() . '_block'; |
|
64 | + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
65 | + $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
66 | + } else { |
|
67 | + $title = ''; |
|
68 | + } |
|
69 | + if ($num == 1) { |
|
70 | + // I18N: i.e. most popular given name. |
|
71 | + $title .= I18N::translate('Top given name'); |
|
72 | + } else { |
|
73 | + // I18N: Title for a list of the most common given names, %s is a number. Note that a separate translation exists when %s is 1 |
|
74 | + $title .= I18N::plural('Top %s given name', 'Top %s given names', $num, I18N::number($num)); |
|
75 | + } |
|
76 | + |
|
77 | + $content = '<div class="normal_inner_block">'; |
|
78 | + //Select List or Table |
|
79 | + switch ($infoStyle) { |
|
80 | + case "list": // Output style 1: Simple list style. Better suited to left side of page. |
|
81 | + if (I18N::direction() === 'ltr') { |
|
82 | + $padding = 'padding-left: 15px'; |
|
83 | + } else { |
|
84 | + $padding = 'padding-right: 15px'; |
|
85 | + } |
|
86 | + $params = array(1, $num, 'rcount'); |
|
87 | + // List Female names |
|
88 | + $totals = $stats->commonGivenFemaleTotals($params); |
|
89 | + if ($totals) { |
|
90 | + $content .= '<b>' . I18N::translate('Females') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
91 | + } |
|
92 | + // List Male names |
|
93 | + $totals = $stats->commonGivenMaleTotals($params); |
|
94 | + if ($totals) { |
|
95 | + $content .= '<b>' . I18N::translate('Males') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
96 | + } |
|
97 | + break; |
|
98 | + case "table": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page |
|
99 | + $params = array(1, $num, 'rcount'); |
|
100 | + $content .= '<table style="margin:auto;"> |
|
101 | 101 | <tr> |
102 | 102 | <td>' . $stats->commonGivenFemaleTable($params) . '</td> |
103 | 103 | <td>' . $stats->commonGivenMaleTable($params) . '</td>'; |
104 | - $content .= '</tr></table>'; |
|
105 | - break; |
|
106 | - } |
|
107 | - $content .= "</div>"; |
|
108 | - |
|
109 | - if ($template) { |
|
110 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
111 | - } else { |
|
112 | - return $content; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - /** {@inheritdoc} */ |
|
117 | - public function loadAjax() { |
|
118 | - return true; |
|
119 | - } |
|
120 | - |
|
121 | - /** {@inheritdoc} */ |
|
122 | - public function isUserBlock() { |
|
123 | - return true; |
|
124 | - } |
|
125 | - |
|
126 | - /** {@inheritdoc} */ |
|
127 | - public function isGedcomBlock() { |
|
128 | - return true; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * An HTML form to edit block settings |
|
133 | - * |
|
134 | - * @param int $block_id |
|
135 | - */ |
|
136 | - public function configureBlock($block_id) { |
|
137 | - if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
138 | - $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); |
|
139 | - $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); |
|
140 | - } |
|
141 | - |
|
142 | - $num = $this->getBlockSetting($block_id, 'num', '10'); |
|
143 | - $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
144 | - |
|
145 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
146 | - echo /* I18N: ... to show in a list */ I18N::translate('Number of given names'); |
|
147 | - echo '</td><td class="optionbox">'; |
|
148 | - echo '<input type="text" name="num" size="2" value="', $num, '">'; |
|
149 | - echo '</td></tr>'; |
|
150 | - |
|
151 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
152 | - echo I18N::translate('Presentation style'); |
|
153 | - echo '</td><td class="optionbox">'; |
|
154 | - echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); |
|
155 | - echo '</td></tr>'; |
|
156 | - } |
|
104 | + $content .= '</tr></table>'; |
|
105 | + break; |
|
106 | + } |
|
107 | + $content .= "</div>"; |
|
108 | + |
|
109 | + if ($template) { |
|
110 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
111 | + } else { |
|
112 | + return $content; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + /** {@inheritdoc} */ |
|
117 | + public function loadAjax() { |
|
118 | + return true; |
|
119 | + } |
|
120 | + |
|
121 | + /** {@inheritdoc} */ |
|
122 | + public function isUserBlock() { |
|
123 | + return true; |
|
124 | + } |
|
125 | + |
|
126 | + /** {@inheritdoc} */ |
|
127 | + public function isGedcomBlock() { |
|
128 | + return true; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * An HTML form to edit block settings |
|
133 | + * |
|
134 | + * @param int $block_id |
|
135 | + */ |
|
136 | + public function configureBlock($block_id) { |
|
137 | + if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
138 | + $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); |
|
139 | + $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); |
|
140 | + } |
|
141 | + |
|
142 | + $num = $this->getBlockSetting($block_id, 'num', '10'); |
|
143 | + $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
144 | + |
|
145 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
146 | + echo /* I18N: ... to show in a list */ I18N::translate('Number of given names'); |
|
147 | + echo '</td><td class="optionbox">'; |
|
148 | + echo '<input type="text" name="num" size="2" value="', $num, '">'; |
|
149 | + echo '</td></tr>'; |
|
150 | + |
|
151 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
152 | + echo I18N::translate('Presentation style'); |
|
153 | + echo '</td><td class="optionbox">'; |
|
154 | + echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); |
|
155 | + echo '</td></tr>'; |
|
156 | + } |
|
157 | 157 | } |
@@ -77,32 +77,32 @@ |
||
77 | 77 | $content = '<div class="normal_inner_block">'; |
78 | 78 | //Select List or Table |
79 | 79 | switch ($infoStyle) { |
80 | - case "list": // Output style 1: Simple list style. Better suited to left side of page. |
|
81 | - if (I18N::direction() === 'ltr') { |
|
82 | - $padding = 'padding-left: 15px'; |
|
83 | - } else { |
|
84 | - $padding = 'padding-right: 15px'; |
|
85 | - } |
|
86 | - $params = array(1, $num, 'rcount'); |
|
87 | - // List Female names |
|
88 | - $totals = $stats->commonGivenFemaleTotals($params); |
|
89 | - if ($totals) { |
|
90 | - $content .= '<b>' . I18N::translate('Females') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
91 | - } |
|
92 | - // List Male names |
|
93 | - $totals = $stats->commonGivenMaleTotals($params); |
|
94 | - if ($totals) { |
|
95 | - $content .= '<b>' . I18N::translate('Males') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
96 | - } |
|
97 | - break; |
|
98 | - case "table": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page |
|
99 | - $params = array(1, $num, 'rcount'); |
|
100 | - $content .= '<table style="margin:auto;"> |
|
80 | + case "list": // Output style 1: Simple list style. Better suited to left side of page. |
|
81 | + if (I18N::direction() === 'ltr') { |
|
82 | + $padding = 'padding-left: 15px'; |
|
83 | + } else { |
|
84 | + $padding = 'padding-right: 15px'; |
|
85 | + } |
|
86 | + $params = array(1, $num, 'rcount'); |
|
87 | + // List Female names |
|
88 | + $totals = $stats->commonGivenFemaleTotals($params); |
|
89 | + if ($totals) { |
|
90 | + $content .= '<b>' . I18N::translate('Females') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
91 | + } |
|
92 | + // List Male names |
|
93 | + $totals = $stats->commonGivenMaleTotals($params); |
|
94 | + if ($totals) { |
|
95 | + $content .= '<b>' . I18N::translate('Males') . '</b><div class="wrap" style="' . $padding . '">' . $totals . '</div><br>'; |
|
96 | + } |
|
97 | + break; |
|
98 | + case "table": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page |
|
99 | + $params = array(1, $num, 'rcount'); |
|
100 | + $content .= '<table style="margin:auto;"> |
|
101 | 101 | <tr> |
102 | 102 | <td>' . $stats->commonGivenFemaleTable($params) . '</td> |
103 | 103 | <td>' . $stats->commonGivenMaleTable($params) . '</td>'; |
104 | - $content .= '</tr></table>'; |
|
105 | - break; |
|
104 | + $content .= '</tr></table>'; |
|
105 | + break; |
|
106 | 106 | } |
107 | 107 | $content .= "</div>"; |
108 | 108 |
@@ -25,14 +25,17 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Class TopGivenNamesModule |
27 | 27 | */ |
28 | -class TopGivenNamesModule extends AbstractModule implements ModuleBlockInterface { |
|
28 | +class TopGivenNamesModule extends AbstractModule implements ModuleBlockInterface |
|
29 | +{ |
|
29 | 30 | /** {@inheritdoc} */ |
30 | - public function getTitle() { |
|
31 | + public function getTitle() |
|
32 | + { |
|
31 | 33 | return /* I18N: Name of a module. Top=Most common */ I18N::translate('Top given names'); |
32 | 34 | } |
33 | 35 | |
34 | 36 | /** {@inheritdoc} */ |
35 | - public function getDescription() { |
|
37 | + public function getDescription() |
|
38 | + { |
|
36 | 39 | return /* I18N: Description of the “Top given names” module */ I18N::translate('A list of the most popular given names.'); |
37 | 40 | } |
38 | 41 | |
@@ -45,7 +48,8 @@ discard block |
||
45 | 48 | * |
46 | 49 | * @return string |
47 | 50 | */ |
48 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
51 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
52 | + { |
|
49 | 53 | global $ctype, $WT_TREE; |
50 | 54 | |
51 | 55 | $num = $this->getBlockSetting($block_id, 'num', '10'); |
@@ -114,17 +118,20 @@ discard block |
||
114 | 118 | } |
115 | 119 | |
116 | 120 | /** {@inheritdoc} */ |
117 | - public function loadAjax() { |
|
121 | + public function loadAjax() |
|
122 | + { |
|
118 | 123 | return true; |
119 | 124 | } |
120 | 125 | |
121 | 126 | /** {@inheritdoc} */ |
122 | - public function isUserBlock() { |
|
127 | + public function isUserBlock() |
|
128 | + { |
|
123 | 129 | return true; |
124 | 130 | } |
125 | 131 | |
126 | 132 | /** {@inheritdoc} */ |
127 | - public function isGedcomBlock() { |
|
133 | + public function isGedcomBlock() |
|
134 | + { |
|
128 | 135 | return true; |
129 | 136 | } |
130 | 137 | |
@@ -133,7 +140,8 @@ discard block |
||
133 | 140 | * |
134 | 141 | * @param int $block_id |
135 | 142 | */ |
136 | - public function configureBlock($block_id) { |
|
143 | + public function configureBlock($block_id) |
|
144 | + { |
|
137 | 145 | if (Filter::postBool('save') && Filter::checkCsrf()) { |
138 | 146 | $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); |
139 | 147 | $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); |
@@ -20,5 +20,6 @@ |
||
20 | 20 | * |
21 | 21 | * This class is not currently used |
22 | 22 | */ |
23 | -interface ModuleThemeInterface { |
|
23 | +interface ModuleThemeInterface |
|
24 | +{ |
|
24 | 25 | } |
@@ -23,42 +23,42 @@ |
||
23 | 23 | * Class DescendancyReportModule |
24 | 24 | */ |
25 | 25 | class DescendancyReportModule extends AbstractModule implements ModuleReportInterface { |
26 | - /** {@inheritdoc} */ |
|
27 | - public function getTitle() { |
|
28 | - // This text also appears in the .XML file - update both together |
|
29 | - return /* I18N: Name of a module/report */ I18N::translate('Descendants'); |
|
30 | - } |
|
26 | + /** {@inheritdoc} */ |
|
27 | + public function getTitle() { |
|
28 | + // This text also appears in the .XML file - update both together |
|
29 | + return /* I18N: Name of a module/report */ I18N::translate('Descendants'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** {@inheritdoc} */ |
|
33 | - public function getDescription() { |
|
34 | - // This text also appears in the .XML file - update both together |
|
35 | - return /* I18N: Description of the “Descendants” module */ I18N::translate('A report of an individual’s descendants, in a narrative style.'); |
|
36 | - } |
|
32 | + /** {@inheritdoc} */ |
|
33 | + public function getDescription() { |
|
34 | + // This text also appears in the .XML file - update both together |
|
35 | + return /* I18N: Description of the “Descendants” module */ I18N::translate('A report of an individual’s descendants, in a narrative style.'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * What is the default access level for this module? |
|
40 | - * |
|
41 | - * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function defaultAccessLevel() { |
|
46 | - return Auth::PRIV_PRIVATE; |
|
47 | - } |
|
38 | + /** |
|
39 | + * What is the default access level for this module? |
|
40 | + * |
|
41 | + * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function defaultAccessLevel() { |
|
46 | + return Auth::PRIV_PRIVATE; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Return a menu item for this report. |
|
51 | - * |
|
52 | - * @return Menu |
|
53 | - */ |
|
54 | - public function getReportMenu() { |
|
55 | - global $controller, $WT_TREE; |
|
49 | + /** |
|
50 | + * Return a menu item for this report. |
|
51 | + * |
|
52 | + * @return Menu |
|
53 | + */ |
|
54 | + public function getReportMenu() { |
|
55 | + global $controller, $WT_TREE; |
|
56 | 56 | |
57 | - return new Menu( |
|
58 | - $this->getTitle(), |
|
59 | - 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), |
|
60 | - 'menu-report-' . $this->getName(), |
|
61 | - array('rel' => 'nofollow') |
|
62 | - ); |
|
63 | - } |
|
57 | + return new Menu( |
|
58 | + $this->getTitle(), |
|
59 | + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), |
|
60 | + 'menu-report-' . $this->getName(), |
|
61 | + array('rel' => 'nofollow') |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | } |
@@ -22,15 +22,18 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Class DescendancyReportModule |
24 | 24 | */ |
25 | -class DescendancyReportModule extends AbstractModule implements ModuleReportInterface { |
|
25 | +class DescendancyReportModule extends AbstractModule implements ModuleReportInterface |
|
26 | +{ |
|
26 | 27 | /** {@inheritdoc} */ |
27 | - public function getTitle() { |
|
28 | + public function getTitle() |
|
29 | + { |
|
28 | 30 | // This text also appears in the .XML file - update both together |
29 | 31 | return /* I18N: Name of a module/report */ I18N::translate('Descendants'); |
30 | 32 | } |
31 | 33 | |
32 | 34 | /** {@inheritdoc} */ |
33 | - public function getDescription() { |
|
35 | + public function getDescription() |
|
36 | + { |
|
34 | 37 | // This text also appears in the .XML file - update both together |
35 | 38 | return /* I18N: Description of the “Descendants” module */ I18N::translate('A report of an individual’s descendants, in a narrative style.'); |
36 | 39 | } |
@@ -42,7 +45,8 @@ discard block |
||
42 | 45 | * |
43 | 46 | * @return int |
44 | 47 | */ |
45 | - public function defaultAccessLevel() { |
|
48 | + public function defaultAccessLevel() |
|
49 | + { |
|
46 | 50 | return Auth::PRIV_PRIVATE; |
47 | 51 | } |
48 | 52 | |
@@ -51,7 +55,8 @@ discard block |
||
51 | 55 | * |
52 | 56 | * @return Menu |
53 | 57 | */ |
54 | - public function getReportMenu() { |
|
58 | + public function getReportMenu() |
|
59 | + { |
|
55 | 60 | global $controller, $WT_TREE; |
56 | 61 | |
57 | 62 | return new Menu( |
@@ -23,42 +23,42 @@ |
||
23 | 23 | * Class IndividualFamiliesReportModule |
24 | 24 | */ |
25 | 25 | class IndividualFamiliesReportModule extends AbstractModule implements ModuleReportInterface { |
26 | - /** {@inheritdoc} */ |
|
27 | - public function getTitle() { |
|
28 | - // This text also appears in the .XML file - update both together |
|
29 | - return /* I18N: Name of a module/report */ I18N::translate('Related families'); |
|
30 | - } |
|
26 | + /** {@inheritdoc} */ |
|
27 | + public function getTitle() { |
|
28 | + // This text also appears in the .XML file - update both together |
|
29 | + return /* I18N: Name of a module/report */ I18N::translate('Related families'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** {@inheritdoc} */ |
|
33 | - public function getDescription() { |
|
34 | - // This text also appears in the .XML file - update both together |
|
35 | - return /* I18N: Description of the “Related families” */ I18N::translate('A report of the families that are closely related to an individual.'); |
|
36 | - } |
|
32 | + /** {@inheritdoc} */ |
|
33 | + public function getDescription() { |
|
34 | + // This text also appears in the .XML file - update both together |
|
35 | + return /* I18N: Description of the “Related families” */ I18N::translate('A report of the families that are closely related to an individual.'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * What is the default access level for this module? |
|
40 | - * |
|
41 | - * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function defaultAccessLevel() { |
|
46 | - return Auth::PRIV_USER; |
|
47 | - } |
|
38 | + /** |
|
39 | + * What is the default access level for this module? |
|
40 | + * |
|
41 | + * Some modules are aimed at admins or managers, and are not generally shown to users. |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function defaultAccessLevel() { |
|
46 | + return Auth::PRIV_USER; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Return a menu item for this report. |
|
51 | - * |
|
52 | - * @return Menu |
|
53 | - */ |
|
54 | - public function getReportMenu() { |
|
55 | - global $controller, $WT_TREE; |
|
49 | + /** |
|
50 | + * Return a menu item for this report. |
|
51 | + * |
|
52 | + * @return Menu |
|
53 | + */ |
|
54 | + public function getReportMenu() { |
|
55 | + global $controller, $WT_TREE; |
|
56 | 56 | |
57 | - return new Menu( |
|
58 | - $this->getTitle(), |
|
59 | - 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), |
|
60 | - 'menu-report-' . $this->getName(), |
|
61 | - array('rel' => 'nofollow') |
|
62 | - ); |
|
63 | - } |
|
57 | + return new Menu( |
|
58 | + $this->getTitle(), |
|
59 | + 'reportengine.php?ged=' . $WT_TREE->getNameUrl() . '&action=setup&report=' . WT_MODULES_DIR . $this->getName() . '/report.xml&pid=' . $controller->getSignificantIndividual()->getXref(), |
|
60 | + 'menu-report-' . $this->getName(), |
|
61 | + array('rel' => 'nofollow') |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | } |
@@ -22,15 +22,18 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Class IndividualFamiliesReportModule |
24 | 24 | */ |
25 | -class IndividualFamiliesReportModule extends AbstractModule implements ModuleReportInterface { |
|
25 | +class IndividualFamiliesReportModule extends AbstractModule implements ModuleReportInterface |
|
26 | +{ |
|
26 | 27 | /** {@inheritdoc} */ |
27 | - public function getTitle() { |
|
28 | + public function getTitle() |
|
29 | + { |
|
28 | 30 | // This text also appears in the .XML file - update both together |
29 | 31 | return /* I18N: Name of a module/report */ I18N::translate('Related families'); |
30 | 32 | } |
31 | 33 | |
32 | 34 | /** {@inheritdoc} */ |
33 | - public function getDescription() { |
|
35 | + public function getDescription() |
|
36 | + { |
|
34 | 37 | // This text also appears in the .XML file - update both together |
35 | 38 | return /* I18N: Description of the “Related families” */ I18N::translate('A report of the families that are closely related to an individual.'); |
36 | 39 | } |
@@ -42,7 +45,8 @@ discard block |
||
42 | 45 | * |
43 | 46 | * @return int |
44 | 47 | */ |
45 | - public function defaultAccessLevel() { |
|
48 | + public function defaultAccessLevel() |
|
49 | + { |
|
46 | 50 | return Auth::PRIV_USER; |
47 | 51 | } |
48 | 52 | |
@@ -51,7 +55,8 @@ discard block |
||
51 | 55 | * |
52 | 56 | * @return Menu |
53 | 57 | */ |
54 | - public function getReportMenu() { |
|
58 | + public function getReportMenu() |
|
59 | + { |
|
55 | 60 | global $controller, $WT_TREE; |
56 | 61 | |
57 | 62 | return new Menu( |
@@ -26,137 +26,137 @@ |
||
26 | 26 | * Class OnThisDayModule |
27 | 27 | */ |
28 | 28 | class OnThisDayModule extends AbstractModule implements ModuleBlockInterface { |
29 | - /** {@inheritdoc} */ |
|
30 | - public function getTitle() { |
|
31 | - return /* I18N: Name of a module */ I18N::translate('On this day'); |
|
32 | - } |
|
33 | - |
|
34 | - /** {@inheritdoc} */ |
|
35 | - public function getDescription() { |
|
36 | - return /* I18N: Description of the “On this day” module */ I18N::translate('A list of the anniversaries that occur today.'); |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Generate the HTML content of this block. |
|
41 | - * |
|
42 | - * @param int $block_id |
|
43 | - * @param bool $template |
|
44 | - * @param string[] $cfg |
|
45 | - * |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
49 | - global $ctype, $WT_TREE; |
|
50 | - |
|
51 | - $filter = $this->getBlockSetting($block_id, 'filter', '1'); |
|
52 | - $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
53 | - $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'alpha'); |
|
54 | - $block = $this->getBlockSetting($block_id, 'block', '1'); |
|
55 | - |
|
56 | - foreach (array('filter', 'infoStyle', 'sortStyle', 'block') as $name) { |
|
57 | - if (array_key_exists($name, $cfg)) { |
|
58 | - $$name = $cfg[$name]; |
|
59 | - } |
|
60 | - } |
|
61 | - |
|
62 | - $todayjd = WT_CLIENT_JD; |
|
63 | - |
|
64 | - $id = $this->getName() . $block_id; |
|
65 | - $class = $this->getName() . '_block'; |
|
66 | - if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
67 | - $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
68 | - } else { |
|
69 | - $title = ''; |
|
70 | - } |
|
71 | - $title .= $this->getTitle(); |
|
72 | - |
|
73 | - $content = ''; |
|
74 | - |
|
75 | - // If we are only showing living individuals, then we don't need to search for DEAT events. |
|
76 | - $tags = $filter ? 'BIRT MARR' : 'BIRT MARR DEAT'; |
|
77 | - |
|
78 | - switch ($infoStyle) { |
|
79 | - case 'list': |
|
80 | - // Output style 1: Old format, no visible tables, much smaller text. Better suited to right side of page. |
|
81 | - $content .= FunctionsPrintLists::eventsList($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
82 | - break; |
|
83 | - case 'table': |
|
84 | - // Style 2: New format, tables, big text, etc. Not too good on right side of page |
|
85 | - ob_start(); |
|
86 | - $content .= FunctionsPrintLists::eventsTable($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
87 | - $content .= ob_get_clean(); |
|
88 | - break; |
|
89 | - } |
|
90 | - |
|
91 | - if ($template) { |
|
92 | - if ($block) { |
|
93 | - $class .= ' small_inner_block'; |
|
94 | - } |
|
95 | - |
|
96 | - return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
97 | - } else { |
|
98 | - return $content; |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - /** {@inheritdoc} */ |
|
103 | - public function loadAjax() { |
|
104 | - return true; |
|
105 | - } |
|
106 | - |
|
107 | - /** {@inheritdoc} */ |
|
108 | - public function isUserBlock() { |
|
109 | - return true; |
|
110 | - } |
|
111 | - |
|
112 | - /** {@inheritdoc} */ |
|
113 | - public function isGedcomBlock() { |
|
114 | - return true; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * An HTML form to edit block settings |
|
119 | - * |
|
120 | - * @param int $block_id |
|
121 | - */ |
|
122 | - public function configureBlock($block_id) { |
|
123 | - if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
124 | - $this->setBlockSetting($block_id, 'filter', Filter::postBool('filter')); |
|
125 | - $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); |
|
126 | - $this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'alpha|anniv', 'alpha')); |
|
127 | - $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); |
|
128 | - } |
|
129 | - |
|
130 | - $filter = $this->getBlockSetting($block_id, 'filter', '1'); |
|
131 | - $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
132 | - $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'alpha'); |
|
133 | - $block = $this->getBlockSetting($block_id, 'block', '1'); |
|
134 | - |
|
135 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
136 | - echo /* I18N: Label for a configuration option */ I18N::translate('Show only events of living individuals'); |
|
137 | - echo '</td><td class="optionbox">'; |
|
138 | - echo FunctionsEdit::editFieldYesNo('filter', $filter); |
|
139 | - echo '</td></tr>'; |
|
140 | - |
|
141 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
142 | - echo /* I18N: Label for a configuration option */ I18N::translate('Presentation style'); |
|
143 | - echo '</td><td class="optionbox">'; |
|
144 | - echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); |
|
145 | - echo '</td></tr>'; |
|
146 | - |
|
147 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
148 | - echo /* I18N: Label for a configuration option */ I18N::translate('Sort order'); |
|
149 | - echo '</td><td class="optionbox">'; |
|
150 | - echo FunctionsEdit::selectEditControl('sortStyle', array( |
|
151 | - /* I18N: An option in a list-box */ 'alpha' => I18N::translate('sort by name'), |
|
152 | - /* I18N: An option in a list-box */ 'anniv' => I18N::translate('sort by date'), |
|
153 | - ), null, $sortStyle, ''); |
|
154 | - echo '</td></tr>'; |
|
155 | - |
|
156 | - echo '<tr><td class="descriptionbox wrap width33">'; |
|
157 | - echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow'); |
|
158 | - echo '</td><td class="optionbox">'; |
|
159 | - echo FunctionsEdit::editFieldYesNo('block', $block); |
|
160 | - echo '</td></tr>'; |
|
161 | - } |
|
29 | + /** {@inheritdoc} */ |
|
30 | + public function getTitle() { |
|
31 | + return /* I18N: Name of a module */ I18N::translate('On this day'); |
|
32 | + } |
|
33 | + |
|
34 | + /** {@inheritdoc} */ |
|
35 | + public function getDescription() { |
|
36 | + return /* I18N: Description of the “On this day” module */ I18N::translate('A list of the anniversaries that occur today.'); |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Generate the HTML content of this block. |
|
41 | + * |
|
42 | + * @param int $block_id |
|
43 | + * @param bool $template |
|
44 | + * @param string[] $cfg |
|
45 | + * |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
49 | + global $ctype, $WT_TREE; |
|
50 | + |
|
51 | + $filter = $this->getBlockSetting($block_id, 'filter', '1'); |
|
52 | + $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
53 | + $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'alpha'); |
|
54 | + $block = $this->getBlockSetting($block_id, 'block', '1'); |
|
55 | + |
|
56 | + foreach (array('filter', 'infoStyle', 'sortStyle', 'block') as $name) { |
|
57 | + if (array_key_exists($name, $cfg)) { |
|
58 | + $$name = $cfg[$name]; |
|
59 | + } |
|
60 | + } |
|
61 | + |
|
62 | + $todayjd = WT_CLIENT_JD; |
|
63 | + |
|
64 | + $id = $this->getName() . $block_id; |
|
65 | + $class = $this->getName() . '_block'; |
|
66 | + if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { |
|
67 | + $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>'; |
|
68 | + } else { |
|
69 | + $title = ''; |
|
70 | + } |
|
71 | + $title .= $this->getTitle(); |
|
72 | + |
|
73 | + $content = ''; |
|
74 | + |
|
75 | + // If we are only showing living individuals, then we don't need to search for DEAT events. |
|
76 | + $tags = $filter ? 'BIRT MARR' : 'BIRT MARR DEAT'; |
|
77 | + |
|
78 | + switch ($infoStyle) { |
|
79 | + case 'list': |
|
80 | + // Output style 1: Old format, no visible tables, much smaller text. Better suited to right side of page. |
|
81 | + $content .= FunctionsPrintLists::eventsList($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
82 | + break; |
|
83 | + case 'table': |
|
84 | + // Style 2: New format, tables, big text, etc. Not too good on right side of page |
|
85 | + ob_start(); |
|
86 | + $content .= FunctionsPrintLists::eventsTable($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
87 | + $content .= ob_get_clean(); |
|
88 | + break; |
|
89 | + } |
|
90 | + |
|
91 | + if ($template) { |
|
92 | + if ($block) { |
|
93 | + $class .= ' small_inner_block'; |
|
94 | + } |
|
95 | + |
|
96 | + return Theme::theme()->formatBlock($id, $title, $class, $content); |
|
97 | + } else { |
|
98 | + return $content; |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + /** {@inheritdoc} */ |
|
103 | + public function loadAjax() { |
|
104 | + return true; |
|
105 | + } |
|
106 | + |
|
107 | + /** {@inheritdoc} */ |
|
108 | + public function isUserBlock() { |
|
109 | + return true; |
|
110 | + } |
|
111 | + |
|
112 | + /** {@inheritdoc} */ |
|
113 | + public function isGedcomBlock() { |
|
114 | + return true; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * An HTML form to edit block settings |
|
119 | + * |
|
120 | + * @param int $block_id |
|
121 | + */ |
|
122 | + public function configureBlock($block_id) { |
|
123 | + if (Filter::postBool('save') && Filter::checkCsrf()) { |
|
124 | + $this->setBlockSetting($block_id, 'filter', Filter::postBool('filter')); |
|
125 | + $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); |
|
126 | + $this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'alpha|anniv', 'alpha')); |
|
127 | + $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); |
|
128 | + } |
|
129 | + |
|
130 | + $filter = $this->getBlockSetting($block_id, 'filter', '1'); |
|
131 | + $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); |
|
132 | + $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'alpha'); |
|
133 | + $block = $this->getBlockSetting($block_id, 'block', '1'); |
|
134 | + |
|
135 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
136 | + echo /* I18N: Label for a configuration option */ I18N::translate('Show only events of living individuals'); |
|
137 | + echo '</td><td class="optionbox">'; |
|
138 | + echo FunctionsEdit::editFieldYesNo('filter', $filter); |
|
139 | + echo '</td></tr>'; |
|
140 | + |
|
141 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
142 | + echo /* I18N: Label for a configuration option */ I18N::translate('Presentation style'); |
|
143 | + echo '</td><td class="optionbox">'; |
|
144 | + echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); |
|
145 | + echo '</td></tr>'; |
|
146 | + |
|
147 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
148 | + echo /* I18N: Label for a configuration option */ I18N::translate('Sort order'); |
|
149 | + echo '</td><td class="optionbox">'; |
|
150 | + echo FunctionsEdit::selectEditControl('sortStyle', array( |
|
151 | + /* I18N: An option in a list-box */ 'alpha' => I18N::translate('sort by name'), |
|
152 | + /* I18N: An option in a list-box */ 'anniv' => I18N::translate('sort by date'), |
|
153 | + ), null, $sortStyle, ''); |
|
154 | + echo '</td></tr>'; |
|
155 | + |
|
156 | + echo '<tr><td class="descriptionbox wrap width33">'; |
|
157 | + echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow'); |
|
158 | + echo '</td><td class="optionbox">'; |
|
159 | + echo FunctionsEdit::editFieldYesNo('block', $block); |
|
160 | + echo '</td></tr>'; |
|
161 | + } |
|
162 | 162 | } |
@@ -76,16 +76,16 @@ |
||
76 | 76 | $tags = $filter ? 'BIRT MARR' : 'BIRT MARR DEAT'; |
77 | 77 | |
78 | 78 | switch ($infoStyle) { |
79 | - case 'list': |
|
80 | - // Output style 1: Old format, no visible tables, much smaller text. Better suited to right side of page. |
|
81 | - $content .= FunctionsPrintLists::eventsList($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
82 | - break; |
|
83 | - case 'table': |
|
84 | - // Style 2: New format, tables, big text, etc. Not too good on right side of page |
|
85 | - ob_start(); |
|
86 | - $content .= FunctionsPrintLists::eventsTable($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
87 | - $content .= ob_get_clean(); |
|
88 | - break; |
|
79 | + case 'list': |
|
80 | + // Output style 1: Old format, no visible tables, much smaller text. Better suited to right side of page. |
|
81 | + $content .= FunctionsPrintLists::eventsList($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
82 | + break; |
|
83 | + case 'table': |
|
84 | + // Style 2: New format, tables, big text, etc. Not too good on right side of page |
|
85 | + ob_start(); |
|
86 | + $content .= FunctionsPrintLists::eventsTable($todayjd, $todayjd, $tags, $filter, $sortStyle); |
|
87 | + $content .= ob_get_clean(); |
|
88 | + break; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if ($template) { |
@@ -25,14 +25,17 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Class OnThisDayModule |
27 | 27 | */ |
28 | -class OnThisDayModule extends AbstractModule implements ModuleBlockInterface { |
|
28 | +class OnThisDayModule extends AbstractModule implements ModuleBlockInterface |
|
29 | +{ |
|
29 | 30 | /** {@inheritdoc} */ |
30 | - public function getTitle() { |
|
31 | + public function getTitle() |
|
32 | + { |
|
31 | 33 | return /* I18N: Name of a module */ I18N::translate('On this day'); |
32 | 34 | } |
33 | 35 | |
34 | 36 | /** {@inheritdoc} */ |
35 | - public function getDescription() { |
|
37 | + public function getDescription() |
|
38 | + { |
|
36 | 39 | return /* I18N: Description of the “On this day” module */ I18N::translate('A list of the anniversaries that occur today.'); |
37 | 40 | } |
38 | 41 | |
@@ -45,7 +48,8 @@ discard block |
||
45 | 48 | * |
46 | 49 | * @return string |
47 | 50 | */ |
48 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
51 | + public function getBlock($block_id, $template = true, $cfg = array()) |
|
52 | + { |
|
49 | 53 | global $ctype, $WT_TREE; |
50 | 54 | |
51 | 55 | $filter = $this->getBlockSetting($block_id, 'filter', '1'); |
@@ -100,17 +104,20 @@ discard block |
||
100 | 104 | } |
101 | 105 | |
102 | 106 | /** {@inheritdoc} */ |
103 | - public function loadAjax() { |
|
107 | + public function loadAjax() |
|
108 | + { |
|
104 | 109 | return true; |
105 | 110 | } |
106 | 111 | |
107 | 112 | /** {@inheritdoc} */ |
108 | - public function isUserBlock() { |
|
113 | + public function isUserBlock() |
|
114 | + { |
|
109 | 115 | return true; |
110 | 116 | } |
111 | 117 | |
112 | 118 | /** {@inheritdoc} */ |
113 | - public function isGedcomBlock() { |
|
119 | + public function isGedcomBlock() |
|
120 | + { |
|
114 | 121 | return true; |
115 | 122 | } |
116 | 123 | |
@@ -119,7 +126,8 @@ discard block |
||
119 | 126 | * |
120 | 127 | * @param int $block_id |
121 | 128 | */ |
122 | - public function configureBlock($block_id) { |
|
129 | + public function configureBlock($block_id) |
|
130 | + { |
|
123 | 131 | if (Filter::postBool('save') && Filter::checkCsrf()) { |
124 | 132 | $this->setBlockSetting($block_id, 'filter', Filter::postBool('filter')); |
125 | 133 | $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); |