@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | - * |
|
| 5 | - * @package MyArtJaub\Webtrees |
|
| 6 | - * @subpackage Hook |
|
| 7 | - * @author Jonathan Jaubart <[email protected]> |
|
| 8 | - * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
| 9 | - * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
| 10 | - */ |
|
| 3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | + * |
|
| 5 | + * @package MyArtJaub\Webtrees |
|
| 6 | + * @subpackage Hook |
|
| 7 | + * @author Jonathan Jaubart <[email protected]> |
|
| 8 | + * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
| 9 | + * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
| 10 | + */ |
|
| 11 | 11 | namespace MyArtJaub\Webtrees\Hook\HookInterfaces; |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | interface PageFooterExtender { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Get HTML code for extending the footer of a page. |
|
| 20 | - * |
|
| 21 | - * @return string HTML code extension |
|
| 22 | - */ |
|
| 23 | - public function hPrintFooter(); |
|
| 18 | + /** |
|
| 19 | + * Get HTML code for extending the footer of a page. |
|
| 20 | + * |
|
| 21 | + * @return string HTML code extension |
|
| 22 | + */ |
|
| 23 | + public function hPrintFooter(); |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | - * |
|
| 5 | - * @package MyArtJaub\Webtrees |
|
| 6 | - * @subpackage Hook |
|
| 7 | - * @author Jonathan Jaubart <[email protected]> |
|
| 8 | - * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
| 9 | - * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
| 10 | - */ |
|
| 3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | + * |
|
| 5 | + * @package MyArtJaub\Webtrees |
|
| 6 | + * @subpackage Hook |
|
| 7 | + * @author Jonathan Jaubart <[email protected]> |
|
| 8 | + * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
| 9 | + * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
| 10 | + */ |
|
| 11 | 11 | namespace MyArtJaub\Webtrees\Hook\HookInterfaces; |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | interface PageHeaderExtender { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Get HTML code for extending the header of a page. |
|
| 20 | - * |
|
| 21 | - * @return string HTML code extension |
|
| 22 | - */ |
|
| 23 | - public function hPrintHeader(); |
|
| 18 | + /** |
|
| 19 | + * Get HTML code for extending the header of a page. |
|
| 20 | + * |
|
| 21 | + * @return string HTML code extension |
|
| 22 | + */ |
|
| 23 | + public function hPrintHeader(); |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | - * |
|
| 5 | - * @package MyArtJaub\Webtrees |
|
| 6 | - * @subpackage Hook |
|
| 7 | - * @author Jonathan Jaubart <[email protected]> |
|
| 8 | - * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
| 9 | - * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
| 10 | - */ |
|
| 3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
| 4 | + * |
|
| 5 | + * @package MyArtJaub\Webtrees |
|
| 6 | + * @subpackage Hook |
|
| 7 | + * @author Jonathan Jaubart <[email protected]> |
|
| 8 | + * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
| 9 | + * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
| 10 | + */ |
|
| 11 | 11 | namespace MyArtJaub\Webtrees\Hook; |
| 12 | 12 | |
| 13 | 13 | use \Fisharebest\Webtrees as fw; |
@@ -32,158 +32,158 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | class CertificateController extends MvcController |
| 34 | 34 | { |
| 35 | - /** |
|
| 36 | - * Certificate Provider |
|
| 37 | - * @var CertificateProviderInterface $provider |
|
| 38 | - */ |
|
| 39 | - protected $provider; |
|
| 35 | + /** |
|
| 36 | + * Certificate Provider |
|
| 37 | + * @var CertificateProviderInterface $provider |
|
| 38 | + */ |
|
| 39 | + protected $provider; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Constructor for Certificate controller |
|
| 43 | - * @param AbstractModule $module |
|
| 44 | - */ |
|
| 45 | - public function __construct(AbstractModule $module) { |
|
| 46 | - parent::__construct($module); |
|
| 47 | - |
|
| 48 | - $this->provider = $this->module->getProvider(); |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * Constructor for Certificate controller |
|
| 43 | + * @param AbstractModule $module |
|
| 44 | + */ |
|
| 45 | + public function __construct(AbstractModule $module) { |
|
| 46 | + parent::__construct($module); |
|
| 47 | + |
|
| 48 | + $this->provider = $this->module->getProvider(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Pages |
|
| 54 | - */ |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Certificate@index |
|
| 58 | - */ |
|
| 59 | - public function index() { |
|
| 60 | - global $WT_TREE; |
|
| 61 | - |
|
| 62 | - $controller = new PageController(); |
|
| 63 | - $controller |
|
| 64 | - ->setPageTitle(I18N::translate('Certificate')) |
|
| 65 | - ->restrictAccess( |
|
| 66 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 67 | - ); |
|
| 68 | - |
|
| 69 | - $cid = Filter::get('cid'); |
|
| 70 | - |
|
| 71 | - $certificate = null; |
|
| 72 | - if(!empty($cid) && strlen($cid) > 22){ |
|
| 73 | - $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - $data = new ViewBag(); |
|
| 77 | - $data->set('title', $controller->getPageTitle()); |
|
| 78 | - |
|
| 79 | - $data->set('has_certif', false); |
|
| 80 | - if($certificate) { |
|
| 81 | - $controller->restrictAccess($certificate->canShow()); |
|
| 82 | - $data->set('title', $certificate->getTitle()); |
|
| 83 | - $data->set('has_certif', true); |
|
| 84 | - $data->set('certificate', $certificate); |
|
| 52 | + /** |
|
| 53 | + * Pages |
|
| 54 | + */ |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Certificate@index |
|
| 58 | + */ |
|
| 59 | + public function index() { |
|
| 60 | + global $WT_TREE; |
|
| 61 | + |
|
| 62 | + $controller = new PageController(); |
|
| 63 | + $controller |
|
| 64 | + ->setPageTitle(I18N::translate('Certificate')) |
|
| 65 | + ->restrictAccess( |
|
| 66 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 67 | + ); |
|
| 68 | + |
|
| 69 | + $cid = Filter::get('cid'); |
|
| 70 | + |
|
| 71 | + $certificate = null; |
|
| 72 | + if(!empty($cid) && strlen($cid) > 22){ |
|
| 73 | + $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + $data = new ViewBag(); |
|
| 77 | + $data->set('title', $controller->getPageTitle()); |
|
| 78 | + |
|
| 79 | + $data->set('has_certif', false); |
|
| 80 | + if($certificate) { |
|
| 81 | + $controller->restrictAccess($certificate->canShow()); |
|
| 82 | + $data->set('title', $certificate->getTitle()); |
|
| 83 | + $data->set('has_certif', true); |
|
| 84 | + $data->set('certificate', $certificate); |
|
| 85 | 85 | |
| 86 | - $data->set( |
|
| 87 | - 'url_certif_city', |
|
| 88 | - 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
| 89 | - '&mod_action=Certificate@listAll' . |
|
| 90 | - '&ged=' . $WT_TREE->getNameUrl() . |
|
| 91 | - '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
| 92 | - ); |
|
| 86 | + $data->set( |
|
| 87 | + 'url_certif_city', |
|
| 88 | + 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
| 89 | + '&mod_action=Certificate@listAll' . |
|
| 90 | + '&ged=' . $WT_TREE->getNameUrl() . |
|
| 91 | + '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - $controller->addInlineJavascript(' |
|
| 94 | + $controller->addInlineJavascript(' |
|
| 95 | 95 | jQuery("#certificate-tabs").tabs(); |
| 96 | 96 | jQuery("#certificate-tabs").css("visibility", "visible"); |
| 97 | 97 | '); |
| 98 | 98 | |
| 99 | - $data->set('has_linked_indis', false); |
|
| 100 | - $data->set('has_linked_fams', false); |
|
| 99 | + $data->set('has_linked_indis', false); |
|
| 100 | + $data->set('has_linked_fams', false); |
|
| 101 | 101 | |
| 102 | - $linked_indis = $certificate->linkedIndividuals(); |
|
| 103 | - $linked_fams = $certificate->linkedFamilies(); |
|
| 102 | + $linked_indis = $certificate->linkedIndividuals(); |
|
| 103 | + $linked_fams = $certificate->linkedFamilies(); |
|
| 104 | 104 | |
| 105 | - if($linked_indis && count($linked_indis) > 0) { |
|
| 106 | - $data->set('has_linked_indis', true); |
|
| 107 | - $data->set('linked_indis', $linked_indis); |
|
| 108 | - } |
|
| 105 | + if($linked_indis && count($linked_indis) > 0) { |
|
| 106 | + $data->set('has_linked_indis', true); |
|
| 107 | + $data->set('linked_indis', $linked_indis); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - if(!empty($linked_fams)) { |
|
| 111 | - $data->set('has_linked_fams', true); |
|
| 112 | - $data->set('linked_fams', $linked_fams); |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
| 117 | - } |
|
| 110 | + if(!empty($linked_fams)) { |
|
| 111 | + $data->set('has_linked_fams', true); |
|
| 112 | + $data->set('linked_fams', $linked_fams); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + ViewFactory::make('Certificate', $this, $controller, $data)->render(); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * Certificate@image |
|
| 121 | - */ |
|
| 122 | - public function image() { |
|
| 123 | - global $WT_TREE; |
|
| 119 | + /** |
|
| 120 | + * Certificate@image |
|
| 121 | + */ |
|
| 122 | + public function image() { |
|
| 123 | + global $WT_TREE; |
|
| 124 | 124 | |
| 125 | - $cid = Filter::get('cid'); |
|
| 126 | - $certificate = null; |
|
| 127 | - if(!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 125 | + $cid = Filter::get('cid'); |
|
| 126 | + $certificate = null; |
|
| 127 | + if(!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 128 | 128 | |
| 129 | - $imageBuilder = new ImageBuilder($certificate); |
|
| 129 | + $imageBuilder = new ImageBuilder($certificate); |
|
| 130 | 130 | |
| 131 | - if (!empty(Filter::get('cb'))) { |
|
| 132 | - $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
| 133 | - } |
|
| 131 | + if (!empty(Filter::get('cb'))) { |
|
| 132 | + $imageBuilder->setExpireOffset($imageBuilder->getExpireOffset() * 7); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - $imageBuilder |
|
| 136 | - ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
| 137 | - ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
| 138 | - ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
| 139 | - ; |
|
| 135 | + $imageBuilder |
|
| 136 | + ->setShowWatermark(Auth::accessLevel($WT_TREE) >= $this->module->getSetting('MAJ_SHOW_NO_WATERMARK', Auth::PRIV_HIDE)) |
|
| 137 | + ->setFontMaxSize($this->module->getSetting('MAJ_WM_FONT_MAXSIZE', 18)) |
|
| 138 | + ->setFontColor($this->module->getSetting('MAJ_WM_FONT_COLOR', '#4D6DF3')) |
|
| 139 | + ; |
|
| 140 | 140 | |
| 141 | - $imageBuilder->render(); |
|
| 141 | + $imageBuilder->render(); |
|
| 142 | 142 | |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Certificate@listAll |
|
| 147 | - */ |
|
| 148 | - public function listAll() { |
|
| 149 | - global $WT_TREE; |
|
| 150 | - |
|
| 151 | - $controller = new PageController(); |
|
| 152 | - $controller |
|
| 153 | - ->setPageTitle(I18N::translate('Certificates')) |
|
| 154 | - ->restrictAccess( |
|
| 155 | - $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 156 | - ); |
|
| 157 | - |
|
| 158 | - $city = Filter::get('city'); |
|
| 159 | - |
|
| 160 | - if(!empty($city) && strlen($city) > 22){ |
|
| 161 | - $city = Functions::decryptFromSafeBase64($city); |
|
| 162 | - $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $data = new ViewBag(); |
|
| 166 | - $data->set('title', $controller->getPageTitle()); |
|
| 167 | - $data->set('url_module', $this->module->getName()); |
|
| 168 | - $data->set('url_action', 'Certificate@listAll'); |
|
| 169 | - $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 170 | - |
|
| 171 | - $data->set('cities', $this->provider->getCitiesList()); |
|
| 172 | - $data->set('selected_city', $city); |
|
| 173 | - |
|
| 174 | - $data->set('has_list', false); |
|
| 175 | - if(!empty($city)) { |
|
| 176 | - $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
| 145 | + /** |
|
| 146 | + * Certificate@listAll |
|
| 147 | + */ |
|
| 148 | + public function listAll() { |
|
| 149 | + global $WT_TREE; |
|
| 150 | + |
|
| 151 | + $controller = new PageController(); |
|
| 152 | + $controller |
|
| 153 | + ->setPageTitle(I18N::translate('Certificates')) |
|
| 154 | + ->restrictAccess( |
|
| 155 | + $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE) |
|
| 156 | + ); |
|
| 157 | + |
|
| 158 | + $city = Filter::get('city'); |
|
| 159 | + |
|
| 160 | + if(!empty($city) && strlen($city) > 22){ |
|
| 161 | + $city = Functions::decryptFromSafeBase64($city); |
|
| 162 | + $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $data = new ViewBag(); |
|
| 166 | + $data->set('title', $controller->getPageTitle()); |
|
| 167 | + $data->set('url_module', $this->module->getName()); |
|
| 168 | + $data->set('url_action', 'Certificate@listAll'); |
|
| 169 | + $data->set('url_ged', $WT_TREE->getNameUrl()); |
|
| 170 | + |
|
| 171 | + $data->set('cities', $this->provider->getCitiesList()); |
|
| 172 | + $data->set('selected_city', $city); |
|
| 173 | + |
|
| 174 | + $data->set('has_list', false); |
|
| 175 | + if(!empty($city)) { |
|
| 176 | + $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
| 177 | 177 | |
| 178 | - $certif_list = $this->provider->getCertificatesList($city); |
|
| 179 | - if(!empty($certif_list)) { |
|
| 180 | - $data->set('has_list', true); |
|
| 181 | - $data->set('table_id', $table_id); |
|
| 182 | - $data->set('certificate_list', $certif_list); |
|
| 178 | + $certif_list = $this->provider->getCertificatesList($city); |
|
| 179 | + if(!empty($certif_list)) { |
|
| 180 | + $data->set('has_list', true); |
|
| 181 | + $data->set('table_id', $table_id); |
|
| 182 | + $data->set('certificate_list', $certif_list); |
|
| 183 | 183 | |
| 184 | - $controller |
|
| 185 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 186 | - ->addInlineJavascript(' |
|
| 184 | + $controller |
|
| 185 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
| 186 | + ->addInlineJavascript(' |
|
| 187 | 187 | /* Initialise datatables */ |
| 188 | 188 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
| 189 | 189 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -210,29 +210,29 @@ discard block |
||
| 210 | 210 | jQuery(".certificate-list").css("visibility", "visible"); |
| 211 | 211 | jQuery(".loading-image").css("display", "none"); |
| 212 | 212 | '); |
| 213 | - } |
|
| 214 | - } |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
| 216 | + ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); |
|
| 217 | 217 | |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * Certificate@autocomplete |
|
| 222 | - */ |
|
| 223 | - public function autocomplete() { |
|
| 224 | - global $WT_TREE; |
|
| 220 | + /** |
|
| 221 | + * Certificate@autocomplete |
|
| 222 | + */ |
|
| 223 | + public function autocomplete() { |
|
| 224 | + global $WT_TREE; |
|
| 225 | 225 | |
| 226 | - $controller = new JsonController(); |
|
| 226 | + $controller = new JsonController(); |
|
| 227 | 227 | |
| 228 | - $city = Filter::get('city'); |
|
| 229 | - $contains = Filter::get('term'); |
|
| 228 | + $city = Filter::get('city'); |
|
| 229 | + $contains = Filter::get('term'); |
|
| 230 | 230 | |
| 231 | - $controller |
|
| 232 | - ->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains)) |
|
| 233 | - ->pageHeader(); |
|
| 231 | + $controller |
|
| 232 | + ->restrictAccess(Auth::isEditor($WT_TREE) && !empty($city) && !empty($contains)) |
|
| 233 | + ->pageHeader(); |
|
| 234 | 234 | |
| 235 | - $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
| 236 | - echo \Zend_Json::encode($listCert); |
|
| 237 | - } |
|
| 235 | + $listCert = $this->provider->getCertificatesListBeginWith($city, $contains); |
|
| 236 | + echo \Zend_Json::encode($listCert); |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | \ No newline at end of file |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $cid = Filter::get('cid'); |
| 70 | 70 | |
| 71 | 71 | $certificate = null; |
| 72 | - if(!empty($cid) && strlen($cid) > 22){ |
|
| 72 | + if (!empty($cid) && strlen($cid) > 22) { |
|
| 73 | 73 | $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $data->set('title', $controller->getPageTitle()); |
| 78 | 78 | |
| 79 | 79 | $data->set('has_certif', false); |
| 80 | - if($certificate) { |
|
| 80 | + if ($certificate) { |
|
| 81 | 81 | $controller->restrictAccess($certificate->canShow()); |
| 82 | 82 | $data->set('title', $certificate->getTitle()); |
| 83 | 83 | $data->set('has_certif', true); |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $data->set( |
| 87 | 87 | 'url_certif_city', |
| 88 | - 'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . |
|
| 89 | - '&mod_action=Certificate@listAll' . |
|
| 90 | - '&ged=' . $WT_TREE->getNameUrl() . |
|
| 91 | - '&city=' . Functions::encryptToSafeBase64($certificate->getCity()) |
|
| 88 | + 'module.php?mod='.Constants::MODULE_MAJ_CERTIF_NAME. |
|
| 89 | + '&mod_action=Certificate@listAll'. |
|
| 90 | + '&ged='.$WT_TREE->getNameUrl(). |
|
| 91 | + '&city='.Functions::encryptToSafeBase64($certificate->getCity()) |
|
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | $controller->addInlineJavascript(' |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | $linked_indis = $certificate->linkedIndividuals(); |
| 103 | 103 | $linked_fams = $certificate->linkedFamilies(); |
| 104 | 104 | |
| 105 | - if($linked_indis && count($linked_indis) > 0) { |
|
| 105 | + if ($linked_indis && count($linked_indis) > 0) { |
|
| 106 | 106 | $data->set('has_linked_indis', true); |
| 107 | 107 | $data->set('linked_indis', $linked_indis); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(!empty($linked_fams)) { |
|
| 110 | + if (!empty($linked_fams)) { |
|
| 111 | 111 | $data->set('has_linked_fams', true); |
| 112 | 112 | $data->set('linked_fams', $linked_fams); |
| 113 | 113 | } |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | public function image() { |
| 123 | 123 | global $WT_TREE; |
| 124 | 124 | |
| 125 | - $cid = Filter::get('cid'); |
|
| 125 | + $cid = Filter::get('cid'); |
|
| 126 | 126 | $certificate = null; |
| 127 | - if(!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 127 | + if (!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 128 | 128 | |
| 129 | 129 | $imageBuilder = new ImageBuilder($certificate); |
| 130 | 130 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | $city = Filter::get('city'); |
| 159 | 159 | |
| 160 | - if(!empty($city) && strlen($city) > 22){ |
|
| 160 | + if (!empty($city) && strlen($city) > 22) { |
|
| 161 | 161 | $city = Functions::decryptFromSafeBase64($city); |
| 162 | 162 | $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); |
| 163 | 163 | } |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | $data->set('selected_city', $city); |
| 173 | 173 | |
| 174 | 174 | $data->set('has_list', false); |
| 175 | - if(!empty($city)) { |
|
| 176 | - $table_id = 'table-certiflist-' . Uuid::uuid4(); |
|
| 175 | + if (!empty($city)) { |
|
| 176 | + $table_id = 'table-certiflist-'.Uuid::uuid4(); |
|
| 177 | 177 | |
| 178 | 178 | $certif_list = $this->provider->getCertificatesList($city); |
| 179 | - if(!empty($certif_list)) { |
|
| 179 | + if (!empty($certif_list)) { |
|
| 180 | 180 | $data->set('has_list', true); |
| 181 | 181 | $data->set('table_id', $table_id); |
| 182 | 182 | $data->set('certificate_list', $certif_list); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
| 192 | 192 | |
| 193 | 193 | jQuery("#'.$table_id.'").dataTable( { |
| 194 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
| 194 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
| 195 | 195 | '.I18N::datatablesI18N().', |
| 196 | 196 | jQueryUI: true, |
| 197 | 197 | autoWidth: false, |
@@ -124,7 +124,9 @@ |
||
| 124 | 124 | |
| 125 | 125 | $cid = Filter::get('cid'); |
| 126 | 126 | $certificate = null; |
| 127 | - if(!empty($cid)) $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 127 | + if(!empty($cid)) { |
|
| 128 | + $certificate = Certificate::getInstance($cid, $WT_TREE, null, $this->provider); |
|
| 129 | + } |
|
| 128 | 130 | |
| 129 | 131 | $imageBuilder = new ImageBuilder($certificate); |
| 130 | 132 | |
@@ -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)'. |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @return boolean |
| 136 | 136 | */ |
| 137 | 137 | public static function isEncryptionCompatible() { |
| 138 | - return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt'); |
|
| 138 | + return function_exists('mcrypt_encrypt') && function_exists('mcrypt_encrypt') && function_exists('mcrypt_decrypt'); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * @return string Encrypted and encoded text |
| 147 | 147 | */ |
| 148 | 148 | public static function encryptToSafeBase64($data){ |
| 149 | - if(!self::isEncryptionCompatible()) |
|
| 150 | - throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 149 | + if(!self::isEncryptionCompatible()) |
|
| 150 | + throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 151 | 151 | |
| 152 | 152 | $key = 'STANDARDKEYIFNOSERVER'; |
| 153 | 153 | if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | * @return string Decrypted text |
| 170 | 170 | */ |
| 171 | 171 | public static function decryptFromSafeBase64($encrypted){ |
| 172 | - if(!self::isEncryptionCompatible()) |
|
| 173 | - throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 172 | + if(!self::isEncryptionCompatible()) |
|
| 173 | + throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 174 | 174 | |
| 175 | 175 | $key = 'STANDARDKEYIFNOSERVER'; |
| 176 | 176 | if(Filter::server('SERVER_NAME') && Filter::server('SERVER_SOFTWARE')) |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | public static function encodeFileSystemToUtf8($string){ |
| 199 | 199 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
| 200 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
| 200 | + return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
| 201 | 201 | } |
| 202 | 202 | return $string; |
| 203 | 203 | } |
@@ -262,20 +262,20 @@ discard block |
||
| 262 | 262 | * @return boolean|string Is supported? |
| 263 | 263 | */ |
| 264 | 264 | public static function isImageTypeSupported($reqtype) { |
| 265 | - $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
| 266 | - $reqtype = strtolower($reqtype); |
|
| 265 | + $supportByGD = array('jpg'=>'jpeg', 'jpeg'=>'jpeg', 'gif'=>'gif', 'png'=>'png'); |
|
| 266 | + $reqtype = strtolower($reqtype); |
|
| 267 | 267 | |
| 268 | - if (empty($supportByGD[$reqtype])) { |
|
| 269 | - return false; |
|
| 270 | - } |
|
| 268 | + if (empty($supportByGD[$reqtype])) { |
|
| 269 | + return false; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $type = $supportByGD[$reqtype]; |
|
| 272 | + $type = $supportByGD[$reqtype]; |
|
| 273 | 273 | |
| 274 | - if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
| 275 | - return $type; |
|
| 276 | - } |
|
| 274 | + if (function_exists('imagecreatefrom'.$type) && function_exists('image'.$type)) { |
|
| 275 | + return $type; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - return false; |
|
| 278 | + return false; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | } |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param string $text Text to display |
| 40 | 40 | */ |
| 41 | - static public function promptAlert($text){ |
|
| 41 | + static public function promptAlert($text) { |
|
| 42 | 42 | echo '<script>'; |
| 43 | - echo 'alert("',fw\Filter::escapeHtml($text),'")'; |
|
| 43 | + echo 'alert("', fw\Filter::escapeHtml($text), '")'; |
|
| 44 | 44 | echo '</script>'; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @return float Result of the safe division |
| 54 | 54 | */ |
| 55 | 55 | public static function safeDivision($num, $denom, $default = 0) { |
| 56 | - if($denom && $denom!=0){ |
|
| 56 | + if ($denom && $denom != 0) { |
|
| 57 | 57 | return $num / $denom; |
| 58 | 58 | } |
| 59 | 59 | return $default; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param float $default Default value if denominator null or 0 |
| 68 | 68 | * @return float Percentage |
| 69 | 69 | */ |
| 70 | - public static function getPercentage($num, $denom, $default = 0){ |
|
| 70 | + public static function getPercentage($num, $denom, $default = 0) { |
|
| 71 | 71 | return 100 * self::safeDivision($num, $denom, $default); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @param int $target The final max width/height |
| 79 | 79 | * @return array array of ($width, $height). One of them must be $target |
| 80 | 80 | */ |
| 81 | - static public function getResizedImageSize($file, $target=25){ |
|
| 82 | - list($width, $height, , ) = getimagesize($file); |
|
| 81 | + static public function getResizedImageSize($file, $target = 25) { |
|
| 82 | + list($width, $height,,) = getimagesize($file); |
|
| 83 | 83 | $max = max($width, $height); |
| 84 | 84 | $rapp = $target / $max; |
| 85 | 85 | $width = intval($rapp * $width); |
@@ -109,21 +109,21 @@ discard block |
||
| 109 | 109 | * @param int $length Length of the token, default to 32 |
| 110 | 110 | * @return string Random token |
| 111 | 111 | */ |
| 112 | - public static function generateRandomToken($length=32) { |
|
| 112 | + public static function generateRandomToken($length = 32) { |
|
| 113 | 113 | $chars = str_split('abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); |
| 114 | 114 | $len_chars = count($chars); |
| 115 | 115 | $token = ''; |
| 116 | 116 | |
| 117 | 117 | for ($i = 0; $i < $length; $i++) |
| 118 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
| 118 | + $token .= $chars[mt_rand(0, $len_chars - 1)]; |
|
| 119 | 119 | |
| 120 | 120 | # Number of 32 char chunks |
| 121 | - $chunks = ceil( strlen($token) / 32 ); |
|
| 121 | + $chunks = ceil(strlen($token) / 32); |
|
| 122 | 122 | $md5token = ''; |
| 123 | 123 | |
| 124 | 124 | # Run each chunk through md5 |
| 125 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
| 126 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
| 125 | + for ($i = 1; $i <= $chunks; $i++) |
|
| 126 | + $md5token .= md5(substr($token, $i * 32 - 32, 32)); |
|
| 127 | 127 | |
| 128 | 128 | # Trim the token |
| 129 | 129 | return substr($md5token, 0, $length); |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | * @param string $data Text to encrypt |
| 146 | 146 | * @return string Encrypted and encoded text |
| 147 | 147 | */ |
| 148 | - public static function encryptToSafeBase64($data){ |
|
| 149 | - if(!self::isEncryptionCompatible()) |
|
| 148 | + public static function encryptToSafeBase64($data) { |
|
| 149 | + if (!self::isEncryptionCompatible()) |
|
| 150 | 150 | throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
| 151 | 151 | |
| 152 | 152 | $key = 'STANDARDKEYIFNOSERVER'; |
| 153 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
| 153 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
| 154 | 154 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
| 155 | 155 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
| 156 | - $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
|
| 156 | + $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); |
|
| 157 | 157 | $encrypted = base64_encode($iv.$id); |
| 158 | 158 | // +, / and = are not URL-compatible |
| 159 | 159 | $encrypted = str_replace('+', '-', $encrypted); |
@@ -168,25 +168,25 @@ discard block |
||
| 168 | 168 | * @param string $encrypted Text to decrypt |
| 169 | 169 | * @return string Decrypted text |
| 170 | 170 | */ |
| 171 | - public static function decryptFromSafeBase64($encrypted){ |
|
| 172 | - if(!self::isEncryptionCompatible()) |
|
| 171 | + public static function decryptFromSafeBase64($encrypted) { |
|
| 172 | + if (!self::isEncryptionCompatible()) |
|
| 173 | 173 | throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
| 174 | 174 | |
| 175 | 175 | $key = 'STANDARDKEYIFNOSERVER'; |
| 176 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
| 176 | + if (!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
| 177 | 177 | $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
| 178 | 178 | $encrypted = str_replace('-', '+', $encrypted); |
| 179 | 179 | $encrypted = str_replace('_', '/', $encrypted); |
| 180 | 180 | $encrypted = str_replace('*', '=', $encrypted); |
| 181 | 181 | $encrypted = base64_decode($encrypted); |
| 182 | - if(!$encrypted) |
|
| 182 | + if (!$encrypted) |
|
| 183 | 183 | throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
| 184 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
| 184 | + if (strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
| 185 | 185 | throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
| 186 | 186 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
| 187 | 187 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
| 188 | 188 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
| 189 | - return preg_replace('~(?:\\000+)$~','',$decrypted); |
|
| 189 | + return preg_replace('~(?:\\000+)$~', '', $decrypted); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -195,9 +195,9 @@ discard block |
||
| 195 | 195 | * @param string $string Filesystem encoded string to encode |
| 196 | 196 | * @return string UTF-8 encoded string |
| 197 | 197 | */ |
| 198 | - public static function encodeFileSystemToUtf8($string){ |
|
| 198 | + public static function encodeFileSystemToUtf8($string) { |
|
| 199 | 199 | if (strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
| 200 | - return iconv('cp1252', 'utf-8//IGNORE',$string); |
|
| 200 | + return iconv('cp1252', 'utf-8//IGNORE', $string); |
|
| 201 | 201 | } |
| 202 | 202 | return $string; |
| 203 | 203 | } |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * @param string $string UTF-8 encoded string to encode |
| 209 | 209 | * @return string Filesystem encoded string |
| 210 | 210 | */ |
| 211 | - public static function encodeUtf8ToFileSystem($string){ |
|
| 211 | + public static function encodeUtf8ToFileSystem($string) { |
|
| 212 | 212 | if (preg_match('//u', $string) && strtoupper(substr(php_uname('s'), 0, 7)) === 'WINDOWS') { |
| 213 | - return iconv('utf-8', 'cp1252//IGNORE' , $string); |
|
| 213 | + return iconv('utf-8', 'cp1252//IGNORE', $string); |
|
| 214 | 214 | } |
| 215 | 215 | return $string; |
| 216 | 216 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @return boolean True if path valid |
| 224 | 224 | */ |
| 225 | 225 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
| 226 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
| 226 | + if (strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
| 227 | 227 | return false; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @return array Array of month short names |
| 236 | 236 | */ |
| 237 | 237 | public static function getCalendarShortMonths($calendarId = 0) { |
| 238 | - if(!isset(self::$calendarShortMonths[$calendarId])) { |
|
| 238 | + if (!isset(self::$calendarShortMonths[$calendarId])) { |
|
| 239 | 239 | $calendar_info = cal_info($calendarId); |
| 240 | 240 | self::$calendarShortMonths[$calendarId] = $calendar_info['abbrevmonths']; |
| 241 | 241 | } |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * @param int $sosa Sosa number |
| 249 | 249 | * @return number |
| 250 | 250 | */ |
| 251 | - public static function getGeneration($sosa){ |
|
| 252 | - return(int)log($sosa, 2)+1; |
|
| 251 | + public static function getGeneration($sosa) { |
|
| 252 | + return(int)log($sosa, 2) + 1; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -114,16 +114,18 @@ discard block |
||
| 114 | 114 | $len_chars = count($chars); |
| 115 | 115 | $token = ''; |
| 116 | 116 | |
| 117 | - for ($i = 0; $i < $length; $i++) |
|
| 118 | - $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
| 117 | + for ($i = 0; $i < $length; $i++) { |
|
| 118 | + $token .= $chars[ mt_rand(0, $len_chars - 1) ]; |
|
| 119 | + } |
|
| 119 | 120 | |
| 120 | 121 | # Number of 32 char chunks |
| 121 | 122 | $chunks = ceil( strlen($token) / 32 ); |
| 122 | 123 | $md5token = ''; |
| 123 | 124 | |
| 124 | 125 | # Run each chunk through md5 |
| 125 | - for ( $i=1; $i<=$chunks; $i++ ) |
|
| 126 | - $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
| 126 | + for ( $i=1; $i<=$chunks; $i++ ) { |
|
| 127 | + $md5token .= md5( substr($token, $i * 32 - 32, 32) ); |
|
| 128 | + } |
|
| 127 | 129 | |
| 128 | 130 | # Trim the token |
| 129 | 131 | return substr($md5token, 0, $length); |
@@ -146,12 +148,14 @@ discard block |
||
| 146 | 148 | * @return string Encrypted and encoded text |
| 147 | 149 | */ |
| 148 | 150 | public static function encryptToSafeBase64($data){ |
| 149 | - if(!self::isEncryptionCompatible()) |
|
| 150 | - throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 151 | + if(!self::isEncryptionCompatible()) { |
|
| 152 | + throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 153 | + } |
|
| 151 | 154 | |
| 152 | 155 | $key = 'STANDARDKEYIFNOSERVER'; |
| 153 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
| 154 | - $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
| 156 | + if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) { |
|
| 157 | + $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
| 158 | + } |
|
| 155 | 159 | $iv = mcrypt_create_iv(self::ENCRYPTION_IV_SIZE, MCRYPT_RAND); |
| 156 | 160 | $id = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC,$iv); |
| 157 | 161 | $encrypted = base64_encode($iv.$id); |
@@ -169,20 +173,24 @@ discard block |
||
| 169 | 173 | * @return string Decrypted text |
| 170 | 174 | */ |
| 171 | 175 | public static function decryptFromSafeBase64($encrypted){ |
| 172 | - if(!self::isEncryptionCompatible()) |
|
| 173 | - throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 176 | + if(!self::isEncryptionCompatible()) { |
|
| 177 | + throw new \Exception('MCrypt PHP extension is required to use encryption.'); |
|
| 178 | + } |
|
| 174 | 179 | |
| 175 | 180 | $key = 'STANDARDKEYIFNOSERVER'; |
| 176 | - if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) |
|
| 177 | - $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
| 181 | + if(!empty(Filter::server('SERVER_NAME')) && !empty(Filter::server('SERVER_SOFTWARE'))) { |
|
| 182 | + $key = md5(Filter::server('SERVER_NAME').Filter::server('SERVER_SOFTWARE')); |
|
| 183 | + } |
|
| 178 | 184 | $encrypted = str_replace('-', '+', $encrypted); |
| 179 | 185 | $encrypted = str_replace('_', '/', $encrypted); |
| 180 | 186 | $encrypted = str_replace('*', '=', $encrypted); |
| 181 | 187 | $encrypted = base64_decode($encrypted); |
| 182 | - if(!$encrypted) |
|
| 183 | - throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
| 184 | - if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) |
|
| 185 | - throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
| 188 | + if(!$encrypted) { |
|
| 189 | + throw new \InvalidArgumentException('The encrypted value is not in correct base64 format.'); |
|
| 190 | + } |
|
| 191 | + if(strlen($encrypted) < self::ENCRYPTION_IV_SIZE) { |
|
| 192 | + throw new \InvalidArgumentException('The encrypted value does not contain enough characters for the key.'); |
|
| 193 | + } |
|
| 186 | 194 | $iv_dec = substr($encrypted, 0, self::ENCRYPTION_IV_SIZE); |
| 187 | 195 | $encrypted = substr($encrypted, self::ENCRYPTION_IV_SIZE); |
| 188 | 196 | $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encrypted, MCRYPT_MODE_CBC, $iv_dec); |
@@ -223,7 +231,9 @@ discard block |
||
| 223 | 231 | * @return boolean True if path valid |
| 224 | 232 | */ |
| 225 | 233 | public static function isValidPath($filename, $acceptfolder = FALSE) { |
| 226 | - if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) return true; |
|
| 234 | + if(strpbrk($filename, $acceptfolder ? '?%*:|"<>' : '\\/?%*:|"<>') === FALSE) { |
|
| 235 | + return true; |
|
| 236 | + } |
|
| 227 | 237 | return false; |
| 228 | 238 | } |
| 229 | 239 | |
@@ -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 | } |