Пример #1
0
 /**
  * AdminConfig@index
  */
 public function index()
 {
     global $WT_TREE;
     $action = Filter::post('action');
     if ($action == 'update' && Filter::checkCsrf()) {
         $this->update();
     }
     Theme::theme(new AdministrationTheme())->init($WT_TREE);
     $ctrl = new PageController();
     $ctrl->restrictAccess(Auth::isAdmin())->setPageTitle($this->module->getTitle());
     $view_bag = new ViewBag();
     $view_bag->set('title', $ctrl->getPageTitle());
     $view_bag->set('module', $this->module);
     ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render();
 }
Пример #2
0
 /**
  * Piwik@index
  */
 public function index()
 {
     $ctrl = new AjaxController();
     $data = new ViewBag();
     $data->set('has_stats', false);
     $block_id = Filter::get('block_id');
     if ($block_id) {
         $cached_item = Cache::get('piwikCountYear', $this->module);
         $visitCountYear = $cached_item->get();
         if (!$cached_item->isHit()) {
             $visitCountYear = $this->getNumberOfVisitsPiwik($block_id);
             Cache::save($cached_item, $visitCountYear);
         }
         if ($visitCountYear) {
             $visitCountToday = max(0, $this->getNumberOfVisitsPiwik($block_id, 'day'));
             $visitCountYear = max(0, $visitCountYear);
             $data->set('has_stats', true);
             $data->set('visits_today', $visitCountToday);
             $data->set('visits_year', $visitCountYear + $visitCountToday);
         }
     }
     ViewFactory::make('PiwikStats', $this, $ctrl, $data)->render();
 }
Пример #3
0
 /**
  * SosaStats@index
  */
 public function index()
 {
     global $WT_TREE;
     $controller = new PageController();
     $controller->setPageTitle(I18N::translate('Sosa Statistics'))->addInlineJavascript('$(".help_tooltip").tooltip();');
     $view_bag = new ViewBag();
     $view_bag->set('title', $controller->getPageTitle());
     $view_bag->set('is_setup', false);
     if ($this->sosa_provider->isSetup()) {
         $view_bag->set('is_setup', true);
         $view_bag->set('root_indi', $this->sosa_provider->getRootIndi());
         $sosaCount = $this->sosa_provider->getSosaCount();
         $diffSosaCount = $this->sosa_provider->getDifferentSosaCount();
         $general_stats = array('sosa_count' => $sosaCount, 'distinct_count' => $diffSosaCount, 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime());
         $view_bag->set('general_stats', $general_stats);
         $stats_gen = $this->sosa_provider->getStatisticsByGeneration();
         $view_bag->set('missinganc_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=SosaList@missing&ged=' . $WT_TREE->getNameUrl() . '&gen=');
         $view_bag->set('sosaanc_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=SosaList&ged=' . $WT_TREE->getNameUrl() . '&gen=');
         $gen_theoretical = 1;
         $total_theoretical = 0;
         $prev_diff = 0;
         $prev_known = 0.5;
         $gen_equiv = 0;
         $generation_stats = array();
         foreach ($stats_gen as $gen => $tab) {
             $genY1 = I18N::translate('-');
             $genY2 = I18N::translate('-');
             if ($tab['firstBirth'] > 0) {
                 $genY1 = $tab['firstBirth'];
             }
             if ($tab['lastBirth'] > 0) {
                 $genY2 = $tab['lastBirth'];
             }
             $total_theoretical += $gen_theoretical;
             $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical);
             $gen_equiv += $perc_sosa_count_theor;
             $missing = 2 * $prev_known - $tab['sosaCount'];
             $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff;
             $generation_stats[$gen] = array('gen_min_birth' => $genY1, 'gen_max_birth' => $genY2, 'theoretical' => $gen_theoretical, 'known' => $tab['sosaCount'], 'perc_known' => $perc_sosa_count_theor, 'missing' => $missing, 'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known), 'total_known' => $tab['sosaTotalCount'], 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), 'different' => $gen_diff, 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), 'total_different' => $tab['diffSosaTotalCount'], 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']));
             $gen_theoretical = $gen_theoretical * 2;
             $prev_known = $tab['sosaCount'];
             $prev_diff = $tab['diffSosaTotalCount'];
         }
         $view_bag->set('generation_stats', $generation_stats);
         $view_bag->set('equivalent_gen', $gen_equiv);
         $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2());
         $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3());
     }
     ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render();
 }
    /**
     * Translation@status
     */
    public function status()
    {
        global $WT_TREE;
        $table_id = \Rhumsaa\Uuid\Uuid::uuid4();
        Theme::theme(new AdministrationTheme())->init($WT_TREE);
        $ctrl = new PageController();
        $ctrl->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Translations status'))->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
                //Datatable initialisation
				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_missing_' . $table_id . '").DataTable({
					' . I18N::datatablesI18N() . ',			
					sorting: [[0, "asc"]],                    
					pageLength: 15,
                    columns: [
						/* 0 Message	 	*/ null,
                        /* 1 Reference      */ null
					],
				});
                
                jQuery("#table_nonused_' . $table_id . '").DataTable({
					' . I18N::datatablesI18N() . ',			
					sorting: [[0, "asc"]],                    
					pageLength: 15,
                    columns: [
						/* 0 Message	 	*/ null,
                        /* 1 Reference      */ null
					],
				});
            ');
        $source_code_paths = array(WT_ROOT . 'vendor/jon48/webtrees-lib/src', WT_ROOT . 'vendor/jon48/webtrees-tools/src/app');
        $analyzer = new TranslationsAnalyzer($source_code_paths);
        $analyzer->load();
        $locale = $analyzer->getLocale();
        $view_bag = new ViewBag();
        $view_bag->set('table_id', $table_id);
        $view_bag->set('module', $this->module);
        $view_bag->set('source_code_paths', $source_code_paths);
        $view_bag->set('title', $ctrl->getPageTitle() . ' - ' . I18N::languageName($locale->languageTag()));
        $view_bag->set('missing_translations', $analyzer->getMissingTranslations());
        $view_bag->set('non_used_translations', $analyzer->getMajNonUsedTranslations());
        $view_bag->set('loading_stats', $analyzer->getLoadingStatistics());
        ViewFactory::make('TranslationStatus', $this, $ctrl, $view_bag)->render();
    }
