1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
4
|
|
|
* |
5
|
|
|
* @package MyArtJaub\Webtrees |
6
|
|
|
* @subpackage WelcomeBlock |
7
|
|
|
* @author Jonathan Jaubart <[email protected]> |
8
|
|
|
* @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
9
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
10
|
|
|
*/ |
11
|
|
|
namespace MyArtJaub\Webtrees\Module\WelcomeBlock; |
12
|
|
|
|
13
|
|
|
use Fisharebest\Webtrees\Auth; |
14
|
|
|
use Fisharebest\Webtrees\Controller\BaseController; |
15
|
|
|
use Fisharebest\Webtrees\Controller\PageController; |
16
|
|
|
use Fisharebest\Webtrees\Filter; |
17
|
|
|
use Fisharebest\Webtrees\I18N; |
18
|
|
|
use Fisharebest\Webtrees\Theme; |
19
|
|
|
use Fisharebest\Webtrees\Tree; |
20
|
|
|
use MyArtJaub\Webtrees\Cache; |
21
|
|
|
use MyArtJaub\Webtrees\Mvc\Controller\MvcController; |
22
|
|
|
use MyArtJaub\Webtrees\Mvc\MvcException; |
23
|
|
|
use MyArtJaub\Webtrees\Mvc\View\ViewBag; |
24
|
|
|
use MyArtJaub\Webtrees\Mvc\View\ViewFactory; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Controller for Lineage |
28
|
|
|
*/ |
29
|
|
|
class WelcomeBlockController extends MvcController |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Pages |
34
|
|
|
*/ |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* WelcomeBlock@index |
38
|
|
|
* |
39
|
|
|
* @param PageController $parent_controller |
40
|
|
|
* @param Tree $tree |
41
|
|
|
* @param string $block_id |
42
|
|
|
* @param string $template |
43
|
|
|
* @return $string |
|
|
|
|
44
|
|
|
*/ |
45
|
|
|
public function index(PageController $parent_controller, Tree $tree, $block_id, $template) { |
46
|
|
|
$view_bag = new ViewBag(); |
47
|
|
|
|
48
|
|
|
if($parent_controller && $tree) { |
49
|
|
|
|
50
|
|
|
$view_bag->set('tree', $tree); |
51
|
|
|
$view_bag->set('indi', $parent_controller->getSignificantIndividual()); |
52
|
|
|
|
53
|
|
|
$id = $this->module->getName().$block_id; |
54
|
|
|
$class = $this->module->getName().'_block'; |
55
|
|
|
$parent_controller->addInlineJavascript(' |
56
|
|
|
jQuery("#maj-new_passwd").hide(); |
57
|
|
|
jQuery("#maj-passwd_click").click(function() |
58
|
|
|
{ |
59
|
|
|
jQuery("#maj-new_passwd").slideToggle(100, function() { |
60
|
|
|
jQuery("#maj-new_passwd_username").focus(); |
61
|
|
|
}); |
62
|
|
|
return false; |
63
|
|
|
}); |
64
|
|
|
'); |
65
|
|
|
|
66
|
|
|
if (Auth::isAdmin()) { |
67
|
|
|
$title='<a class="icon-admin" title="'.I18N::translate('Configure').'" href="block_edit.php?block_id='.$block_id.'&ged=' . $tree->getNameHtml() . '&ctype=gedcom"></a>'; |
68
|
|
|
} else { |
69
|
|
|
$title=''; |
70
|
|
|
} |
71
|
|
|
$title .='<span dir="auto">'.$tree->getTitleHtml().'</span>'; |
72
|
|
|
|
73
|
|
|
$piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false); |
74
|
|
|
$view_bag->set('piwik_enabled', $piwik_enabled); |
75
|
|
|
if($piwik_enabled) { |
76
|
|
|
$parent_controller->addInlineJavascript( |
77
|
|
|
'$("#piwik_stats") |
78
|
|
|
.load("module.php?mod='.$this->module->getName().'&mod_action=Piwik&block_id='.$block_id.'");' |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$content = ViewFactory::make('WelcomeBlock', $this, new BaseController(), $view_bag)->getHtmlPartial(); |
83
|
|
|
|
84
|
|
|
if ($template) { |
85
|
|
|
return Theme::theme()->formatBlock($id, $title, $class, $content); |
86
|
|
|
} else { |
87
|
|
|
return $content; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* WelcomeBlock@config |
96
|
|
|
* |
97
|
|
|
* @param string $block_id |
98
|
|
|
*/ |
99
|
|
|
public function config($block_id) { |
100
|
|
|
|
101
|
|
|
if (Filter::postBool('save') && Filter::checkCsrf()) { |
102
|
|
|
$this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled')); |
103
|
|
|
$this->module->setBlockSetting($block_id, 'piwik_url', trim(Filter::postUrl('piwik_url'))); |
104
|
|
|
$this->module->setBlockSetting($block_id, 'piwik_siteid', trim(Filter::post('piwik_siteid'))); |
105
|
|
|
$this->module->setBlockSetting($block_id, 'piwik_token', trim(Filter::post('piwik_token'))); |
106
|
|
|
Cache::delete('piwikCountYear', $this->module); |
107
|
|
|
throw new MvcException(200); // Use this instead of exit |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
$view_bag = new ViewBag(); |
111
|
|
|
|
112
|
|
|
// Is Piwik Statistic Enabled ? |
113
|
|
|
$view_bag->set('piwik_enabled', $this->module->getBlockSetting($block_id, 'piwik_enabled', '0')); |
114
|
|
|
//Piwik Root Url |
115
|
|
|
$view_bag->set('piwik_url', $this->module->getBlockSetting($block_id, 'piwik_url', '')); |
116
|
|
|
// Piwik token |
117
|
|
|
$view_bag->set('piwik_token', $this->module->getBlockSetting($block_id, 'piwik_token', '')); |
118
|
|
|
// Piwik side id |
119
|
|
|
$view_bag->set('piwik_siteid', $this->module->getBlockSetting($block_id, 'piwik_siteid', '')); |
120
|
|
|
|
121
|
|
|
ViewFactory::make('WelcomeBlockConfig', $this, new BaseController(), $view_bag)->renderPartial(); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
|
125
|
|
|
|
126
|
|
|
} |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.