@@ -20,111 +20,111 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class CertificateFileProvider implements CertificateProviderInterface { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Relative path to the root certificate folder |
|
| 25 | - * @var string $root_path |
|
| 26 | - */ |
|
| 27 | - protected $root_path; |
|
| 23 | + /** |
|
| 24 | + * Relative path to the root certificate folder |
|
| 25 | + * @var string $root_path |
|
| 26 | + */ |
|
| 27 | + protected $root_path; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Reference tree |
|
| 31 | - * @var Tree $tree |
|
| 32 | - */ |
|
| 33 | - protected $tree; |
|
| 29 | + /** |
|
| 30 | + * Reference tree |
|
| 31 | + * @var Tree $tree |
|
| 32 | + */ |
|
| 33 | + protected $tree; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Cached list of certificates' cities. |
|
| 37 | - * @var (null|array) $cities_list |
|
| 38 | - */ |
|
| 39 | - protected $cities_list = null; |
|
| 35 | + /** |
|
| 36 | + * Cached list of certificates' cities. |
|
| 37 | + * @var (null|array) $cities_list |
|
| 38 | + */ |
|
| 39 | + protected $cities_list = null; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Constructor for the File Provider |
|
| 43 | - * @param string $root_path |
|
| 44 | - * @param Tree $tree |
|
| 45 | - */ |
|
| 46 | - public function __construct($root_path, Tree $tree) { |
|
| 47 | - $this->root_path = $root_path; |
|
| 48 | - $this->tree = $tree; |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * Constructor for the File Provider |
|
| 43 | + * @param string $root_path |
|
| 44 | + * @param Tree $tree |
|
| 45 | + */ |
|
| 46 | + public function __construct($root_path, Tree $tree) { |
|
| 47 | + $this->root_path = $root_path; |
|
| 48 | + $this->tree = $tree; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * {@inhericDoc} |
|
| 53 | - * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getRealCertificatesDirectory() |
|
| 54 | - */ |
|
| 55 | - public function getRealCertificatesDirectory(){ |
|
| 56 | - return WT_DATA_DIR . $this->root_path; |
|
| 57 | - } |
|
| 51 | + /** |
|
| 52 | + * {@inhericDoc} |
|
| 53 | + * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getRealCertificatesDirectory() |
|
| 54 | + */ |
|
| 55 | + public function getRealCertificatesDirectory(){ |
|
| 56 | + return WT_DATA_DIR . $this->root_path; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * {@inhericDoc} |
|
| 61 | - * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCitiesList() |
|
| 62 | - */ |
|
| 63 | - public function getCitiesList(){ |
|
| 64 | - if(!isset($this->cities_list) || is_null($this->cities_list)){ |
|
| 65 | - $certdir = $this->getRealCertificatesDirectory(); |
|
| 66 | - $this->cities_list = array(); |
|
| 59 | + /** |
|
| 60 | + * {@inhericDoc} |
|
| 61 | + * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCitiesList() |
|
| 62 | + */ |
|
| 63 | + public function getCitiesList(){ |
|
| 64 | + if(!isset($this->cities_list) || is_null($this->cities_list)){ |
|
| 65 | + $certdir = $this->getRealCertificatesDirectory(); |
|
| 66 | + $this->cities_list = array(); |
|
| 67 | 67 | |
| 68 | - $dir = opendir($certdir); |
|
| 68 | + $dir = opendir($certdir); |
|
| 69 | 69 | |
| 70 | - while($entry = readdir($dir)){ |
|
| 71 | - if($entry != '.' && $entry != '..' && is_dir($certdir.$entry)){ |
|
| 72 | - $this->cities_list[]= Functions::encodeFileSystemToUtf8($entry); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - sort($this->cities_list); |
|
| 76 | - } |
|
| 77 | - return $this->cities_list; |
|
| 78 | - } |
|
| 70 | + while($entry = readdir($dir)){ |
|
| 71 | + if($entry != '.' && $entry != '..' && is_dir($certdir.$entry)){ |
|
| 72 | + $this->cities_list[]= Functions::encodeFileSystemToUtf8($entry); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + sort($this->cities_list); |
|
| 76 | + } |
|
| 77 | + return $this->cities_list; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * {@inhericDoc} |
|
| 82 | - * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList() |
|
| 83 | - */ |
|
| 84 | - public function getCertificatesList($selCity){ |
|
| 80 | + /** |
|
| 81 | + * {@inhericDoc} |
|
| 82 | + * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList() |
|
| 83 | + */ |
|
| 84 | + public function getCertificatesList($selCity){ |
|
| 85 | 85 | |
| 86 | - $selCity = Functions::encodeUtf8ToFileSystem($selCity); |
|
| 86 | + $selCity = Functions::encodeUtf8ToFileSystem($selCity); |
|
| 87 | 87 | |
| 88 | - $certdir = $this->getRealCertificatesDirectory(); |
|
| 89 | - $tabCertif= array(); |
|
| 88 | + $certdir = $this->getRealCertificatesDirectory(); |
|
| 89 | + $tabCertif= array(); |
|
| 90 | 90 | |
| 91 | - if(is_dir($certdir.$selCity)){ |
|
| 92 | - $dir=opendir($certdir.$selCity); |
|
| 93 | - while($entry = readdir($dir)){ |
|
| 94 | - if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){ |
|
| 95 | - $path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry); |
|
| 96 | - $certificate = new Certificate($path, $this->tree, $this); |
|
| 97 | - if(Functions::isImageTypeSupported($certificate->extension())){ |
|
| 98 | - $tabCertif[] = $certificate; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - return $tabCertif; |
|
| 104 | - } |
|
| 91 | + if(is_dir($certdir.$selCity)){ |
|
| 92 | + $dir=opendir($certdir.$selCity); |
|
| 93 | + while($entry = readdir($dir)){ |
|
| 94 | + if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){ |
|
| 95 | + $path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry); |
|
| 96 | + $certificate = new Certificate($path, $this->tree, $this); |
|
| 97 | + if(Functions::isImageTypeSupported($certificate->extension())){ |
|
| 98 | + $tabCertif[] = $certificate; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + return $tabCertif; |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * {@inhericDoc} |
|
| 108 | - * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesListBeginWith() |
|
| 109 | - */ |
|
| 110 | - public function getCertificatesListBeginWith($city, $contains, $limit= 9999){ |
|
| 111 | - $tabFiles= array(); |
|
| 112 | - $dirPath= $this->getRealCertificatesDirectory() . Functions::encodeUtf8ToFileSystem($city).'/'; |
|
| 113 | - $contains = utf8_decode($contains); |
|
| 114 | - $nbCert = 0; |
|
| 106 | + /** |
|
| 107 | + * {@inhericDoc} |
|
| 108 | + * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesListBeginWith() |
|
| 109 | + */ |
|
| 110 | + public function getCertificatesListBeginWith($city, $contains, $limit= 9999){ |
|
| 111 | + $tabFiles= array(); |
|
| 112 | + $dirPath= $this->getRealCertificatesDirectory() . Functions::encodeUtf8ToFileSystem($city).'/'; |
|
| 113 | + $contains = utf8_decode($contains); |
|
| 114 | + $nbCert = 0; |
|
| 115 | 115 | |
| 116 | - if(is_dir($dirPath)){ |
|
| 117 | - $dir=opendir($dirPath); |
|
| 118 | - while(($entry = readdir($dir)) && $nbCert < $limit){ |
|
| 119 | - if($entry!='.' && $entry!='..' && $entry!='Thumbs.db' &&!is_dir($dirPath.$entry.'/') && stripos($entry, $contains)!== false){ |
|
| 120 | - $tabFiles[]= Functions::encodeFileSystemToUtf8($entry); |
|
| 121 | - $nbCert++; |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - sort($tabFiles); |
|
| 126 | - return $tabFiles; |
|
| 127 | - } |
|
| 116 | + if(is_dir($dirPath)){ |
|
| 117 | + $dir=opendir($dirPath); |
|
| 118 | + while(($entry = readdir($dir)) && $nbCert < $limit){ |
|
| 119 | + if($entry!='.' && $entry!='..' && $entry!='Thumbs.db' &&!is_dir($dirPath.$entry.'/') && stripos($entry, $contains)!== false){ |
|
| 120 | + $tabFiles[]= Functions::encodeFileSystemToUtf8($entry); |
|
| 121 | + $nbCert++; |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + sort($tabFiles); |
|
| 126 | + return $tabFiles; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | * {@inhericDoc} |
| 53 | 53 | * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getRealCertificatesDirectory() |
| 54 | 54 | */ |
| 55 | - public function getRealCertificatesDirectory(){ |
|
| 56 | - return WT_DATA_DIR . $this->root_path; |
|
| 55 | + public function getRealCertificatesDirectory() { |
|
| 56 | + return WT_DATA_DIR.$this->root_path; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * {@inhericDoc} |
| 61 | 61 | * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCitiesList() |
| 62 | 62 | */ |
| 63 | - public function getCitiesList(){ |
|
| 64 | - if(!isset($this->cities_list) || is_null($this->cities_list)){ |
|
| 63 | + public function getCitiesList() { |
|
| 64 | + if (!isset($this->cities_list) || is_null($this->cities_list)) { |
|
| 65 | 65 | $certdir = $this->getRealCertificatesDirectory(); |
| 66 | 66 | $this->cities_list = array(); |
| 67 | 67 | |
| 68 | 68 | $dir = opendir($certdir); |
| 69 | 69 | |
| 70 | - while($entry = readdir($dir)){ |
|
| 71 | - if($entry != '.' && $entry != '..' && is_dir($certdir.$entry)){ |
|
| 72 | - $this->cities_list[]= Functions::encodeFileSystemToUtf8($entry); |
|
| 70 | + while ($entry = readdir($dir)) { |
|
| 71 | + if ($entry != '.' && $entry != '..' && is_dir($certdir.$entry)) { |
|
| 72 | + $this->cities_list[] = Functions::encodeFileSystemToUtf8($entry); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | sort($this->cities_list); |
@@ -81,21 +81,21 @@ discard block |
||
| 81 | 81 | * {@inhericDoc} |
| 82 | 82 | * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList() |
| 83 | 83 | */ |
| 84 | - public function getCertificatesList($selCity){ |
|
| 84 | + public function getCertificatesList($selCity) { |
|
| 85 | 85 | |
| 86 | 86 | $selCity = Functions::encodeUtf8ToFileSystem($selCity); |
| 87 | 87 | |
| 88 | 88 | $certdir = $this->getRealCertificatesDirectory(); |
| 89 | - $tabCertif= array(); |
|
| 89 | + $tabCertif = array(); |
|
| 90 | 90 | |
| 91 | - if(is_dir($certdir.$selCity)){ |
|
| 92 | - $dir=opendir($certdir.$selCity); |
|
| 93 | - while($entry = readdir($dir)){ |
|
| 94 | - if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){ |
|
| 91 | + if (is_dir($certdir.$selCity)) { |
|
| 92 | + $dir = opendir($certdir.$selCity); |
|
| 93 | + while ($entry = readdir($dir)) { |
|
| 94 | + if ($entry != '.' && $entry != '..' && !is_dir($certdir.$entry.'/')) { |
|
| 95 | 95 | $path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry); |
| 96 | 96 | $certificate = new Certificate($path, $this->tree, $this); |
| 97 | - if(Functions::isImageTypeSupported($certificate->extension())){ |
|
| 98 | - $tabCertif[] = $certificate; |
|
| 97 | + if (Functions::isImageTypeSupported($certificate->extension())) { |
|
| 98 | + $tabCertif[] = $certificate; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | * {@inhericDoc} |
| 108 | 108 | * @see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesListBeginWith() |
| 109 | 109 | */ |
| 110 | - public function getCertificatesListBeginWith($city, $contains, $limit= 9999){ |
|
| 111 | - $tabFiles= array(); |
|
| 112 | - $dirPath= $this->getRealCertificatesDirectory() . Functions::encodeUtf8ToFileSystem($city).'/'; |
|
| 110 | + public function getCertificatesListBeginWith($city, $contains, $limit = 9999) { |
|
| 111 | + $tabFiles = array(); |
|
| 112 | + $dirPath = $this->getRealCertificatesDirectory().Functions::encodeUtf8ToFileSystem($city).'/'; |
|
| 113 | 113 | $contains = utf8_decode($contains); |
| 114 | 114 | $nbCert = 0; |
| 115 | 115 | |
| 116 | - if(is_dir($dirPath)){ |
|
| 117 | - $dir=opendir($dirPath); |
|
| 118 | - while(($entry = readdir($dir)) && $nbCert < $limit){ |
|
| 119 | - if($entry!='.' && $entry!='..' && $entry!='Thumbs.db' &&!is_dir($dirPath.$entry.'/') && stripos($entry, $contains)!== false){ |
|
| 120 | - $tabFiles[]= Functions::encodeFileSystemToUtf8($entry); |
|
| 116 | + if (is_dir($dirPath)) { |
|
| 117 | + $dir = opendir($dirPath); |
|
| 118 | + while (($entry = readdir($dir)) && $nbCert < $limit) { |
|
| 119 | + if ($entry != '.' && $entry != '..' && $entry != 'Thumbs.db' && !is_dir($dirPath.$entry.'/') && stripos($entry, $contains) !== false) { |
|
| 120 | + $tabFiles[] = Functions::encodeFileSystemToUtf8($entry); |
|
| 121 | 121 | $nbCert++; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @return string HTML code of the inserted flag |
| 80 | 80 | */ |
| 81 | 81 | public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
| 82 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
| 82 | + return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * @return boolean |
| 356 | 356 | */ |
| 357 | 357 | public static function isDateWithinChartsRange(Date $date) { |
| 358 | - return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030; |
|
| 358 | + return $date->gregorianYear() >= 1550 && $date->gregorianYear() < 2030; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @return string List of elements |
| 33 | 33 | */ |
| 34 | 34 | public static function getListFromArray(array $array) { |
| 35 | - $n=count($array); |
|
| 35 | + $n = count($array); |
|
| 36 | 36 | switch ($n) { |
| 37 | 37 | case 0: |
| 38 | 38 | return ''; |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | default: |
| 42 | 42 | return implode( |
| 43 | 43 | /* I18N: list separator */ I18N::translate(', '), |
| 44 | - array_slice($array, 0, $n-1) |
|
| 45 | - ) . |
|
| 46 | - /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and ') . |
|
| 47 | - $array[$n-1]; |
|
| 44 | + array_slice($array, 0, $n - 1) |
|
| 45 | + ). |
|
| 46 | + /* I18N: last list separator, " and " in English, " et " in French */ I18N::translate(' and '). |
|
| 47 | + $array[$n - 1]; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider |
| 61 | 61 | ) { |
| 62 | 62 | $place = $fact->getPlace(); |
| 63 | - if(!$place->isEmpty()) { |
|
| 64 | - $iconPlace= $mapProvider->getPlaceIcon($place); |
|
| 65 | - if($iconPlace && strlen($iconPlace) > 0){ |
|
| 66 | - return '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; |
|
| 63 | + if (!$place->isEmpty()) { |
|
| 64 | + $iconPlace = $mapProvider->getPlaceIcon($place); |
|
| 65 | + if ($iconPlace && strlen($iconPlace) > 0) { |
|
| 66 | + return '<div class="fact_flag">'.self::htmlPlaceIcon($place, $iconPlace, 50).'</div>'; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | return ''; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | * @param number $size |
| 78 | 78 | * @return string HTML code of the inserted flag |
| 79 | 79 | */ |
| 80 | - public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { |
|
| 81 | - return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; |
|
| 80 | + public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path, $size = 50) { |
|
| 81 | + return '<img class="flag_gm_h'.$size.'" src="'.$icon_path.'" title="'.$place->getGedcomName().'" alt="'.$place->getGedcomName().'" />'; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $minimum = PHP_INT_MAX; |
| 97 | 97 | $maximum = 1; |
| 98 | 98 | foreach ($list as $params) { |
| 99 | - if(array_key_exists('count', $params)) { |
|
| 99 | + if (array_key_exists('count', $params)) { |
|
| 100 | 100 | $maximum = max($maximum, $params['count']); |
| 101 | 101 | $minimum = min($minimum, $params['count']); |
| 102 | 102 | } |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | $size = 75.0 + 125.0 * ($count - $minimum) / ($maximum - $minimum); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $html .= '<a style="font-size:' . $size . '%" href="' . $url . '">'; |
|
| 117 | + $html .= '<a style="font-size:'.$size.'%" href="'.$url.'">'; |
|
| 118 | 118 | if ($totals) { |
| 119 | - $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $text . '</span>', I18N::number($count)); |
|
| 119 | + $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">'.$text.'</span>', I18N::number($count)); |
|
| 120 | 120 | } else { |
| 121 | 121 | $html .= $text; |
| 122 | 122 | } |
| 123 | 123 | $html .= '</a>'; |
| 124 | 124 | } |
| 125 | - return '<div class="tag_cloud">' . $html . '</div>'; |
|
| 125 | + return '<div class="tag_cloud">'.$html.'</div>'; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | * @param bool $isStrong Bolden the name ? |
| 158 | 158 | * @return string HTML Code for individual item |
| 159 | 159 | */ |
| 160 | - public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
|
| 160 | + public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true) { |
|
| 161 | 161 | $html = ''; |
| 162 | 162 | $tag = 'em'; |
| 163 | - if($isStrong) $tag = 'strong'; |
|
| 164 | - if($individual && $individual->canShow()){ |
|
| 163 | + if ($isStrong) $tag = 'strong'; |
|
| 164 | + if ($individual && $individual->canShow()) { |
|
| 165 | 165 | $dindi = new Individual($individual); |
| 166 | 166 | $html = $individual->getSexImage(); |
| 167 | 167 | $html .= '<a class="list_item" href="'. |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $html .= '</a>'; |
| 177 | 177 | } |
| 178 | 178 | else { |
| 179 | - $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
|
| 179 | + $html .= '<span class=\"list_item\"><'.$tag.'>'.I18N::translate('Private').'</'.$tag.'></span>'; |
|
| 180 | 180 | } |
| 181 | 181 | return $html; |
| 182 | 182 | } |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | * @param boolean $anchor option to print a link to calendar |
| 189 | 189 | * @return string HTML code for short date |
| 190 | 190 | */ |
| 191 | - public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor=false) { |
|
| 192 | - $html=''; |
|
| 191 | + public static function formatFactDateShort(\Fisharebest\Webtrees\Fact $fact, $anchor = false) { |
|
| 192 | + $html = ''; |
|
| 193 | 193 | $date = $fact->getDate(); |
| 194 | - if($date->isOK()){ |
|
| 195 | - $html.=' '.$date->Display($anchor && !Globals::isSearchSpider(), '%Y'); |
|
| 194 | + if ($date->isOK()) { |
|
| 195 | + $html .= ' '.$date->Display($anchor && !Globals::isSearchSpider(), '%Y'); |
|
| 196 | 196 | } |
| 197 | - else{ |
|
| 197 | + else { |
|
| 198 | 198 | // 1 DEAT Y with no DATE => print YES |
| 199 | 199 | // 1 BIRT 2 SOUR @S1@ => print YES |
| 200 | 200 | // 1 DEAT N is not allowed |
| 201 | 201 | // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen. |
| 202 | 202 | $factdetail = explode(' ', trim($fact->getGedcom())); |
| 203 | 203 | if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || (count($factdetail) == 4 && $factdetail[2] == 'SOUR')) { |
| 204 | - $html.=I18N::translate('yes'); |
|
| 204 | + $html .= I18N::translate('yes'); |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | return $html; |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @param boolean $anchor option to print a link to placelist |
| 216 | 216 | * @return string HTML code for short place |
| 217 | 217 | */ |
| 218 | - public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
|
| 219 | - $html=''; |
|
| 218 | + public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor = false) { |
|
| 219 | + $html = ''; |
|
| 220 | 220 | |
| 221 | 221 | if ($fact === null) return $html; |
| 222 | 222 | $place = $fact->getPlace(); |
| 223 | - if($place){ |
|
| 223 | + if ($place) { |
|
| 224 | 224 | $dplace = new Place($place); |
| 225 | 225 | $html .= $dplace->htmlFormattedName($format, $anchor); |
| 226 | 226 | } |
@@ -238,21 +238,21 @@ discard block |
||
| 238 | 238 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
| 239 | 239 | * @return string HTML code for the formatted Sosa numbers |
| 240 | 240 | */ |
| 241 | - public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small'){ |
|
| 241 | + public static function formatSosaNumbers(array $sosatab, $format = 1, $size = 'small') { |
|
| 242 | 242 | $html = ''; |
| 243 | - switch($format){ |
|
| 243 | + switch ($format) { |
|
| 244 | 244 | case 1: |
| 245 | - if(count($sosatab)>0){ |
|
| 245 | + if (count($sosatab) > 0) { |
|
| 246 | 246 | $html = '<i class="icon-maj-sosa_'.$size.'" title="'.I18N::translate('Sosa').'"></i>'; |
| 247 | 247 | } |
| 248 | 248 | break; |
| 249 | 249 | case 2: |
| 250 | - if(count($sosatab)>0){ |
|
| 250 | + if (count($sosatab) > 0) { |
|
| 251 | 251 | ksort($sosatab); |
| 252 | 252 | $tmp_html = array(); |
| 253 | 253 | foreach ($sosatab as $sosa => $gen) { |
| 254 | 254 | $tmp_html[] = sprintf( |
| 255 | - '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen) .'</strong>', |
|
| 255 | + '<i class="icon-maj-sosa_%1$s" title="'.I18N::translate('Sosa').'"></i> <strong>%2$d '.I18N::translate('(G%s)', $gen).'</strong>', |
|
| 256 | 256 | $size, |
| 257 | 257 | $sosa |
| 258 | 258 | ); |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | * @param string $size CSS size for the icon. A CSS style css_$size is required |
| 279 | 279 | * @return string HTML code for IsSourced icon |
| 280 | 280 | */ |
| 281 | - public static function formatIsSourcedIcon($sourceType, $isSourced, $tag='EVEN', $format = 1, $size='normal'){ |
|
| 282 | - $html=''; |
|
| 283 | - $image=null; |
|
| 284 | - $title=null; |
|
| 285 | - switch($format){ |
|
| 281 | + public static function formatIsSourcedIcon($sourceType, $isSourced, $tag = 'EVEN', $format = 1, $size = 'normal') { |
|
| 282 | + $html = ''; |
|
| 283 | + $image = null; |
|
| 284 | + $title = null; |
|
| 285 | + switch ($format) { |
|
| 286 | 286 | case 1: |
| 287 | - switch($sourceType){ |
|
| 287 | + switch ($sourceType) { |
|
| 288 | 288 | case 'E': |
| 289 | - switch($isSourced){ |
|
| 289 | + switch ($isSourced) { |
|
| 290 | 290 | case 0: |
| 291 | 291 | $image = 'event_unknown'; |
| 292 | 292 | $title = I18N::translate('%s not found', GedcomTag::getLabel($tag)); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | break; |
| 318 | 318 | case 'R': |
| 319 | - switch($isSourced){ |
|
| 319 | + switch ($isSourced) { |
|
| 320 | 320 | case -1: |
| 321 | 321 | $image = 'record_notsourced'; |
| 322 | 322 | $title = I18N::translate('%s not sourced', GedcomTag::getLabel($tag)); |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | default: |
| 337 | 337 | break; |
| 338 | 338 | } |
| 339 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
| 339 | + if ($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
| 340 | 340 | break; |
| 341 | 341 | default: |
| 342 | 342 | break; |
@@ -160,7 +160,9 @@ discard block |
||
| 160 | 160 | public static function htmlIndividualForList(\Fisharebest\Webtrees\Individual $individual, $isStrong = true){ |
| 161 | 161 | $html = ''; |
| 162 | 162 | $tag = 'em'; |
| 163 | - if($isStrong) $tag = 'strong'; |
|
| 163 | + if($isStrong) { |
|
| 164 | + $tag = 'strong'; |
|
| 165 | + } |
|
| 164 | 166 | if($individual && $individual->canShow()){ |
| 165 | 167 | $dindi = new Individual($individual); |
| 166 | 168 | $html = $individual->getSexImage(); |
@@ -174,8 +176,7 @@ discard block |
||
| 174 | 176 | $html .= ' <span><small><em>'.$dindi->formatFirstMajorFact(WT_EVENTS_BIRT, 10).'</em></small></span>'; |
| 175 | 177 | $html .= ' <span><small><em>'.$dindi->formatFirstMajorFact(WT_EVENTS_DEAT, 10).'</em></small></span>'; |
| 176 | 178 | $html .= '</a>'; |
| 177 | - } |
|
| 178 | - else { |
|
| 179 | + } else { |
|
| 179 | 180 | $html .= '<span class=\"list_item\"><'.$tag.'>' . I18N::translate('Private') . '</'.$tag.'></span>'; |
| 180 | 181 | } |
| 181 | 182 | return $html; |
@@ -193,8 +194,7 @@ discard block |
||
| 193 | 194 | $date = $fact->getDate(); |
| 194 | 195 | if($date->isOK()){ |
| 195 | 196 | $html.=' '.$date->Display($anchor && !Globals::isSearchSpider(), '%Y'); |
| 196 | - } |
|
| 197 | - else{ |
|
| 197 | + } else{ |
|
| 198 | 198 | // 1 DEAT Y with no DATE => print YES |
| 199 | 199 | // 1 BIRT 2 SOUR @S1@ => print YES |
| 200 | 200 | // 1 DEAT N is not allowed |
@@ -218,7 +218,9 @@ discard block |
||
| 218 | 218 | public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ |
| 219 | 219 | $html=''; |
| 220 | 220 | |
| 221 | - if ($fact === null) return $html; |
|
| 221 | + if ($fact === null) { |
|
| 222 | + return $html; |
|
| 223 | + } |
|
| 222 | 224 | $place = $fact->getPlace(); |
| 223 | 225 | if($place){ |
| 224 | 226 | $dplace = new Place($place); |
@@ -336,7 +338,9 @@ discard block |
||
| 336 | 338 | default: |
| 337 | 339 | break; |
| 338 | 340 | } |
| 339 | - if($image && $title) $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
| 341 | + if($image && $title) { |
|
| 342 | + $html = '<i class="icon-maj-sourced-'.$size.'_'.$image.'" title="'.$title.'"></i>'; |
|
| 343 | + } |
|
| 340 | 344 | break; |
| 341 | 345 | default: |
| 342 | 346 | break; |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | * @param string $gedcom |
| 31 | 31 | * @return NULL|\MyArtJaub\Webtrees\Family |
| 32 | 32 | */ |
| 33 | - public static function getIntance($xref, Tree $tree, $gedcom = null){ |
|
| 33 | + public static function getIntance($xref, Tree $tree, $gedcom = null) { |
|
| 34 | 34 | $dfam = null; |
| 35 | 35 | $fam = fw\Family::getInstance($xref, $tree, $gedcom); |
| 36 | - if($fam){ |
|
| 36 | + if ($fam) { |
|
| 37 | 37 | $dfam = new Family($fam); |
| 38 | 38 | } |
| 39 | 39 | return $dfam; |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return int Level of sources |
| 46 | 46 | * */ |
| 47 | - function isMarriageSourced(){ |
|
| 48 | - if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
|
| 47 | + function isMarriageSourced() { |
|
| 48 | + if ($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
|
| 49 | 49 | $this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
| 50 | 50 | return $this->is_marriage_sourced; |
| 51 | 51 | } |
@@ -45,7 +45,9 @@ |
||
| 45 | 45 | * @return int Level of sources |
| 46 | 46 | * */ |
| 47 | 47 | function isMarriageSourced(){ |
| 48 | - if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
|
| 48 | + if($this->is_marriage_sourced !== null) { |
|
| 49 | + return $this->is_marriage_sourced; |
|
| 50 | + } |
|
| 49 | 51 | $this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
| 50 | 52 | return $this->is_marriage_sourced; |
| 51 | 53 | } |
@@ -40,10 +40,10 @@ |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * Check if this family's marriages are sourced |
|
| 44 | - * |
|
| 45 | - * @return int Level of sources |
|
| 46 | - * */ |
|
| 43 | + * Check if this family's marriages are sourced |
|
| 44 | + * |
|
| 45 | + * @return int Level of sources |
|
| 46 | + * */ |
|
| 47 | 47 | function isMarriageSourced(){ |
| 48 | 48 | if($this->is_marriage_sourced !== null) return $this->is_marriage_sourced; |
| 49 | 49 | $this->is_marriage_sourced = $this->isFactSourced(WT_EVENTS_MARR.'|MARC'); |
@@ -113,29 +113,29 @@ discard block |
||
| 113 | 113 | * @return string|array Estimated birth place if found, null otherwise |
| 114 | 114 | */ |
| 115 | 115 | public function getSignificantPlace(){ |
| 116 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
| 117 | - return $bplace; |
|
| 118 | - } |
|
| 116 | + if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
| 117 | + return $bplace; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { |
|
| 121 | - if ($rplace) { |
|
| 122 | - return $rplace; |
|
| 123 | - } |
|
| 124 | - } |
|
| 120 | + foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { |
|
| 121 | + if ($rplace) { |
|
| 122 | + return $rplace; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
| 127 | - return $dplace; |
|
| 128 | - } |
|
| 126 | + if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
| 127 | + return $dplace; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
| 131 | - foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
|
| 132 | - if ($rplace) { |
|
| 133 | - return $rplace; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 130 | + foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
| 131 | + foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
|
| 132 | + if ($rplace) { |
|
| 133 | + return $rplace; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - return null; |
|
| 138 | + return null; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @return boolean Is the individual a Sosa ancestor |
| 145 | 145 | */ |
| 146 | 146 | public function isSosa(){ |
| 147 | - return count($this->getSosaNumbers()) > 0; |
|
| 147 | + return count($this->getSosaNumbers()) > 0; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @return array List of Sosa numbers |
| 156 | 156 | */ |
| 157 | 157 | public function getSosaNumbers(){ |
| 158 | - if($this->sosa === null) { |
|
| 159 | - $provider = new SosaProvider($this->gedcomrecord->getTree()); |
|
| 160 | - $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); |
|
| 161 | - } |
|
| 162 | - return $this->sosa; |
|
| 158 | + if($this->sosa === null) { |
|
| 159 | + $provider = new SosaProvider($this->gedcomrecord->getTree()); |
|
| 160 | + $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); |
|
| 161 | + } |
|
| 162 | + return $this->sosa; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Check if this individual's death is sourced |
|
| 178 | - * |
|
| 179 | - * @return int Level of sources |
|
| 180 | - * */ |
|
| 177 | + * Check if this individual's death is sourced |
|
| 178 | + * |
|
| 179 | + * @return int Level of sources |
|
| 180 | + * */ |
|
| 181 | 181 | public function isDeathSourced(){ |
| 182 | 182 | if($this->is_death_sourced !== null) return $this->is_death_sourced; |
| 183 | 183 | $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | class Individual extends GedcomRecord { |
| 22 | 22 | |
| 23 | 23 | /** @var array|null List of titles the individal holds */ |
| 24 | - protected $titles=null; |
|
| 24 | + protected $titles = null; |
|
| 25 | 25 | |
| 26 | 26 | /** @var string|null Individual's primary surname, without any privacy applied to it */ |
| 27 | 27 | protected $unprotected_prim_surname = null; |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param null|string $gedcom |
| 44 | 44 | * @return null|Individual |
| 45 | 45 | */ |
| 46 | - public static function getIntance($xref, Tree $tree, $gedcom = null){ |
|
| 46 | + public static function getIntance($xref, Tree $tree, $gedcom = null) { |
|
| 47 | 47 | $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); |
| 48 | - if($indi){ |
|
| 48 | + if ($indi) { |
|
| 49 | 49 | return new Individual($indi); |
| 50 | 50 | } |
| 51 | 51 | return null; |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return array Array of titles |
| 58 | 58 | */ |
| 59 | - public function getTitles(){ |
|
| 60 | - if(is_null($this->titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)){ |
|
| 59 | + public function getTitles() { |
|
| 60 | + if (is_null($this->titles) && $module = Module::getModuleByName(Constants::MODULE_MAJ_MISC_NAME)) { |
|
| 61 | 61 | $pattern = '/(.*) (('.$module->getSetting('MAJ_TITLE_PREFIX', '').')(.*))/'; |
| 62 | - $this->titles=array(); |
|
| 62 | + $this->titles = array(); |
|
| 63 | 63 | $titlefacts = $this->gedcomrecord->getFacts('TITL'); |
| 64 | - foreach($titlefacts as $titlefact){ |
|
| 64 | + foreach ($titlefacts as $titlefact) { |
|
| 65 | 65 | $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2); |
| 66 | - if($ct2>0){ |
|
| 67 | - $this->titles[$match2[1][0]][]= trim($match2[2][0]); |
|
| 66 | + if ($ct2 > 0) { |
|
| 67 | + $this->titles[$match2[1][0]][] = trim($match2[2][0]); |
|
| 68 | 68 | } |
| 69 | - else{ |
|
| 70 | - $this->titles[$titlefact->getValue()][]=''; |
|
| 69 | + else { |
|
| 70 | + $this->titles[$titlefact->getValue()][] = ''; |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | * @return string Primary surname |
| 82 | 82 | */ |
| 83 | 83 | public function getUnprotectedPrimarySurname() { |
| 84 | - if(!$this->unprotected_prim_surname){ |
|
| 85 | - $tmp=$this->gedcomrecord->getAllNames(); |
|
| 84 | + if (!$this->unprotected_prim_surname) { |
|
| 85 | + $tmp = $this->gedcomrecord->getAllNames(); |
|
| 86 | 86 | $this->unprotected_prim_surname = $tmp[$this->gedcomrecord->getPrimaryName()]['surname']; |
| 87 | 87 | } |
| 88 | 88 | return $this->unprotected_prim_surname; |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | * @param boolean $perc Should the coefficient of reliability be returned |
| 95 | 95 | * @return string|array Estimated birth place if found, null otherwise |
| 96 | 96 | */ |
| 97 | - public function getEstimatedBirthPlace($perc=false){ |
|
| 98 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
| 99 | - if($perc){ |
|
| 100 | - return array ($bplace, 1); |
|
| 97 | + public function getEstimatedBirthPlace($perc = false) { |
|
| 98 | + if ($bplace = $this->gedcomrecord->getBirthPlace()) { |
|
| 99 | + if ($perc) { |
|
| 100 | + return array($bplace, 1); |
|
| 101 | 101 | } |
| 102 | - else{ |
|
| 102 | + else { |
|
| 103 | 103 | return $bplace; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * @param boolean $perc Should the coefficient of reliability be returned |
| 113 | 113 | * @return string|array Estimated birth place if found, null otherwise |
| 114 | 114 | */ |
| 115 | - public function getSignificantPlace(){ |
|
| 116 | - if($bplace = $this->gedcomrecord->getBirthPlace()){ |
|
| 115 | + public function getSignificantPlace() { |
|
| 116 | + if ($bplace = $this->gedcomrecord->getBirthPlace()) { |
|
| 117 | 117 | return $bplace; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if($dplace = $this->gedcomrecord->getDeathPlace()){ |
|
| 126 | + if ($dplace = $this->gedcomrecord->getDeathPlace()) { |
|
| 127 | 127 | return $dplace; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
| 130 | + foreach ($this->gedcomrecord->getSpouseFamilies() as $fams) { |
|
| 131 | 131 | foreach ($fams->getAllEventPlaces('RESI') as $rplace) { |
| 132 | 132 | if ($rplace) { |
| 133 | 133 | return $rplace; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return boolean Is the individual a Sosa ancestor |
| 145 | 145 | */ |
| 146 | - public function isSosa(){ |
|
| 146 | + public function isSosa() { |
|
| 147 | 147 | return count($this->getSosaNumbers()) > 0; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | * @uses \MyArtJaub\Webtrees\Functions\ModuleManager |
| 155 | 155 | * @return array List of Sosa numbers |
| 156 | 156 | */ |
| 157 | - public function getSosaNumbers(){ |
|
| 158 | - if($this->sosa === null) { |
|
| 157 | + public function getSosaNumbers() { |
|
| 158 | + if ($this->sosa === null) { |
|
| 159 | 159 | $provider = new SosaProvider($this->gedcomrecord->getTree()); |
| 160 | 160 | $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); |
| 161 | 161 | } |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return int Level of sources |
| 169 | 169 | * */ |
| 170 | - public function isBirthSourced(){ |
|
| 171 | - if($this->is_birth_sourced !== null) return $this->is_birth_sourced; |
|
| 170 | + public function isBirthSourced() { |
|
| 171 | + if ($this->is_birth_sourced !== null) return $this->is_birth_sourced; |
|
| 172 | 172 | $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); |
| 173 | 173 | return $this->is_birth_sourced; |
| 174 | 174 | } |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return int Level of sources |
| 180 | 180 | * */ |
| 181 | - public function isDeathSourced(){ |
|
| 182 | - if($this->is_death_sourced !== null) return $this->is_death_sourced; |
|
| 181 | + public function isDeathSourced() { |
|
| 182 | + if ($this->is_death_sourced !== null) return $this->is_death_sourced; |
|
| 183 | 183 | $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); |
| 184 | 184 | return $this->is_death_sourced; |
| 185 | 185 | } |
@@ -65,8 +65,7 @@ discard block |
||
| 65 | 65 | $ct2 = preg_match_all($pattern, $titlefact->getValue(), $match2); |
| 66 | 66 | if($ct2>0){ |
| 67 | 67 | $this->titles[$match2[1][0]][]= trim($match2[2][0]); |
| 68 | - } |
|
| 69 | - else{ |
|
| 68 | + } else{ |
|
| 70 | 69 | $this->titles[$titlefact->getValue()][]=''; |
| 71 | 70 | } |
| 72 | 71 | } |
@@ -98,8 +97,7 @@ discard block |
||
| 98 | 97 | if($bplace = $this->gedcomrecord->getBirthPlace()){ |
| 99 | 98 | if($perc){ |
| 100 | 99 | return array ($bplace, 1); |
| 101 | - } |
|
| 102 | - else{ |
|
| 100 | + } else{ |
|
| 103 | 101 | return $bplace; |
| 104 | 102 | } |
| 105 | 103 | } |
@@ -168,7 +166,9 @@ discard block |
||
| 168 | 166 | * @return int Level of sources |
| 169 | 167 | * */ |
| 170 | 168 | public function isBirthSourced(){ |
| 171 | - if($this->is_birth_sourced !== null) return $this->is_birth_sourced; |
|
| 169 | + if($this->is_birth_sourced !== null) { |
|
| 170 | + return $this->is_birth_sourced; |
|
| 171 | + } |
|
| 172 | 172 | $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); |
| 173 | 173 | return $this->is_birth_sourced; |
| 174 | 174 | } |
@@ -179,7 +179,9 @@ discard block |
||
| 179 | 179 | * @return int Level of sources |
| 180 | 180 | * */ |
| 181 | 181 | public function isDeathSourced(){ |
| 182 | - if($this->is_death_sourced !== null) return $this->is_death_sourced; |
|
| 182 | + if($this->is_death_sourced !== null) { |
|
| 183 | + return $this->is_death_sourced; |
|
| 184 | + } |
|
| 183 | 185 | $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); |
| 184 | 186 | return $this->is_death_sourced; |
| 185 | 187 | } |
@@ -20,253 +20,253 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class AbstractTask { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Time out for runnign tasks, in seconds. Default 5 min |
|
| 25 | - * @var int TASK_TIME_OUT |
|
| 26 | - */ |
|
| 27 | - const TASK_TIME_OUT = 300; |
|
| 23 | + /** |
|
| 24 | + * Time out for runnign tasks, in seconds. Default 5 min |
|
| 25 | + * @var int TASK_TIME_OUT |
|
| 26 | + */ |
|
| 27 | + const TASK_TIME_OUT = 300; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Task provider |
|
| 31 | - * @var TaskProviderInterface $provider |
|
| 32 | - */ |
|
| 29 | + /** |
|
| 30 | + * Task provider |
|
| 31 | + * @var TaskProviderInterface $provider |
|
| 32 | + */ |
|
| 33 | 33 | protected $provider; |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Task name |
| 37 | 37 | * @var string $name |
| 38 | 38 | */ |
| 39 | - protected $name; |
|
| 39 | + protected $name; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Status of the task |
|
| 43 | - * @var bool $is_enabled |
|
| 44 | - */ |
|
| 45 | - protected $is_enabled; |
|
| 41 | + /** |
|
| 42 | + * Status of the task |
|
| 43 | + * @var bool $is_enabled |
|
| 44 | + */ |
|
| 45 | + protected $is_enabled; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Last updated date |
|
| 49 | - * @var \DateTime $last_updated |
|
| 50 | - */ |
|
| 51 | - protected $last_updated; |
|
| 47 | + /** |
|
| 48 | + * Last updated date |
|
| 49 | + * @var \DateTime $last_updated |
|
| 50 | + */ |
|
| 51 | + protected $last_updated; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Last run result |
|
| 55 | - * @var bool $last_result |
|
| 56 | - */ |
|
| 57 | - protected $last_result; |
|
| 53 | + /** |
|
| 54 | + * Last run result |
|
| 55 | + * @var bool $last_result |
|
| 56 | + */ |
|
| 57 | + protected $last_result; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Task run frequency |
|
| 61 | - * @var int $frequency |
|
| 62 | - */ |
|
| 63 | - protected $frequency; |
|
| 59 | + /** |
|
| 60 | + * Task run frequency |
|
| 61 | + * @var int $frequency |
|
| 62 | + */ |
|
| 63 | + protected $frequency; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Task remaining runs |
|
| 67 | - * @var int $nb_occurrences |
|
| 68 | - */ |
|
| 69 | - protected $nb_occurrences; |
|
| 65 | + /** |
|
| 66 | + * Task remaining runs |
|
| 67 | + * @var int $nb_occurrences |
|
| 68 | + */ |
|
| 69 | + protected $nb_occurrences; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Current running status of the task |
|
| 73 | - * @var bool $is_running |
|
| 74 | - */ |
|
| 75 | - protected $is_running; |
|
| 71 | + /** |
|
| 72 | + * Current running status of the task |
|
| 73 | + * @var bool $is_running |
|
| 74 | + */ |
|
| 75 | + protected $is_running; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Constructor for the Admin task class |
|
| 77 | + /** |
|
| 78 | + * Constructor for the Admin task class |
|
| 79 | 79 | * |
| 80 | 80 | * @param string $file Filename containing the task object |
| 81 | 81 | * @param TaskProviderInterface $provider Provider for tasks |
| 82 | - */ |
|
| 83 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
| 84 | - $this->name = trim(basename($file, '.php')); |
|
| 82 | + */ |
|
| 83 | + public function __construct($file, TaskProviderInterface $provider = null){ |
|
| 84 | + $this->name = trim(basename($file, '.php')); |
|
| 85 | 85 | $this->provider = $provider; |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Get the provider. |
|
| 90 | - * |
|
| 91 | - * @return TaskProviderInterface |
|
| 92 | - */ |
|
| 93 | - public function getProvider(){ |
|
| 94 | - return $this->provider; |
|
| 95 | - } |
|
| 88 | + /** |
|
| 89 | + * Get the provider. |
|
| 90 | + * |
|
| 91 | + * @return TaskProviderInterface |
|
| 92 | + */ |
|
| 93 | + public function getProvider(){ |
|
| 94 | + return $this->provider; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Set the provider. |
|
| 99 | - * |
|
| 100 | - * @param TaskProviderInterface $provider |
|
| 101 | - * @return self Enable method-chaining |
|
| 102 | - */ |
|
| 103 | - public function setProvider(TaskProviderInterface $provider){ |
|
| 104 | - $this->provider = $provider; |
|
| 105 | - return $this; |
|
| 106 | - } |
|
| 97 | + /** |
|
| 98 | + * Set the provider. |
|
| 99 | + * |
|
| 100 | + * @param TaskProviderInterface $provider |
|
| 101 | + * @return self Enable method-chaining |
|
| 102 | + */ |
|
| 103 | + public function setProvider(TaskProviderInterface $provider){ |
|
| 104 | + $this->provider = $provider; |
|
| 105 | + return $this; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Set parameters of the Task |
|
| 110 | - * |
|
| 111 | - * @param bool $is_enabled Status of the task |
|
| 112 | - * @param \DateTime $lastupdated Time of the last task run |
|
| 113 | - * @param bool $last_result Result of the last run, true for success, false for failure |
|
| 114 | - * @param int $frequency Frequency of execution in minutes |
|
| 115 | - * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
| 116 | - * @param bool $is_running Indicates if the task is currently running |
|
| 117 | - */ |
|
| 118 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
| 119 | - $this->is_enabled = $is_enabled; |
|
| 120 | - $this->last_updated = $last_updated; |
|
| 121 | - $this->last_result = $last_result; |
|
| 122 | - $this->frequency = $frequency; |
|
| 123 | - $this->nb_occurrences = $nb_occur; |
|
| 124 | - $this->is_running = $is_running; |
|
| 125 | - } |
|
| 108 | + /** |
|
| 109 | + * Set parameters of the Task |
|
| 110 | + * |
|
| 111 | + * @param bool $is_enabled Status of the task |
|
| 112 | + * @param \DateTime $lastupdated Time of the last task run |
|
| 113 | + * @param bool $last_result Result of the last run, true for success, false for failure |
|
| 114 | + * @param int $frequency Frequency of execution in minutes |
|
| 115 | + * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
|
| 116 | + * @param bool $is_running Indicates if the task is currently running |
|
| 117 | + */ |
|
| 118 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
| 119 | + $this->is_enabled = $is_enabled; |
|
| 120 | + $this->last_updated = $last_updated; |
|
| 121 | + $this->last_result = $last_result; |
|
| 122 | + $this->frequency = $frequency; |
|
| 123 | + $this->nb_occurrences = $nb_occur; |
|
| 124 | + $this->is_running = $is_running; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Get the name of the task |
|
| 129 | - * |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public function getName(){ |
|
| 133 | - return $this->name; |
|
| 134 | - } |
|
| 127 | + /** |
|
| 128 | + * Get the name of the task |
|
| 129 | + * |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public function getName(){ |
|
| 133 | + return $this->name; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Return the status of the task in a boolean way |
|
| 139 | - * |
|
| 140 | - * @return boolean True if enabled |
|
| 141 | - */ |
|
| 142 | - public function isEnabled(){ |
|
| 143 | - return $this->is_enabled; |
|
| 144 | - } |
|
| 137 | + /** |
|
| 138 | + * Return the status of the task in a boolean way |
|
| 139 | + * |
|
| 140 | + * @return boolean True if enabled |
|
| 141 | + */ |
|
| 142 | + public function isEnabled(){ |
|
| 143 | + return $this->is_enabled; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Get the last updated time. |
|
| 148 | - * |
|
| 149 | - * @return \DateTime |
|
| 150 | - */ |
|
| 151 | - public function getLastUpdated(){ |
|
| 152 | - return $this->last_updated; |
|
| 153 | - } |
|
| 146 | + /** |
|
| 147 | + * Get the last updated time. |
|
| 148 | + * |
|
| 149 | + * @return \DateTime |
|
| 150 | + */ |
|
| 151 | + public function getLastUpdated(){ |
|
| 152 | + return $this->last_updated; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * Check if the last result has been successful. |
|
| 157 | - * |
|
| 158 | - * @return bool |
|
| 159 | - */ |
|
| 160 | - public function isLastRunSuccess(){ |
|
| 161 | - return $this->last_result; |
|
| 162 | - } |
|
| 155 | + /** |
|
| 156 | + * Check if the last result has been successful. |
|
| 157 | + * |
|
| 158 | + * @return bool |
|
| 159 | + */ |
|
| 160 | + public function isLastRunSuccess(){ |
|
| 161 | + return $this->last_result; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Get the task frequency. |
|
| 166 | - * |
|
| 167 | - * @return int |
|
| 168 | - */ |
|
| 169 | - public function getFrequency(){ |
|
| 170 | - return $this->frequency; |
|
| 171 | - } |
|
| 164 | + /** |
|
| 165 | + * Get the task frequency. |
|
| 166 | + * |
|
| 167 | + * @return int |
|
| 168 | + */ |
|
| 169 | + public function getFrequency(){ |
|
| 170 | + return $this->frequency; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | - * Set the task frequency. |
|
| 175 | - * |
|
| 174 | + * Set the task frequency. |
|
| 175 | + * |
|
| 176 | 176 | * @param int $frequency |
| 177 | - * @return self Enable method-chaining |
|
| 178 | - */ |
|
| 179 | - public function setFrequency($frequency){ |
|
| 180 | - $this->frequency = $frequency; |
|
| 177 | + * @return self Enable method-chaining |
|
| 178 | + */ |
|
| 179 | + public function setFrequency($frequency){ |
|
| 180 | + $this->frequency = $frequency; |
|
| 181 | 181 | return $this; |
| 182 | - } |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Get the number of remaining occurrences. |
|
| 186 | - * |
|
| 187 | - * @return int |
|
| 188 | - */ |
|
| 189 | - public function getRemainingOccurrences(){ |
|
| 190 | - return $this->nb_occurrences; |
|
| 191 | - } |
|
| 184 | + /** |
|
| 185 | + * Get the number of remaining occurrences. |
|
| 186 | + * |
|
| 187 | + * @return int |
|
| 188 | + */ |
|
| 189 | + public function getRemainingOccurrences(){ |
|
| 190 | + return $this->nb_occurrences; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * Set the number of remaining occurrences. |
|
| 195 | - * |
|
| 194 | + * Set the number of remaining occurrences. |
|
| 195 | + * |
|
| 196 | 196 | * @param int $nb_occur |
| 197 | - * @return self Enable method-chaining |
|
| 198 | - */ |
|
| 199 | - public function setRemainingOccurrences($nb_occur){ |
|
| 200 | - $this->nb_occurrences = $nb_occur; |
|
| 197 | + * @return self Enable method-chaining |
|
| 198 | + */ |
|
| 199 | + public function setRemainingOccurrences($nb_occur){ |
|
| 200 | + $this->nb_occurrences = $nb_occur; |
|
| 201 | 201 | return $this; |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * Check if the task if running. |
|
| 206 | - * |
|
| 207 | - * @return bool |
|
| 208 | - */ |
|
| 209 | - public function isRunning(){ |
|
| 210 | - return $this->is_running; |
|
| 211 | - } |
|
| 204 | + /** |
|
| 205 | + * Check if the task if running. |
|
| 206 | + * |
|
| 207 | + * @return bool |
|
| 208 | + */ |
|
| 209 | + public function isRunning(){ |
|
| 210 | + return $this->is_running; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Return the name to display for the task |
|
| 216 | - * |
|
| 217 | - * @return string Title for the task |
|
| 218 | - */ |
|
| 219 | - abstract public function getTitle(); |
|
| 214 | + /** |
|
| 215 | + * Return the name to display for the task |
|
| 216 | + * |
|
| 217 | + * @return string Title for the task |
|
| 218 | + */ |
|
| 219 | + abstract public function getTitle(); |
|
| 220 | 220 | |
| 221 | - /** |
|
| 222 | - * Return the default frequency for the execution of the task |
|
| 223 | - * |
|
| 224 | - * @return int Frequency for the execution of the task |
|
| 225 | - */ |
|
| 226 | - abstract public function getDefaultFrequency(); |
|
| 221 | + /** |
|
| 222 | + * Return the default frequency for the execution of the task |
|
| 223 | + * |
|
| 224 | + * @return int Frequency for the execution of the task |
|
| 225 | + */ |
|
| 226 | + abstract public function getDefaultFrequency(); |
|
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Execute the task's actions |
|
| 230 | - */ |
|
| 231 | - abstract protected function executeSteps(); |
|
| 228 | + /** |
|
| 229 | + * Execute the task's actions |
|
| 230 | + */ |
|
| 231 | + abstract protected function executeSteps(); |
|
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * Persist task state into database. |
| 235 | 235 | * @return bool |
| 236 | 236 | */ |
| 237 | 237 | public function save() { |
| 238 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 238 | + if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 239 | 239 | return $this->provider->updateTask($this); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Execute the task, default skeleton |
|
| 244 | - * |
|
| 245 | - */ |
|
| 246 | - public function execute(){ |
|
| 242 | + /** |
|
| 243 | + * Execute the task, default skeleton |
|
| 244 | + * |
|
| 245 | + */ |
|
| 246 | + public function execute(){ |
|
| 247 | 247 | |
| 248 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 249 | - $this->is_running = false; |
|
| 248 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 249 | + $this->is_running = false; |
|
| 250 | 250 | |
| 251 | - if(!$this->is_running){ |
|
| 252 | - $this->last_result = false; |
|
| 253 | - $this->is_running = true; |
|
| 254 | - $this->save(); |
|
| 251 | + if(!$this->is_running){ |
|
| 252 | + $this->last_result = false; |
|
| 253 | + $this->is_running = true; |
|
| 254 | + $this->save(); |
|
| 255 | 255 | |
| 256 | - Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
| 257 | - $this->last_result = $this->executeSteps(); |
|
| 258 | - if($this->last_result){ |
|
| 259 | - $this->last_updated = new \DateTime(); |
|
| 260 | - if($this->nb_occurrences > 0){ |
|
| 261 | - $this->nb_occurrences--; |
|
| 262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - $this->is_running = false; |
|
| 266 | - $this->save(); |
|
| 267 | - Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
| 268 | - } |
|
| 269 | - } |
|
| 256 | + Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
|
| 257 | + $this->last_result = $this->executeSteps(); |
|
| 258 | + if($this->last_result){ |
|
| 259 | + $this->last_updated = new \DateTime(); |
|
| 260 | + if($this->nb_occurrences > 0){ |
|
| 261 | + $this->nb_occurrences--; |
|
| 262 | + if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + $this->is_running = false; |
|
| 266 | + $this->save(); |
|
| 267 | + Log::addDebugLog('Execution completed for Admin task: '.$this->getTitle().' - '.($this->last_result ? 'Success' : 'Failure')); |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param string $file Filename containing the task object |
| 81 | 81 | * @param TaskProviderInterface $provider Provider for tasks |
| 82 | 82 | */ |
| 83 | - public function __construct($file, TaskProviderInterface $provider = null){ |
|
| 83 | + public function __construct($file, TaskProviderInterface $provider = null) { |
|
| 84 | 84 | $this->name = trim(basename($file, '.php')); |
| 85 | 85 | $this->provider = $provider; |
| 86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return TaskProviderInterface |
| 92 | 92 | */ |
| 93 | - public function getProvider(){ |
|
| 93 | + public function getProvider() { |
|
| 94 | 94 | return $this->provider; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param TaskProviderInterface $provider |
| 101 | 101 | * @return self Enable method-chaining |
| 102 | 102 | */ |
| 103 | - public function setProvider(TaskProviderInterface $provider){ |
|
| 103 | + public function setProvider(TaskProviderInterface $provider) { |
|
| 104 | 104 | $this->provider = $provider; |
| 105 | 105 | return $this; |
| 106 | 106 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param int $nb_occur Number of remaining occurrences, 0 for tasks not limited |
| 116 | 116 | * @param bool $is_running Indicates if the task is currently running |
| 117 | 117 | */ |
| 118 | - public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running){ |
|
| 118 | + public function setParameters($is_enabled, \DateTime $last_updated, $last_result, $frequency, $nb_occur, $is_running) { |
|
| 119 | 119 | $this->is_enabled = $is_enabled; |
| 120 | 120 | $this->last_updated = $last_updated; |
| 121 | 121 | $this->last_result = $last_result; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public function getName(){ |
|
| 132 | + public function getName() { |
|
| 133 | 133 | return $this->name; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return boolean True if enabled |
| 141 | 141 | */ |
| 142 | - public function isEnabled(){ |
|
| 142 | + public function isEnabled() { |
|
| 143 | 143 | return $this->is_enabled; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return \DateTime |
| 150 | 150 | */ |
| 151 | - public function getLastUpdated(){ |
|
| 151 | + public function getLastUpdated() { |
|
| 152 | 152 | return $this->last_updated; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return bool |
| 159 | 159 | */ |
| 160 | - public function isLastRunSuccess(){ |
|
| 160 | + public function isLastRunSuccess() { |
|
| 161 | 161 | return $this->last_result; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return int |
| 168 | 168 | */ |
| 169 | - public function getFrequency(){ |
|
| 169 | + public function getFrequency() { |
|
| 170 | 170 | return $this->frequency; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @param int $frequency |
| 177 | 177 | * @return self Enable method-chaining |
| 178 | 178 | */ |
| 179 | - public function setFrequency($frequency){ |
|
| 179 | + public function setFrequency($frequency) { |
|
| 180 | 180 | $this->frequency = $frequency; |
| 181 | 181 | return $this; |
| 182 | 182 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @return int |
| 188 | 188 | */ |
| 189 | - public function getRemainingOccurrences(){ |
|
| 189 | + public function getRemainingOccurrences() { |
|
| 190 | 190 | return $this->nb_occurrences; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @param int $nb_occur |
| 197 | 197 | * @return self Enable method-chaining |
| 198 | 198 | */ |
| 199 | - public function setRemainingOccurrences($nb_occur){ |
|
| 199 | + public function setRemainingOccurrences($nb_occur) { |
|
| 200 | 200 | $this->nb_occurrences = $nb_occur; |
| 201 | 201 | return $this; |
| 202 | 202 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return bool |
| 208 | 208 | */ |
| 209 | - public function isRunning(){ |
|
| 209 | + public function isRunning() { |
|
| 210 | 210 | return $this->is_running; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @return bool |
| 236 | 236 | */ |
| 237 | 237 | public function save() { |
| 238 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 238 | + if (!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 239 | 239 | return $this->provider->updateTask($this); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -243,23 +243,23 @@ discard block |
||
| 243 | 243 | * Execute the task, default skeleton |
| 244 | 244 | * |
| 245 | 245 | */ |
| 246 | - public function execute(){ |
|
| 246 | + public function execute() { |
|
| 247 | 247 | |
| 248 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 248 | + if ($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 249 | 249 | $this->is_running = false; |
| 250 | 250 | |
| 251 | - if(!$this->is_running){ |
|
| 251 | + if (!$this->is_running) { |
|
| 252 | 252 | $this->last_result = false; |
| 253 | 253 | $this->is_running = true; |
| 254 | 254 | $this->save(); |
| 255 | 255 | |
| 256 | 256 | Log::addDebugLog('Start execution of Admin task: '.$this->getTitle()); |
| 257 | 257 | $this->last_result = $this->executeSteps(); |
| 258 | - if($this->last_result){ |
|
| 258 | + if ($this->last_result) { |
|
| 259 | 259 | $this->last_updated = new \DateTime(); |
| 260 | - if($this->nb_occurrences > 0){ |
|
| 260 | + if ($this->nb_occurrences > 0) { |
|
| 261 | 261 | $this->nb_occurrences--; |
| 262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 262 | + if ($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | $this->is_running = false; |
@@ -235,7 +235,9 @@ discard block |
||
| 235 | 235 | * @return bool |
| 236 | 236 | */ |
| 237 | 237 | public function save() { |
| 238 | - if(!$this->provider) throw new \Exception('The task has not been initialised with a provider.'); |
|
| 238 | + if(!$this->provider) { |
|
| 239 | + throw new \Exception('The task has not been initialised with a provider.'); |
|
| 240 | + } |
|
| 239 | 241 | return $this->provider->updateTask($this); |
| 240 | 242 | } |
| 241 | 243 | |
@@ -245,8 +247,9 @@ discard block |
||
| 245 | 247 | */ |
| 246 | 248 | public function execute(){ |
| 247 | 249 | |
| 248 | - if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) |
|
| 249 | - $this->is_running = false; |
|
| 250 | + if($this->last_updated->add(new \DateInterval('PT'.self::TASK_TIME_OUT.'S')) < new \DateTime()) { |
|
| 251 | + $this->is_running = false; |
|
| 252 | + } |
|
| 250 | 253 | |
| 251 | 254 | if(!$this->is_running){ |
| 252 | 255 | $this->last_result = false; |
@@ -259,7 +262,9 @@ discard block |
||
| 259 | 262 | $this->last_updated = new \DateTime(); |
| 260 | 263 | if($this->nb_occurrences > 0){ |
| 261 | 264 | $this->nb_occurrences--; |
| 262 | - if($this->nb_occurrences == 0) $this->is_enabled = false; |
|
| 265 | + if($this->nb_occurrences == 0) { |
|
| 266 | + $this->is_enabled = false; |
|
| 267 | + } |
|
| 263 | 268 | } |
| 264 | 269 | } |
| 265 | 270 | $this->is_running = false; |
@@ -16,51 +16,51 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface HookProviderInterface { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Return an instance of the hook linked to the specifed function / context |
|
| 21 | - * |
|
| 22 | - * @param string $hook_function |
|
| 23 | - * @param string $hook_context |
|
| 24 | - * @return Hook |
|
| 25 | - */ |
|
| 26 | - public function get($hook_function, $hook_context = null); |
|
| 19 | + /** |
|
| 20 | + * Return an instance of the hook linked to the specifed function / context |
|
| 21 | + * |
|
| 22 | + * @param string $hook_function |
|
| 23 | + * @param string $hook_context |
|
| 24 | + * @return Hook |
|
| 25 | + */ |
|
| 26 | + public function get($hook_function, $hook_context = null); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Return whether the Hook module is active and the table has been created. |
|
| 30 | - * |
|
| 31 | - * @uses \MyArtJaub\Webtrees\Module\ModuleManager to check if the module is operational |
|
| 32 | - * @return bool True if module active and table created, false otherwise |
|
| 33 | - */ |
|
| 34 | - public function isModuleOperational(); |
|
| 28 | + /** |
|
| 29 | + * Return whether the Hook module is active and the table has been created. |
|
| 30 | + * |
|
| 31 | + * @uses \MyArtJaub\Webtrees\Module\ModuleManager to check if the module is operational |
|
| 32 | + * @return bool True if module active and table created, false otherwise |
|
| 33 | + */ |
|
| 34 | + public function isModuleOperational(); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Get the list of possible hooks in the list of modules files. |
|
| 38 | - * A hook will be registered: |
|
| 39 | - * - for all modules already registered in Webtrees |
|
| 40 | - * - if the module implements HookSubscriberInterface |
|
| 41 | - * - if the method exist within the module |
|
| 42 | - * |
|
| 43 | - * @return Array List of possible hooks, with the priority |
|
| 44 | - */ |
|
| 45 | - public function getPossibleHooks(); |
|
| 36 | + /** |
|
| 37 | + * Get the list of possible hooks in the list of modules files. |
|
| 38 | + * A hook will be registered: |
|
| 39 | + * - for all modules already registered in Webtrees |
|
| 40 | + * - if the module implements HookSubscriberInterface |
|
| 41 | + * - if the method exist within the module |
|
| 42 | + * |
|
| 43 | + * @return Array List of possible hooks, with the priority |
|
| 44 | + */ |
|
| 45 | + public function getPossibleHooks(); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
| 49 | - * |
|
| 50 | - * @return array List of installed hooks |
|
| 51 | - */ |
|
| 52 | - public function getRawInstalledHooks(); |
|
| 47 | + /** |
|
| 48 | + * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
| 49 | + * |
|
| 50 | + * @return array List of installed hooks |
|
| 51 | + */ |
|
| 52 | + public function getRawInstalledHooks(); |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
| 56 | - * |
|
| 57 | - * @return Array List of installed hooks, with id, status and priority |
|
| 58 | - */ |
|
| 59 | - public function getInstalledHooks(); |
|
| 54 | + /** |
|
| 55 | + * Get the list of hooks intalled in webtrees, with their id, status and priority. |
|
| 56 | + * |
|
| 57 | + * @return Array List of installed hooks, with id, status and priority |
|
| 58 | + */ |
|
| 59 | + public function getInstalledHooks(); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Update the list of hooks, identifying missing ones and removed ones. |
|
| 63 | - */ |
|
| 64 | - public function updateHooks(); |
|
| 61 | + /** |
|
| 62 | + * Update the list of hooks, identifying missing ones and removed ones. |
|
| 63 | + */ |
|
| 64 | + public function updateHooks(); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | \ No newline at end of file |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param \Fisharebest\Webtrees\Controller\IndividualController $ctrl_individual_in The Individual Controller to extend |
| 34 | 34 | */ |
| 35 | - public function __construct(fw\Controller\IndividualController $ctrl_individual_in){ |
|
| 35 | + public function __construct(fw\Controller\IndividualController $ctrl_individual_in) { |
|
| 36 | 36 | $this->ctrl_individual = $ctrl_individual_in; |
| 37 | 37 | $this->dindi = new mw\Individual($this->ctrl_individual->getSignificantIndividual()); |
| 38 | 38 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
| 45 | 45 | */ |
| 46 | - public function printHeaderExtensions(){ |
|
| 46 | + public function printHeaderExtensions() { |
|
| 47 | 47 | $hook_extend_indi_header_left = new mw\Hook\Hook('hExtendIndiHeaderLeft'); |
| 48 | 48 | $hook_extend_indi_header_right = new mw\Hook\Hook('hExtendIndiHeaderRight'); |
| 49 | 49 | $hook_extend_indi_header_left = $hook_extend_indi_header_left->execute($this->ctrl_individual); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | echo '<div id="indi_perso_header">', |
| 53 | 53 | '<div id="indi_perso_header_left">'; |
| 54 | 54 | foreach ($hook_extend_indi_header_left as $div) { |
| 55 | - if(count($div)==2){ |
|
| 55 | + if (count($div) == 2) { |
|
| 56 | 56 | echo '<div id="', $div[0], '" class="indi_perso_header_left_div">', |
| 57 | 57 | $div[1], '</div>'; |
| 58 | 58 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | echo '</div>', |
| 61 | 61 | '<div id="indi_perso_header_right">'; |
| 62 | 62 | foreach ($hook_extend_indi_header_right as $div) { |
| 63 | - if(count($div)==2){ |
|
| 63 | + if (count($div) == 2) { |
|
| 64 | 64 | echo '<div id="', $div[0], '" class="indi_perso_header_right_div">', |
| 65 | 65 | $div[1], '</div>'; |
| 66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
| 77 | 77 | */ |
| 78 | - public function printHeaderExtraIcons(){ |
|
| 78 | + public function printHeaderExtraIcons() { |
|
| 79 | 79 | $hook_extend_indi_header_icons = new Hook('hExtendIndiHeaderIcons'); |
| 80 | 80 | $hook_extend_indi_header_icons = $hook_extend_indi_header_icons->execute($this->ctrl_individual); |
| 81 | 81 | |
@@ -24,16 +24,16 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function upgrade() { |
| 26 | 26 | Database::exec( |
| 27 | - 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
| 28 | - ' majat_name VARCHAR(32) NOT NULL,'. |
|
| 29 | - ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
| 30 | - ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
| 31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
| 32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
| 33 | - ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
| 34 | - ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
| 35 | - ' PRIMARY KEY (majat_name)'. |
|
| 36 | - ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
| 27 | + 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
| 28 | + ' majat_name VARCHAR(32) NOT NULL,'. |
|
| 29 | + ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
| 30 | + ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
| 31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
| 32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
| 33 | + ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
| 34 | + ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
| 35 | + ' PRIMARY KEY (majat_name)'. |
|
| 36 | + ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -28,8 +28,8 @@ |
||
| 28 | 28 | ' majat_name VARCHAR(32) NOT NULL,'. |
| 29 | 29 | ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
| 30 | 30 | ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
| 31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
| 32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
| 31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'.// 0 means error, 1 is success |
|
| 32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'.// In min, Default every week |
|
| 33 | 33 | ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
| 34 | 34 | ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
| 35 | 35 | ' PRIMARY KEY (majat_name)'. |
@@ -18,35 +18,35 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Dispatcher implements DispatcherInterface { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var Dispatcher $instance Singleton pattern instance |
|
| 23 | - */ |
|
| 24 | - private static $instance = null; |
|
| 21 | + /** |
|
| 22 | + * @var Dispatcher $instance Singleton pattern instance |
|
| 23 | + */ |
|
| 24 | + private static $instance = null; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Returns the *Dispatcher* instance of this class. |
|
| 28 | - * |
|
| 29 | - * @return Dispatcher The *Singleton* instance. |
|
| 30 | - */ |
|
| 31 | - public static function getInstance() |
|
| 32 | - { |
|
| 33 | - if (null === static::$instance) { |
|
| 34 | - static::$instance = new static(); |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * Returns the *Dispatcher* instance of this class. |
|
| 28 | + * |
|
| 29 | + * @return Dispatcher The *Singleton* instance. |
|
| 30 | + */ |
|
| 31 | + public static function getInstance() |
|
| 32 | + { |
|
| 33 | + if (null === static::$instance) { |
|
| 34 | + static::$instance = new static(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return static::$instance; |
|
| 38 | - } |
|
| 37 | + return static::$instance; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * Protected constructor. |
|
| 42 | - */ |
|
| 43 | - protected function __construct() {} |
|
| 41 | + * Protected constructor. |
|
| 42 | + */ |
|
| 43 | + protected function __construct() {} |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * {@inheritdoc } |
|
| 47 | - * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle() |
|
| 48 | - */ |
|
| 49 | - public function handle(fw\Module\AbstractModule $module, $request) { |
|
| 45 | + /** |
|
| 46 | + * {@inheritdoc } |
|
| 47 | + * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle() |
|
| 48 | + */ |
|
| 49 | + public function handle(fw\Module\AbstractModule $module, $request) { |
|
| 50 | 50 | |
| 51 | 51 | $fq_modclass_name = get_class($module); |
| 52 | 52 | $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
| 68 | 68 | if(class_exists($ctrl_class) |
| 69 | - && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
|
| 69 | + && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
|
| 70 | 70 | && $ctrl = new $ctrl_class($module) ) { |
| 71 | 71 | if(method_exists($ctrl, $method)) { |
| 72 | - try { |
|
| 73 | - call_user_func_array(array($ctrl, $method), array()); |
|
| 74 | - } |
|
| 75 | - catch (MvcException $ex) { |
|
| 76 | - if(!headers_sent()) { |
|
| 77 | - http_response_code($ex->getHttpCode()); |
|
| 78 | - } |
|
| 79 | - echo $ex->getMessage(); |
|
| 80 | - } |
|
| 72 | + try { |
|
| 73 | + call_user_func_array(array($ctrl, $method), array()); |
|
| 74 | + } |
|
| 75 | + catch (MvcException $ex) { |
|
| 76 | + if(!headers_sent()) { |
|
| 77 | + http_response_code($ex->getHttpCode()); |
|
| 78 | + } |
|
| 79 | + echo $ex->getMessage(); |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | else { |
| 83 | 83 | throw new \Exception('The page requested does not exist'); |
@@ -86,27 +86,27 @@ discard block |
||
| 86 | 86 | else { |
| 87 | 87 | throw new \Exception('The page requested does not exist'); |
| 88 | 88 | } |
| 89 | - } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Private clone method to prevent cloning of the instance of the |
|
| 93 | - * *Dispatcher* instance. |
|
| 94 | - * |
|
| 95 | - * @return void |
|
| 96 | - */ |
|
| 97 | - private function __clone() |
|
| 98 | - { |
|
| 99 | - } |
|
| 91 | + /** |
|
| 92 | + * Private clone method to prevent cloning of the instance of the |
|
| 93 | + * *Dispatcher* instance. |
|
| 94 | + * |
|
| 95 | + * @return void |
|
| 96 | + */ |
|
| 97 | + private function __clone() |
|
| 98 | + { |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
| 103 | - * instance. |
|
| 104 | - * |
|
| 105 | - * @return void |
|
| 106 | - */ |
|
| 107 | - private function __wakeup() |
|
| 108 | - { |
|
| 109 | - } |
|
| 101 | + /** |
|
| 102 | + * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
| 103 | + * instance. |
|
| 104 | + * |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | + private function __wakeup() |
|
| 108 | + { |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | public function handle(fw\Module\AbstractModule $module, $request) { |
| 50 | 50 | |
| 51 | 51 | $fq_modclass_name = get_class($module); |
| 52 | - $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
|
| 52 | + $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\'; |
|
| 53 | 53 | |
| 54 | - $args = explode( '@', $request, 2); |
|
| 55 | - switch(count($args)) { |
|
| 54 | + $args = explode('@', $request, 2); |
|
| 55 | + switch (count($args)) { |
|
| 56 | 56 | case 1: |
| 57 | 57 | $ctrl_name = $args[0]; |
| 58 | 58 | $method = 'index'; |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | break; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
|
| 68 | - if(class_exists($ctrl_class) |
|
| 67 | + $ctrl_class = $ctrl_namespace.$ctrl_name.'Controller'; |
|
| 68 | + if (class_exists($ctrl_class) |
|
| 69 | 69 | && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
| 70 | - && $ctrl = new $ctrl_class($module) ) { |
|
| 71 | - if(method_exists($ctrl, $method)) { |
|
| 70 | + && $ctrl = new $ctrl_class($module)) { |
|
| 71 | + if (method_exists($ctrl, $method)) { |
|
| 72 | 72 | try { |
| 73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
| 74 | 74 | } |
| 75 | 75 | catch (MvcException $ex) { |
| 76 | - if(!headers_sent()) { |
|
| 76 | + if (!headers_sent()) { |
|
| 77 | 77 | http_response_code($ex->getHttpCode()); |
| 78 | 78 | } |
| 79 | 79 | echo $ex->getMessage(); |
@@ -71,19 +71,16 @@ |
||
| 71 | 71 | if(method_exists($ctrl, $method)) { |
| 72 | 72 | try { |
| 73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
| 74 | - } |
|
| 75 | - catch (MvcException $ex) { |
|
| 74 | + } catch (MvcException $ex) { |
|
| 76 | 75 | if(!headers_sent()) { |
| 77 | 76 | http_response_code($ex->getHttpCode()); |
| 78 | 77 | } |
| 79 | 78 | echo $ex->getMessage(); |
| 80 | 79 | } |
| 81 | - } |
|
| 82 | - else { |
|
| 80 | + } else { |
|
| 83 | 81 | throw new \Exception('The page requested does not exist'); |
| 84 | 82 | } |
| 85 | - } |
|
| 86 | - else { |
|
| 83 | + } else { |
|
| 87 | 84 | throw new \Exception('The page requested does not exist'); |
| 88 | 85 | } |
| 89 | 86 | } |