Пример #5
0
    /**
     * Render the Ajax response for the sortable table of Sosa family
     * @param AjaxController $controller
     */
    protected function renderFamSosaListIndi(AjaxController $controller)
    {
        global $WT_TREE;
        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);
        $this->view_bag->set('has_sosa', false);
        if (count($listFamSosa) > 0) {
            $this->view_bag->set('has_sosa', true);
            $table_id = 'table-sosa-fam-' . Uuid::uuid4();
            $this->view_bag->set('table_id', $table_id);
            $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addInlineJavascript('
                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 . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
                    ' . I18N::datatablesI18N(array(16, 32, 64, 128, -1)) . ',
					jQueryUI: true,
					autoWidth: false,
					processing: true,
					retrieve: true,
					columns: [
						/* 0-Sosa */  	   { dataSort: 1, class: "center"},
		                /* 1-SOSA */ 	   { type: "num", visible: false },
						/* 2-Husb Givn */  { dataSort: 4},
						/* 3-Husb Surn */  { dataSort: 5},
						/* 4-GIVN,SURN */  { type: "unicode", visible: false},
						/* 5-SURN,GIVN */  { type: "unicode", visible: false},
						/* 6-Husb Age  */  { dataSort: 7, class: "center"},
						/* 7-AGE       */  { type: "num", visible: false},
						/* 8-Wife Givn */  { dataSort: 10},
						/* 9-Wife Surn */  { dataSort: 11},
						/* 10-GIVN,SURN */ { type: "unicode", visible: false},
						/* 11-SURN,GIVN */ { type: "unicode", visible: false},
						/* 12-Wife Age  */ { dataSort: 13, class: "center"},
						/* 13-AGE       */ { type: "num", visible: false},
						/* 14-Marr Date */ { dataSort: 15, class: "center"},
						/* 15-MARR:DATE */ { visible: false},
						/* 16-Marr Plac */ { type: "unicode", class: "center"},
						/* 17-Marr Sour */ { dataSort : 18, class: "center", visible: ' . (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME) ? 'true' : 'false') . ' },
						/* 18-Sort Sour */ { visible: false},
						/* 19-Children  */ { dataSort: 20, class: "center"},
						/* 20-NCHI      */ { type: "num", visible: false},
						/* 21-MARR      */ { visible: false},
						/* 22-DEAT      */ { visible: false},
						/* 23-TREE      */ { visible: false}
					],
					sorting: [[0, "asc"]],
					displayLength: 16,
					pagingType: "full_numbers"
			   });
					
				jQuery("#' . $table_id . '")
				/* Hide/show parents */
				.on("click", ".btn-toggle-parents", function() {
					jQuery(this).toggleClass("ui-state-active");
					jQuery(".parents", jQuery(this).closest("table").DataTable().rows().nodes()).slideToggle();
				})
				/* Hide/show statistics */
				.on("click",  ".btn-toggle-statistics", function() {
					jQuery(this).toggleClass("ui-state-active");
					jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle();
				})
				/* Filter buttons in table header */
				.on("click", "button[data-filter-column]", function() {
					var btn = $(this);
					// De-activate the other buttons in this button group
					btn.siblings().removeClass("ui-state-active");
					// Apply (or clear) this filter
					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
					if (btn.hasClass("ui-state-active")) {
						btn.removeClass("ui-state-active");
						col.search("").draw();
					} else {
						btn.addClass("ui-state-active");
						col.search(btn.data("filter-value")).draw();
					}
				});					
				
				jQuery("#sosa-fam-list").css("visibility", "visible");
				
				jQuery("#btn-toggle-statistics-' . $table_id . '").click();
           ');
            $stats = new Stats($WT_TREE);
            $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
            //-- init chart data
            $marr_by_age = array();
            for ($age = 0; $age <= $max_age; $age++) {
                $marr_by_age[$age] = '';
            }
            $birt_by_decade = array();
            $marr_by_decade = array();
            for ($year = 1550; $year < 2030; $year += 10) {
                $birt_by_decade[$year] = '';
                $marr_by_decade[$year] = '';
            }
            foreach ($listFamSosa as $sosa => $fid) {
                $sfamily = Family::getInstance($fid, $WT_TREE);
                if (!$sfamily || !$sfamily->canShow()) {
                    unset($sfamily[$sosa]);
                    continue;
                }
                $mdate = $sfamily->getMarriageDate();
                if (($husb = $sfamily->getHusband()) && ($hdate = $husb->getBirthDate()) && $hdate->isOK() && $mdate->isOK()) {
                    if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
                        $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
                    }
                    $hage = Date::getAge($hdate, $mdate, 0);
                    if ($hage >= 0 && $hage <= $max_age) {
                        $marr_by_age[$hage] .= $husb->getSex();
                    }
                }
                if (($wife = $sfamily->getWife()) && ($wdate = $wife->getBirthDate()) && $wdate->isOK() && $mdate->isOK()) {
                    if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
                        $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
                    }
                    $wage = Date::getAge($wdate, $mdate, 0);
                    if ($wage >= 0 && $wage <= $max_age) {
                        $marr_by_age[$wage] .= $wife->getSex();
                    }
                }
                if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
                    $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
                }
                $listFamSosa[$sosa] = $sfamily;
            }
            $this->view_bag->set('sosa_list', $listFamSosa);
            $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
            $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
            $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
        }
        ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
    }
