/** * {@inhericDoc} * @see \Fisharebest\Webtrees\GedcomRecord::getInstance() */ public static function getInstance($xref, Tree $tree, $gedcom = null, CertificateProviderInterface $provider = null) { try { $certfile = Functions::decryptFromSafeBase64($xref); //NEED TO CHECK THAT !!! if (Functions::isValidPath($certfile, true)) { return new Certificate($certfile, $tree, $provider); } } catch (\Exception $ex) { Log::addErrorLog('Certificate module error : > ' . $ex->getMessage() . ' < with data > ' . $xref . ' <'); } return null; }
/** * Certificate@listAll */ public function listAll() { global $WT_TREE; $controller = new PageController(); $controller->setPageTitle(I18N::translate('Certificates'))->restrictAccess($this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)); $city = Filter::get('city'); if (!empty($city) && strlen($city) > 22) { $city = Functions::decryptFromSafeBase64($city); $controller->setPageTitle(I18N::translate('Certificates for %s', $city)); } $data = new ViewBag(); $data->set('title', $controller->getPageTitle()); $data->set('url_module', $this->module->getName()); $data->set('url_action', 'Certificate@listAll'); $data->set('url_ged', $WT_TREE->getNameUrl()); $data->set('cities', $this->provider->getCitiesList()); $data->set('selected_city', $city); $data->set('has_list', false); if (!empty($city)) { $table_id = 'table-certiflist-' . Uuid::uuid4(); $certif_list = $this->provider->getCertificatesList($city); if (!empty($certif_list)) { $data->set('has_list', true); $data->set('table_id', $table_id); $data->set('certificate_list', $certif_list); $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript(' /* Initialise datatables */ jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; 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);}; jQuery("#' . $table_id . '").dataTable( { dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', ' . I18N::datatablesI18N() . ', jQueryUI: true, autoWidth: false, processing: true, columns: [ /* 0-Date */ { dataSort: 1, width: "15%", class: "center" }, /* 1-DateSort */ { type: "unicode", visible : false }, /* 2-Type */ { width: "5%", searchable: false, class: "center"}, /* 3-CertificateSort */ { type: "unicode", visible : false }, /* 4-Certificate */ { dataSort: 3, class: "left" } ], sorting: [[0,"asc"], [2,"asc"]], displayLength: 20, pagingType: "full_numbers" }); jQuery(".certificate-list").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); } } ViewFactory::make('CertificatesList', $this, $controller, $data)->render(); }