@@ -23,77 +23,77 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class PiwikController extends MvcController |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Retrieve the number of visitors from Piwik, for a given period. |
|
| 28 | - * |
|
| 29 | - * @param string $block_id |
|
| 30 | - * @param string $period |
|
| 31 | - * @param (null|int) Number of visits |
|
| 32 | - */ |
|
| 33 | - private function getNumberOfVisitsPiwik($block_id, $period='year'){ |
|
| 26 | + /** |
|
| 27 | + * Retrieve the number of visitors from Piwik, for a given period. |
|
| 28 | + * |
|
| 29 | + * @param string $block_id |
|
| 30 | + * @param string $period |
|
| 31 | + * @param (null|int) Number of visits |
|
| 32 | + */ |
|
| 33 | + private function getNumberOfVisitsPiwik($block_id, $period='year'){ |
|
| 34 | 34 | |
| 35 | - $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url'); |
|
| 36 | - $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid'); |
|
| 37 | - $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token'); |
|
| 35 | + $piwik_url = $this->module->getBlockSetting($block_id, 'piwik_url'); |
|
| 36 | + $piwik_siteid = $this->module->getBlockSetting($block_id, 'piwik_siteid'); |
|
| 37 | + $piwik_token = $this->module->getBlockSetting($block_id, 'piwik_token'); |
|
| 38 | 38 | |
| 39 | - if($piwik_url && strlen($piwik_url) > 0 && |
|
| 40 | - $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
| 41 | - $piwik_token && strlen($piwik_token) |
|
| 42 | - ) |
|
| 43 | - { |
|
| 44 | - // calling Piwik REST API |
|
| 45 | - $url = $piwik_url; |
|
| 46 | - $url .= '?module=API&method=VisitsSummary.getVisits'; |
|
| 47 | - $url .= '&idSite='.$piwik_siteid.'&period='.$period.'&date=today'; |
|
| 48 | - $url .= '&format=PHP'; |
|
| 49 | - $url .= '&token_auth='.$piwik_token; |
|
| 39 | + if($piwik_url && strlen($piwik_url) > 0 && |
|
| 40 | + $piwik_siteid && strlen($piwik_siteid) > 0 && |
|
| 41 | + $piwik_token && strlen($piwik_token) |
|
| 42 | + ) |
|
| 43 | + { |
|
| 44 | + // calling Piwik REST API |
|
| 45 | + $url = $piwik_url; |
|
| 46 | + $url .= '?module=API&method=VisitsSummary.getVisits'; |
|
| 47 | + $url .= '&idSite='.$piwik_siteid.'&period='.$period.'&date=today'; |
|
| 48 | + $url .= '&format=PHP'; |
|
| 49 | + $url .= '&token_auth='.$piwik_token; |
|
| 50 | 50 | |
| 51 | - if($fetched = File::fetchUrl($url)) { |
|
| 52 | - $content = @unserialize($fetched); |
|
| 53 | - if(is_numeric($content)) return $content; |
|
| 54 | - } |
|
| 55 | - } |
|
| 51 | + if($fetched = File::fetchUrl($url)) { |
|
| 52 | + $content = @unserialize($fetched); |
|
| 53 | + if(is_numeric($content)) return $content; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - return null; |
|
| 58 | - } |
|
| 57 | + return null; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Pages |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * Pages |
|
| 62 | + */ |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Piwik@index |
|
| 66 | - */ |
|
| 67 | - public function index() { |
|
| 64 | + /** |
|
| 65 | + * Piwik@index |
|
| 66 | + */ |
|
| 67 | + public function index() { |
|
| 68 | 68 | |
| 69 | - $ctrl = new AjaxController(); |
|
| 69 | + $ctrl = new AjaxController(); |
|
| 70 | 70 | |
| 71 | - $data = new ViewBag(); |
|
| 72 | - $data->set('has_stats', false); |
|
| 71 | + $data = new ViewBag(); |
|
| 72 | + $data->set('has_stats', false); |
|
| 73 | 73 | |
| 74 | - $block_id = Filter::get('block_id'); |
|
| 75 | - if($block_id){ |
|
| 76 | - $cached_item = Cache::get('piwikCountYear', $this->module); |
|
| 77 | - $visitCountYear = $cached_item->get(); |
|
| 78 | - if(!$cached_item->isHit()) { |
|
| 79 | - $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
|
| 80 | - if(!is_null($visitCountYear)) { |
|
| 81 | - $cached_item->expiresAt(new \DateTime('tomorrow')); // Expires the next day at midnight |
|
| 82 | - Cache::save($cached_item, $visitCountYear); |
|
| 83 | - } |
|
| 84 | - } |
|
| 74 | + $block_id = Filter::get('block_id'); |
|
| 75 | + if($block_id){ |
|
| 76 | + $cached_item = Cache::get('piwikCountYear', $this->module); |
|
| 77 | + $visitCountYear = $cached_item->get(); |
|
| 78 | + if(!$cached_item->isHit()) { |
|
| 79 | + $visitCountYear = $this->getNumberOfVisitsPiwik($block_id); |
|
| 80 | + if(!is_null($visitCountYear)) { |
|
| 81 | + $cached_item->expiresAt(new \DateTime('tomorrow')); // Expires the next day at midnight |
|
| 82 | + Cache::save($cached_item, $visitCountYear); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - if($visitCountYear){ |
|
| 87 | - $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
|
| 88 | - $visitCountYear = max( 0, $visitCountYear); |
|
| 86 | + if($visitCountYear){ |
|
| 87 | + $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day')); |
|
| 88 | + $visitCountYear = max( 0, $visitCountYear); |
|
| 89 | 89 | |
| 90 | - $data->set('has_stats', true); |
|
| 91 | - $data->set('visits_today', $visitCountToday); |
|
| 92 | - $data->set('visits_year', $visitCountYear + $visitCountToday); |
|
| 93 | - } |
|
| 94 | - } |
|
| 90 | + $data->set('has_stats', true); |
|
| 91 | + $data->set('visits_today', $visitCountToday); |
|
| 92 | + $data->set('visits_year', $visitCountYear + $visitCountToday); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render(); |
|
| 97 | - } |
|
| 96 | + ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render(); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | } |
| 100 | 100 | \ No newline at end of file |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * {@inhericDoc} |
| 33 | 33 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
| 34 | 34 | */ |
| 35 | - protected function renderContent() { |
|
| 35 | + protected function renderContent() { |
|
| 36 | 36 | |
| 37 | - if($this->data->get('has_sosa', false)) { |
|
| 38 | - $table_id = $this->data->get('table_id'); |
|
| 39 | - ?> |
|
| 37 | + if($this->data->get('has_sosa', false)) { |
|
| 38 | + $table_id = $this->data->get('table_id'); |
|
| 39 | + ?> |
|
| 40 | 40 | |
| 41 | 41 | <div id="sosa-fam-list" class="sosa-list"> |
| 42 | 42 | <table id="<?php echo $table_id; ?>"> |
@@ -176,61 +176,61 @@ discard block |
||
| 176 | 176 | <tbody> |
| 177 | 177 | |
| 178 | 178 | <?php foreach($this->data->get('sosa_list') as $sosa => $family) { |
| 179 | - /** @var \Fisharebest\Webtrees\Family $person */ |
|
| 179 | + /** @var \Fisharebest\Webtrees\Family $person */ |
|
| 180 | 180 | |
| 181 | - //PERSO Create decorator for Family |
|
| 182 | - $dfamily = new Family($family); |
|
| 181 | + //PERSO Create decorator for Family |
|
| 182 | + $dfamily = new Family($family); |
|
| 183 | 183 | |
| 184 | - $husb = $family->getHusband(); |
|
| 185 | - if (is_null($husb)) { |
|
| 186 | - $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree()); |
|
| 187 | - } |
|
| 188 | - $wife = $family->getWife(); |
|
| 189 | - if (is_null($wife)) { |
|
| 190 | - $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree()); |
|
| 191 | - } |
|
| 184 | + $husb = $family->getHusband(); |
|
| 185 | + if (is_null($husb)) { |
|
| 186 | + $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree()); |
|
| 187 | + } |
|
| 188 | + $wife = $family->getWife(); |
|
| 189 | + if (is_null($wife)) { |
|
| 190 | + $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree()); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - $mdate=$family->getMarriageDate(); |
|
| 193 | + $mdate=$family->getMarriageDate(); |
|
| 194 | 194 | |
| 195 | - if ($family->isPendingAddtion()) { |
|
| 196 | - $class = ' class="new"'; |
|
| 197 | - } elseif ($family->isPendingDeletion()) { |
|
| 198 | - $class = ' class="old"'; |
|
| 199 | - } else { |
|
| 200 | - $class = ''; |
|
| 201 | - } |
|
| 202 | - ?> |
|
| 195 | + if ($family->isPendingAddtion()) { |
|
| 196 | + $class = ' class="new"'; |
|
| 197 | + } elseif ($family->isPendingDeletion()) { |
|
| 198 | + $class = ' class="old"'; |
|
| 199 | + } else { |
|
| 200 | + $class = ''; |
|
| 201 | + } |
|
| 202 | + ?> |
|
| 203 | 203 | <tr <?= $class ?>> |
| 204 | 204 | <td class="transparent" data-sort="<?= $sosa ?>"><?= I18N::translate('%1$d/%2$d', $sosa, ($sosa + 1) % 10) ?></td> |
| 205 | 205 | <!-- HUSBAND --> |
| 206 | 206 | <?php list($surn_givn, $givn_surn) = FunctionsPrintLists::sortableNames($husb); ?> |
| 207 | 207 | <td colspan="2" data-sort="<?= Filter::escapeHtml($givn_surn) ?>"> |
| 208 | 208 | <?php foreach ($husb->getAllNames() as $num=>$name) { |
| 209 | - if ($name['type']=='NAME') { |
|
| 210 | - $title=''; |
|
| 211 | - } else { |
|
| 212 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $husb)).'"'; |
|
| 213 | - } |
|
| 214 | - if ($num==$husb->getPrimaryName()) { |
|
| 215 | - $class=' class="name2"'; |
|
| 216 | - $sex_image=$husb->getSexImage(); |
|
| 217 | - } else { |
|
| 218 | - $class=''; |
|
| 219 | - $sex_image=''; |
|
| 220 | - } ?> |
|
| 209 | + if ($name['type']=='NAME') { |
|
| 210 | + $title=''; |
|
| 211 | + } else { |
|
| 212 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $husb)).'"'; |
|
| 213 | + } |
|
| 214 | + if ($num==$husb->getPrimaryName()) { |
|
| 215 | + $class=' class="name2"'; |
|
| 216 | + $sex_image=$husb->getSexImage(); |
|
| 217 | + } else { |
|
| 218 | + $class=''; |
|
| 219 | + $sex_image=''; |
|
| 220 | + } ?> |
|
| 221 | 221 | <a <?php echo $title.' '.$class; ?> href="<?php echo $husb->getHtmlUrl(); ?>"> |
| 222 | 222 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
| 223 | 223 | </a> |
| 224 | 224 | <?php echo $sex_image; |
| 225 | - echo implode(' ', |
|
| 226 | - \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 227 | - ->get('hRecordNameAppend') |
|
| 228 | - ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $husb, 'smaller')); |
|
| 229 | - ?> |
|
| 225 | + echo implode(' ', |
|
| 226 | + \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 227 | + ->get('hRecordNameAppend') |
|
| 228 | + ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $husb, 'smaller')); |
|
| 229 | + ?> |
|
| 230 | 230 | <br/> |
| 231 | 231 | <?php } |
| 232 | - echo $husb->getPrimaryParentsNames('parents details1', 'none'); |
|
| 233 | - ?> |
|
| 232 | + echo $husb->getPrimaryParentsNames('parents details1', 'none'); |
|
| 233 | + ?> |
|
| 234 | 234 | </td> |
| 235 | 235 | <td hidden data-sort="<?= Filter::escapeHtml($surn_givn) ?>"></td> |
| 236 | 236 | <?php $hdate=$husb->getBirthDate(); ?> |
@@ -239,60 +239,60 @@ discard block |
||
| 239 | 239 | <?php list($surn_givn, $givn_surn) = FunctionsPrintLists::sortableNames($wife); ?> |
| 240 | 240 | <td colspan="2"> |
| 241 | 241 | <?php foreach ($wife->getAllNames() as $num=>$name) { |
| 242 | - if ($name['type']=='NAME') { |
|
| 243 | - $title=''; |
|
| 244 | - } else { |
|
| 245 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $wife)).'"'; |
|
| 246 | - } |
|
| 247 | - if ($num==$wife->getPrimaryName()) { |
|
| 248 | - $class=' class="name2"'; |
|
| 249 | - $sex_image=$wife->getSexImage(); |
|
| 250 | - } else { |
|
| 251 | - $class=''; |
|
| 252 | - $sex_image=''; |
|
| 253 | - } ?> |
|
| 242 | + if ($name['type']=='NAME') { |
|
| 243 | + $title=''; |
|
| 244 | + } else { |
|
| 245 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $wife)).'"'; |
|
| 246 | + } |
|
| 247 | + if ($num==$wife->getPrimaryName()) { |
|
| 248 | + $class=' class="name2"'; |
|
| 249 | + $sex_image=$wife->getSexImage(); |
|
| 250 | + } else { |
|
| 251 | + $class=''; |
|
| 252 | + $sex_image=''; |
|
| 253 | + } ?> |
|
| 254 | 254 | <a <?= $title.' '.$class ?> href="<?= $wife->getHtmlUrl() ?>"> |
| 255 | 255 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']) ?> |
| 256 | 256 | </a> |
| 257 | 257 | <?= $sex_image; |
| 258 | - echo implode(' ', |
|
| 259 | - \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 260 | - ->get('hRecordNameAppend') |
|
| 261 | - ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $wife, 'smaller')); |
|
| 262 | - ?> |
|
| 258 | + echo implode(' ', |
|
| 259 | + \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 260 | + ->get('hRecordNameAppend') |
|
| 261 | + ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $wife, 'smaller')); |
|
| 262 | + ?> |
|
| 263 | 263 | <br/> |
| 264 | 264 | <?php } |
| 265 | - echo $wife->getPrimaryParentsNames('parents details1', 'none'); |
|
| 266 | - ?> |
|
| 265 | + echo $wife->getPrimaryParentsNames('parents details1', 'none'); |
|
| 266 | + ?> |
|
| 267 | 267 | </td> |
| 268 | 268 | <td hidden data-sort="<?= Filter::escapeHtml($surn_givn) ?>"></td> |
| 269 | 269 | <?php $wdate=$wife->getBirthDate(); ?> |
| 270 | 270 | <td class="center" data-sort="<?= Date::getAge($wdate, $mdate, 1) ?>"><?= Date::getAge($wdate, $mdate, 2) ?></td> |
| 271 | 271 | <td data-sort="<?= $mdate->julianDay() ?>"><?php |
| 272 | - if ($marriage_dates = $family->getAllMarriageDates()) { |
|
| 273 | - foreach ($marriage_dates as $n => $marriage_date) { |
|
| 274 | - if ($n) { echo '<br>'; } ?> |
|
| 272 | + if ($marriage_dates = $family->getAllMarriageDates()) { |
|
| 273 | + foreach ($marriage_dates as $n => $marriage_date) { |
|
| 274 | + if ($n) { echo '<br>'; } ?> |
|
| 275 | 275 | <div><?= $marriage_date->display(true) ?></div> |
| 276 | 276 | <?php } |
| 277 | - } elseif ($family->getFacts('_NMR')) { |
|
| 278 | - echo I18N::translate('no'); |
|
| 279 | - } elseif ($family->getFacts('MARR')) { |
|
| 280 | - echo I18N::translate('yes'); |
|
| 281 | - } else { |
|
| 282 | - echo ' '; |
|
| 283 | - } ?> |
|
| 277 | + } elseif ($family->getFacts('_NMR')) { |
|
| 278 | + echo I18N::translate('no'); |
|
| 279 | + } elseif ($family->getFacts('MARR')) { |
|
| 280 | + echo I18N::translate('yes'); |
|
| 281 | + } else { |
|
| 282 | + echo ' '; |
|
| 283 | + } ?> |
|
| 284 | 284 | </td> |
| 285 | 285 | <td><?php |
| 286 | - foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { |
|
| 287 | - $tmp = new Place($marriage_place, $family->getTree()); |
|
| 288 | - if ($n) { ?><br><?php } ?> |
|
| 286 | + foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { |
|
| 287 | + $tmp = new Place($marriage_place, $family->getTree()); |
|
| 288 | + if ($n) { ?><br><?php } ?> |
|
| 289 | 289 | <a href="'<?= $tmp->getURL() ?>" title="<?= strip_tags($tmp->getFullName()) ?>"> |
| 290 | 290 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()) ?> |
| 291 | 291 | </a> |
| 292 | 292 | <?php } ?> |
| 293 | 293 | </td> |
| 294 | 294 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
| 295 | - $isMSourced = $dfamily->isMarriageSourced(); ?> |
|
| 295 | + $isMSourced = $dfamily->isMarriageSourced(); ?> |
|
| 296 | 296 | <td data-sort=<?= $isMSourced ?>><?= FunctionsPrint::formatIsSourcedIcon('E', $isMSourced, 'MARR', 1, 'medium') ?></td> |
| 297 | 297 | <?php } else { ?> |
| 298 | 298 | <td> </td> |
@@ -303,30 +303,30 @@ discard block |
||
| 303 | 303 | <td hidden><?php |
| 304 | 304 | if (!$mdate->isOK()) { echo 'U'; } |
| 305 | 305 | else { |
| 306 | - if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } |
|
| 307 | - else { echo 'YES'; } |
|
| 306 | + if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } |
|
| 307 | + else { echo 'YES'; } |
|
| 308 | 308 | } |
| 309 | 309 | if ($family->getFacts(WT_EVENTS_DIV)) { echo 'D'; } |
| 310 | 310 | if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) { |
| 311 | - echo 'M'; |
|
| 311 | + echo 'M'; |
|
| 312 | 312 | } ?> |
| 313 | 313 | </td> |
| 314 | 314 | <td hidden><?php |
| 315 | - if ($husb->isDead() && $wife->isDead()) { echo 'Y'; } |
|
| 316 | - if ($husb->isDead() && !$wife->isDead()) { |
|
| 317 | - if ($wife->getSex() == 'F') { echo 'H'; } |
|
| 318 | - if ($wife->getSex() == 'M') { echo 'W'; } // male partners |
|
| 319 | - } |
|
| 320 | - if (!$husb->isDead() && $wife->isDead()) { |
|
| 321 | - if ($husb->getSex() == 'M') { echo 'W'; } |
|
| 322 | - if ($husb->getSex() == 'F') { echo 'H'; } // female partners |
|
| 323 | - } |
|
| 324 | - if (!$husb->isDead() && !$wife->isDead()) { echo 'N'; } ?> |
|
| 315 | + if ($husb->isDead() && $wife->isDead()) { echo 'Y'; } |
|
| 316 | + if ($husb->isDead() && !$wife->isDead()) { |
|
| 317 | + if ($wife->getSex() == 'F') { echo 'H'; } |
|
| 318 | + if ($wife->getSex() == 'M') { echo 'W'; } // male partners |
|
| 319 | + } |
|
| 320 | + if (!$husb->isDead() && $wife->isDead()) { |
|
| 321 | + if ($husb->getSex() == 'M') { echo 'W'; } |
|
| 322 | + if ($husb->getSex() == 'F') { echo 'H'; } // female partners |
|
| 323 | + } |
|
| 324 | + if (!$husb->isDead() && !$wife->isDead()) { echo 'N'; } ?> |
|
| 325 | 325 | </td> |
| 326 | 326 | <td hidden><?php |
| 327 | - if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } |
|
| 328 | - elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } |
|
| 329 | - else { echo ' '; } ?> |
|
| 327 | + if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } |
|
| 328 | + elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } |
|
| 329 | + else { echo ' '; } ?> |
|
| 330 | 330 | </td> |
| 331 | 331 | </tr> |
| 332 | 332 | <?php } ?> |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | <p class="warning"><?= I18N::translate('No family has been found for generation %d', $this->data->get('generation')) ?></p> |
| 365 | 365 | <?php |
| 366 | 366 | } |
| 367 | - } |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | \ No newline at end of file |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | * {@inhericDoc} |
| 31 | 31 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
| 32 | 32 | */ |
| 33 | - protected function renderContent() { |
|
| 34 | - ?> |
|
| 33 | + protected function renderContent() { |
|
| 34 | + ?> |
|
| 35 | 35 | <div id="maj-sosa-missing-page" class="center"> |
| 36 | 36 | <h2><?= $this->data->get('title') ?></h2> |
| 37 | 37 | |
| 38 | 38 | <?php if($this->data->get('is_setup')) { |
| 39 | - $this->renderSosaHeader(); |
|
| 40 | - if($this->data->get('has_missing', false)) { |
|
| 41 | - $table_id = $this->data->get('table_id'); |
|
| 42 | - ?> |
|
| 39 | + $this->renderSosaHeader(); |
|
| 40 | + if($this->data->get('has_missing', false)) { |
|
| 41 | + $table_id = $this->data->get('table_id'); |
|
| 42 | + ?> |
|
| 43 | 43 | <div id="sosa-indi-missing" class="smissing-list"> |
| 44 | 44 | <table id="<?= $table_id ?>"> |
| 45 | 45 | <thead> |
@@ -103,52 +103,52 @@ discard block |
||
| 103 | 103 | <tbody> |
| 104 | 104 | |
| 105 | 105 | <?php foreach($this->data->get('missing_list') as $missing_tab) { |
| 106 | - $person = $missing_tab['indi']; |
|
| 106 | + $person = $missing_tab['indi']; |
|
| 107 | 107 | |
| 108 | - /** @var \Fisharebest\Webtrees\Individual $person */ |
|
| 109 | - if ($person->isPendingAddtion()) { |
|
| 110 | - $class = ' class="new"'; |
|
| 111 | - } elseif ($person->isPendingDeletion()) { |
|
| 112 | - $class = ' class="old"'; |
|
| 113 | - } else { |
|
| 114 | - $class = ''; |
|
| 115 | - } |
|
| 116 | - $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
| 117 | - list($surn_givn, $givn_surn) = FunctionsPrintLists::sortableNames($person); |
|
| 118 | - ?> |
|
| 108 | + /** @var \Fisharebest\Webtrees\Individual $person */ |
|
| 109 | + if ($person->isPendingAddtion()) { |
|
| 110 | + $class = ' class="new"'; |
|
| 111 | + } elseif ($person->isPendingDeletion()) { |
|
| 112 | + $class = ' class="old"'; |
|
| 113 | + } else { |
|
| 114 | + $class = ''; |
|
| 115 | + } |
|
| 116 | + $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
| 117 | + list($surn_givn, $givn_surn) = FunctionsPrintLists::sortableNames($person); |
|
| 118 | + ?> |
|
| 119 | 119 | <tr <?= $class ?>> |
| 120 | 120 | <td class="transparent"><?= $missing_tab['sosa'] ?></td> |
| 121 | 121 | <td class="transparent"><?= $person->getXref() ?></td> |
| 122 | 122 | <td colspan="2" data-sort="<?= Filter::escapeHtml($givn_surn) ?>"> |
| 123 | 123 | <?php foreach ($person->getAllNames() as $num=>$name) { |
| 124 | - if ($name['type']=='NAME') { |
|
| 125 | - $title=''; |
|
| 126 | - } else { |
|
| 127 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
| 128 | - } |
|
| 129 | - if ($num==$person->getPrimaryName()) { |
|
| 130 | - $class=' class="name2"'; |
|
| 131 | - $sex_image=$person->getSexImage(); |
|
| 132 | - } else { |
|
| 133 | - $class=''; |
|
| 134 | - $sex_image=''; |
|
| 135 | - } ?> |
|
| 124 | + if ($name['type']=='NAME') { |
|
| 125 | + $title=''; |
|
| 126 | + } else { |
|
| 127 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
| 128 | + } |
|
| 129 | + if ($num==$person->getPrimaryName()) { |
|
| 130 | + $class=' class="name2"'; |
|
| 131 | + $sex_image=$person->getSexImage(); |
|
| 132 | + } else { |
|
| 133 | + $class=''; |
|
| 134 | + $sex_image=''; |
|
| 135 | + } ?> |
|
| 136 | 136 | <a <?= $title.' '.$class ?> href="<?= $person->getHtmlUrl() ?>"> |
| 137 | 137 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']) ?> |
| 138 | 138 | </a> |
| 139 | 139 | <?= $sex_image; |
| 140 | - echo implode(' ', |
|
| 141 | - \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 142 | - ->get('hRecordNameAppend') |
|
| 143 | - ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $person, 'smaller')); ?> |
|
| 140 | + echo implode(' ', |
|
| 141 | + \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 142 | + ->get('hRecordNameAppend') |
|
| 143 | + ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $person, 'smaller')); ?> |
|
| 144 | 144 | <br/> |
| 145 | 145 | <?php } |
| 146 | - echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
| 147 | - ?> |
|
| 146 | + echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
| 147 | + ?> |
|
| 148 | 148 | </td> |
| 149 | 149 | <td hidden data-sort="<?= Filter::escapeHtml($surn_givn) ?>"></td> |
| 150 | 150 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
| 151 | - $isISourced = $dperson->isSourced(); ?> |
|
| 151 | + $isISourced = $dperson->isSourced(); ?> |
|
| 152 | 152 | <td data-sort="<?= $isISourced ?>"><?= FunctionsPrint::formatIsSourcedIcon('R', $isISourced, 'INDI', 1, 'medium') ?></td> |
| 153 | 153 | <?php } else { ?> |
| 154 | 154 | <td> </td> |
@@ -158,23 +158,23 @@ discard block |
||
| 158 | 158 | <?php $birth_dates = $person->getAllBirthDates(); ?> |
| 159 | 159 | <td data-sort="<?= $person->getEstimatedBirthDate()->julianDay() ?>"> |
| 160 | 160 | <?php |
| 161 | - foreach ($birth_dates as $n => $birth_date) { |
|
| 162 | - if ($n > 0) { ?> <br> <?php } |
|
| 163 | - echo $birth_date->display(true); |
|
| 164 | - } |
|
| 165 | - ?> |
|
| 161 | + foreach ($birth_dates as $n => $birth_date) { |
|
| 162 | + if ($n > 0) { ?> <br> <?php } |
|
| 163 | + echo $birth_date->display(true); |
|
| 164 | + } |
|
| 165 | + ?> |
|
| 166 | 166 | </td> |
| 167 | 167 | <td> |
| 168 | 168 | <?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { |
| 169 | - $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
| 170 | - if ($n > 0) { ?><br><?php } ?> |
|
| 169 | + $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
| 170 | + if ($n > 0) { ?><br><?php } ?> |
|
| 171 | 171 | <a href="'<?= $tmp->getURL(); ?>" title="<?= strip_tags($tmp->getFullName()) ?>"> |
| 172 | 172 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()) ?> |
| 173 | 173 | </a> |
| 174 | 174 | <?php } ?> |
| 175 | 175 | </td> |
| 176 | 176 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
| 177 | - $isBSourced = $dperson->isBirthSourced(); ?> |
|
| 177 | + $isBSourced = $dperson->isBirthSourced(); ?> |
|
| 178 | 178 | <td data-sort="<?= $isBSourced ?>"><?= FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium') ?></td> |
| 179 | 179 | <?php } else { ?> |
| 180 | 180 | <td> </td> |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | <?php } else if ($this->data->get('generation', 0) > 0) { ?> |
| 200 | 200 | <p><?= I18N::translate('No ancestors are missing for this generation. Generation complete at %s.', I18N::percentage($this->data->get('perc_sosa'), 2)) ?></p> |
| 201 | 201 | <?php } |
| 202 | - } else { ?> |
|
| 202 | + } else { ?> |
|
| 203 | 203 | <p class="warning"><?= I18N::translate('The list could not be displayed. Reasons might be:') ?><br/> |
| 204 | 204 | <ul> |
| 205 | 205 | <li><?= I18N::translate('No Sosa root individual has been defined.') ?></li> |
@@ -210,6 +210,6 @@ discard block |
||
| 210 | 210 | <?php } ?> |
| 211 | 211 | </div> |
| 212 | 212 | <?php |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | \ No newline at end of file |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * {@inhericDoc} |
| 32 | 32 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
| 33 | 33 | */ |
| 34 | - protected function renderContent() { |
|
| 34 | + protected function renderContent() { |
|
| 35 | 35 | |
| 36 | - if($this->data->get('has_sosa', false)) { |
|
| 37 | - $table_id = $this->data->get('table_id'); |
|
| 38 | - ?> |
|
| 36 | + if($this->data->get('has_sosa', false)) { |
|
| 37 | + $table_id = $this->data->get('table_id'); |
|
| 38 | + ?> |
|
| 39 | 39 | |
| 40 | 40 | <div id="sosa-indi-list" class="sosa-list"> |
| 41 | 41 | <table id="<?= $table_id ?>"> |
@@ -177,67 +177,67 @@ discard block |
||
| 177 | 177 | <tbody> |
| 178 | 178 | |
| 179 | 179 | <?php foreach($this->data->get('sosa_list') as $sosa => $person) { |
| 180 | - /** @var \Fisharebest\Webtrees\Individual $person */ |
|
| 181 | - if ($person->isPendingAddtion()) { |
|
| 182 | - $class = ' class="new"'; |
|
| 183 | - } elseif ($person->isPendingDeletion()) { |
|
| 184 | - $class = ' class="old"'; |
|
| 185 | - } else { |
|
| 186 | - $class = ''; |
|
| 187 | - } |
|
| 188 | - $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
| 189 | - ?> |
|
| 180 | + /** @var \Fisharebest\Webtrees\Individual $person */ |
|
| 181 | + if ($person->isPendingAddtion()) { |
|
| 182 | + $class = ' class="new"'; |
|
| 183 | + } elseif ($person->isPendingDeletion()) { |
|
| 184 | + $class = ' class="old"'; |
|
| 185 | + } else { |
|
| 186 | + $class = ''; |
|
| 187 | + } |
|
| 188 | + $dperson = new \MyArtJaub\Webtrees\Individual($person); |
|
| 189 | + ?> |
|
| 190 | 190 | <tr <?= $class ?>> |
| 191 | 191 | <td class="transparent"><?= $sosa ?></td> |
| 192 | 192 | <td hidden><?= $person->getXref() ?></td> |
| 193 | 193 | <?php list($surn_givn, $givn_surn) = FunctionsPrintLists::sortableNames($person); ?> |
| 194 | 194 | <td colspan="2" data-sort="<?= Filter::escapeHtml($givn_surn) ?>"> |
| 195 | 195 | <?php foreach ($person->getAllNames() as $num=>$name) { |
| 196 | - if ($name['type']=='NAME') { |
|
| 197 | - $title=''; |
|
| 198 | - } else { |
|
| 199 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
| 200 | - } |
|
| 201 | - if ($num==$person->getPrimaryName()) { |
|
| 202 | - $class=' class="name2"'; |
|
| 203 | - $sex_image=$person->getSexImage(); |
|
| 204 | - } else { |
|
| 205 | - $class=''; |
|
| 206 | - $sex_image=''; |
|
| 207 | - } ?> |
|
| 196 | + if ($name['type']=='NAME') { |
|
| 197 | + $title=''; |
|
| 198 | + } else { |
|
| 199 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
| 200 | + } |
|
| 201 | + if ($num==$person->getPrimaryName()) { |
|
| 202 | + $class=' class="name2"'; |
|
| 203 | + $sex_image=$person->getSexImage(); |
|
| 204 | + } else { |
|
| 205 | + $class=''; |
|
| 206 | + $sex_image=''; |
|
| 207 | + } ?> |
|
| 208 | 208 | <a <?= $title.' '.$class; ?> href="<?= $person->getHtmlUrl() ?>"> |
| 209 | 209 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']) ?> |
| 210 | 210 | </a> |
| 211 | 211 | <?= $sex_image; |
| 212 | - echo implode(' ', |
|
| 213 | - \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 214 | - ->get('hRecordNameAppend') |
|
| 215 | - ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $person, 'smaller')); |
|
| 216 | - ?> |
|
| 212 | + echo implode(' ', |
|
| 213 | + \MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
|
| 214 | + ->get('hRecordNameAppend') |
|
| 215 | + ->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $person, 'smaller')); |
|
| 216 | + ?> |
|
| 217 | 217 | <br/> |
| 218 | 218 | <?php } |
| 219 | - echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
| 220 | - ?> |
|
| 219 | + echo $person->getPrimaryParentsNames('parents details1', 'none'); |
|
| 220 | + ?> |
|
| 221 | 221 | </td> |
| 222 | 222 | <td hidden data-sort="<?= Filter::escapeHtml($surn_givn) ?>"></td> |
| 223 | 223 | <?php $birth_dates = $person->getAllBirthDates(); ?> |
| 224 | 224 | <td data-sort="<?= $person->getEstimatedBirthDate()->julianDay() ?>"> |
| 225 | 225 | <?php foreach ($birth_dates as $n => $birth_date) { |
| 226 | - if ($n > 0) { ?><br/><?php } ?> |
|
| 226 | + if ($n > 0) { ?><br/><?php } ?> |
|
| 227 | 227 | <?php echo $birth_date->display(true); |
| 228 | - } ?> |
|
| 228 | + } ?> |
|
| 229 | 229 | </td> |
| 230 | 230 | <td> |
| 231 | 231 | <?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { |
| 232 | - $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
| 233 | - if ($n > 0) { ?><br><?php } ?> |
|
| 232 | + $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
|
| 233 | + if ($n > 0) { ?><br><?php } ?> |
|
| 234 | 234 | <a href="'<?= $tmp->getURL() ?>" title="<?= strip_tags($tmp->getFullName()) ?>"> |
| 235 | 235 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()) ?> |
| 236 | 236 | </a> |
| 237 | 237 | <?php } ?> |
| 238 | 238 | </td> |
| 239 | 239 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
| 240 | - $isBSourced = $dperson->isBirthSourced(); ?> |
|
| 240 | + $isBSourced = $dperson->isBirthSourced(); ?> |
|
| 241 | 241 | <td data-sort="<?= $isBSourced ?>"><?= FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium') ?></td> |
| 242 | 242 | <?php } else { ?> |
| 243 | 243 | <td> </td> |
@@ -245,63 +245,63 @@ discard block |
||
| 245 | 245 | <?php $death_dates = $person->getAllDeathDates(); ?> |
| 246 | 246 | <td data-sort="<?= $person->getEstimatedDeathDate()->julianDay() ?>"> |
| 247 | 247 | <?php foreach ($death_dates as $num => $death_date) { |
| 248 | - if ($num) { ?><br/><?php } ?> |
|
| 248 | + if ($num) { ?><br/><?php } ?> |
|
| 249 | 249 | <?php echo $death_date->display(true); |
| 250 | - } ?> |
|
| 250 | + } ?> |
|
| 251 | 251 | </td> |
| 252 | 252 | <?php if (isset($birth_dates[0]) && isset($death_dates[0])) { |
| 253 | - $age_at_death = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
| 254 | - $age_at_death_sort = Date::getAge($birth_dates[0], $death_dates[0], 2); |
|
| 255 | - } else { |
|
| 256 | - $age_at_death = ''; |
|
| 257 | - $age_at_death_sort = PHP_INT_MAX; |
|
| 258 | - } ?> |
|
| 253 | + $age_at_death = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
| 254 | + $age_at_death_sort = Date::getAge($birth_dates[0], $death_dates[0], 2); |
|
| 255 | + } else { |
|
| 256 | + $age_at_death = ''; |
|
| 257 | + $age_at_death_sort = PHP_INT_MAX; |
|
| 258 | + } ?> |
|
| 259 | 259 | <td class="center" data-sort="<?= $age_at_death_sort ?>"><?= $age_at_death ?></td> |
| 260 | 260 | <td> |
| 261 | 261 | <?php foreach ($person->getAllDeathPlaces() as $n => $death_place) { |
| 262 | - $tmp = new Place($death_place, $person->getTree()); |
|
| 263 | - if ($n) { ?><br><?php } ?> |
|
| 262 | + $tmp = new Place($death_place, $person->getTree()); |
|
| 263 | + if ($n) { ?><br><?php } ?> |
|
| 264 | 264 | <a href="'<?= $tmp->getURL() ?>" title="<?= strip_tags($tmp->getFullName()) ?>"> |
| 265 | 265 | <?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()) ?> |
| 266 | 266 | </a> |
| 267 | 267 | <?php } ?> |
| 268 | 268 | </td> |
| 269 | 269 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
| 270 | - if($person->isDead()) { |
|
| 271 | - $isDSourced = $dperson->isDeathSourced(); ?> |
|
| 270 | + if($person->isDead()) { |
|
| 271 | + $isDSourced = $dperson->isDeathSourced(); ?> |
|
| 272 | 272 | <td data-sort=<?= $isDSourced ?>><?= FunctionsPrint::formatIsSourcedIcon('E', $isDSourced, 'DEAT', 1, 'medium') ?></td> |
| 273 | 273 | <?php } else { ?> |
| 274 | 274 | <td data-sort="-99"> </td> |
| 275 | 275 | <?php } |
| 276 | - } else { ?> |
|
| 276 | + } else { ?> |
|
| 277 | 277 | <td> </td> |
| 278 | 278 | <?php } ?> |
| 279 | 279 | <td hidden><?= $person->getSex() ?></td> |
| 280 | 280 | <td hidden> |
| 281 | 281 | <?php if (!$person->canShow() || Date::compare($person->getEstimatedBirthDate(), new Date(date('Y') - 100)) > 0) { |
| 282 | - echo 'Y100'; |
|
| 283 | - } else { |
|
| 284 | - echo 'YES'; |
|
| 285 | - } ?> |
|
| 282 | + echo 'Y100'; |
|
| 283 | + } else { |
|
| 284 | + echo 'YES'; |
|
| 285 | + } ?> |
|
| 286 | 286 | </td> |
| 287 | 287 | <td hidden> |
| 288 | 288 | <?php if (isset($death_dates[0]) && Date::compare($death_dates[0], new Date(date('Y') - 100)) > 0) { |
| 289 | - echo 'Y100'; |
|
| 290 | - } elseif ($person->isDead()) { |
|
| 291 | - echo 'YES'; |
|
| 292 | - } else { |
|
| 293 | - echo 'N'; |
|
| 294 | - } ?> |
|
| 289 | + echo 'Y100'; |
|
| 290 | + } elseif ($person->isDead()) { |
|
| 291 | + echo 'YES'; |
|
| 292 | + } else { |
|
| 293 | + echo 'N'; |
|
| 294 | + } ?> |
|
| 295 | 295 | </td> |
| 296 | 296 | <td hidden> |
| 297 | 297 | <?php if (!$person->getChildFamilies()) { |
| 298 | - echo 'R'; |
|
| 298 | + echo 'R'; |
|
| 299 | 299 | } // roots |
| 300 | 300 | elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) { |
| 301 | - echo 'L'; |
|
| 301 | + echo 'L'; |
|
| 302 | 302 | } // leaves |
| 303 | 303 | else { |
| 304 | - echo ' '; |
|
| 304 | + echo ' '; |
|
| 305 | 305 | } ?> |
| 306 | 306 | </td> |
| 307 | 307 | </tr> |
@@ -312,12 +312,12 @@ discard block |
||
| 312 | 312 | <th class="ui-state-default" colspan="15"> |
| 313 | 313 | <div class="center"> |
| 314 | 314 | <?= I18N::translate('Number of Sosa ancestors: %1$s known / %2$s theoretical (%3$s)', |
| 315 | - I18N::number($this->data->get('sosa_count')), |
|
| 316 | - I18N::number($this->data->get('sosa_theo')), |
|
| 317 | - I18N::percentage($this->data->get('sosa_ratio'),2) |
|
| 318 | - ) ?> |
|
| 315 | + I18N::number($this->data->get('sosa_count')), |
|
| 316 | + I18N::number($this->data->get('sosa_theo')), |
|
| 317 | + I18N::percentage($this->data->get('sosa_ratio'),2) |
|
| 318 | + ) ?> |
|
| 319 | 319 | <?php if($this->data->get('sosa_hidden') > 0) { |
| 320 | - echo '['. I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']'; |
|
| 320 | + echo '['. I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']'; |
|
| 321 | 321 | } ?> |
| 322 | 322 | </div> |
| 323 | 323 | </th> |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | </div> |
| 352 | 352 | </div> |
| 353 | 353 | <?php |
| 354 | - } |
|
| 355 | - } |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | \ No newline at end of file |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | - * |
|
| 5 | - * @package MyArtJaub\Webtrees |
|
| 6 | - * @subpackage Hook |
|
| 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 | - */ |
|
| 3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | + * |
|
| 5 | + * @package MyArtJaub\Webtrees |
|
| 6 | + * @subpackage Hook |
|
| 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 | 11 | namespace MyArtJaub\Webtrees\Hook; |
| 12 | 12 | |
| 13 | 13 | use Fisharebest\Webtrees\Database; |
@@ -137,17 +137,17 @@ discard block |
||
| 137 | 137 | * @return array Results of the hook executions |
| 138 | 138 | */ |
| 139 | 139 | public function executeOnlyFor(array $module_names) { |
| 140 | - $result = array(); |
|
| 141 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
| 142 | - $params = func_get_args(); |
|
| 143 | - array_shift($params); |
|
| 144 | - foreach ($module_names as $module_name) { |
|
| 145 | - if($module = Module::getModuleByName($module_name)) { |
|
| 146 | - $result[] = call_user_func_array(array($module, $this->hook_function), $params); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - return $result; |
|
| 140 | + $result = array(); |
|
| 141 | + if(HookProvider::getInstance()->isModuleOperational()){ |
|
| 142 | + $params = func_get_args(); |
|
| 143 | + array_shift($params); |
|
| 144 | + foreach ($module_names as $module_name) { |
|
| 145 | + if($module = Module::getModuleByName($module_name)) { |
|
| 146 | + $result[] = call_user_func_array(array($module, $this->hook_function), $params); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + return $result; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -15,66 +15,66 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | abstract class AbstractView { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Reference controller |
|
| 20 | - * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
| 21 | - */ |
|
| 22 | - protected $ctrl; |
|
| 18 | + /** |
|
| 19 | + * Reference controller |
|
| 20 | + * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
| 21 | + */ |
|
| 22 | + protected $ctrl; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Structure containing the data of the view |
|
| 26 | - * @var ViewBag $data |
|
| 27 | - */ |
|
| 28 | - protected $data; |
|
| 24 | + /** |
|
| 25 | + * Structure containing the data of the view |
|
| 26 | + * @var ViewBag $data |
|
| 27 | + */ |
|
| 28 | + protected $data; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Constructor |
|
| 32 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
| 33 | - * @param ViewBag $data ViewBag holding view data |
|
| 34 | - */ |
|
| 35 | - public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
| 36 | - $this->ctrl = $ctrl; |
|
| 37 | - $this->data = $data; |
|
| 38 | - } |
|
| 30 | + /** |
|
| 31 | + * Constructor |
|
| 32 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
| 33 | + * @param ViewBag $data ViewBag holding view data |
|
| 34 | + */ |
|
| 35 | + public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
| 36 | + $this->ctrl = $ctrl; |
|
| 37 | + $this->data = $data; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Render the view to the page, including header. |
|
| 42 | - * |
|
| 43 | - * @throws \Exception |
|
| 44 | - */ |
|
| 45 | - public function render() { |
|
| 46 | - global $controller; |
|
| 40 | + /** |
|
| 41 | + * Render the view to the page, including header. |
|
| 42 | + * |
|
| 43 | + * @throws \Exception |
|
| 44 | + */ |
|
| 45 | + public function render() { |
|
| 46 | + global $controller; |
|
| 47 | 47 | |
| 48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
| 48 | + if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
| 49 | 49 | |
| 50 | 50 | $controller = $this->ctrl; |
| 51 | - $this->ctrl->pageHeader(); |
|
| 51 | + $this->ctrl->pageHeader(); |
|
| 52 | 52 | |
| 53 | - echo $this->renderContent(); |
|
| 54 | - } |
|
| 53 | + echo $this->renderContent(); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Render the view to the page, without any header |
|
| 58 | - */ |
|
| 59 | - public function renderPartial() { |
|
| 60 | - echo $this->getHtmlPartial(); |
|
| 61 | - } |
|
| 56 | + /** |
|
| 57 | + * Render the view to the page, without any header |
|
| 58 | + */ |
|
| 59 | + public function renderPartial() { |
|
| 60 | + echo $this->getHtmlPartial(); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Return the HTML code generated by the view, without any header |
|
| 65 | - */ |
|
| 66 | - public function getHtmlPartial() { |
|
| 67 | - ob_start(); |
|
| 68 | - $html_render = $this->renderContent(); |
|
| 69 | - $html_buffer = ob_get_clean(); |
|
| 63 | + /** |
|
| 64 | + * Return the HTML code generated by the view, without any header |
|
| 65 | + */ |
|
| 66 | + public function getHtmlPartial() { |
|
| 67 | + ob_start(); |
|
| 68 | + $html_render = $this->renderContent(); |
|
| 69 | + $html_buffer = ob_get_clean(); |
|
| 70 | 70 | |
| 71 | - return empty($html_render) ? $html_buffer : $html_render; |
|
| 72 | - } |
|
| 71 | + return empty($html_render) ? $html_buffer : $html_render; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Abstract method containing the details of the view. |
|
| 76 | - */ |
|
| 77 | - abstract protected function renderContent(); |
|
| 74 | + /** |
|
| 75 | + * Abstract method containing the details of the view. |
|
| 76 | + */ |
|
| 77 | + abstract protected function renderContent(); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | \ No newline at end of file |
@@ -23,62 +23,62 @@ discard block |
||
| 23 | 23 | class AdminTasksModule extends AbstractModule |
| 24 | 24 | implements ModuleConfigInterface, ModuleBlockInterface |
| 25 | 25 | { |
| 26 | - // How to update the database schema for this module |
|
| 27 | - const SCHEMA_TARGET_VERSION = 1; |
|
| 28 | - const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
|
| 29 | - const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\AdminTasks\Schema'; |
|
| 26 | + // How to update the database schema for this module |
|
| 27 | + const SCHEMA_TARGET_VERSION = 1; |
|
| 28 | + const SCHEMA_SETTING_NAME = 'MAJ_ADMTASKS_SCHEMA_VERSION'; |
|
| 29 | + const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\AdminTasks\Schema'; |
|
| 30 | 30 | |
| 31 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 32 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 31 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 32 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Admin Task provider |
|
| 36 | - * @var \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface $provider |
|
| 37 | - */ |
|
| 38 | - protected $provider; |
|
| 34 | + /** |
|
| 35 | + * Admin Task provider |
|
| 36 | + * @var \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface $provider |
|
| 37 | + */ |
|
| 38 | + protected $provider; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * {@inheritDoc} |
|
| 42 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
| 43 | - */ |
|
| 44 | - public function getTitle() { |
|
| 45 | - return I18N::translate('Administration Tasks'); |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * {@inheritDoc} |
|
| 42 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
| 43 | + */ |
|
| 44 | + public function getTitle() { |
|
| 45 | + return I18N::translate('Administration Tasks'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * {@inheritDoc} |
| 50 | 50 | * @see \Fisharebest\Webtrees\Module\AbstractModule::getDescription() |
| 51 | 51 | */ |
| 52 | - public function getDescription() { |
|
| 53 | - return I18N::translate('Manage and run nearly-scheduled administration tasks.'); |
|
| 54 | - } |
|
| 52 | + public function getDescription() { |
|
| 53 | + return I18N::translate('Manage and run nearly-scheduled administration tasks.'); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * {@inheritDoc} |
|
| 58 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::modAction() |
|
| 59 | - */ |
|
| 60 | - public function modAction($mod_action) { |
|
| 61 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 56 | + /** |
|
| 57 | + * {@inheritDoc} |
|
| 58 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::modAction() |
|
| 59 | + */ |
|
| 60 | + public function modAction($mod_action) { |
|
| 61 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 62 | 62 | |
| 63 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 64 | - } |
|
| 63 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * {@inheritDoc} |
|
| 68 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 69 | - */ |
|
| 70 | - public function getConfigLink() { |
|
| 71 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 66 | + /** |
|
| 67 | + * {@inheritDoc} |
|
| 68 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 69 | + */ |
|
| 70 | + public function getConfigLink() { |
|
| 71 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 72 | 72 | |
| 73 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 74 | - } |
|
| 73 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * {@inheritDoc} |
|
| 78 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
| 79 | - */ |
|
| 80 | - public function getBlock($block_id, $template = true, $cfg = array()) { |
|
| 81 | - Globals::getController()->addInlineJavascript(' |
|
| 76 | + /** |
|
| 77 | + * {@inheritDoc} |
|
| 78 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::getBlock() |
|
| 79 | + */ |
|
| 80 | + public function getBlock($block_id, $template = true, $cfg = array()) { |
|
| 81 | + Globals::getController()->addInlineJavascript(' |
|
| 82 | 82 | $(document).ready(function(){ |
| 83 | 83 | $.ajax({ |
| 84 | 84 | url: "module.php", |
@@ -89,60 +89,60 @@ discard block |
||
| 89 | 89 | }); |
| 90 | 90 | }); |
| 91 | 91 | '); |
| 92 | - return ''; |
|
| 93 | - } |
|
| 92 | + return ''; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * {@inheritDoc} |
|
| 97 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::loadAjax() |
|
| 98 | - */ |
|
| 99 | - public function loadAjax() { |
|
| 100 | - return false; |
|
| 101 | - } |
|
| 95 | + /** |
|
| 96 | + * {@inheritDoc} |
|
| 97 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::loadAjax() |
|
| 98 | + */ |
|
| 99 | + public function loadAjax() { |
|
| 100 | + return false; |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * {@inheritDoc} |
|
| 105 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isGedcomBlock() |
|
| 106 | - */ |
|
| 107 | - public function isGedcomBlock() { |
|
| 108 | - return true; |
|
| 109 | - } |
|
| 103 | + /** |
|
| 104 | + * {@inheritDoc} |
|
| 105 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isGedcomBlock() |
|
| 106 | + */ |
|
| 107 | + public function isGedcomBlock() { |
|
| 108 | + return true; |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * {@inheritDoc} |
|
| 113 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isUserBlock() |
|
| 114 | - */ |
|
| 115 | - public function isUserBlock() { |
|
| 116 | - return false; |
|
| 117 | - } |
|
| 111 | + /** |
|
| 112 | + * {@inheritDoc} |
|
| 113 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::isUserBlock() |
|
| 114 | + */ |
|
| 115 | + public function isUserBlock() { |
|
| 116 | + return false; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * {@inheritDoc} |
|
| 121 | - * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::configureBlock() |
|
| 122 | - */ |
|
| 123 | - public function configureBlock($block_id) { |
|
| 119 | + /** |
|
| 120 | + * {@inheritDoc} |
|
| 121 | + * @see \Fisharebest\Webtrees\Module\ModuleBlockInterface::configureBlock() |
|
| 122 | + */ |
|
| 123 | + public function configureBlock($block_id) { |
|
| 124 | 124 | |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | - * Get the Admin Tasks Provider (initialise it if not done yet). |
|
| 129 | - * |
|
| 130 | - * @return \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface |
|
| 131 | - */ |
|
| 132 | - public function getProvider() { |
|
| 133 | - if(!$this->provider) { |
|
| 134 | - $this->provider = new TaskProvider(WT_ROOT.WT_MODULES_DIR.$this->getName().'/tasks/'); |
|
| 135 | - } |
|
| 136 | - return $this->provider; |
|
| 137 | - } |
|
| 128 | + * Get the Admin Tasks Provider (initialise it if not done yet). |
|
| 129 | + * |
|
| 130 | + * @return \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface |
|
| 131 | + */ |
|
| 132 | + public function getProvider() { |
|
| 133 | + if(!$this->provider) { |
|
| 134 | + $this->provider = new TaskProvider(WT_ROOT.WT_MODULES_DIR.$this->getName().'/tasks/'); |
|
| 135 | + } |
|
| 136 | + return $this->provider; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * Set the Admin Tasks Provider. |
| 141 | 141 | * |
| 142 | 142 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\TaskProviderInterface |
| 143 | 143 | */ |
| 144 | - public function setProvider(TaskProviderInterface $provider) { |
|
| 145 | - $this->provider = $provider; |
|
| 146 | - } |
|
| 144 | + public function setProvider(TaskProviderInterface $provider) { |
|
| 145 | + $this->provider = $provider; |
|
| 146 | + } |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | \ No newline at end of file |
@@ -35,25 +35,25 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class TaskController extends MvcController |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * Tasks Provider |
|
| 40 | - * @var TaskProviderInterface $provider |
|
| 41 | - */ |
|
| 42 | - protected $provider; |
|
| 38 | + /** |
|
| 39 | + * Tasks Provider |
|
| 40 | + * @var TaskProviderInterface $provider |
|
| 41 | + */ |
|
| 42 | + protected $provider; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Constructor for Admin Config controller |
|
| 46 | - * @param AbstractModule $module |
|
| 47 | - */ |
|
| 48 | - public function __construct(AbstractModule $module) { |
|
| 49 | - parent::__construct($module); |
|
| 44 | + /** |
|
| 45 | + * Constructor for Admin Config controller |
|
| 46 | + * @param AbstractModule $module |
|
| 47 | + */ |
|
| 48 | + public function __construct(AbstractModule $module) { |
|
| 49 | + parent::__construct($module); |
|
| 50 | 50 | |
| 51 | - $this->provider = $this->module->getProvider(); |
|
| 52 | - } |
|
| 51 | + $this->provider = $this->module->getProvider(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Pages |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * Pages |
|
| 56 | + */ |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Task@trigger |
@@ -77,50 +77,50 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * Task@setStatus |
| 79 | 79 | */ |
| 80 | - public function setStatus() { |
|
| 81 | - $controller = new JsonController(); |
|
| 80 | + public function setStatus() { |
|
| 81 | + $controller = new JsonController(); |
|
| 82 | 82 | |
| 83 | - $task_name = Filter::get('task'); |
|
| 84 | - $task = $this->provider->getTask($task_name, false); |
|
| 83 | + $task_name = Filter::get('task'); |
|
| 84 | + $task = $this->provider->getTask($task_name, false); |
|
| 85 | 85 | |
| 86 | - $controller->restrictAccess( |
|
| 87 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
| 88 | - && Auth::isAdmin() |
|
| 89 | - && $task |
|
| 90 | - ); |
|
| 86 | + $controller->restrictAccess( |
|
| 87 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
| 88 | + && Auth::isAdmin() |
|
| 89 | + && $task |
|
| 90 | + ); |
|
| 91 | 91 | |
| 92 | - $status = Filter::getBool('status'); |
|
| 93 | - $res = array('task' => $task->getName() , 'error' => null); |
|
| 94 | - try{ |
|
| 95 | - $this->provider->setTaskStatus($task, $status); |
|
| 96 | - $res['status'] = $status; |
|
| 92 | + $status = Filter::getBool('status'); |
|
| 93 | + $res = array('task' => $task->getName() , 'error' => null); |
|
| 94 | + try{ |
|
| 95 | + $this->provider->setTaskStatus($task, $status); |
|
| 96 | + $res['status'] = $status; |
|
| 97 | 97 | Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
| 98 | - } |
|
| 99 | - catch (\Exception $ex) { |
|
| 100 | - $res['error'] = $ex->getMessage(); |
|
| 98 | + } |
|
| 99 | + catch (\Exception $ex) { |
|
| 100 | + $res['error'] = $ex->getMessage(); |
|
| 101 | 101 | Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $controller->pageHeader(); |
|
| 105 | - if($res['error']) http_response_code(500); |
|
| 104 | + $controller->pageHeader(); |
|
| 105 | + if($res['error']) http_response_code(500); |
|
| 106 | 106 | |
| 107 | - $controller->encode($res); |
|
| 108 | - } |
|
| 107 | + $controller->encode($res); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Task@edit |
| 112 | 112 | */ |
| 113 | 113 | public function edit() { |
| 114 | - $tree = Globals::getTree(); |
|
| 115 | - $task_name = Filter::get('task'); |
|
| 116 | - $task = $this->provider->getTask($task_name, false); |
|
| 114 | + $tree = Globals::getTree(); |
|
| 115 | + $task_name = Filter::get('task'); |
|
| 116 | + $task = $this->provider->getTask($task_name, false); |
|
| 117 | 117 | |
| 118 | - Theme::theme(new AdministrationTheme)->init($tree); |
|
| 119 | - $controller = new PageController(); |
|
| 120 | - $controller |
|
| 121 | - ->restrictAccess(Auth::isAdmin() && $task) |
|
| 118 | + Theme::theme(new AdministrationTheme)->init($tree); |
|
| 119 | + $controller = new PageController(); |
|
| 120 | + $controller |
|
| 121 | + ->restrictAccess(Auth::isAdmin() && $task) |
|
| 122 | 122 | ->setPageTitle(I18N::translate('Edit the administrative task')) |
| 123 | - ->addInlineJavascript(' |
|
| 123 | + ->addInlineJavascript(' |
|
| 124 | 124 | function toggleRemainingOccurrences() { |
| 125 | 125 | if($("input:radio[name=\'is_limited\']:checked").val() == 1) { |
| 126 | 126 | $("#nb_occurences").show(); |
@@ -133,39 +133,39 @@ discard block |
||
| 133 | 133 | $("[name=\'is_limited\']").on("change", toggleRemainingOccurrences); |
| 134 | 134 | toggleRemainingOccurrences(); |
| 135 | 135 | ') |
| 136 | - ; |
|
| 136 | + ; |
|
| 137 | 137 | |
| 138 | 138 | |
| 139 | - $data = new ViewBag(); |
|
| 140 | - $data->set('title', $controller->getPageTitle()); |
|
| 139 | + $data = new ViewBag(); |
|
| 140 | + $data->set('title', $controller->getPageTitle()); |
|
| 141 | 141 | $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $tree->getNameUrl()); |
| 142 | - $data->set('module_title', $this->module->getTitle()); |
|
| 142 | + $data->set('module_title', $this->module->getTitle()); |
|
| 143 | 143 | $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $tree->getNameUrl()); |
| 144 | 144 | $data->set('task', $task); |
| 145 | 145 | |
| 146 | - ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
|
| 146 | + ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | 150 | * Task@save |
| 151 | 151 | */ |
| 152 | 152 | public function save() { |
| 153 | - $tmp_contrl = new PageController(); |
|
| 153 | + $tmp_contrl = new PageController(); |
|
| 154 | 154 | |
| 155 | - $tmp_contrl->restrictAccess( |
|
| 156 | - Auth::isAdmin() |
|
| 157 | - && Filter::checkCsrf() |
|
| 158 | - ); |
|
| 155 | + $tmp_contrl->restrictAccess( |
|
| 156 | + Auth::isAdmin() |
|
| 157 | + && Filter::checkCsrf() |
|
| 158 | + ); |
|
| 159 | 159 | |
| 160 | 160 | $task_name = Filter::post('task'); |
| 161 | - $frequency = Filter::postInteger('frequency'); |
|
| 162 | - $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
| 163 | - $nb_occur = Filter::postInteger('nb_occur'); |
|
| 161 | + $frequency = Filter::postInteger('frequency'); |
|
| 162 | + $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
| 163 | + $nb_occur = Filter::postInteger('nb_occur'); |
|
| 164 | 164 | |
| 165 | 165 | $task = $this->provider->getTask($task_name, false); |
| 166 | 166 | |
| 167 | - $success = false; |
|
| 168 | - if($task) { |
|
| 167 | + $success = false; |
|
| 168 | + if($task) { |
|
| 169 | 169 | $task->setFrequency($frequency); |
| 170 | 170 | if($is_limited == 1) { |
| 171 | 171 | $task->setRemainingOccurrences($nb_occur); |
@@ -197,13 +197,13 @@ discard block |
||
| 197 | 197 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
| 203 | - if(!$success) { |
|
| 202 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
| 203 | + if(!$success) { |
|
| 204 | 204 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName(); |
| 205 | - } |
|
| 206 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
| 205 | + } |
|
| 206 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | } |
| 210 | 210 | \ No newline at end of file |
@@ -35,37 +35,37 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class AdminConfigController extends MvcController |
| 37 | 37 | { |
| 38 | - /** |
|
| 39 | - * Tasks Provider |
|
| 40 | - * @var TaskProviderInterface $provider |
|
| 41 | - */ |
|
| 42 | - protected $provider; |
|
| 38 | + /** |
|
| 39 | + * Tasks Provider |
|
| 40 | + * @var TaskProviderInterface $provider |
|
| 41 | + */ |
|
| 42 | + protected $provider; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Constructor for Admin Config controller |
|
| 46 | - * @param \Fisharebest\Webtrees\Module\AbstractModule $module |
|
| 47 | - */ |
|
| 48 | - public function __construct(AbstractModule $module) { |
|
| 49 | - parent::__construct($module); |
|
| 44 | + /** |
|
| 45 | + * Constructor for Admin Config controller |
|
| 46 | + * @param \Fisharebest\Webtrees\Module\AbstractModule $module |
|
| 47 | + */ |
|
| 48 | + public function __construct(AbstractModule $module) { |
|
| 49 | + parent::__construct($module); |
|
| 50 | 50 | |
| 51 | - $this->provider = $this->module->getProvider(); |
|
| 52 | - } |
|
| 51 | + $this->provider = $this->module->getProvider(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Pages |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * Pages |
|
| 56 | + */ |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * AdminConfig@index |
|
| 60 | - */ |
|
| 61 | - public function index() { |
|
| 58 | + /** |
|
| 59 | + * AdminConfig@index |
|
| 60 | + */ |
|
| 61 | + public function index() { |
|
| 62 | 62 | |
| 63 | - $tree = Globals::getTree(); |
|
| 64 | - Theme::theme(new AdministrationTheme)->init($tree); |
|
| 65 | - $controller = new PageController(); |
|
| 66 | - $controller |
|
| 67 | - ->restrictAccess(Auth::isAdmin()) |
|
| 68 | - ->setPageTitle($this->module->getTitle()); |
|
| 63 | + $tree = Globals::getTree(); |
|
| 64 | + Theme::theme(new AdministrationTheme)->init($tree); |
|
| 65 | + $controller = new PageController(); |
|
| 66 | + $controller |
|
| 67 | + ->restrictAccess(Auth::isAdmin()) |
|
| 68 | + ->setPageTitle($this->module->getTitle()); |
|
| 69 | 69 | |
| 70 | 70 | $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); |
| 71 | 71 | if(is_null($token)) { |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | $this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $data = new ViewBag(); |
|
| 77 | - $data->set('title', $controller->getPageTitle()); |
|
| 76 | + $data = new ViewBag(); |
|
| 77 | + $data->set('title', $controller->getPageTitle()); |
|
| 78 | 78 | |
| 79 | - $table_id = 'table-admintasks-' . Uuid::uuid4(); |
|
| 80 | - $data->set('table_id', $table_id); |
|
| 79 | + $table_id = 'table-admintasks-' . Uuid::uuid4(); |
|
| 80 | + $data->set('table_id', $table_id); |
|
| 81 | 81 | |
| 82 | 82 | $data->set('trigger_url_root', WT_BASE_URL.'module.php?mod='.$this->module->getName().'&mod_action=Task@trigger'); |
| 83 | 83 | $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN'); |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | $this->provider->getInstalledTasks(); |
| 91 | 91 | |
| 92 | 92 | $controller |
| 93 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 94 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
| 95 | - ->addInlineJavascript(' |
|
| 93 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 94 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
| 95 | + ->addInlineJavascript(' |
|
| 96 | 96 | //Datatable initialisation |
| 97 | 97 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 98 | 98 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | }); |
| 125 | 125 | |
| 126 | 126 | ') |
| 127 | - ->addInlineJavascript(' |
|
| 127 | + ->addInlineJavascript(' |
|
| 128 | 128 | function generate_force_token() { |
| 129 | 129 | jQuery("#bt_genforcetoken").attr("disabled", "disabled"); |
| 130 | 130 | jQuery("#bt_tokentext").empty().html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>"); |
@@ -172,54 +172,54 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | '); |
| 174 | 174 | |
| 175 | - ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
| 176 | - } |
|
| 175 | + ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * AdminConfig@jsonTasksList |
|
| 180 | - */ |
|
| 181 | - public function jsonTasksList() { |
|
| 182 | - $controller = new JsonController(); |
|
| 183 | - $controller |
|
| 184 | - ->restrictAccess(Auth::isAdmin()); |
|
| 178 | + /** |
|
| 179 | + * AdminConfig@jsonTasksList |
|
| 180 | + */ |
|
| 181 | + public function jsonTasksList() { |
|
| 182 | + $controller = new JsonController(); |
|
| 183 | + $controller |
|
| 184 | + ->restrictAccess(Auth::isAdmin()); |
|
| 185 | 185 | |
| 186 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 187 | - $search = Filter::postArray('search'); |
|
| 188 | - if($search) $search = $search['value']; |
|
| 189 | - $start = Filter::postInteger('start'); |
|
| 190 | - $length = Filter::postInteger('length'); |
|
| 191 | - $order = Filter::postArray('order'); |
|
| 186 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 187 | + $search = Filter::postArray('search'); |
|
| 188 | + if($search) $search = $search['value']; |
|
| 189 | + $start = Filter::postInteger('start'); |
|
| 190 | + $length = Filter::postInteger('length'); |
|
| 191 | + $order = Filter::postArray('order'); |
|
| 192 | 192 | |
| 193 | 193 | $order_by_name = false; |
| 194 | - foreach($order as $key => &$value) { |
|
| 195 | - switch($value['column']) { |
|
| 196 | - case 3: |
|
| 194 | + foreach($order as $key => &$value) { |
|
| 195 | + switch($value['column']) { |
|
| 196 | + case 3: |
|
| 197 | 197 | $order_by_name = true; |
| 198 | - unset($order[$key]); |
|
| 199 | - break; |
|
| 200 | - case 4; |
|
| 198 | + unset($order[$key]); |
|
| 199 | + break; |
|
| 200 | + case 4; |
|
| 201 | 201 | $value['column'] = 'majat_last_run'; |
| 202 | 202 | break; |
| 203 | 203 | case 4; |
| 204 | 204 | $value['column'] = 'majat_last_result'; |
| 205 | 205 | break; |
| 206 | - default: |
|
| 207 | - unset($order[$key]); |
|
| 208 | - } |
|
| 209 | - } |
|
| 206 | + default: |
|
| 207 | + unset($order[$key]); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
|
| 211 | + $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
|
| 212 | 212 | if($order_by_name) { |
| 213 | 213 | usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); }); |
| 214 | 214 | } |
| 215 | - $recordsFiltered = count($list); |
|
| 216 | - $recordsTotal = $this->provider->getTasksCount(); |
|
| 215 | + $recordsFiltered = count($list); |
|
| 216 | + $recordsTotal = $this->provider->getTasksCount(); |
|
| 217 | 217 | |
| 218 | - $data = array(); |
|
| 219 | - foreach($list as $task) { |
|
| 220 | - $datum = array(); |
|
| 218 | + $data = array(); |
|
| 219 | + foreach($list as $task) { |
|
| 220 | + $datum = array(); |
|
| 221 | 221 | |
| 222 | - $datum[0] = ' |
|
| 222 | + $datum[0] = ' |
|
| 223 | 223 | <div class="btn-group"> |
| 224 | 224 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
| 225 | 225 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -237,50 +237,50 @@ discard block |
||
| 237 | 237 | </li> |
| 238 | 238 | </ul> |
| 239 | 239 | </div>'; |
| 240 | - $datum[1] = $task->getName(); |
|
| 241 | - $datum[2] = $task->isEnabled() ? |
|
| 240 | + $datum[1] = $task->getName(); |
|
| 241 | + $datum[2] = $task->isEnabled() ? |
|
| 242 | 242 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
| 243 | 243 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
| 244 | - $datum[3] = $task->getTitle(); |
|
| 245 | - $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 244 | + $datum[3] = $task->getTitle(); |
|
| 245 | + $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 246 | 246 | $datum[4] = $task->getLastUpdated()->format($date_format); |
| 247 | - $datum[5] = $task->isLastRunSuccess() ? |
|
| 247 | + $datum[5] = $task->isLastRunSuccess() ? |
|
| 248 | 248 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
| 249 | 249 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
| 250 | - $dtF = new \DateTime('@0'); |
|
| 251 | - $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 252 | - $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
|
| 250 | + $dtF = new \DateTime('@0'); |
|
| 251 | + $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 252 | + $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
|
| 253 | 253 | $datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited'); |
| 254 | 254 | $datum[8] = $task->isRunning() ? |
| 255 | 255 | '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : |
| 256 | 256 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; |
| 257 | 257 | if($task->isEnabled() && !$task->isRunning()) { |
| 258 | - $datum[9] = ' |
|
| 258 | + $datum[9] = ' |
|
| 259 | 259 | <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> |
| 260 | 260 | <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> |
| 261 | 261 | </button>'; |
| 262 | 262 | } |
| 263 | 263 | else { |
| 264 | - $datum[9] = ''; |
|
| 264 | + $datum[9] = ''; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - $data[] = $datum; |
|
| 268 | - } |
|
| 267 | + $data[] = $datum; |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - $controller->pageHeader(); |
|
| 270 | + $controller->pageHeader(); |
|
| 271 | 271 | |
| 272 | - $controller->encode(array( |
|
| 273 | - 'draw' => Filter::getInteger('draw'), |
|
| 274 | - 'recordsTotal' => $recordsTotal, |
|
| 275 | - 'recordsFiltered' => $recordsFiltered, |
|
| 276 | - 'data' => $data |
|
| 277 | - )); |
|
| 272 | + $controller->encode(array( |
|
| 273 | + 'draw' => Filter::getInteger('draw'), |
|
| 274 | + 'recordsTotal' => $recordsTotal, |
|
| 275 | + 'recordsFiltered' => $recordsFiltered, |
|
| 276 | + 'data' => $data |
|
| 277 | + )); |
|
| 278 | 278 | |
| 279 | - } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * AdminConfig@generateToken |
| 283 | - * |
|
| 283 | + * |
|
| 284 | 284 | * Ajax call to generate a new token. Display the token, if generated. |
| 285 | 285 | * Tokens call only be generated by a site administrator. |
| 286 | 286 | * |