Пример #6
0
 /**
  * Lineage@index
  */
 public function index()
 {
     global $WT_TREE;
     $controller = new PageController();
     $controller->setPageTitle(I18N::translate('Patronymic Lineages') . ' : ' . $this->legend);
     $view_bag = new ViewBag();
     $view_bag->set('title', $controller->getPageTitle());
     $view_bag->set('tree', $WT_TREE);
     $view_bag->set('alpha', $this->alpha);
     $view_bag->set('surname', $this->surname);
     $view_bag->set('legend', $this->legend);
     $view_bag->set('show_all', $this->show_all);
     if ($this->isShowingSurnames()) {
         $view_bag->set('issurnames', true);
         $view_bag->set('surnameslist', $this->getSurnamesList());
     }
     if ($this->isShowingLineages()) {
         $view_bag->set('islineages', true);
         $view_bag->set('lineages', $this->getLineages());
         if ($this->show_all === 'no') {
             $view_bag->set('table_title', I18N::translate('Individuals in %s lineages', $this->legend));
         } else {
             $view_bag->set('table_title', I18N::translate('All lineages'));
         }
     }
     ViewFactory::make('Lineage', $this, $controller, $view_bag)->render();
 }
Пример #7
0
    /**
     * AdminConfig@index
     */
    public function index()
    {
        global $WT_TREE;
        HookProvider::getInstance()->updateHooks();
        $action = Filter::post('action');
        if ($action == 'update' && Filter::checkCsrf()) {
            $this->update();
        }
        Theme::theme(new AdministrationTheme())->init($WT_TREE);
        $ctrl = new PageController();
        $ctrl->restrictAccess(Auth::isAdmin())->setPageTitle($this->module->getTitle());
        $table_id = 'table-installedhooks-' . Uuid::uuid4();
        $view_bag = new ViewBag();
        $view_bag->set('title', $ctrl->getPageTitle());
        $view_bag->set('table_id', $table_id);
        $view_bag->set('hook_list', HookProvider::getInstance()->getRawInstalledHooks());
        $ctrl->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
		  	jQuery(document).ready(function() {
				jQuery("#' . $table_id . '").dataTable( {
					' . I18N::datatablesI18N() . ',		
					sorting: [[ 2, "asc" ], [ 3, "asc" ]],
					displayLength: 10,
					pagingType: "full_numbers",
					columns: [
						/* 0 Enabled 		*/	{ dataSort: 1, class: "center" },
						/* 1 Enabled sort	*/	{ visible: false},
						/* 2 Hook function	*/	null,
						/* 3 Hook context	*/	null,
						/* 4 Module name	*/	null,
						/* 5 Priority		*/	{ dataSort: 6, class: "center" },
						/* 6 Priority sort	*/	{ type: "num", visible: false}
					]
			  });
			});
		');
        ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render();
    }
Пример #8
0
 /**
  * SosaConfig@computePartial
  */
 public function computePartial()
 {
     global $WT_TREE;
     $controller = new AjaxController();
     $controller->restrictAccess($this->canUpdate());
     $view_bag = new ViewBag();
     $view_bag->set('is_success', false);
     $user = User::find(Filter::getInteger('userid', -1));
     $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE);
     if ($user && $indi) {
         $calculator = new SosaCalculator($WT_TREE, $user);
         if ($calculator->computeFromIndividual($indi)) {
             $view_bag->set('is_success', true);
         }
     } else {
         $view_bag->set('error', I18N::translate('Non existing individual'));
     }
     ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render();
 }
Пример #9
0
 /**
  * Returns HTML code for the GeoAnalysis generations tab.
  *
  * @param GeoAnalysis $ga Reference GeoAnalysis 
  * @param array $placesGenerationsResults Analysis results at a generations level
  * @param (null|array) $flags Array of flags
  * @return string HTML code for the generations tab
  */
 protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null)
 {
     global $WT_TREE;
     if (!empty($placesGenerationsResults) && $ga->getOptions()) {
         $data = new ViewBag();
         ksort($placesGenerationsResults);
         $detailslevel = $ga->getOptions()->getMaxDetailsInGen();
         $data->set('max_details_gen', $detailslevel);
         $data->set('use_flags', $ga->getOptions()->isUsingFlags());
         $data->set('analysis_level', $ga->getAnalysisLevel());
         $display_all_places = !is_null($detailslevel) && $detailslevel == 0;
         $data->set('display_all_places', $display_all_places);
         $results_by_gen = array();
         foreach ($placesGenerationsResults as $gen => $genData) {
             $sum = 0;
             $other = 0;
             $unknown = 0;
             if (isset($genData['sum'])) {
                 $sum = $genData['sum'];
             }
             if (isset($genData['other'])) {
                 $other = $genData['other'];
             }
             if (isset($genData['unknown'])) {
                 $unknown = $genData['unknown'];
             }
             if ($sum > 0) {
                 $results_by_gen[$gen]['sum'] = $sum;
                 $results_by_gen[$gen]['other'] = $other;
                 $results_by_gen[$gen]['unknown'] = $unknown;
                 $results_by_gen[$gen]['places'] = array();
                 arsort($genData['places']);
                 if ($display_all_places) {
                     foreach ($genData['places'] as $placename => $count) {
                         $results_by_gen[$gen]['places'][$placename]['count'] = $count;
                         if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') {
                             $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE);
                             $results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
                         }
                     }
                 } else {
                     $tmp = $genData['places'];
                     if ($other > 0) {
                         $tmp = array_slice($tmp, 0, 5, true);
                         $tmp['other'] = $other;
                         arsort($tmp);
                     }
                     $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true);
                 }
             }
         }
         $data->set('results_by_generations', $results_by_gen);
         $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
     } else {
         $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
     }
     return $html;
 }
Пример #10
0
 /**
  * WelcomeBlock@config
  * 
  * @param string $block_id
  */
 public function config($block_id)
 {
     if (Filter::postBool('save') && Filter::checkCsrf()) {
         $this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled'));
         $this->module->setBlockSetting($block_id, 'piwik_url', trim(Filter::postUrl('piwik_url')));
         $this->module->setBlockSetting($block_id, 'piwik_siteid', trim(Filter::post('piwik_siteid')));
         $this->module->setBlockSetting($block_id, 'piwik_token', trim(Filter::post('piwik_token')));
         Cache::delete('piwikCountYear', $this->module);
         throw new MvcException(200);
         // Use this instead of exit
     }
     $view_bag = new ViewBag();
     // Is Piwik Statistic Enabled ?
     $view_bag->set('piwik_enabled', $this->module->getBlockSetting($block_id, 'piwik_enabled', '0'));
     //Piwik Root Url
     $view_bag->set('piwik_url', $this->module->getBlockSetting($block_id, 'piwik_url', ''));
     // Piwik token
     $view_bag->set('piwik_token', $this->module->getBlockSetting($block_id, 'piwik_token', ''));
     // Piwik side id
     $view_bag->set('piwik_siteid', $this->module->getBlockSetting($block_id, 'piwik_siteid', ''));
     ViewFactory::make('WelcomeBlockConfig', $this, new BaseController(), $view_bag)->renderPartial();
 }
Пример #11
0
 /**
  * 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();
 }
Пример #12
0
    /**
     * AdminConfig@index
     */
    public function index()
    {
        global $WT_TREE;
        Theme::theme(new AdministrationTheme())->init($WT_TREE);
        $controller = new PageController();
        $controller->restrictAccess(Auth::isAdmin())->setPageTitle($this->module->getTitle());
        $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
        if (is_null($token)) {
            $token = Functions::generateRandomToken();
            $this->module->setSetting('PAT_FORCE_EXEC_TOKEN', $token);
        }
        $data = new ViewBag();
        $data->set('title', $controller->getPageTitle());
        $table_id = 'table-admintasks-' . Uuid::uuid4();
        $data->set('table_id', $table_id);
        $data->set('trigger_url_root', WT_BASE_URL . 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@trigger');
        $token = $this->module->getSetting('MAJ_AT_FORCE_EXEC_TOKEN');
        if (is_null($token)) {
            $token = Functions::generateRandomToken();
            $this->module->setSetting('MAJ_AT_FORCE_EXEC_TOKEN', $token);
        }
        $data->set('trigger_token', $token);
        $this->provider->getInstalledTasks();
        $controller->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
                //Datatable initialisation
				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);};
	
				var adminTasksTable = jQuery("#' . $table_id . '").DataTable({
					' . I18N::datatablesI18N() . ',			
					sorting: [[3, "asc"]],
					pageLength: 10,
                    processing: true,
                    serverSide : true,
					ajax : {
						url : "module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@jsonTasksList&ged=' . $WT_TREE->getNameUrl() . '",
                        type : "POST"
					},
                    columns: [
						/* 0 Edit		 	*/ { sortable: false, className: "text-center"},
                        /* 1 task_name      */ { visible: false },
						/* 2 Enabled 		*/ { sortable: false, className: "text-center"  },
						/* 3 Task Title		*/ null,
						/* 4 Last Run		*/ null,
						/* 5 Last status 	*/ { className: "text-center" },
						/* 6 Frequency      */ { sortable: false, className: "text-center" },
						/* 7 Nb Occcurrences*/ { sortable: false, className: "text-center" },
						/* 8 Is Running    	*/ { sortable: false, className: "text-center" },					
						/* 9 Run task		*/ { sortable: false, className: "text-center" }
					],
				});
                
                ')->addInlineJavascript('					
					function generate_force_token() {
						jQuery("#bt_genforcetoken").attr("disabled", "disabled");
						jQuery("#bt_tokentext").empty().html("<i class=\\"fa fa-spinner fa-pulse fa-fw\\"></i>");
						jQuery("#token_url").load(
							"module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@generateToken",
							function() {
								jQuery("#bt_genforcetoken").removeAttr("disabled");
								jQuery("#bt_tokentext").empty().html("' . I18N::translate('Regenerate token') . '");
                                adminTasksTable.ajax.reload();
							}
						);
					}
				
                    function set_admintask_status(task, status) {
                		jQuery.ajax({
                            url: "module.php", 
                            type: "GET",
                            data: {
                			    mod: "' . $this->module->getName() . '",
                                mod_action:  "Task@setStatus",
                			    task: task,
                                status: status
                            },
                            error: function(result, stat, error) {
                                var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error;
                                alert("' . I18N::translate('An error occured while editing this task:') . '" + err);
                            },
                            complete: function(result, stat) {
                                adminTasksTable.ajax.reload(null, false);
                            }                            
                		});
                    } 
                    
                    function run_admintask(taskname) {
                        jQuery("#bt_runtask_" + taskname).attr("disabled", "disabled");
				        jQuery("#bt_runtasktext_" + taskname).empty().html("<i class=\\"fa fa-cog fa-spin fa-fw\\"></i><span class=\\"sr-only\\">' . I18N::translate('Running') . '</span>");
				        jQuery("#bt_runtasktext_" + taskname).load(
					       "module.php?mod=' . $this->module->getName() . '&mod_action=Task@trigger&force=' . $token . '&task=" + taskname,
        					function() {
        						jQuery("#bt_runtasktext_" + taskname).empty().html("<i class=\\"fa fa-check\\"></i>' . I18N::translate('Done') . '");
        						adminTasksTable.ajax.reload();
        					}
				        );
                    
                    } 
                ');
        ViewFactory::make('AdminConfig', $this, $controller, $data)->render();
    }
Пример #13
0
 /**
  * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one.
  * 
  * @param (GeoAnalysis!null) $ga GeoAnalysis to edit
  */
 protected function renderEdit(GeoAnalysis $ga = null)
 {
     global $WT_TREE;
     Theme::theme(new AdministrationTheme())->init($WT_TREE);
     $controller = new PageController();
     $controller->restrictAccess(Auth::isManager($WT_TREE))->addInlineJavascript('
             function toggleMapOptions() {
                 if($("input:radio[name=\'use_map\']:checked").val() == 1) {
                     $("#map_options").show();
                 }
                 else {
                     $("#map_options").hide();
                 }
             }
     
             $("[name=\'use_map\']").on("change", toggleMapOptions);
             toggleMapOptions();
         ');
     $data = new ViewBag();
     if ($ga) {
         $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
         $data->set('geo_analysis', $ga);
     } else {
         $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
     }
     $data->set('title', $controller->getPageTitle());
     $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl());
     $data->set('module_title', $this->module->getTitle());
     $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl());
     $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
     $map_list = array_map(function (OutlineMap $map) {
         return $map->getDescription();
     }, $this->provider->getOutlineMapsList());
     asort($map_list);
     $data->set('map_list', $map_list);
     $gen_details = array(0 => I18N::translate('All'));
     for ($i = 1; $i <= 10; $i++) {
         $gen_details[$i] = $i;
     }
     $data->set('generation_details', $gen_details);
     ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
 }
Пример #14
0
 /**
  * Task@edit
  */
 public function edit()
 {
     global $WT_TREE;
     $task_name = Filter::get('task');
     $task = $this->provider->getTask($task_name, false);
     Theme::theme(new AdministrationTheme())->init($WT_TREE);
     $controller = new PageController();
     $controller->restrictAccess(Auth::isAdmin() && $task)->setPageTitle(I18N::translate('Edit the administrative task'))->addInlineJavascript('
             function toggleRemainingOccurrences() {
                 if($("input:radio[name=\'is_limited\']:checked").val() == 1) {
                     $("#nb_occurences").show();
                 }
                 else {
                     $("#nb_occurences").hide();
                 }
             }
     
             $("[name=\'is_limited\']").on("change", toggleRemainingOccurrences);
             toggleRemainingOccurrences();
         ');
     $data = new ViewBag();
     $data->set('title', $controller->getPageTitle());
     $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl());
     $data->set('module_title', $this->module->getTitle());
     $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl());
     $data->set('task', $task);
     ViewFactory::make('TaskEdit', $this, $controller, $data)->render();
 }