@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Fisharebest\Webtrees\Controller\AjaxController; |
| 15 | 15 | use Fisharebest\Webtrees\Controller\PageController; |
| 16 | 16 | use Fisharebest\Webtrees\Filter; |
| 17 | -use Fisharebest\Webtrees\Html; |
|
| 18 | 17 | use Fisharebest\Webtrees\I18N; |
| 19 | 18 | use Fisharebest\Webtrees\Log; |
| 20 | 19 | use Fisharebest\Webtrees\Module; |
@@ -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 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 | - /** |
|
| 59 | - * AdminConfig@index |
|
| 60 | - */ |
|
| 61 | - public function index() { |
|
| 62 | - global $WT_TREE; |
|
| 58 | + /** |
|
| 59 | + * AdminConfig@index |
|
| 60 | + */ |
|
| 61 | + public function index() { |
|
| 62 | + global $WT_TREE; |
|
| 63 | 63 | |
| 64 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 65 | - $controller = new PageController(); |
|
| 66 | - $controller |
|
| 67 | - ->restrictAccess(Auth::isAdmin()) |
|
| 68 | - ->setPageTitle($this->module->getTitle()); |
|
| 64 | + Theme::theme(new AdministrationTheme)->init($WT_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,56 +172,56 @@ 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 | - global $WT_TREE; |
|
| 178 | + /** |
|
| 179 | + * AdminConfig@jsonTasksList |
|
| 180 | + */ |
|
| 181 | + public function jsonTasksList() { |
|
| 182 | + global $WT_TREE; |
|
| 183 | 183 | |
| 184 | - $controller = new JsonController(); |
|
| 185 | - $controller |
|
| 186 | - ->restrictAccess(Auth::isAdmin()); |
|
| 184 | + $controller = new JsonController(); |
|
| 185 | + $controller |
|
| 186 | + ->restrictAccess(Auth::isAdmin()); |
|
| 187 | 187 | |
| 188 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 189 | - $search = Filter::postArray('search'); |
|
| 190 | - if($search) $search = $search['value']; |
|
| 191 | - $start = Filter::postInteger('start'); |
|
| 192 | - $length = Filter::postInteger('length'); |
|
| 193 | - $order = Filter::postArray('order'); |
|
| 188 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 189 | + $search = Filter::postArray('search'); |
|
| 190 | + if($search) $search = $search['value']; |
|
| 191 | + $start = Filter::postInteger('start'); |
|
| 192 | + $length = Filter::postInteger('length'); |
|
| 193 | + $order = Filter::postArray('order'); |
|
| 194 | 194 | |
| 195 | 195 | $order_by_name = false; |
| 196 | - foreach($order as $key => &$value) { |
|
| 197 | - switch($value['column']) { |
|
| 198 | - case 3: |
|
| 196 | + foreach($order as $key => &$value) { |
|
| 197 | + switch($value['column']) { |
|
| 198 | + case 3: |
|
| 199 | 199 | $order_by_name = true; |
| 200 | - unset($order[$key]); |
|
| 201 | - break; |
|
| 202 | - case 4; |
|
| 200 | + unset($order[$key]); |
|
| 201 | + break; |
|
| 202 | + case 4; |
|
| 203 | 203 | $value['column'] = 'majat_last_run'; |
| 204 | 204 | break; |
| 205 | 205 | case 4; |
| 206 | 206 | $value['column'] = 'majat_last_result'; |
| 207 | 207 | break; |
| 208 | - default: |
|
| 209 | - unset($order[$key]); |
|
| 210 | - } |
|
| 211 | - } |
|
| 208 | + default: |
|
| 209 | + unset($order[$key]); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
|
| 213 | + $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); |
|
| 214 | 214 | if($order_by_name) { |
| 215 | 215 | usort($list, function(AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); }); |
| 216 | 216 | } |
| 217 | - $recordsFiltered = count($list); |
|
| 218 | - $recordsTotal = $this->provider->getTasksCount(); |
|
| 217 | + $recordsFiltered = count($list); |
|
| 218 | + $recordsTotal = $this->provider->getTasksCount(); |
|
| 219 | 219 | |
| 220 | - $data = array(); |
|
| 221 | - foreach($list as $task) { |
|
| 222 | - $datum = array(); |
|
| 220 | + $data = array(); |
|
| 221 | + foreach($list as $task) { |
|
| 222 | + $datum = array(); |
|
| 223 | 223 | |
| 224 | - $datum[0] = ' |
|
| 224 | + $datum[0] = ' |
|
| 225 | 225 | <div class="btn-group"> |
| 226 | 226 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
| 227 | 227 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -239,50 +239,50 @@ discard block |
||
| 239 | 239 | </li> |
| 240 | 240 | </ul> |
| 241 | 241 | </div>'; |
| 242 | - $datum[1] = $task->getName(); |
|
| 243 | - $datum[2] = $task->isEnabled() ? |
|
| 242 | + $datum[1] = $task->getName(); |
|
| 243 | + $datum[2] = $task->isEnabled() ? |
|
| 244 | 244 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
| 245 | 245 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
| 246 | - $datum[3] = $task->getTitle(); |
|
| 247 | - $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 246 | + $datum[3] = $task->getTitle(); |
|
| 247 | + $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; |
|
| 248 | 248 | $datum[4] = $task->getLastUpdated()->format($date_format); |
| 249 | - $datum[5] = $task->isLastRunSuccess() ? |
|
| 249 | + $datum[5] = $task->isLastRunSuccess() ? |
|
| 250 | 250 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
| 251 | 251 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
| 252 | - $dtF = new \DateTime('@0'); |
|
| 253 | - $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 254 | - $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
|
| 252 | + $dtF = new \DateTime('@0'); |
|
| 253 | + $dtT = new \DateTime('@' . ($task->getFrequency() * 60)); |
|
| 254 | + $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); |
|
| 255 | 255 | $datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited'); |
| 256 | 256 | $datum[8] = $task->isRunning() ? |
| 257 | 257 | '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">'.I18N::translate('Running').'</span>' : |
| 258 | 258 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Not running').'</span>'; |
| 259 | 259 | if($task->isEnabled() && !$task->isRunning()) { |
| 260 | - $datum[9] = ' |
|
| 260 | + $datum[9] = ' |
|
| 261 | 261 | <button id="bt_runtask_'. $task->getName() .'" class="btn btn-primary" href="#" onclick="return run_admintask(\''. $task->getName() .'\')"> |
| 262 | 262 | <div id="bt_runtasktext_'. $task->getName() .'"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> |
| 263 | 263 | </button>'; |
| 264 | 264 | } |
| 265 | 265 | else { |
| 266 | - $datum[9] = ''; |
|
| 266 | + $datum[9] = ''; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - $data[] = $datum; |
|
| 270 | - } |
|
| 269 | + $data[] = $datum; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $controller->pageHeader(); |
|
| 272 | + $controller->pageHeader(); |
|
| 273 | 273 | |
| 274 | - echo \Zend_Json::encode(array( |
|
| 275 | - 'draw' => Filter::getInteger('draw'), |
|
| 276 | - 'recordsTotal' => $recordsTotal, |
|
| 277 | - 'recordsFiltered' => $recordsFiltered, |
|
| 278 | - 'data' => $data |
|
| 279 | - )); |
|
| 274 | + echo \Zend_Json::encode(array( |
|
| 275 | + 'draw' => Filter::getInteger('draw'), |
|
| 276 | + 'recordsTotal' => $recordsTotal, |
|
| 277 | + 'recordsFiltered' => $recordsFiltered, |
|
| 278 | + 'data' => $data |
|
| 279 | + )); |
|
| 280 | 280 | |
| 281 | - } |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * AdminConfig@generateToken |
| 285 | - * |
|
| 285 | + * |
|
| 286 | 286 | * Ajax call to generate a new token. Display the token, if generated. |
| 287 | 287 | * Tokens call only be generated by a site administrator. |
| 288 | 288 | * |
@@ -11,7 +11,6 @@ |
||
| 11 | 11 | namespace MyArtJaub\Webtrees\Module\AdminTasks\Model; |
| 12 | 12 | |
| 13 | 13 | use Fisharebest\Webtrees\Log; |
| 14 | -use Fisharebest\Webtrees\Place; |
|
| 15 | 14 | use MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface; |
| 16 | 15 | |
| 17 | 16 | /** |
@@ -21,254 +21,254 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | abstract class AbstractTask { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Time out for runnign tasks, in seconds. Default 5 min |
|
| 26 | - * @var int TASK_TIME_OUT |
|
| 27 | - */ |
|
| 28 | - const TASK_TIME_OUT = 300; |
|
| 24 | + /** |
|
| 25 | + * Time out for runnign tasks, in seconds. Default 5 min |
|
| 26 | + * @var int TASK_TIME_OUT |
|
| 27 | + */ |
|
| 28 | + const TASK_TIME_OUT = 300; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Task provider |
|
| 32 | - * @var TaskProviderInterface $provider |
|
| 33 | - */ |
|
| 30 | + /** |
|
| 31 | + * Task provider |
|
| 32 | + * @var TaskProviderInterface $provider |
|
| 33 | + */ |
|
| 34 | 34 | protected $provider; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Task name |
| 38 | 38 | * @var string $name |
| 39 | 39 | */ |
| 40 | - protected $name; |
|
| 40 | + protected $name; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Status of the task |
|
| 44 | - * @var bool $is_enabled |
|
| 45 | - */ |
|
| 46 | - protected $is_enabled; |
|
| 42 | + /** |
|
| 43 | + * Status of the task |
|
| 44 | + * @var bool $is_enabled |
|
| 45 | + */ |
|
| 46 | + protected $is_enabled; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Last updated date |
|
| 50 | - * @var \DateTime $last_updated |
|
| 51 | - */ |
|
| 52 | - protected $last_updated; |
|
| 48 | + /** |
|
| 49 | + * Last updated date |
|
| 50 | + * @var \DateTime $last_updated |
|
| 51 | + */ |
|
| 52 | + protected $last_updated; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Last run result |
|
| 56 | - * @var bool $last_result |
|
| 57 | - */ |
|
| 58 | - protected $last_result; |
|
| 54 | + /** |
|
| 55 | + * Last run result |
|
| 56 | + * @var bool $last_result |
|
| 57 | + */ |
|
| 58 | + protected $last_result; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Task run frequency |
|
| 62 | - * @var int $frequency |
|
| 63 | - */ |
|
| 64 | - protected $frequency; |
|
| 60 | + /** |
|
| 61 | + * Task run frequency |
|
| 62 | + * @var int $frequency |
|
| 63 | + */ |
|
| 64 | + protected $frequency; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Task remaining runs |
|
| 68 | - * @var int $nb_occurrences |
|
| 69 | - */ |
|
| 70 | - protected $nb_occurrences; |
|
| 66 | + /** |
|
| 67 | + * Task remaining runs |
|
| 68 | + * @var int $nb_occurrences |
|
| 69 | + */ |
|
| 70 | + protected $nb_occurrences; |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Current running status of the task |
|
| 74 | - * @var bool $is_running |
|
| 75 | - */ |
|
| 76 | - protected $is_running; |
|
| 72 | + /** |
|
| 73 | + * Current running status of the task |
|
| 74 | + * @var bool $is_running |
|
| 75 | + */ |
|
| 76 | + protected $is_running; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Constructor for the Admin task class |
|
| 78 | + /** |
|
| 79 | + * Constructor for the Admin task class |
|
| 80 | 80 | * |
| 81 | 81 | * @param string $file Filename containing the task object |
| 82 | 82 | * @param TaskProviderInterface $provider Provider for tasks |
| 83 | - */ |
|
| 84 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
| 85 | - $this->name = trim(basename($file, '.php')); |
|
| 83 | + */ |
|
| 84 | + public function __construct($file, TaskProviderInterface $provider = null){ |
|
| 85 | + $this->name = trim(basename($file, '.php')); |
|
| 86 | 86 | $this->provider = $provider; |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Get the provider. |
|
| 91 | - * |
|
| 92 | - * @return TaskProviderInterface |
|
| 93 | - */ |
|
| 94 | - public function getProvider(){ |
|
| 95 | - return $this->provider; |
|
| 96 | - } |
|
| 89 | + /** |
|
| 90 | + * Get the provider. |
|
| 91 | + * |
|
| 92 | + * @return TaskProviderInterface |
|
| 93 | + */ |
|
| 94 | + public function getProvider(){ |
|
| 95 | + return $this->provider; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Set the provider. |
|
| 100 | - * |
|
| 101 | - * @param TaskProviderInterface $provider |
|
| 102 | - * @return self Enable method-chaining |
|
| 103 | - */ |
|
| 104 | - public function setProvider(TaskProviderInterface $provider){ |
|
| 105 | - $this->provider = $provider; |
|
| 106 | - return $this; |
|
| 107 | - } |
|
| 98 | + /** |
|
| 99 | + * Set the provider. |
|
| 100 | + * |
|
| 101 | + * @param TaskProviderInterface $provider |
|
| 102 | + * @return self Enable method-chaining |
|
| 103 | + */ |
|
| 104 | + public function setProvider(TaskProviderInterface $provider){ |
|
| 105 | + $this->provider = $provider; |
|
| 106 | + return $this; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Set parameters of the Task |
|
| 111 | - * |
|
| 112 | - * @param bool $is_enabled Status of the task |
|
| 113 | - * @param \DateTime $lastupdated Time of the last task run |
|
| 114 | - * @param bool $last_result Result of the last run, true for success, false for failure |
|
| 115 | - * @param int $frequency Frequency of execution in minutes |
|
| 116 | - * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
| 117 | - * @param bool $is_running Indicates if the task is currently running |
|
| 118 | - */ |
|
| 119 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
| 120 | - $this->is_enabled = $is_enabled; |
|
| 121 | - $this->last_updated = $last_updated; |
|
| 122 | - $this->last_result = $last_result; |
|
| 123 | - $this->frequency = $frequency; |
|
| 124 | - $this->nb_occurrences = $nb_occur; |
|
| 125 | - $this->is_running = $is_running; |
|
| 126 | - } |
|
| 109 | + /** |
|
| 110 | + * Set parameters of the Task |
|
| 111 | + * |
|
| 112 | + * @param bool $is_enabled Status of the task |
|
| 113 | + * @param \DateTime $lastupdated Time of the last task run |
|
| 114 | + * @param bool $last_result Result of the last run, true for success, false for failure |
|
| 115 | + * @param int $frequency Frequency of execution in minutes |
|
| 116 | + * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
| 117 | + * @param bool $is_running Indicates if the task is currently running |
|
| 118 | + */ |
|
| 119 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
| 120 | + $this->is_enabled = $is_enabled; |
|
| 121 | + $this->last_updated = $last_updated; |
|
| 122 | + $this->last_result = $last_result; |
|
| 123 | + $this->frequency = $frequency; |
|
| 124 | + $this->nb_occurrences = $nb_occur; |
|
| 125 | + $this->is_running = $is_running; |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Get the name of the task |
|
| 130 | - * |
|
| 131 | - * @return string |
|
| 132 | - */ |
|
| 133 | - public function getName(){ |
|
| 134 | - return $this->name; |
|
| 135 | - } |
|
| 128 | + /** |
|
| 129 | + * Get the name of the task |
|
| 130 | + * |
|
| 131 | + * @return string |
|
| 132 | + */ |
|
| 133 | + public function getName(){ |
|
| 134 | + return $this->name; |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Return the status of the task in a boolean way |
|
| 140 | - * |
|
| 141 | - * @return boolean True if enabled |
|
| 142 | - */ |
|
| 143 | - public function isEnabled(){ |
|
| 144 | - return $this->is_enabled; |
|
| 145 | - } |
|
| 138 | + /** |
|
| 139 | + * Return the status of the task in a boolean way |
|
| 140 | + * |
|
| 141 | + * @return boolean True if enabled |
|
| 142 | + */ |
|
| 143 | + public function isEnabled(){ |
|
| 144 | + return $this->is_enabled; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - /** |
|
| 148 | - * Get the last updated time. |
|
| 149 | - * |
|
| 150 | - * @return \DateTime |
|
| 151 | - */ |
|
| 152 | - public function getLastUpdated(){ |
|
| 153 | - return $this->last_updated; |
|
| 154 | - } |
|
| 147 | + /** |
|
| 148 | + * Get the last updated time. |
|
| 149 | + * |
|
| 150 | + * @return \DateTime |
|
| 151 | + */ |
|
| 152 | + public function getLastUpdated(){ |
|
| 153 | + return $this->last_updated; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Check if the last result has been successful. |
|
| 158 | - * |
|
| 159 | - * @return bool |
|
| 160 | - */ |
|
| 161 | - public function isLastRunSuccess(){ |
|
| 162 | - return $this->last_result; |
|
| 163 | - } |
|
| 156 | + /** |
|
| 157 | + * Check if the last result has been successful. |
|
| 158 | + * |
|
| 159 | + * @return bool |
|
| 160 | + */ |
|
| 161 | + public function isLastRunSuccess(){ |
|
| 162 | + return $this->last_result; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Get the task frequency. |
|
| 167 | - * |
|
| 168 | - * @return int |
|
| 169 | - */ |
|
| 170 | - public function getFrequency(){ |
|
| 171 | - return $this->frequency; |
|
| 172 | - } |
|
| 165 | + /** |
|
| 166 | + * Get the task frequency. |
|
| 167 | + * |
|
| 168 | + * @return int |
|
| 169 | + */ |
|
| 170 | + public function getFrequency(){ |
|
| 171 | + return $this->frequency; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | - * Set the task frequency. |
|
| 176 | - * |
|
| 175 | + * Set the task frequency. |
|
| 176 | + * |
|
| 177 | 177 | * @param int $frequency |
| 178 | - * @return self Enable method-chaining |
|
| 179 | - */ |
|
| 180 | - public function setFrequency($frequency){ |
|
| 181 | - $this->frequency = $frequency; |
|
| 178 | + * @return self Enable method-chaining |
|
| 179 | + */ |
|
| 180 | + public function setFrequency($frequency){ |
|
| 181 | + $this->frequency = $frequency; |
|
| 182 | 182 | return $this; |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Get the number of remaining occurrences. |
|
| 187 | - * |
|
| 188 | - * @return int |
|
| 189 | - */ |
|
| 190 | - public function getRemainingOccurrences(){ |
|
| 191 | - return $this->nb_occurrences; |
|
| 192 | - } |
|
| 185 | + /** |
|
| 186 | + * Get the number of remaining occurrences. |
|
| 187 | + * |
|
| 188 | + * @return int |
|
| 189 | + */ |
|
| 190 | + public function getRemainingOccurrences(){ |
|
| 191 | + return $this->nb_occurrences; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | - * Set the number of remaining occurrences. |
|
| 196 | - * |
|
| 195 | + * Set the number of remaining occurrences. |
|
| 196 | + * |
|
| 197 | 197 | * @param int $nb_occur |
| 198 | - * @return self Enable method-chaining |
|
| 199 | - */ |
|
| 200 | - public function setRemainingOccurrences($nb_occur){ |
|
| 201 | - $this->nb_occurrences = $nb_occur; |
|
| 198 | + * @return self Enable method-chaining |
|
| 199 | + */ |
|
| 200 | + public function setRemainingOccurrences($nb_occur){ |
|
| 201 | + $this->nb_occurrences = $nb_occur; |
|
| 202 | 202 | return $this; |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - /** |
|
| 206 | - * Check if the task if running. |
|
| 207 | - * |
|
| 208 | - * @return bool |
|
| 209 | - */ |
|
| 210 | - public function isRunning(){ |
|
| 211 | - return $this->is_running; |
|
| 212 | - } |
|
| 205 | + /** |
|
| 206 | + * Check if the task if running. |
|
| 207 | + * |
|
| 208 | + * @return bool |
|
| 209 | + */ |
|
| 210 | + public function isRunning(){ |
|
| 211 | + return $this->is_running; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Return the name to display for the task |
|
| 217 | - * |
|
| 218 | - * @return string Title for the task |
|
| 219 | - */ |
|
| 220 | - abstract public function getTitle(); |
|
| 215 | + /** |
|
| 216 | + * Return the name to display for the task |
|
| 217 | + * |
|
| 218 | + * @return string Title for the task |
|
| 219 | + */ |
|
| 220 | + abstract public function getTitle(); |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Return the default frequency for the execution of the task |
|
| 224 | - * |
|
| 225 | - * @return int Frequency for the execution of the task |
|
| 226 | - */ |
|
| 227 | - abstract public function getDefaultFrequency(); |
|
| 222 | + /** |
|
| 223 | + * Return the default frequency for the execution of the task |
|
| 224 | + * |
|
| 225 | + * @return int Frequency for the execution of the task |
|
| 226 | + */ |
|
| 227 | + abstract public function getDefaultFrequency(); |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Execute the task's actions |
|
| 231 | - */ |
|
| 232 | - abstract protected function executeSteps(); |
|
| 229 | + /** |
|
| 230 | + * Execute the task's actions |
|
| 231 | + */ |
|
| 232 | + abstract protected function executeSteps(); |
|
| 233 | 233 | |
| 234 | 234 | /** |
| 235 | 235 | * Persist task state into database. |
| 236 | 236 | * @return bool |
| 237 | 237 | */ |
| 238 | 238 | public function save() { |
| 239 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 239 | + if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 240 | 240 | return $this->provider->updateTask($this); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Execute the task, default skeleton |
|
| 245 | - * |
|
| 246 | - */ |
|
| 247 | - public function execute(){ |
|
| 243 | + /** |
|
| 244 | + * Execute the task, default skeleton |
|
| 245 | + * |
|
| 246 | + */ |
|
| 247 | + public function execute(){ |
|
| 248 | 248 | |
| 249 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 250 | - $this->is_running = false; |
|
| 249 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 250 | + $this->is_running = false; |
|
| 251 | 251 | |
| 252 | - if(!$this->is_running){ //TODO put in place a time_out for running... |
|
| 253 | - //TODO Log the executions in the logs |
|
| 254 | - $this->last_result = false; |
|
| 255 | - $this->is_running = true; |
|
| 256 | - $this->save(); |
|
| 252 | + if(!$this->is_running){ //TODO put in place a time_out for running... |
|
| 253 | + //TODO Log the executions in the logs |
|
| 254 | + $this->last_result = false; |
|
| 255 | + $this->is_running = true; |
|
| 256 | + $this->save(); |
|
| 257 | 257 | |
| 258 | - Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
| 259 | - $this->last_result = $this->executeSteps(); |
|
| 260 | - if($this->last_result){ |
|
| 261 | - $this->last_updated = new \DateTime(); |
|
| 262 | - if($this->nb_occurrences > 0){ |
|
| 263 | - $this->nb_occurrences--; |
|
| 264 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - $this->is_running = false; |
|
| 268 | - $this->save(); |
|
| 269 | - Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
| 270 | - } |
|
| 271 | - } |
|
| 258 | + Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
| 259 | + $this->last_result = $this->executeSteps(); |
|
| 260 | + if($this->last_result){ |
|
| 261 | + $this->last_updated = new \DateTime(); |
|
| 262 | + if($this->nb_occurrences > 0){ |
|
| 263 | + $this->nb_occurrences--; |
|
| 264 | + if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + $this->is_running = false; |
|
| 268 | + $this->save(); |
|
| 269 | + Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | 273 | |
| 274 | 274 | } |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | use Fisharebest\Webtrees\Controller\PageController; |
| 16 | 16 | use Fisharebest\Webtrees\Filter; |
| 17 | 17 | use Fisharebest\Webtrees\FlashMessages; |
| 18 | -use Fisharebest\Webtrees\Html; |
|
| 19 | 18 | use Fisharebest\Webtrees\I18N; |
| 20 | 19 | use Fisharebest\Webtrees\Log; |
| 21 | 20 | use Fisharebest\Webtrees\Module; |
@@ -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,35 +77,35 @@ 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 | - echo \Zend_Json::encode($res); |
|
| 108 | - } |
|
| 107 | + echo \Zend_Json::encode($res); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Task@edit |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | public function edit() { |
| 114 | 114 | global $WT_TREE; |
| 115 | 115 | |
| 116 | - $task_name = Filter::get('task'); |
|
| 117 | - $task = $this->provider->getTask($task_name, false); |
|
| 116 | + $task_name = Filter::get('task'); |
|
| 117 | + $task = $this->provider->getTask($task_name, false); |
|
| 118 | 118 | |
| 119 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 120 | - $controller = new PageController(); |
|
| 121 | - $controller |
|
| 122 | - ->restrictAccess(Auth::isAdmin() && $task) |
|
| 119 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 120 | + $controller = new PageController(); |
|
| 121 | + $controller |
|
| 122 | + ->restrictAccess(Auth::isAdmin() && $task) |
|
| 123 | 123 | ->setPageTitle(I18N::translate('Edit the administrative task')) |
| 124 | - ->addInlineJavascript(' |
|
| 124 | + ->addInlineJavascript(' |
|
| 125 | 125 | function toggleRemainingOccurrences() { |
| 126 | 126 | if($("input:radio[name=\'is_limited\']:checked").val() == 1) { |
| 127 | 127 | $("#nb_occurences").show(); |
@@ -134,39 +134,39 @@ discard block |
||
| 134 | 134 | $("[name=\'is_limited\']").on("change", toggleRemainingOccurrences); |
| 135 | 135 | toggleRemainingOccurrences(); |
| 136 | 136 | ') |
| 137 | - ; |
|
| 137 | + ; |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | - $data = new ViewBag(); |
|
| 141 | - $data->set('title', $controller->getPageTitle()); |
|
| 140 | + $data = new ViewBag(); |
|
| 141 | + $data->set('title', $controller->getPageTitle()); |
|
| 142 | 142 | $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
| 143 | - $data->set('module_title', $this->module->getTitle()); |
|
| 143 | + $data->set('module_title', $this->module->getTitle()); |
|
| 144 | 144 | $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl()); |
| 145 | 145 | $data->set('task', $task); |
| 146 | 146 | |
| 147 | - ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
|
| 147 | + ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * Task@save |
| 152 | 152 | */ |
| 153 | 153 | public function save() { |
| 154 | - $tmp_contrl = new PageController(); |
|
| 154 | + $tmp_contrl = new PageController(); |
|
| 155 | 155 | |
| 156 | - $tmp_contrl->restrictAccess( |
|
| 157 | - Auth::isAdmin() |
|
| 158 | - && Filter::checkCsrf() |
|
| 159 | - ); |
|
| 156 | + $tmp_contrl->restrictAccess( |
|
| 157 | + Auth::isAdmin() |
|
| 158 | + && Filter::checkCsrf() |
|
| 159 | + ); |
|
| 160 | 160 | |
| 161 | 161 | $task_name = Filter::post('task'); |
| 162 | - $frequency = Filter::postInteger('frequency'); |
|
| 163 | - $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
| 164 | - $nb_occur = Filter::postInteger('nb_occur'); |
|
| 162 | + $frequency = Filter::postInteger('frequency'); |
|
| 163 | + $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
| 164 | + $nb_occur = Filter::postInteger('nb_occur'); |
|
| 165 | 165 | |
| 166 | 166 | $task = $this->provider->getTask($task_name, false); |
| 167 | 167 | |
| 168 | - $success = false; |
|
| 169 | - if($task) { |
|
| 168 | + $success = false; |
|
| 169 | + if($task) { |
|
| 170 | 170 | $task->setFrequency($frequency); |
| 171 | 171 | if($is_limited == 1) { |
| 172 | 172 | $task->setRemainingOccurrences($nb_occur); |
@@ -198,13 +198,13 @@ discard block |
||
| 198 | 198 | Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
| 204 | - if(!$success) { |
|
| 203 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
| 204 | + if(!$success) { |
|
| 205 | 205 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName(); |
| 206 | - } |
|
| 207 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
| 206 | + } |
|
| 207 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | } |
| 211 | 211 | \ No newline at end of file |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use Fisharebest\Webtrees\Auth; |
| 14 | 14 | use Fisharebest\Webtrees\Controller\PageController; |
| 15 | 15 | use Fisharebest\Webtrees\Filter; |
| 16 | -use Fisharebest\Webtrees\Html; |
|
| 17 | 16 | use Fisharebest\Webtrees\I18N; |
| 18 | 17 | use Fisharebest\Webtrees\Module; |
| 19 | 18 | use Fisharebest\Webtrees\Module\AbstractModule; |
@@ -33,160 +33,160 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | class CertificateController extends MvcController |
| 35 | 35 | { |
| 36 | - /** |
|
| 37 | - * Certificate Provider |
|
| 38 | - * @var CertificateProviderInterface $provider |
|
| 39 | - */ |
|
| 40 | - protected $provider; |
|
| 36 | + /** |
|
| 37 | + * Certificate Provider |
|
| 38 | + * @var CertificateProviderInterface $provider |
|
| 39 | + */ |
|
| 40 | + protected $provider; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Constructor for Certificate controller |
|
| 44 | - * @param AbstractModule $module |
|
| 45 | - */ |
|
| 46 | - public function __construct(AbstractModule $module) { |
|
| 47 | - parent::__construct($module); |
|
| 48 | - |
|
| 49 | - $this->provider = $this->module->getProvider(); |
|
| 50 | - } |
|
| 42 | + /** |
|
| 43 | + * Constructor for Certificate controller |
|
| 44 | + * @param AbstractModule $module |
|
| 45 | + */ |
|
| 46 | + public function __construct(AbstractModule $module) { |
|
| 47 | + parent::__construct($module); |
|
| 48 | + |
|
| 49 | + $this->provider = $this->module->getProvider(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Pages |
|
| 55 | - */ |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Certificate@index |
|
| 59 | - */ |
|
| 60 | - public function index() { |
|
| 61 | - global $WT_TREE; |
|
| 62 | - |
|
| 63 | - $controller = new PageController(); |
|
| 64 | - $controller |
|
| 65 | - ->setPageTitle(I18N::translate('Certificate')) |
|
| 66 | - ->restrictAccess( |
|
| 67 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 68 | - ); |
|
| 69 | - |
|
| 70 | - $cid = Filter::get('cid'); |
|
| 71 | - |
|
| 72 | - $certificate = null; |
|
| 73 | - $city = ''; |
|
| 74 | - if($cid && strlen($cid) > 22){ |
|
| 75 | - $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 76 | - if($certificate) $city = $certificate->getCity(); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $data = new ViewBag(); |
|
| 80 | - $data->set('title', $controller->getPageTitle()); |
|
| 81 | - |
|
| 82 | - $data->set('has_certif', false); |
|
| 83 | - if($certificate) { |
|
| 84 | - $controller->restrictAccess($certificate->canShow()); |
|
| 85 | - $data->set('title', $certificate->getTitle()); |
|
| 86 | - $data->set('has_certif', true); |
|
| 87 | - $data->set('certificate', $certificate); |
|
| 53 | + /** |
|
| 54 | + * Pages |
|
| 55 | + */ |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Certificate@index |
|
| 59 | + */ |
|
| 60 | + public function index() { |
|
| 61 | + global $WT_TREE; |
|
| 62 | + |
|
| 63 | + $controller = new PageController(); |
|
| 64 | + $controller |
|
| 65 | + ->setPageTitle(I18N::translate('Certificate')) |
|
| 66 | + ->restrictAccess( |
|
| 67 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 68 | + ); |
|
| 69 | + |
|
| 70 | + $cid = Filter::get('cid'); |
|
| 71 | + |
|
| 72 | + $certificate = null; |
|
| 73 | + $city = ''; |
|
| 74 | + if($cid && strlen($cid) > 22){ |
|
| 75 | + $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 76 | + if($certificate) $city = $certificate->getCity(); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $data = new ViewBag(); |
|
| 80 | + $data->set('title', $controller->getPageTitle()); |
|
| 81 | + |
|
| 82 | + $data->set('has_certif', false); |
|
| 83 | + if($certificate) { |
|
| 84 | + $controller->restrictAccess($certificate->canShow()); |
|
| 85 | + $data->set('title', $certificate->getTitle()); |
|
| 86 | + $data->set('has_certif', true); |
|
| 87 | + $data->set('certificate', $certificate); |
|
| 88 | 88 | |
| 89 | - $data->set( |
|
| 90 | - 'url_certif_city', |
|
| 91 | - 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
| 92 | - '&mod_action=Certificate@listAll' . |
|
| 93 | - '&ged=' . $WT_TREE->getNameUrl() . |
|
| 94 | - '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
| 95 | - ); |
|
| 89 | + $data->set( |
|
| 90 | + 'url_certif_city', |
|
| 91 | + 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
| 92 | + '&mod_action=Certificate@listAll' . |
|
| 93 | + '&ged=' . $WT_TREE->getNameUrl() . |
|
| 94 | + '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - $controller->addInlineJavascript(' |
|
| 97 | + $controller->addInlineJavascript(' |
|
| 98 | 98 | jQuery("#certificate-tabs").tabs(); |
| 99 | 99 | jQuery("#certificate-tabs").css("visibility", "visible"); |
| 100 | 100 | '); |
| 101 | 101 | |
| 102 | - $data->set('has_linked_indis', false); |
|
| 103 | - $data->set('has_linked_fams', false); |
|
| 102 | + $data->set('has_linked_indis', false); |
|
| 103 | + $data->set('has_linked_fams', false); |
|
| 104 | 104 | |
| 105 | - $linked_indis = $certificate->linkedIndividuals(); |
|
| 106 | - $linked_fams = $certificate->linkedFamilies(); |
|
| 105 | + $linked_indis = $certificate->linkedIndividuals(); |
|
| 106 | + $linked_fams = $certificate->linkedFamilies(); |
|
| 107 | 107 | |
| 108 | - if($linked_indis && count($linked_indis) > 0) { |
|
| 109 | - $data->set('has_linked_indis', true); |
|
| 110 | - $data->set('linked_indis', $linked_indis); |
|
| 111 | - } |
|
| 108 | + if($linked_indis && count($linked_indis) > 0) { |
|
| 109 | + $data->set('has_linked_indis', true); |
|
| 110 | + $data->set('linked_indis', $linked_indis); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if($linked_fams && count($linked_fams) > 0) { |
|
| 114 | - $data->set('has_linked_fams', true); |
|
| 115 | - $data->set('linked_fams', $linked_fams); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
| 120 | - } |
|
| 113 | + if($linked_fams && count($linked_fams) > 0) { |
|
| 114 | + $data->set('has_linked_fams', true); |
|
| 115 | + $data->set('linked_fams', $linked_fams); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Certificate@image |
|
| 124 | - */ |
|
| 125 | - public function image() { |
|
| 126 | - global $WT_TREE; |
|
| 122 | + /** |
|
| 123 | + * Certificate@image |
|
| 124 | + */ |
|
| 125 | + public function image() { |
|
| 126 | + global $WT_TREE; |
|
| 127 | 127 | |
| 128 | - $cid = Filter::get('cid'); |
|
| 129 | - $certificate = null; |
|
| 130 | - if($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 128 | + $cid = Filter::get('cid'); |
|
| 129 | + $certificate = null; |
|
| 130 | + if($cid) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 131 | 131 | |
| 132 | - $imageBuilder = new ImageBuilder($certificate); |
|
| 132 | + $imageBuilder = new ImageBuilder($certificate); |
|
| 133 | 133 | |
| 134 | - if (Filter::get('cb')) { |
|
| 135 | - $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
| 136 | - } |
|
| 134 | + if (Filter::get('cb')) { |
|
| 135 | + $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - $imageBuilder |
|
| 139 | - ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
| 140 | - ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
| 141 | - ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
| 142 | - ; |
|
| 138 | + $imageBuilder |
|
| 139 | + ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
| 140 | + ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
| 141 | + ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
| 142 | + ; |
|
| 143 | 143 | |
| 144 | - $imageBuilder->render(); |
|
| 144 | + $imageBuilder->render(); |
|
| 145 | 145 | |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Certificate@listAll |
|
| 150 | - */ |
|
| 151 | - public function listAll() { |
|
| 152 | - global $WT_TREE; |
|
| 153 | - |
|
| 154 | - $controller = new PageController(); |
|
| 155 | - $controller |
|
| 156 | - ->setPageTitle(I18N::translate('Certificates')) |
|
| 157 | - ->restrictAccess( |
|
| 158 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 159 | - ); |
|
| 160 | - |
|
| 161 | - $city = Filter::get('city'); |
|
| 162 | - |
|
| 163 | - if($city && strlen($city) > 22){ |
|
| 164 | - $city = Functions::decryptFromSafeBase64($city); |
|
| 165 | - $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - $data = new ViewBag(); |
|
| 169 | - $data->set('title', $controller->getPageTitle()); |
|
| 170 | - $data->set('url_module', $this->module->getName()); |
|
| 171 | - $data->set('url_action', 'Certificate@listAll'); |
|
| 172 | - $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 173 | - |
|
| 174 | - $data->set('cities', $this->provider->getCitiesList()); |
|
| 175 | - $data->set('selected_city', $city); |
|
| 176 | - |
|
| 177 | - $data->set('has_list', false); |
|
| 178 | - if($city) { |
|
| 179 | - $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
| 148 | + /** |
|
| 149 | + * Certificate@listAll |
|
| 150 | + */ |
|
| 151 | + public function listAll() { |
|
| 152 | + global $WT_TREE; |
|
| 153 | + |
|
| 154 | + $controller = new PageController(); |
|
| 155 | + $controller |
|
| 156 | + ->setPageTitle(I18N::translate('Certificates')) |
|
| 157 | + ->restrictAccess( |
|
| 158 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 159 | + ); |
|
| 160 | + |
|
| 161 | + $city = Filter::get('city'); |
|
| 162 | + |
|
| 163 | + if($city && strlen($city) > 22){ |
|
| 164 | + $city = Functions::decryptFromSafeBase64($city); |
|
| 165 | + $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + $data = new ViewBag(); |
|
| 169 | + $data->set('title', $controller->getPageTitle()); |
|
| 170 | + $data->set('url_module', $this->module->getName()); |
|
| 171 | + $data->set('url_action', 'Certificate@listAll'); |
|
| 172 | + $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 173 | + |
|
| 174 | + $data->set('cities', $this->provider->getCitiesList()); |
|
| 175 | + $data->set('selected_city', $city); |
|
| 176 | + |
|
| 177 | + $data->set('has_list', false); |
|
| 178 | + if($city) { |
|
| 179 | + $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
| 180 | 180 | |
| 181 | - $certif_list = $this->provider->getCertificatesList($city); |
|
| 182 | - if($certif_list) { |
|
| 183 | - $data->set('has_list', true); |
|
| 184 | - $data->set('table_id', $table_id); |
|
| 185 | - $data->set('certificate_list', $certif_list); |
|
| 181 | + $certif_list = $this->provider->getCertificatesList($city); |
|
| 182 | + if($certif_list) { |
|
| 183 | + $data->set('has_list', true); |
|
| 184 | + $data->set('table_id', $table_id); |
|
| 185 | + $data->set('certificate_list', $certif_list); |
|
| 186 | 186 | |
| 187 | - $controller |
|
| 188 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 189 | - ->addInlineJavascript(' |
|
| 187 | + $controller |
|
| 188 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 189 | + ->addInlineJavascript(' |
|
| 190 | 190 | /* Initialise datatables */ |
| 191 | 191 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 192 | 192 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -213,29 +213,29 @@ discard block |
||
| 213 | 213 | jQuery(".certificate-list").css("visibility", "visible"); |
| 214 | 214 | jQuery(".loading-image").css("display", "none"); |
| 215 | 215 | '); |
| 216 | - } |
|
| 217 | - } |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
| 219 | + ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
| 220 | 220 | |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - /** |
|
| 224 | - * Certificate@autocomplete |
|
| 225 | - */ |
|
| 226 | - public function autocomplete() { |
|
| 227 | - global $WT_TREE; |
|
| 223 | + /** |
|
| 224 | + * Certificate@autocomplete |
|
| 225 | + */ |
|
| 226 | + public function autocomplete() { |
|
| 227 | + global $WT_TREE; |
|
| 228 | 228 | |
| 229 | - $controller = new JsonController(); |
|
| 229 | + $controller = new JsonController(); |
|
| 230 | 230 | |
| 231 | - $city = Filter::get('city'); |
|
| 232 | - $contains = Filter::get('term'); |
|
| 231 | + $city = Filter::get('city'); |
|
| 232 | + $contains = Filter::get('term'); |
|
| 233 | 233 | |
| 234 | - $controller |
|
| 235 | - ->restrictAccess(Auth::isEditor($WT_TREE) && $city && $contains) |
|
| 236 | - ->pageHeader(); |
|
| 234 | + $controller |
|
| 235 | + ->restrictAccess(Auth::isEditor($WT_TREE) && $city && $contains) |
|
| 236 | + ->pageHeader(); |
|
| 237 | 237 | |
| 238 | - $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
| 239 | - echo \Zend_Json::encode($listCert); |
|
| 240 | - } |
|
| 238 | + $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
| 239 | + echo \Zend_Json::encode($listCert); |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | \ No newline at end of file |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | use Fisharebest\Webtrees\Media; |
| 16 | 16 | use MyArtJaub\Webtrees\Functions\Functions; |
| 17 | 17 | use Fisharebest\Webtrees\Date; |
| 18 | -use Fisharebest\Webtrees\File; |
|
| 19 | 18 | use Fisharebest\Webtrees\Log; |
| 20 | 19 | use Fisharebest\Webtrees\Source; |
| 21 | 20 | use Fisharebest\Webtrees\Tree; |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | class Certificate extends Media { |
| 37 | 37 | |
| 38 | - const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
| 38 | + const URL_PREFIX = 'module.php?mod=myartjaub_certificates&mod_action=Certificate&cid='; |
|
| 39 | 39 | |
| 40 | - /** @var string The "TITL" value from the GEDCOM |
|
| 41 | - * This is a tweak to overcome the private level from the parent object... |
|
| 42 | - */ |
|
| 43 | - protected $title = ''; |
|
| 40 | + /** @var string The "TITL" value from the GEDCOM |
|
| 41 | + * This is a tweak to overcome the private level from the parent object... |
|
| 42 | + */ |
|
| 43 | + protected $title = ''; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Certificate provider |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param CertificateProviderInterface $provider |
| 81 | 81 | */ |
| 82 | 82 | public function __construct($data, Tree $tree, CertificateProviderInterface $provider) { |
| 83 | - $this->provider = $provider; |
|
| 83 | + $this->provider = $provider; |
|
| 84 | 84 | // Data is only the file name |
| 85 | 85 | $data = str_replace("\\", '/', $data); |
| 86 | 86 | $xref = Functions::encryptToSafeBase64($data); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @see \Fisharebest\Webtrees\Media::getTitle() |
| 166 | 166 | */ |
| 167 | 167 | public function getTitle() { |
| 168 | - return $this->title; |
|
| 168 | + return $this->title; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -241,26 +241,26 @@ discard block |
||
| 241 | 241 | $module = Module::getModuleByName(Constants::MODULE_MAJ_CERTIF_NAME); |
| 242 | 242 | |
| 243 | 243 | if($module) { |
| 244 | - $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
| 245 | - $sid= Filter::get('sid', WT_REGEX_XREF); |
|
| 244 | + $wmtext = $module->getSetting('MAJ_WM_DEFAULT', I18N::translate('This image is protected under copyright law.')); |
|
| 245 | + $sid= Filter::get('sid', WT_REGEX_XREF); |
|
| 246 | 246 | |
| 247 | - if($sid){ |
|
| 248 | - $this->source = Source::getInstance($sid, $this->tree); |
|
| 249 | - } |
|
| 250 | - else{ |
|
| 251 | - $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
| 252 | - } |
|
| 247 | + if($sid){ |
|
| 248 | + $this->source = Source::getInstance($sid, $this->tree); |
|
| 249 | + } |
|
| 250 | + else{ |
|
| 251 | + $this->fetchALinkedSource(); // the method already attach the source to the Certificate object; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - if($this->source) { |
|
| 255 | - $wmtext = '©'; |
|
| 256 | - $repofact = $this->source->getFirstFact('REPO'); |
|
| 257 | - if($repofact) { |
|
| 258 | - $repo = $repofact->getTarget(); |
|
| 259 | - if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
| 260 | - } |
|
| 261 | - $wmtext .= $this->source->getFullName(); |
|
| 262 | - } |
|
| 263 | - return $wmtext; |
|
| 254 | + if($this->source) { |
|
| 255 | + $wmtext = '©'; |
|
| 256 | + $repofact = $this->source->getFirstFact('REPO'); |
|
| 257 | + if($repofact) { |
|
| 258 | + $repo = $repofact->getTarget(); |
|
| 259 | + if($repo && $repo instanceof Repository) $wmtext .= ' '.$repo->getFullName().' - '; |
|
| 260 | + } |
|
| 261 | + $wmtext .= $this->source->getFullName(); |
|
| 262 | + } |
|
| 263 | + return $wmtext; |
|
| 264 | 264 | } |
| 265 | 265 | return ''; |
| 266 | 266 | } |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | ' FROM `##individuals`'. |
| 324 | 324 | ' WHERE i_file= :gedcom_id AND i_gedcom LIKE :gedcom') |
| 325 | 325 | ->execute(array( |
| 326 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 327 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 326 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 327 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 328 | 328 | ))->fetchAll(); |
| 329 | 329 | |
| 330 | 330 | $list = array(); |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | ' FROM `##families`'. |
| 348 | 348 | ' WHERE f_file= :gedcom_id AND f_gedcom LIKE :gedcom') |
| 349 | 349 | ->execute(array( |
| 350 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 351 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 350 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 351 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 352 | 352 | ))->fetchAll(); |
| 353 | 353 | |
| 354 | 354 | $list = array(); |
@@ -375,25 +375,25 @@ discard block |
||
| 375 | 375 | 'SELECT i_gedcom AS gedrec FROM `##individuals`'. |
| 376 | 376 | ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') |
| 377 | 377 | ->execute(array( |
| 378 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 379 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 378 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 379 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 380 | 380 | ))->fetchOne(); |
| 381 | 381 | if(!$ged){ |
| 382 | 382 | $ged = Database::prepare( |
| 383 | 383 | 'SELECT f_gedcom AS gedrec FROM `##families`'. |
| 384 | 384 | ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') |
| 385 | - ->execute(array( |
|
| 386 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 387 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 388 | - ))->fetchOne(); |
|
| 385 | + ->execute(array( |
|
| 386 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 387 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 388 | + ))->fetchOne(); |
|
| 389 | 389 | if(!$ged){ |
| 390 | 390 | $ged = Database::prepare( |
| 391 | - 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
| 392 | - ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
| 393 | - ->execute(array( |
|
| 394 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 395 | - 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 396 | - ))->fetchOne(); |
|
| 391 | + 'SELECT o_gedcom AS gedrec FROM `##other`'. |
|
| 392 | + ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') |
|
| 393 | + ->execute(array( |
|
| 394 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 395 | + 'gedcom' => '%_ACT '.$this->getFilename().'%' |
|
| 396 | + ))->fetchOne(); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | //If a record has been found, parse it to find the source reference. |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Fisharebest\Webtrees\Controller\PageController; |
| 15 | 15 | use Fisharebest\Webtrees\Filter; |
| 16 | 16 | use Fisharebest\Webtrees\FlashMessages; |
| 17 | -use Fisharebest\Webtrees\Html; |
|
| 18 | 17 | use Fisharebest\Webtrees\I18N; |
| 19 | 18 | use Fisharebest\Webtrees\Log; |
| 20 | 19 | use Fisharebest\Webtrees\Module; |
@@ -36,59 +36,59 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class AdminConfigController extends MvcController |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * GeoAnalysis Provider |
|
| 41 | - * @var GeoAnalysisProvider $provider |
|
| 42 | - */ |
|
| 43 | - protected $provider; |
|
| 39 | + /** |
|
| 40 | + * GeoAnalysis Provider |
|
| 41 | + * @var GeoAnalysisProvider $provider |
|
| 42 | + */ |
|
| 43 | + protected $provider; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Constructor for Admin Config controller |
|
| 47 | - * @param AbstractModule $module |
|
| 48 | - */ |
|
| 49 | - public function __construct(AbstractModule $module) { |
|
| 50 | - parent::__construct($module); |
|
| 45 | + /** |
|
| 46 | + * Constructor for Admin Config controller |
|
| 47 | + * @param AbstractModule $module |
|
| 48 | + */ |
|
| 49 | + public function __construct(AbstractModule $module) { |
|
| 50 | + parent::__construct($module); |
|
| 51 | 51 | |
| 52 | - $this->provider = $this->module->getProvider(); |
|
| 53 | - } |
|
| 52 | + $this->provider = $this->module->getProvider(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Pages |
|
| 57 | - */ |
|
| 55 | + /** |
|
| 56 | + * Pages |
|
| 57 | + */ |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * AdminConfig@index |
|
| 61 | - */ |
|
| 62 | - public function index() { |
|
| 63 | - global $WT_TREE; |
|
| 59 | + /** |
|
| 60 | + * AdminConfig@index |
|
| 61 | + */ |
|
| 62 | + public function index() { |
|
| 63 | + global $WT_TREE; |
|
| 64 | 64 | |
| 65 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 66 | - $controller = new PageController(); |
|
| 67 | - $controller |
|
| 68 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 69 | - ->setPageTitle($this->module->getTitle()); |
|
| 65 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 66 | + $controller = new PageController(); |
|
| 67 | + $controller |
|
| 68 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 69 | + ->setPageTitle($this->module->getTitle()); |
|
| 70 | 70 | |
| 71 | - $data = new ViewBag(); |
|
| 72 | - $data->set('title', $controller->getPageTitle()); |
|
| 73 | - $data->set('tree', $WT_TREE); |
|
| 71 | + $data = new ViewBag(); |
|
| 72 | + $data->set('title', $controller->getPageTitle()); |
|
| 73 | + $data->set('tree', $WT_TREE); |
|
| 74 | 74 | |
| 75 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
| 75 | + $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
| 76 | 76 | |
| 77 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
| 78 | - $data->set('table_id', $table_id); |
|
| 77 | + $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
| 78 | + $data->set('table_id', $table_id); |
|
| 79 | 79 | |
| 80 | - $other_trees = array(); |
|
| 81 | - foreach (Tree::getAll() as $tree) { |
|
| 82 | - if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
| 83 | - } |
|
| 84 | - $data->set('other_trees', $other_trees); |
|
| 80 | + $other_trees = array(); |
|
| 81 | + foreach (Tree::getAll() as $tree) { |
|
| 82 | + if($tree->getTreeId() != $WT_TREE->getTreeId()) $other_trees[] = $tree; |
|
| 83 | + } |
|
| 84 | + $data->set('other_trees', $other_trees); |
|
| 85 | 85 | |
| 86 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
| 86 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
| 87 | 87 | |
| 88 | - $controller |
|
| 89 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 90 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
| 91 | - ->addInlineJavascript(' |
|
| 88 | + $controller |
|
| 89 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 90 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
| 91 | + ->addInlineJavascript(' |
|
| 92 | 92 | //Datatable initialisation |
| 93 | 93 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 94 | 94 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | }); |
| 124 | 124 | |
| 125 | 125 | ') |
| 126 | - ->addInlineJavascript(' |
|
| 126 | + ->addInlineJavascript(' |
|
| 127 | 127 | function set_geoanalysis_status(ga_id, status, gedcom) { |
| 128 | 128 | jQuery.ajax({ |
| 129 | 129 | url: "module.php", |
@@ -167,55 +167,55 @@ discard block |
||
| 167 | 167 | '); |
| 168 | 168 | |
| 169 | 169 | |
| 170 | - ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
| 171 | - } |
|
| 170 | + ViewFactory::make('AdminConfig', $this, $controller, $data)->render(); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * AdminConfig@jsonGeoAnalysisList |
|
| 175 | - */ |
|
| 176 | - public function jsonGeoAnalysisList() { |
|
| 177 | - global $WT_TREE; |
|
| 173 | + /** |
|
| 174 | + * AdminConfig@jsonGeoAnalysisList |
|
| 175 | + */ |
|
| 176 | + public function jsonGeoAnalysisList() { |
|
| 177 | + global $WT_TREE; |
|
| 178 | 178 | |
| 179 | - $controller = new JsonController(); |
|
| 180 | - $controller |
|
| 181 | - ->restrictAccess(Auth::isManager($WT_TREE)); |
|
| 179 | + $controller = new JsonController(); |
|
| 180 | + $controller |
|
| 181 | + ->restrictAccess(Auth::isManager($WT_TREE)); |
|
| 182 | 182 | |
| 183 | - // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 184 | - $search = Filter::postArray('search'); |
|
| 185 | - if($search) $search = $search['value']; |
|
| 186 | - $start = Filter::postInteger('start'); |
|
| 187 | - $length = Filter::postInteger('length'); |
|
| 188 | - $order = Filter::postArray('order'); |
|
| 183 | + // Generate an AJAX/JSON response for datatables to load a block of rows |
|
| 184 | + $search = Filter::postArray('search'); |
|
| 185 | + if($search) $search = $search['value']; |
|
| 186 | + $start = Filter::postInteger('start'); |
|
| 187 | + $length = Filter::postInteger('length'); |
|
| 188 | + $order = Filter::postArray('order'); |
|
| 189 | 189 | |
| 190 | - foreach($order as $key => &$value) { |
|
| 191 | - switch($value['column']) { |
|
| 192 | - case 3: |
|
| 193 | - $value['column'] = 'majgd_descr'; |
|
| 194 | - break; |
|
| 195 | - case 5; |
|
| 196 | - $value['column'] = 'majgd_sublevel'; |
|
| 197 | - break; |
|
| 198 | - default: |
|
| 199 | - unset($order[$key]); |
|
| 200 | - } |
|
| 201 | - } |
|
| 190 | + foreach($order as $key => &$value) { |
|
| 191 | + switch($value['column']) { |
|
| 192 | + case 3: |
|
| 193 | + $value['column'] = 'majgd_descr'; |
|
| 194 | + break; |
|
| 195 | + case 5; |
|
| 196 | + $value['column'] = 'majgd_sublevel'; |
|
| 197 | + break; |
|
| 198 | + default: |
|
| 199 | + unset($order[$key]); |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - /** @var GeoAnalysisProvider $provider */ |
|
| 204 | - $provider = $this->module->getProvider(); |
|
| 203 | + /** @var GeoAnalysisProvider $provider */ |
|
| 204 | + $provider = $this->module->getProvider(); |
|
| 205 | 205 | |
| 206 | - $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
| 207 | - $recordsFiltered = count($list); |
|
| 208 | - $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
| 206 | + $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length); |
|
| 207 | + $recordsFiltered = count($list); |
|
| 208 | + $recordsTotal = $this->provider->getGeoAnalysisCount(); |
|
| 209 | 209 | |
| 210 | - $data = array(); |
|
| 211 | - $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
| 212 | - foreach($list as $ga) { |
|
| 213 | - /** @var GeoAnalysis $ga */ |
|
| 210 | + $data = array(); |
|
| 211 | + $place_hierarchy = $this->provider->getPlacesHierarchy(); |
|
| 212 | + foreach($list as $ga) { |
|
| 213 | + /** @var GeoAnalysis $ga */ |
|
| 214 | 214 | |
| 215 | - $datum = array(); |
|
| 216 | - $options= $ga->getOptions(); |
|
| 215 | + $datum = array(); |
|
| 216 | + $options= $ga->getOptions(); |
|
| 217 | 217 | |
| 218 | - $datum[0] = ' |
|
| 218 | + $datum[0] = ' |
|
| 219 | 219 | <div class="btn-group"> |
| 220 | 220 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
| 221 | 221 | <i class="fa fa-pencil"></i><span class="caret"></span> |
@@ -239,108 +239,108 @@ discard block |
||
| 239 | 239 | </li> |
| 240 | 240 | </ul> |
| 241 | 241 | </div>'; |
| 242 | - $datum[1] = $ga->getId(); |
|
| 243 | - $datum[2] = $ga->isEnabled() ? |
|
| 242 | + $datum[1] = $ga->getId(); |
|
| 243 | + $datum[2] = $ga->isEnabled() ? |
|
| 244 | 244 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
| 245 | 245 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
| 246 | - $datum[3] = $ga->getTitle(); |
|
| 247 | - $analysis_level = $ga->getAnalysisLevel(); |
|
| 248 | - if($place_hierarchy['type'] == 'header') { |
|
| 249 | - $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
| 250 | - } else { |
|
| 251 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
| 252 | - } |
|
| 253 | - $datum[5] = $ga->getAnalysisLevel(); |
|
| 254 | - $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
| 255 | - $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
| 256 | - if($ga->hasMap()) { |
|
| 257 | - $datum[6] = $options->getMap()->getDescription(); |
|
| 258 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
| 259 | - $top_level = $options->getMapLevel(); |
|
| 260 | - if($place_hierarchy['type'] == 'header') { |
|
| 261 | - $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
| 262 | - } else { |
|
| 263 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
| 264 | - } |
|
| 265 | - $datum[7] .= '</span>'; |
|
| 266 | - } |
|
| 267 | - $datum[8] = $options->isUsingFlags() ? |
|
| 246 | + $datum[3] = $ga->getTitle(); |
|
| 247 | + $analysis_level = $ga->getAnalysisLevel(); |
|
| 248 | + if($place_hierarchy['type'] == 'header') { |
|
| 249 | + $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
|
| 250 | + } else { |
|
| 251 | + $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
| 252 | + } |
|
| 253 | + $datum[5] = $ga->getAnalysisLevel(); |
|
| 254 | + $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
| 255 | + $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
|
| 256 | + if($ga->hasMap()) { |
|
| 257 | + $datum[6] = $options->getMap()->getDescription(); |
|
| 258 | + $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
| 259 | + $top_level = $options->getMapLevel(); |
|
| 260 | + if($place_hierarchy['type'] == 'header') { |
|
| 261 | + $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
|
| 262 | + } else { |
|
| 263 | + $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
| 264 | + } |
|
| 265 | + $datum[7] .= '</span>'; |
|
| 266 | + } |
|
| 267 | + $datum[8] = $options->isUsingFlags() ? |
|
| 268 | 268 | '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
| 269 | 269 | '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
| 270 | - $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
|
| 270 | + $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
|
| 271 | 271 | |
| 272 | - $data[] = $datum; |
|
| 273 | - } |
|
| 272 | + $data[] = $datum; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - $controller->pageHeader(); |
|
| 275 | + $controller->pageHeader(); |
|
| 276 | 276 | |
| 277 | - echo \Zend_Json::encode(array( |
|
| 278 | - 'draw' => Filter::getInteger('draw'), |
|
| 279 | - 'recordsTotal' => $recordsTotal, |
|
| 280 | - 'recordsFiltered' => $recordsFiltered, |
|
| 281 | - 'data' => $data |
|
| 282 | - )); |
|
| 277 | + echo \Zend_Json::encode(array( |
|
| 278 | + 'draw' => Filter::getInteger('draw'), |
|
| 279 | + 'recordsTotal' => $recordsTotal, |
|
| 280 | + 'recordsFiltered' => $recordsFiltered, |
|
| 281 | + 'data' => $data |
|
| 282 | + )); |
|
| 283 | 283 | |
| 284 | - } |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * AdminConfig@edit |
|
| 288 | - */ |
|
| 289 | - public function edit() { |
|
| 290 | - $ga_id = Filter::getInteger('ga_id'); |
|
| 291 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 286 | + /** |
|
| 287 | + * AdminConfig@edit |
|
| 288 | + */ |
|
| 289 | + public function edit() { |
|
| 290 | + $ga_id = Filter::getInteger('ga_id'); |
|
| 291 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 292 | 292 | |
| 293 | - $this->renderEdit($ga); |
|
| 294 | - } |
|
| 293 | + $this->renderEdit($ga); |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - /** |
|
| 297 | - * AdminConfig@add |
|
| 298 | - */ |
|
| 299 | - public function add() { |
|
| 300 | - $this->renderEdit(null); |
|
| 301 | - } |
|
| 296 | + /** |
|
| 297 | + * AdminConfig@add |
|
| 298 | + */ |
|
| 299 | + public function add() { |
|
| 300 | + $this->renderEdit(null); |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - /** |
|
| 304 | - * AdminConfig@save |
|
| 305 | - */ |
|
| 306 | - public function save() { |
|
| 307 | - global $WT_TREE; |
|
| 303 | + /** |
|
| 304 | + * AdminConfig@save |
|
| 305 | + */ |
|
| 306 | + public function save() { |
|
| 307 | + global $WT_TREE; |
|
| 308 | 308 | |
| 309 | - $tmp_contrl = new PageController(); |
|
| 310 | - $tmp_contrl->restrictAccess( |
|
| 311 | - Auth::isManager($WT_TREE) |
|
| 312 | - && Filter::checkCsrf() |
|
| 313 | - ); |
|
| 309 | + $tmp_contrl = new PageController(); |
|
| 310 | + $tmp_contrl->restrictAccess( |
|
| 311 | + Auth::isManager($WT_TREE) |
|
| 312 | + && Filter::checkCsrf() |
|
| 313 | + ); |
|
| 314 | 314 | |
| 315 | - $ga_id = Filter::postInteger('ga_id'); |
|
| 316 | - $description = Filter::post('description'); |
|
| 317 | - $analysislevel = Filter::postInteger('analysislevel'); |
|
| 318 | - $use_map = Filter::postBool('use_map'); |
|
| 319 | - if($use_map) { |
|
| 320 | - $map_file = base64_decode(Filter::post('map_file')); |
|
| 321 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
| 322 | - } |
|
| 323 | - $use_flags = Filter::postBool('use_flags'); |
|
| 324 | - $gen_details = Filter::postInteger('gen_details'); |
|
| 315 | + $ga_id = Filter::postInteger('ga_id'); |
|
| 316 | + $description = Filter::post('description'); |
|
| 317 | + $analysislevel = Filter::postInteger('analysislevel'); |
|
| 318 | + $use_map = Filter::postBool('use_map'); |
|
| 319 | + if($use_map) { |
|
| 320 | + $map_file = base64_decode(Filter::post('map_file')); |
|
| 321 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
| 322 | + } |
|
| 323 | + $use_flags = Filter::postBool('use_flags'); |
|
| 324 | + $gen_details = Filter::postInteger('gen_details'); |
|
| 325 | 325 | |
| 326 | - $success = false; |
|
| 327 | - if($ga_id) { |
|
| 328 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 329 | - if($ga) { |
|
| 330 | - $ga->setTitle($description); |
|
| 331 | - $ga->setAnalysisLevel($analysislevel + 1); |
|
| 332 | - $options = $ga->getOptions(); |
|
| 333 | - if($options) { |
|
| 334 | - $options->setIsUsingFlags($use_flags); |
|
| 335 | - $options->setMaxDetailsInGen($gen_details); |
|
| 336 | - if($use_map) { |
|
| 337 | - $options->setMap(new OutlineMap($map_file)); |
|
| 338 | - $options->setMapLevel($map_top_level + 1); |
|
| 339 | - } |
|
| 340 | - else { |
|
| 341 | - $options->setMap(null); |
|
| 342 | - } |
|
| 343 | - } |
|
| 326 | + $success = false; |
|
| 327 | + if($ga_id) { |
|
| 328 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 329 | + if($ga) { |
|
| 330 | + $ga->setTitle($description); |
|
| 331 | + $ga->setAnalysisLevel($analysislevel + 1); |
|
| 332 | + $options = $ga->getOptions(); |
|
| 333 | + if($options) { |
|
| 334 | + $options->setIsUsingFlags($use_flags); |
|
| 335 | + $options->setMaxDetailsInGen($gen_details); |
|
| 336 | + if($use_map) { |
|
| 337 | + $options->setMap(new OutlineMap($map_file)); |
|
| 338 | + $options->setMapLevel($map_top_level + 1); |
|
| 339 | + } |
|
| 340 | + else { |
|
| 341 | + $options->setMap(null); |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | $res = $this->provider->updateGeoAnalysis($ga); |
| 346 | 346 | if($res) { |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
| 354 | 354 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
| 355 | 355 | } |
| 356 | - } |
|
| 357 | - } else { |
|
| 356 | + } |
|
| 357 | + } else { |
|
| 358 | 358 | $ga = $this->provider->createGeoAnalysis( |
| 359 | 359 | $description, |
| 360 | 360 | $analysislevel + 1, |
@@ -372,34 +372,34 @@ discard block |
||
| 372 | 372 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
| 373 | 373 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
| 374 | 374 | } |
| 375 | - } |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl(); |
|
| 378 | - if(!$success) { |
|
| 379 | - if($ga) { |
|
| 380 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl(); |
|
| 381 | - } |
|
| 382 | - else { |
|
| 383 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
| 377 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl(); |
|
| 378 | + if(!$success) { |
|
| 379 | + if($ga) { |
|
| 380 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $WT_TREE->getNameUrl(); |
|
| 381 | + } |
|
| 382 | + else { |
|
| 383 | + $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + header('Location: ' . WT_BASE_URL . $redirection_url); |
|
| 387 | 387 | |
| 388 | - } |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one. |
| 392 | 392 | * |
| 393 | 393 | * @param (GeoAnalysis!null) $ga GeoAnalysis to edit |
| 394 | 394 | */ |
| 395 | - protected function renderEdit(GeoAnalysis $ga = null) { |
|
| 396 | - global $WT_TREE; |
|
| 395 | + protected function renderEdit(GeoAnalysis $ga = null) { |
|
| 396 | + global $WT_TREE; |
|
| 397 | 397 | |
| 398 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 399 | - $controller = new PageController(); |
|
| 400 | - $controller |
|
| 401 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 402 | - ->addInlineJavascript(' |
|
| 398 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 399 | + $controller = new PageController(); |
|
| 400 | + $controller |
|
| 401 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 402 | + ->addInlineJavascript(' |
|
| 403 | 403 | function toggleMapOptions() { |
| 404 | 404 | if($("input:radio[name=\'use_map\']:checked").val() == 1) { |
| 405 | 405 | $("#map_options").show(); |
@@ -413,34 +413,34 @@ discard block |
||
| 413 | 413 | toggleMapOptions(); |
| 414 | 414 | '); |
| 415 | 415 | |
| 416 | - $data = new ViewBag(); |
|
| 417 | - if($ga) { |
|
| 418 | - $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
| 419 | - $data->set('geo_analysis', $ga); |
|
| 420 | - } else { |
|
| 421 | - $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
| 422 | - } |
|
| 416 | + $data = new ViewBag(); |
|
| 417 | + if($ga) { |
|
| 418 | + $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
|
| 419 | + $data->set('geo_analysis', $ga); |
|
| 420 | + } else { |
|
| 421 | + $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis')); |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - $data->set('title', $controller->getPageTitle()); |
|
| 425 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
| 426 | - $data->set('module_title', $this->module->getTitle()); |
|
| 427 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl()); |
|
| 428 | - $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
| 424 | + $data->set('title', $controller->getPageTitle()); |
|
| 425 | + $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
| 426 | + $data->set('module_title', $this->module->getTitle()); |
|
| 427 | + $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl()); |
|
| 428 | + $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
|
| 429 | 429 | |
| 430 | - $map_list = array_map( |
|
| 431 | - function($map) { |
|
| 432 | - return $map->getDescription(); |
|
| 433 | - }, |
|
| 434 | - $this->provider->getOutlineMapsList() |
|
| 435 | - ); |
|
| 436 | - asort($map_list); |
|
| 437 | - $data->set('map_list', $map_list); |
|
| 430 | + $map_list = array_map( |
|
| 431 | + function($map) { |
|
| 432 | + return $map->getDescription(); |
|
| 433 | + }, |
|
| 434 | + $this->provider->getOutlineMapsList() |
|
| 435 | + ); |
|
| 436 | + asort($map_list); |
|
| 437 | + $data->set('map_list', $map_list); |
|
| 438 | 438 | |
| 439 | - $gen_details = array(0 => I18N::translate('All')); |
|
| 440 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
| 441 | - $data->set('generation_details', $gen_details); |
|
| 439 | + $gen_details = array(0 => I18N::translate('All')); |
|
| 440 | + for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
| 441 | + $data->set('generation_details', $gen_details); |
|
| 442 | 442 | |
| 443 | - ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
| 444 | - } |
|
| 443 | + ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
|
| 444 | + } |
|
| 445 | 445 | |
| 446 | 446 | } |
| 447 | 447 | \ No newline at end of file |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Fisharebest\Webtrees\Controller\BaseController; |
| 15 | 15 | use Fisharebest\Webtrees\Controller\PageController; |
| 16 | 16 | use Fisharebest\Webtrees\Filter; |
| 17 | -use Fisharebest\Webtrees\Html; |
|
| 18 | 17 | use Fisharebest\Webtrees\I18N; |
| 19 | 18 | use Fisharebest\Webtrees\Log; |
| 20 | 19 | use Fisharebest\Webtrees\Module; |
@@ -36,47 +36,47 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | class GeoAnalysisController extends MvcController |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * GeoAnalysis Provider |
|
| 41 | - * @var GeoAnalysisProvider $provider |
|
| 42 | - */ |
|
| 43 | - protected $provider; |
|
| 39 | + /** |
|
| 40 | + * GeoAnalysis Provider |
|
| 41 | + * @var GeoAnalysisProvider $provider |
|
| 42 | + */ |
|
| 43 | + protected $provider; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Constructor for GeoAnalysis controller |
|
| 47 | - * @param AbstractModule $module |
|
| 48 | - */ |
|
| 49 | - public function __construct(AbstractModule $module) { |
|
| 50 | - parent::__construct($module); |
|
| 45 | + /** |
|
| 46 | + * Constructor for GeoAnalysis controller |
|
| 47 | + * @param AbstractModule $module |
|
| 48 | + */ |
|
| 49 | + public function __construct(AbstractModule $module) { |
|
| 50 | + parent::__construct($module); |
|
| 51 | 51 | |
| 52 | - $this->provider = $this->module->getProvider(); |
|
| 53 | - } |
|
| 52 | + $this->provider = $this->module->getProvider(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Pages |
|
| 57 | - */ |
|
| 55 | + /** |
|
| 56 | + * Pages |
|
| 57 | + */ |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * GeoAnalysis@index |
|
| 61 | - */ |
|
| 62 | - public function index() { |
|
| 59 | + /** |
|
| 60 | + * GeoAnalysis@index |
|
| 61 | + */ |
|
| 62 | + public function index() { |
|
| 63 | 63 | |
| 64 | - $controller = new PageController(); |
|
| 65 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
| 64 | + $controller = new PageController(); |
|
| 65 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
| 66 | 66 | |
| 67 | - $data = new ViewBag(); |
|
| 68 | - $data->set('title', $controller->getPageTitle()); |
|
| 69 | - $data->set('has_analysis', false); |
|
| 67 | + $data = new ViewBag(); |
|
| 68 | + $data->set('title', $controller->getPageTitle()); |
|
| 69 | + $data->set('has_analysis', false); |
|
| 70 | 70 | |
| 71 | - $ga_id = Filter::getInteger('ga_id'); |
|
| 71 | + $ga_id = Filter::getInteger('ga_id'); |
|
| 72 | 72 | |
| 73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
| 74 | - $data->set('has_analysis', true); |
|
| 75 | - $data->set('geoanalysis', $ga); |
|
| 73 | + if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
| 74 | + $data->set('has_analysis', true); |
|
| 75 | + $data->set('geoanalysis', $ga); |
|
| 76 | 76 | |
| 77 | - $controller |
|
| 78 | - ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
| 79 | - ->addInlineJavascript(' |
|
| 77 | + $controller |
|
| 78 | + ->addExternalJavascript(Constants::WT_RAPHAEL_JS_URL()) |
|
| 79 | + ->addInlineJavascript(' |
|
| 80 | 80 | jQuery("#geodispersion-tabs").tabs(); |
| 81 | 81 | jQuery("#geodispersion-tabs").css("visibility", "visible"); |
| 82 | 82 | |
@@ -97,133 +97,133 @@ discard block |
||
| 97 | 97 | "json" |
| 98 | 98 | ); |
| 99 | 99 | '); |
| 100 | - } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
| 103 | - } |
|
| 102 | + ViewFactory::make('GeoAnalysis', $this, $controller, $data)->render(); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * GeoAnalysis@listAll |
|
| 107 | - */ |
|
| 108 | - public function listAll() { |
|
| 105 | + /** |
|
| 106 | + * GeoAnalysis@listAll |
|
| 107 | + */ |
|
| 108 | + public function listAll() { |
|
| 109 | 109 | |
| 110 | - $controller = new PageController(); |
|
| 111 | - $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
| 110 | + $controller = new PageController(); |
|
| 111 | + $controller->setPageTitle(I18N::translate('Sosa Geographical dispersion')); |
|
| 112 | 112 | |
| 113 | - $data = new ViewBag(); |
|
| 114 | - $data->set('title', $controller->getPageTitle()); |
|
| 115 | - $data->set('has_list', false); |
|
| 113 | + $data = new ViewBag(); |
|
| 114 | + $data->set('title', $controller->getPageTitle()); |
|
| 115 | + $data->set('has_list', false); |
|
| 116 | 116 | |
| 117 | - $ga_list = $this->provider->getGeoAnalysisList(); |
|
| 118 | - if(count($ga_list) > 0 ) { |
|
| 119 | - $data->set('has_list', true); |
|
| 120 | - $data->set('geoanalysislist', $ga_list); |
|
| 121 | - } |
|
| 117 | + $ga_list = $this->provider->getGeoAnalysisList(); |
|
| 118 | + if(count($ga_list) > 0 ) { |
|
| 119 | + $data->set('has_list', true); |
|
| 120 | + $data->set('geoanalysislist', $ga_list); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
| 124 | - } |
|
| 123 | + ViewFactory::make('GeoAnalysisList', $this, $controller, $data)->render(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * GeoAnalysis@setStatus |
| 128 | 128 | */ |
| 129 | - public function setStatus() { |
|
| 130 | - global $WT_TREE; |
|
| 129 | + public function setStatus() { |
|
| 130 | + global $WT_TREE; |
|
| 131 | 131 | |
| 132 | - $controller = new JsonController(); |
|
| 132 | + $controller = new JsonController(); |
|
| 133 | 133 | |
| 134 | - $ga_id = Filter::getInteger('ga_id'); |
|
| 135 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 134 | + $ga_id = Filter::getInteger('ga_id'); |
|
| 135 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 136 | 136 | |
| 137 | - $controller->restrictAccess( |
|
| 138 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
| 139 | - && Auth::isManager($WT_TREE) |
|
| 140 | - && $ga |
|
| 141 | - ); |
|
| 137 | + $controller->restrictAccess( |
|
| 138 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
| 139 | + && Auth::isManager($WT_TREE) |
|
| 140 | + && $ga |
|
| 141 | + ); |
|
| 142 | 142 | |
| 143 | - $status = Filter::getBool('status'); |
|
| 144 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
| 145 | - try{ |
|
| 146 | - $this->provider->setGeoAnalysisStatus($ga, $status); |
|
| 147 | - $res['status'] = $status; |
|
| 143 | + $status = Filter::getBool('status'); |
|
| 144 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
| 145 | + try{ |
|
| 146 | + $this->provider->setGeoAnalysisStatus($ga, $status); |
|
| 147 | + $res['status'] = $status; |
|
| 148 | 148 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
| 149 | - } |
|
| 150 | - catch (\Exception $ex) { |
|
| 151 | - $res['error'] = $ex->getMessage(); |
|
| 149 | + } |
|
| 150 | + catch (\Exception $ex) { |
|
| 151 | + $res['error'] = $ex->getMessage(); |
|
| 152 | 152 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
| 153 | - } |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - $controller->pageHeader(); |
|
| 156 | - if($res['error']) http_response_code(500); |
|
| 155 | + $controller->pageHeader(); |
|
| 156 | + if($res['error']) http_response_code(500); |
|
| 157 | 157 | |
| 158 | - echo \Zend_Json::encode($res); |
|
| 159 | - } |
|
| 158 | + echo \Zend_Json::encode($res); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | - * GeoAnalysis@delete |
|
| 163 | - */ |
|
| 164 | - public function delete() { |
|
| 165 | - global $WT_TREE; |
|
| 162 | + * GeoAnalysis@delete |
|
| 163 | + */ |
|
| 164 | + public function delete() { |
|
| 165 | + global $WT_TREE; |
|
| 166 | 166 | |
| 167 | - $controller = new JsonController(); |
|
| 167 | + $controller = new JsonController(); |
|
| 168 | 168 | |
| 169 | - $ga_id = Filter::getInteger('ga_id'); |
|
| 170 | - $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 169 | + $ga_id = Filter::getInteger('ga_id'); |
|
| 170 | + $ga = $this->provider->getGeoAnalysis($ga_id, false); |
|
| 171 | 171 | |
| 172 | - $controller->restrictAccess( |
|
| 173 | - true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
| 174 | - && Auth::isManager($WT_TREE) |
|
| 175 | - && $ga |
|
| 176 | - ); |
|
| 172 | + $controller->restrictAccess( |
|
| 173 | + true // Filter::checkCsrf() -- Cannot use CSRF on a GET request (modules can only work with GET requests) |
|
| 174 | + && Auth::isManager($WT_TREE) |
|
| 175 | + && $ga |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
| 179 | - try{ |
|
| 180 | - $this->provider->deleteGeoAnalysis($ga); |
|
| 178 | + $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
| 179 | + try{ |
|
| 180 | + $this->provider->deleteGeoAnalysis($ga); |
|
| 181 | 181 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
| 182 | - } |
|
| 183 | - catch (\Exception $ex) { |
|
| 184 | - $res['error'] = $ex->getMessage(); |
|
| 182 | + } |
|
| 183 | + catch (\Exception $ex) { |
|
| 184 | + $res['error'] = $ex->getMessage(); |
|
| 185 | 185 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - $controller->pageHeader(); |
|
| 189 | - if($res['error']) http_response_code(500); |
|
| 188 | + $controller->pageHeader(); |
|
| 189 | + if($res['error']) http_response_code(500); |
|
| 190 | 190 | |
| 191 | - echo \Zend_Json::encode($res); |
|
| 192 | - } |
|
| 191 | + echo \Zend_Json::encode($res); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * GeoAnalysis@dataTabs |
|
| 196 | - */ |
|
| 197 | - public function dataTabs() { |
|
| 198 | - global $WT_TREE; |
|
| 194 | + /** |
|
| 195 | + * GeoAnalysis@dataTabs |
|
| 196 | + */ |
|
| 197 | + public function dataTabs() { |
|
| 198 | + global $WT_TREE; |
|
| 199 | 199 | |
| 200 | - $controller = new JsonController(); |
|
| 200 | + $controller = new JsonController(); |
|
| 201 | 201 | |
| 202 | - $ga_id = Filter::getInteger('ga_id'); |
|
| 203 | - $ga = $this->provider->getGeoAnalysis($ga_id); |
|
| 204 | - $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
| 202 | + $ga_id = Filter::getInteger('ga_id'); |
|
| 203 | + $ga = $this->provider->getGeoAnalysis($ga_id); |
|
| 204 | + $sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
| 205 | 205 | |
| 206 | - $controller |
|
| 207 | - ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
| 208 | - ->pageHeader(); |
|
| 206 | + $controller |
|
| 207 | + ->restrictAccess($ga && $sosa_provider->isSetup()) |
|
| 208 | + ->pageHeader(); |
|
| 209 | 209 | |
| 210 | - $jsonArray = array(); |
|
| 210 | + $jsonArray = array(); |
|
| 211 | 211 | |
| 212 | - list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
| 212 | + list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
|
| 213 | 213 | |
| 214 | - $flags = array(); |
|
| 215 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
| 216 | - $mapProvider = new GoogleMapsProvider(); |
|
| 217 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
| 218 | - $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
|
| 219 | - } |
|
| 220 | - } |
|
| 214 | + $flags = array(); |
|
| 215 | + if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
| 216 | + $mapProvider = new GoogleMapsProvider(); |
|
| 217 | + foreach($placesDispGeneral['places'] as $place => $count) { |
|
| 218 | + $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE)); |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
| 223 | - $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
| 222 | + $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags); |
|
| 223 | + $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags); |
|
| 224 | 224 | |
| 225 | - echo \Zend_Json::encode($jsonArray); |
|
| 226 | - } |
|
| 225 | + echo \Zend_Json::encode($jsonArray); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * Returns HTML code for the GeoAnalysis general tab (can be either a map or a table). |
@@ -233,73 +233,73 @@ discard block |
||
| 233 | 233 | * @param (null|array) $flags Array of flags |
| 234 | 234 | * @return string HTML code for the general tab |
| 235 | 235 | */ |
| 236 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
| 237 | - global $WT_TREE; |
|
| 236 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
| 237 | + global $WT_TREE; |
|
| 238 | 238 | |
| 239 | - $html = ''; |
|
| 240 | - if($placesGeneralResults){ |
|
| 241 | - $data = new ViewBag(); |
|
| 239 | + $html = ''; |
|
| 240 | + if($placesGeneralResults){ |
|
| 241 | + $data = new ViewBag(); |
|
| 242 | 242 | |
| 243 | - $nb_found = $placesGeneralResults['knownsum']; |
|
| 244 | - $nb_other = 0; |
|
| 245 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
| 246 | - $nb_unknown = $placesGeneralResults['unknown']; |
|
| 243 | + $nb_found = $placesGeneralResults['knownsum']; |
|
| 244 | + $nb_other = 0; |
|
| 245 | + if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
| 246 | + $nb_unknown = $placesGeneralResults['unknown']; |
|
| 247 | 247 | |
| 248 | - $data->set('stats_gen_nb_found', $nb_found); |
|
| 249 | - $data->set('stats_gen_nb_other', $nb_other); |
|
| 250 | - $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
| 248 | + $data->set('stats_gen_nb_found', $nb_found); |
|
| 249 | + $data->set('stats_gen_nb_other', $nb_other); |
|
| 250 | + $data->set('stats_gen_nb_unknown', $nb_unknown); |
|
| 251 | 251 | |
| 252 | - $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
| 252 | + $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
|
| 253 | 253 | |
| 254 | - if($ga->hasMap()) { |
|
| 255 | - $max = $placesGeneralResults['max']; |
|
| 256 | - $map = $ga->getOptions()->getMap(); |
|
| 257 | - $maxcolor = $map->getCanvas()->max_color; |
|
| 258 | - $hovercolor = $map->getCanvas()->hover_color; |
|
| 259 | - $results_by_subdivs = $map->getSubdivisions(); |
|
| 260 | - $places_mappings = $map->getPlacesMappings(); |
|
| 261 | - foreach ($placesGeneralResults['places'] as $location => $count) { |
|
| 262 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
| 263 | - $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
| 264 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
| 265 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
| 266 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
| 267 | - } |
|
| 268 | - else { |
|
| 269 | - $levelref = $levelvalues[0]; |
|
| 270 | - } |
|
| 271 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
| 272 | - if(isset($results_by_subdivs[$levelref])) { |
|
| 273 | - $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
| 274 | - $count_subd += $count; |
|
| 275 | - $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
| 276 | - $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
| 277 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
| 278 | - $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
|
| 279 | - $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - } |
|
| 254 | + if($ga->hasMap()) { |
|
| 255 | + $max = $placesGeneralResults['max']; |
|
| 256 | + $map = $ga->getOptions()->getMap(); |
|
| 257 | + $maxcolor = $map->getCanvas()->max_color; |
|
| 258 | + $hovercolor = $map->getCanvas()->hover_color; |
|
| 259 | + $results_by_subdivs = $map->getSubdivisions(); |
|
| 260 | + $places_mappings = $map->getPlacesMappings(); |
|
| 261 | + foreach ($placesGeneralResults['places'] as $location => $count) { |
|
| 262 | + $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
| 263 | + $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
|
| 264 | + if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
| 265 | + $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
| 266 | + if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
| 267 | + } |
|
| 268 | + else { |
|
| 269 | + $levelref = $levelvalues[0]; |
|
| 270 | + } |
|
| 271 | + if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
| 272 | + if(isset($results_by_subdivs[$levelref])) { |
|
| 273 | + $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
|
| 274 | + $count_subd += $count; |
|
| 275 | + $results_by_subdivs[$levelref]['count'] = $count_subd; |
|
| 276 | + $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
|
| 277 | + if($ga->getOptions()->isUsingFlags() && $flags) { |
|
| 278 | + $results_by_subdivs[$levelref]['place'] = new Place($location, $WT_TREE); |
|
| 279 | + $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - $data->set('map', $ga->getOptions()->getMap()); |
|
| 285 | - $data->set('results_by_subdivisions', $results_by_subdivs); |
|
| 284 | + $data->set('map', $ga->getOptions()->getMap()); |
|
| 285 | + $data->set('results_by_subdivisions', $results_by_subdivs); |
|
| 286 | 286 | |
| 287 | - $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
| 288 | - } |
|
| 289 | - else { |
|
| 290 | - $results = $placesGeneralResults['places']; |
|
| 291 | - arsort($results); |
|
| 292 | - $data->set('results', $results); |
|
| 293 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
| 287 | + $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
|
| 288 | + } |
|
| 289 | + else { |
|
| 290 | + $results = $placesGeneralResults['places']; |
|
| 291 | + arsort($results); |
|
| 292 | + $data->set('results', $results); |
|
| 293 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
| 294 | 294 | |
| 295 | - $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - else { |
|
| 299 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
| 300 | - } |
|
| 301 | - return $html; |
|
| 302 | - } |
|
| 295 | + $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + else { |
|
| 299 | + $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
| 300 | + } |
|
| 301 | + return $html; |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * Returns HTML code for the GeoAnalysis generations tab. |
@@ -309,70 +309,70 @@ discard block |
||
| 309 | 309 | * @param (null|array) $flags Array of flags |
| 310 | 310 | * @return string HTML code for the generations tab |
| 311 | 311 | */ |
| 312 | - protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
| 313 | - global $WT_TREE; |
|
| 312 | + protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
|
| 313 | + global $WT_TREE; |
|
| 314 | 314 | |
| 315 | - $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'<p>'; |
|
| 316 | - if($placesGenerationsResults && $ga->getOptions()){ |
|
| 317 | - $data = new ViewBag(); |
|
| 315 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'<p>'; |
|
| 316 | + if($placesGenerationsResults && $ga->getOptions()){ |
|
| 317 | + $data = new ViewBag(); |
|
| 318 | 318 | |
| 319 | - ksort($placesGenerationsResults); |
|
| 319 | + ksort($placesGenerationsResults); |
|
| 320 | 320 | |
| 321 | - $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
| 322 | - $data->set('max_details_gen', $detailslevel); |
|
| 323 | - $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
| 324 | - $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
| 325 | - $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
| 326 | - $data->set('display_all_places', $display_all_places); |
|
| 321 | + $detailslevel = $ga->getOptions()->getMaxDetailsInGen(); |
|
| 322 | + $data->set('max_details_gen', $detailslevel); |
|
| 323 | + $data->set('use_flags', $ga->getOptions()->isUsingFlags()); |
|
| 324 | + $data->set('analysis_level', $ga->getAnalysisLevel()); |
|
| 325 | + $display_all_places = !is_null($detailslevel) && $detailslevel == 0; |
|
| 326 | + $data->set('display_all_places', $display_all_places); |
|
| 327 | 327 | |
| 328 | - $results_by_gen = array(); |
|
| 329 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
| 330 | - $sum = 0; |
|
| 331 | - $other = 0; |
|
| 332 | - $unknown = 0; |
|
| 333 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
| 334 | - if(isset($genData['other'])) $other = $genData['other']; |
|
| 335 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
| 328 | + $results_by_gen = array(); |
|
| 329 | + foreach($placesGenerationsResults as $gen => $genData){ |
|
| 330 | + $sum = 0; |
|
| 331 | + $other = 0; |
|
| 332 | + $unknown = 0; |
|
| 333 | + if(isset($genData['sum'])) $sum = $genData['sum']; |
|
| 334 | + if(isset($genData['other'])) $other = $genData['other']; |
|
| 335 | + if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
| 336 | 336 | |
| 337 | - if($sum > 0) { |
|
| 338 | - $results_by_gen[$gen]['sum'] = $sum; |
|
| 339 | - $results_by_gen[$gen]['other'] = $other; |
|
| 340 | - $results_by_gen[$gen]['unknown'] = $unknown; |
|
| 341 | - $results_by_gen[$gen]['places'] = array(); |
|
| 342 | - arsort($genData['places']); |
|
| 337 | + if($sum > 0) { |
|
| 338 | + $results_by_gen[$gen]['sum'] = $sum; |
|
| 339 | + $results_by_gen[$gen]['other'] = $other; |
|
| 340 | + $results_by_gen[$gen]['unknown'] = $unknown; |
|
| 341 | + $results_by_gen[$gen]['places'] = array(); |
|
| 342 | + arsort($genData['places']); |
|
| 343 | 343 | |
| 344 | - if($display_all_places){ |
|
| 345 | - foreach($genData['places'] as $placename=> $count){ |
|
| 346 | - $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
| 347 | - $levels = array_map('trim',explode(',', $placename)); |
|
| 344 | + if($display_all_places){ |
|
| 345 | + foreach($genData['places'] as $placename=> $count){ |
|
| 346 | + $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
|
| 347 | + $levels = array_map('trim',explode(',', $placename)); |
|
| 348 | 348 | |
| 349 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
| 350 | - $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
|
| 351 | - $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - else { |
|
| 356 | - $tmp = $genData['places']; |
|
| 357 | - if($other > 0) { |
|
| 358 | - $tmp = array_slice($tmp, 0, 5, true); |
|
| 359 | - $tmp['other'] = $other; |
|
| 360 | - arsort($tmp); |
|
| 361 | - } |
|
| 362 | - $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - } |
|
| 349 | + if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
| 350 | + $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE); |
|
| 351 | + $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + else { |
|
| 356 | + $tmp = $genData['places']; |
|
| 357 | + if($other > 0) { |
|
| 358 | + $tmp = array_slice($tmp, 0, 5, true); |
|
| 359 | + $tmp['other'] = $other; |
|
| 360 | + arsort($tmp); |
|
| 361 | + } |
|
| 362 | + $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true); |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - $data->set('results_by_generations', $results_by_gen); |
|
| 367 | + $data->set('results_by_generations', $results_by_gen); |
|
| 368 | 368 | |
| 369 | - $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
| 369 | + $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
|
| 370 | 370 | |
| 371 | - } |
|
| 372 | - else { |
|
| 373 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
| 374 | - } |
|
| 375 | - return $html; |
|
| 376 | - } |
|
| 371 | + } |
|
| 372 | + else { |
|
| 373 | + $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
| 374 | + } |
|
| 375 | + return $html; |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | 378 | } |
| 379 | 379 | \ No newline at end of file |
@@ -11,7 +11,6 @@ |
||
| 11 | 11 | namespace MyArtJaub\Webtrees\Module\GeoDispersion\Model; |
| 12 | 12 | |
| 13 | 13 | use Fisharebest\Webtrees\I18N; |
| 14 | -use Fisharebest\Webtrees\Place; |
|
| 15 | 14 | use Fisharebest\Webtrees\Tree; |
| 16 | 15 | use MyArtJaub\Webtrees\Constants; |
| 17 | 16 | use MyArtJaub\Webtrees\Individual; |
@@ -25,64 +25,64 @@ discard block |
||
| 25 | 25 | * Geo Analysis ID |
| 26 | 26 | * @var int $id |
| 27 | 27 | */ |
| 28 | - protected $id; |
|
| 28 | + protected $id; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Geo Analysis Title |
| 32 | 32 | * @var string $title |
| 33 | 33 | */ |
| 34 | - protected $title; |
|
| 34 | + protected $title; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Level of the Gedcom hierarchy for the analysis |
| 38 | 38 | * @var int $analysis_level |
| 39 | 39 | */ |
| 40 | - protected $analysis_level; |
|
| 40 | + protected $analysis_level; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Display options |
|
| 44 | - * @var GeoDisplayOptions $options |
|
| 45 | - */ |
|
| 46 | - protected $options; |
|
| 42 | + /** |
|
| 43 | + * Display options |
|
| 44 | + * @var GeoDisplayOptions $options |
|
| 45 | + */ |
|
| 46 | + protected $options; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Reference tree |
|
| 50 | - * @var Tree $tree |
|
| 51 | - */ |
|
| 52 | - protected $tree; |
|
| 48 | + /** |
|
| 49 | + * Reference tree |
|
| 50 | + * @var Tree $tree |
|
| 51 | + */ |
|
| 52 | + protected $tree; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Is the analysis enabled |
|
| 56 | - * @var bool $enabled |
|
| 57 | - */ |
|
| 58 | - protected $enabled; |
|
| 54 | + /** |
|
| 55 | + * Is the analysis enabled |
|
| 56 | + * @var bool $enabled |
|
| 57 | + */ |
|
| 58 | + protected $enabled; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Constructor for GeoAnalysis. |
|
| 62 | - * |
|
| 63 | - * @param Tree $tree Reference tree |
|
| 60 | + /** |
|
| 61 | + * Constructor for GeoAnalysis. |
|
| 62 | + * |
|
| 63 | + * @param Tree $tree Reference tree |
|
| 64 | 64 | * @param int $id GeoAnalysis ID |
| 65 | 65 | * @param string $title GeoAnalysis title |
| 66 | 66 | * @param int $analysis_level Analysis level |
| 67 | 67 | * @param (GeoDisplayOptions|null) $options Display options |
| 68 | 68 | * @param bool $enabled Is analysis enabled |
| 69 | - */ |
|
| 70 | - public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
| 71 | - $this->tree = $tree; |
|
| 72 | - $this->id = $id; |
|
| 73 | - $this->title = $title; |
|
| 74 | - $this->analysis_level = $analysis_level; |
|
| 75 | - $this->options = $options; |
|
| 76 | - $this->enabled = $enabled; |
|
| 77 | - } |
|
| 69 | + */ |
|
| 70 | + public function __construct(Tree $tree, $id, $title, $analysis_level, GeoDisplayOptions $options = null, $enabled = true) { |
|
| 71 | + $this->tree = $tree; |
|
| 72 | + $this->id = $id; |
|
| 73 | + $this->title = $title; |
|
| 74 | + $this->analysis_level = $analysis_level; |
|
| 75 | + $this->options = $options; |
|
| 76 | + $this->enabled = $enabled; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Get the analysis title |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - public function getTitle() { |
|
| 84 | - return $this->title; |
|
| 85 | - } |
|
| 83 | + public function getTitle() { |
|
| 84 | + return $this->title; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Set the analysis title |
@@ -90,53 +90,53 @@ discard block |
||
| 90 | 90 | * @param string $title |
| 91 | 91 | * @return self Enable method-chaining |
| 92 | 92 | */ |
| 93 | - public function setTitle($title) { |
|
| 94 | - $this->title = $title; |
|
| 95 | - return $this; |
|
| 96 | - } |
|
| 93 | + public function setTitle($title) { |
|
| 94 | + $this->title = $title; |
|
| 95 | + return $this; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * Get the analysis ID |
| 100 | 100 | * @return int |
| 101 | 101 | */ |
| 102 | - public function getId() { |
|
| 103 | - return $this->id; |
|
| 104 | - } |
|
| 102 | + public function getId() { |
|
| 103 | + return $this->id; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * Get the analysis status (enabled/disabled) |
| 108 | 108 | * @return bool |
| 109 | 109 | */ |
| 110 | - public function isEnabled() { |
|
| 111 | - return $this->enabled; |
|
| 112 | - } |
|
| 110 | + public function isEnabled() { |
|
| 111 | + return $this->enabled; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Get analysis options |
|
| 116 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
| 117 | - */ |
|
| 118 | - public function getOptions() { |
|
| 119 | - return $this->options; |
|
| 120 | - } |
|
| 114 | + /** |
|
| 115 | + * Get analysis options |
|
| 116 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions |
|
| 117 | + */ |
|
| 118 | + public function getOptions() { |
|
| 119 | + return $this->options; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | - * Set analysis options |
|
| 123 | + * Set analysis options |
|
| 124 | 124 | * |
| 125 | - * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
| 125 | + * @param \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoDisplayOptions $options |
|
| 126 | 126 | * @return self Enable method-chaining |
| 127 | - */ |
|
| 128 | - public function setOptions(GeoDisplayOptions $options) { |
|
| 129 | - $this->options = $options; |
|
| 130 | - return $this; |
|
| 131 | - } |
|
| 127 | + */ |
|
| 128 | + public function setOptions(GeoDisplayOptions $options) { |
|
| 129 | + $this->options = $options; |
|
| 130 | + return $this; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Get analysis level |
| 135 | 135 | * @return int |
| 136 | 136 | */ |
| 137 | - public function getAnalysisLevel() { |
|
| 138 | - return $this->analysis_level; |
|
| 139 | - } |
|
| 137 | + public function getAnalysisLevel() { |
|
| 138 | + return $this->analysis_level; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * Get analysis level |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | * @param int $analysis_level |
| 145 | 145 | * @return self Enable method-chaining |
| 146 | 146 | */ |
| 147 | - public function setAnalysisLevel($analysis_level) { |
|
| 148 | - $this->analysis_level = $analysis_level; |
|
| 149 | - return $this; |
|
| 150 | - } |
|
| 147 | + public function setAnalysisLevel($analysis_level) { |
|
| 148 | + $this->analysis_level = $analysis_level; |
|
| 149 | + return $this; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Check whether the analysis has a linked map |
| 154 | 154 | * |
| 155 | 155 | * @return bool |
| 156 | 156 | */ |
| 157 | - public function hasMap() { |
|
| 158 | - return $this->options && $this->options->getMap(); |
|
| 159 | - } |
|
| 157 | + public function hasMap() { |
|
| 158 | + return $this->options && $this->options->getMap(); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Get the URL for the GeoAnalysis. |
@@ -164,117 +164,117 @@ discard block |
||
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | 166 | public function getHtmlUrl() { |
| 167 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
| 168 | - } |
|
| 167 | + return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Return the dispersion analysis tables. |
|
| 172 | - * Two arrays are returned : |
|
| 173 | - * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
| 174 | - * - knownsum : Number of known places |
|
| 175 | - * - unknown : Number of unknown places |
|
| 176 | - * - max : Maximum count of ancestors within a place |
|
| 177 | - * - other : Other places (not in the top level area) |
|
| 178 | - * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
| 179 | - * - sum : Number of known places |
|
| 180 | - * - unknown : Number of unknown places |
|
| 181 | - * - other : Other places (not in the top level area) |
|
| 182 | - * |
|
| 183 | - * @param array $sosalist List of all sosas |
|
| 184 | - * @return array Array of the general and generations table |
|
| 185 | - */ |
|
| 186 | - public function getAnalysisResults($sosalist) { |
|
| 187 | - $placesDispGeneral = null; |
|
| 188 | - $placesDispGenerations = null; |
|
| 170 | + /** |
|
| 171 | + * Return the dispersion analysis tables. |
|
| 172 | + * Two arrays are returned : |
|
| 173 | + * - the General analysis, which returns the number of ancestors for each place found, plus 4 additional indicators : |
|
| 174 | + * - knownsum : Number of known places |
|
| 175 | + * - unknown : Number of unknown places |
|
| 176 | + * - max : Maximum count of ancestors within a place |
|
| 177 | + * - other : Other places (not in the top level area) |
|
| 178 | + * - the Generations analysis, which returns the number of ancestors for each place found for each generation, plus 3 additional indicators within each generation : |
|
| 179 | + * - sum : Number of known places |
|
| 180 | + * - unknown : Number of unknown places |
|
| 181 | + * - other : Other places (not in the top level area) |
|
| 182 | + * |
|
| 183 | + * @param array $sosalist List of all sosas |
|
| 184 | + * @return array Array of the general and generations table |
|
| 185 | + */ |
|
| 186 | + public function getAnalysisResults($sosalist) { |
|
| 187 | + $placesDispGeneral = null; |
|
| 188 | + $placesDispGenerations = null; |
|
| 189 | 189 | |
| 190 | - if($sosalist && count($sosalist) > 0) { |
|
| 191 | - $placesDispGeneral['knownsum'] = 0; |
|
| 192 | - $placesDispGeneral['unknown'] = 0; |
|
| 193 | - $placesDispGeneral['max'] = 0; |
|
| 194 | - $placesDispGeneral['places'] = array(); |
|
| 195 | - foreach($sosalist as $sosaid => $gens) { |
|
| 196 | - $sosa = Individual::getIntance($sosaid, $this->tree); |
|
| 197 | - $place =$sosa->getSignificantPlace(); |
|
| 198 | - $genstab = explode(',', $gens); |
|
| 199 | - $isUnknown=true; |
|
| 200 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
| 201 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
| 202 | - if(count($levels)>= $this->analysis_level){ |
|
| 203 | - $toplevelvalues = array(); |
|
| 204 | - if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
| 205 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
| 206 | - } |
|
| 207 | - if(!$this->hasMap() |
|
| 208 | - || is_null($this->options->getMapLevel()) |
|
| 209 | - || $this->options->getMap()->getTopLevelName() == '*' |
|
| 210 | - || ( |
|
| 211 | - $this->options->getMapLevel() <= $this->analysis_level |
|
| 212 | - && $this->options->getMapLevel() > 0 |
|
| 213 | - && count($levels) >= $this->options->getMapLevel() |
|
| 214 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
| 215 | - ) |
|
| 216 | - ) { |
|
| 217 | - $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
| 218 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
| 219 | - $placesDispGeneral['places'][$placest] += 1; |
|
| 220 | - } |
|
| 221 | - else { |
|
| 222 | - $placesDispGeneral['places'][$placest] = 1; |
|
| 223 | - } |
|
| 224 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
| 225 | - $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
| 226 | - foreach($genstab as $gen) { |
|
| 227 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
| 228 | - $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
| 229 | - } |
|
| 230 | - else { |
|
| 231 | - $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
| 232 | - } |
|
| 233 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
| 234 | - $placesDispGenerations[$gen]['sum'] += 1; |
|
| 235 | - } |
|
| 236 | - else { |
|
| 237 | - $placesDispGenerations[$gen]['sum'] = 1; |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - else{ |
|
| 242 | - if(isset($placesDispGeneral['other'])) { |
|
| 243 | - $placesDispGeneral['other'] += 1; |
|
| 244 | - } |
|
| 245 | - else { |
|
| 246 | - $placesDispGeneral['other'] = 1; |
|
| 247 | - } |
|
| 248 | - foreach($genstab as $gen) { |
|
| 249 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
| 250 | - $placesDispGenerations[$gen]['other'] += 1; |
|
| 251 | - } |
|
| 252 | - else { |
|
| 253 | - $placesDispGenerations[$gen]['other'] = 1; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - $placesDispGeneral['knownsum'] += 1; |
|
| 258 | - $isUnknown = false; |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - if($isUnknown){ |
|
| 262 | - $placesDispGeneral['unknown'] += 1; |
|
| 263 | - foreach($genstab as $gen) { |
|
| 264 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
| 265 | - $placesDispGenerations[$gen]['unknown'] += 1; |
|
| 266 | - } |
|
| 267 | - else { |
|
| 268 | - $placesDispGenerations[$gen]['unknown'] = 1; |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - } |
|
| 190 | + if($sosalist && count($sosalist) > 0) { |
|
| 191 | + $placesDispGeneral['knownsum'] = 0; |
|
| 192 | + $placesDispGeneral['unknown'] = 0; |
|
| 193 | + $placesDispGeneral['max'] = 0; |
|
| 194 | + $placesDispGeneral['places'] = array(); |
|
| 195 | + foreach($sosalist as $sosaid => $gens) { |
|
| 196 | + $sosa = Individual::getIntance($sosaid, $this->tree); |
|
| 197 | + $place =$sosa->getSignificantPlace(); |
|
| 198 | + $genstab = explode(',', $gens); |
|
| 199 | + $isUnknown=true; |
|
| 200 | + if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
| 201 | + $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
| 202 | + if(count($levels)>= $this->analysis_level){ |
|
| 203 | + $toplevelvalues = array(); |
|
| 204 | + if($this->hasMap() && $toplevelvalue = $this->options->getMap()->getTopLevelName()) { |
|
| 205 | + $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
| 206 | + } |
|
| 207 | + if(!$this->hasMap() |
|
| 208 | + || is_null($this->options->getMapLevel()) |
|
| 209 | + || $this->options->getMap()->getTopLevelName() == '*' |
|
| 210 | + || ( |
|
| 211 | + $this->options->getMapLevel() <= $this->analysis_level |
|
| 212 | + && $this->options->getMapLevel() > 0 |
|
| 213 | + && count($levels) >= $this->options->getMapLevel() |
|
| 214 | + && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
| 215 | + ) |
|
| 216 | + ) { |
|
| 217 | + $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
|
| 218 | + if(isset($placesDispGeneral['places'][$placest])) { |
|
| 219 | + $placesDispGeneral['places'][$placest] += 1; |
|
| 220 | + } |
|
| 221 | + else { |
|
| 222 | + $placesDispGeneral['places'][$placest] = 1; |
|
| 223 | + } |
|
| 224 | + if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
| 225 | + $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
|
| 226 | + foreach($genstab as $gen) { |
|
| 227 | + if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
| 228 | + $placesDispGenerations[$gen]['places'][$placest] += 1; |
|
| 229 | + } |
|
| 230 | + else { |
|
| 231 | + $placesDispGenerations[$gen]['places'][$placest] = 1; |
|
| 232 | + } |
|
| 233 | + if(isset($placesDispGenerations[$gen]['sum'])) { |
|
| 234 | + $placesDispGenerations[$gen]['sum'] += 1; |
|
| 235 | + } |
|
| 236 | + else { |
|
| 237 | + $placesDispGenerations[$gen]['sum'] = 1; |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + else{ |
|
| 242 | + if(isset($placesDispGeneral['other'])) { |
|
| 243 | + $placesDispGeneral['other'] += 1; |
|
| 244 | + } |
|
| 245 | + else { |
|
| 246 | + $placesDispGeneral['other'] = 1; |
|
| 247 | + } |
|
| 248 | + foreach($genstab as $gen) { |
|
| 249 | + if(isset($placesDispGenerations[$gen]['other'])) { |
|
| 250 | + $placesDispGenerations[$gen]['other'] += 1; |
|
| 251 | + } |
|
| 252 | + else { |
|
| 253 | + $placesDispGenerations[$gen]['other'] = 1; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + $placesDispGeneral['knownsum'] += 1; |
|
| 258 | + $isUnknown = false; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + if($isUnknown){ |
|
| 262 | + $placesDispGeneral['unknown'] += 1; |
|
| 263 | + foreach($genstab as $gen) { |
|
| 264 | + if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
| 265 | + $placesDispGenerations[$gen]['unknown'] += 1; |
|
| 266 | + } |
|
| 267 | + else { |
|
| 268 | + $placesDispGenerations[$gen]['unknown'] = 1; |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - return array($placesDispGeneral, $placesDispGenerations); |
|
| 277 | - } |
|
| 276 | + return array($placesDispGeneral, $placesDispGenerations); |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | |
| 280 | 280 | } |
@@ -14,7 +14,6 @@ |
||
| 14 | 14 | use Fisharebest\Webtrees\Controller\PageController; |
| 15 | 15 | use Fisharebest\Webtrees\Filter; |
| 16 | 16 | use Fisharebest\Webtrees\FlashMessages; |
| 17 | -use Fisharebest\Webtrees\Html; |
|
| 18 | 17 | use Fisharebest\Webtrees\I18N; |
| 19 | 18 | use Fisharebest\Webtrees\Module; |
| 20 | 19 | use Fisharebest\Webtrees\Theme; |
@@ -28,56 +28,56 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | class AdminConfigController extends MvcController |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * Manage updates sent from the AdminConfig@index form. |
|
| 33 | - */ |
|
| 34 | - protected function update() { |
|
| 35 | - global $WT_TREE; |
|
| 31 | + /** |
|
| 32 | + * Manage updates sent from the AdminConfig@index form. |
|
| 33 | + */ |
|
| 34 | + protected function update() { |
|
| 35 | + global $WT_TREE; |
|
| 36 | 36 | |
| 37 | - if(Auth::isAdmin()){ |
|
| 37 | + if(Auth::isAdmin()){ |
|
| 38 | 38 | |
| 39 | - $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
|
| 39 | + $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
|
| 40 | 40 | |
| 41 | - $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); |
|
| 42 | - $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
| 43 | - $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); |
|
| 41 | + $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); |
|
| 42 | + $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
| 43 | + $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); |
|
| 44 | 44 | |
| 45 | - $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); |
|
| 46 | - $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
| 47 | - $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); |
|
| 45 | + $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); |
|
| 46 | + $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
| 47 | + $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); |
|
| 48 | 48 | |
| 49 | - $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); |
|
| 50 | - $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); |
|
| 49 | + $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); |
|
| 50 | + $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); |
|
| 51 | 51 | |
| 52 | - FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); |
|
| 52 | + FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); |
|
| 53 | 53 | |
| 54 | - return; |
|
| 55 | - } |
|
| 56 | - } |
|
| 54 | + return; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Pages |
|
| 60 | - */ |
|
| 58 | + /** |
|
| 59 | + * Pages |
|
| 60 | + */ |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * AdminConfig@index |
|
| 64 | - */ |
|
| 65 | - public function index() { |
|
| 66 | - global $WT_TREE; |
|
| 62 | + /** |
|
| 63 | + * AdminConfig@index |
|
| 64 | + */ |
|
| 65 | + public function index() { |
|
| 66 | + global $WT_TREE; |
|
| 67 | 67 | |
| 68 | - $action = Filter::post('action'); |
|
| 69 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
| 68 | + $action = Filter::post('action'); |
|
| 69 | + if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
| 70 | 70 | |
| 71 | - Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 72 | - $ctrl = new PageController(); |
|
| 73 | - $ctrl |
|
| 74 | - ->restrictAccess(Auth::isAdmin()) |
|
| 75 | - ->setPageTitle($this->module->getTitle()); |
|
| 71 | + Theme::theme(new AdministrationTheme)->init($WT_TREE); |
|
| 72 | + $ctrl = new PageController(); |
|
| 73 | + $ctrl |
|
| 74 | + ->restrictAccess(Auth::isAdmin()) |
|
| 75 | + ->setPageTitle($this->module->getTitle()); |
|
| 76 | 76 | |
| 77 | - $view_bag = new ViewBag(); |
|
| 78 | - $view_bag->set('title', $ctrl->getPageTitle()); |
|
| 79 | - $view_bag->set('module', $this->module); |
|
| 77 | + $view_bag = new ViewBag(); |
|
| 78 | + $view_bag->set('title', $ctrl->getPageTitle()); |
|
| 79 | + $view_bag->set('module', $this->module); |
|
| 80 | 80 | |
| 81 | - ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
| 82 | - } |
|
| 81 | + ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
| 82 | + } |
|
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |