Ejemplo n.º 1
1
 /**
  * get edit menu
  */
 public function getEditMenu()
 {
     if (!$this->record || $this->record->isPendingDeletion()) {
         return null;
     }
     // edit menu
     $menu = new Menu(I18N::translate('Edit'), '#', 'menu-sour');
     if (Auth::isEditor($this->record->getTree())) {
         $fact = $this->record->getFirstFact('TITL');
         if ($fact) {
             // Edit existing name
             $menu->addSubmenu(new Menu(I18N::translate('Edit the source'), '#', 'menu-sour-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");')));
         } else {
             // Add new name
             $menu->addSubmenu(new Menu(I18N::translate('Edit the source'), '#', 'menu-sour-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "TITL");')));
         }
         // delete
         $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-sour-del', array('onclick' => "return delete_record('" . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');")));
     }
     // edit raw
     if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
         $menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-sour-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
     }
     return $menu;
 }
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Module\GeoDispersion\Views\AbstractGeoAnalysisTabGeneralView::htmlAnalysisData()
  */
 protected function htmlAnalysisData()
 {
     $results = $this->data->get('results');
     $analysis_level = $this->data->get('analysis_level');
     $nb_found = $this->data->get('stats_gen_nb_found');
     $nb_other = $this->data->get('stats_gen_nb_other');
     $i = 1;
     $previous_nb = 0;
     $html = '<div class="maj-table center">';
     foreach ($results as $place => $nb) {
         $perc = Functions::safeDivision($nb, $nb_found - $nb_other);
         if ($nb != $previous_nb) {
             $j = I18N::number($i);
         } else {
             $j = '&nbsp;';
         }
         $levels = array_map('trim', explode(',', $place));
         $placename = $levels[$analysis_level - 1];
         if ($placename == '' && $analysis_level > 1) {
             $placename = I18N::translate('Unknown (%s)', $levels[$analysis_level - 2]);
         }
         $html .= '<div class="maj-row">
             <div class="label"><strong>' . $j . '</strong></div>
             <div class="label">' . $placename . '</div>
             <div class="value">' . I18N::translate('%d', $nb) . '</div>
             <div class="value">' . I18N::percentage($perc, 1) . '</div>
          </div>';
         $i++;
         $previous_nb = $nb;
     }
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 3
0
 /**
  * get edit menu
  */
 public function getEditMenu()
 {
     if (!$this->record || $this->record->isPendingDeletion()) {
         return null;
     }
     // edit menu
     $menu = new Menu(I18N::translate('Edit'), '#', 'menu-repo');
     if (Auth::isEditor($this->record->getTree())) {
         $fact = $this->record->getFirstFact('NAME');
         if ($fact) {
             // Edit existing name
             $menu->addSubmenu(new Menu(I18N::translate('Edit the repository'), '#', 'menu-repo-edit', array('onclick' => 'return edit_record("' . $this->record->getXref() . '", "' . $fact->getFactId() . '");')));
         } else {
             // Add new name
             $menu->addSubmenu(new Menu(I18N::translate('Edit the repository'), '#', 'menu-repo-edit', array('onclick' => 'return add_fact("' . $this->record->getXref() . '", "NAME");')));
         }
     }
     // delete
     if (Auth::isEditor($this->record->getTree())) {
         $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-repo-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
     }
     // edit raw
     if (Auth::isAdmin() || Auth::isEditor($this->record->getTree()) && $this->record->getTree()->getPreference('SHOW_GEDCOM_RECORD')) {
         $menu->addSubmenu(new Menu(I18N::translate('Edit the raw GEDCOM'), '#', 'menu-repo-editraw', array('onclick' => 'return edit_raw("' . $this->record->getXref() . '");')));
     }
     // add to favorites
     if (Module::getModuleByName('user_favorites')) {
         $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-repo-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite" ,{xref:"' . $this->record->getXref() . '"},function(){location.reload();})')));
     }
     return $menu;
 }
Ejemplo n.º 4
0
    /**
     * {@inhericDoc}
     * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
     */
    protected function renderContent()
    {
        if ($this->data->get('is_success', false)) {
            ?>
        
        	<i class="icon-maj-success" title="<?php 
            echo I18N::translate('Success');
            ?>
"></i>&nbsp;
        	<?php 
            echo I18N::translate('Success');
            ?>
        <?php 
        } else {
            ?>
			<i class="icon-maj-error" title="<?php 
            echo I18N::translate('Error');
            ?>
"></i>&nbsp;
			<?php 
            echo I18N::translate('Error');
            ?>
			<?php 
            if ($error = $this->data->get('error')) {
                echo '&nbsp;-&nbsp;' . $error;
            }
        }
    }
Ejemplo n.º 5
0
 /**
  * Manage updates sent from the AdminConfig@index form.
  */
 protected function update()
 {
     if (Auth::isAdmin()) {
         $this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
         $this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
         if ($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
             $this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
         }
         if ($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
             $this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
         }
         // Only accept valid color for MAJ_WM_FONT_COLOR
         $MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');
         if ($MAJ_WM_FONT_COLOR) {
             $this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
         }
         // Only accept valid folders for MAJ_CERT_ROOTDIR
         $MAJ_CERT_ROOTDIR = preg_replace('/[\\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
         if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
             $MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
         }
         if ($MAJ_CERT_ROOTDIR) {
             if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
                 $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
             } elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
                 $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
                 FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
             } else {
                 FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
             }
         }
         FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
         return;
     }
 }
Ejemplo n.º 6
0
 /**
  * get edit menu
  */
 public function getEditMenu()
 {
     if (!$this->record || $this->record->isPendingDeletion()) {
         return null;
     }
     // edit menu
     $menu = new Menu(I18N::translate('Edit'), '#', 'menu-note');
     if (Auth::isEditor($this->record->getTree())) {
         $menu->addSubmenu(new Menu(I18N::translate('Edit note'), '#', 'menu-note-edit', array('onclick' => 'return edit_note("' . $this->record->getXref() . '");')));
     }
     // delete
     if (Auth::isEditor($this->record->getTree())) {
         $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array('onclick' => 'return delete_note("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJS(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
     }
     // add to favorites
     if (Module::getModuleByName('user_favorites')) {
         $menu->addSubmenu(new Menu(I18N::translate('Add to favorites'), '#', 'menu-note-addfav', array('onclick' => 'jQuery.post("module.php?mod=user_favorites&mod_action=menu-add-favorite",{xref:"' . $this->record->getXref() . '"},function(){location.reload();})')));
     }
     // Get the link for the first submenu and set it as the link for the main menu
     if ($menu->getSubmenus()) {
         $submenus = $menu->getSubmenus();
         $menu->setLink($submenus[0]->getLink());
         $menu->setAttrs($submenus[0]->getAttrs());
     }
     return $menu;
 }
Ejemplo n.º 7
0
 /**
  * Create the chart controller
  *
  * @param int $show_full needed for use by charts module
  */
 public function __construct($show_full = 1)
 {
     global $WT_TREE;
     parent::__construct();
     $rootid = Filter::get('rootid', WT_REGEX_XREF);
     $this->root = Individual::getInstance($rootid, $WT_TREE);
     if (!$this->root) {
         // Missing root individual? Show the chart for someone.
         $this->root = $this->getSignificantIndividual();
     }
     if (!$this->root || !$this->root->canShowName()) {
         http_response_code(404);
         $this->error_message = I18N::translate('This individual does not exist or you do not have permission to view it.');
     }
     // Extract parameter from form
     if ($show_full) {
         $this->show_full = Filter::getInteger('show_full', 0, 1, $WT_TREE->getPreference('PEDIGREE_FULL_DETAILS'));
     } else {
         $this->show_full = 0;
     }
     $this->box = new \stdClass();
     if ($this->showFull()) {
         $this->box->width = Theme::theme()->parameter('chart-box-x');
         $this->box->height = Theme::theme()->parameter('chart-box-y');
     } else {
         $this->box->width = Theme::theme()->parameter('compact-chart-box-x');
         $this->box->height = Theme::theme()->parameter('compact-chart-box-y');
     }
 }
    /**
     * {@inhericDoc}
     * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
     */
    protected function renderContent()
    {
        $nb_found = $this->data->get('stats_gen_nb_found');
        $nb_other = $this->data->get('stats_gen_nb_other');
        $nb_unknown = $this->data->get('stats_gen_nb_unknown');
        $perc_known = Functions::safeDivision($nb_found - $nb_other, $nb_found + $nb_unknown);
        $html = '<div id="geodispersion_summary">
        	<div class="maj-table center">
        		<div class="maj-row">
        			<div class="label">' . I18N::translate('Places found') . '</div>
        			<div class="value">' . I18N::translate('%1$d (%2$s)', $nb_found - $nb_other, I18N::percentage($perc_known)) . '</div>
        		</div>';
        if ($nb_other > 0) {
            $perc_other = Functions::safeDivision($nb_other, $nb_found + $nb_unknown);
            $html .= '<div class="maj-row">
        			<div class="label">' . I18N::translate('Other places') . '</div>
        			<div class="value">' . I18N::translate('%1$d (%2$s)', $nb_other, I18N::percentage($perc_other)) . '</div>
        		</div>';
        }
        $html .= '<div class="maj-row">
        			<div class="label">' . I18N::translate('Places not found') . '</div>
        			<div class="value">' . I18N::translate('%1$d (%2$s)', $nb_unknown, I18N::percentage(1 - $perc_known)) . '</div>
        		</div>
        	</div>
        </div>
        <br/>
		<div id="geodispersion_data">
		' . $this->htmlAnalysisData() . '
		</div>';
        return $html;
    }
Ejemplo n.º 9
0
    public function pageBody()
    {
        $tmp_dir = WT_DATA_DIR . 'ftv_pdf_tmp/';
        define('_JPGRAPH_PATH', $tmp_dir);
        define('_MPDF_TEMP_PATH', $tmp_dir);
        define('_MPDF_TTFONTDATAPATH', $tmp_dir);
        require_once WT_MODULES_DIR . $this->getName() . '/mpdf/mpdf.php';
        $stylesheet = file_get_contents($this->directory . '/css/style.css');
        $stylesheet_rtl = file_get_contents($this->directory . '/css/style-rtl.css');
        $html = Filter::post('pdfContent');
        $header = '<header>=== ' . $this->tree()->getTitleHtml() . ' ===</header>';
        $footer = '<footer>' . '<table><tr>' . '<td class="left">' . WT_BASE_URL . '</td>' . '<td class="center">{DATE d-m-Y}</td>' . '<td class="right">{PAGENO}</td>' . '</tr></table>' . '</footer>';
        $mpdf = new mPDF();
        $mpdf->simpleTables = true;
        $mpdf->shrink_tables_to_fit = 1;
        $mpdf->autoScriptToLang = true;
        $mpdf->baseScript = 1;
        $mpdf->autoVietnamese = true;
        $mpdf->autoArabic = true;
        $mpdf->autoLangToFont = true;
        if (I18N::direction() === 'rtl') {
            $mpdf->SetDirectionality('rtl');
            $mpdf->WriteHTML($stylesheet_rtl, 1);
        } else {
            $mpdf->WriteHTML($stylesheet, 1);
        }
        $mpdf->setAutoTopMargin = 'stretch';
        $mpdf->setAutoBottomMargin = 'stretch';
        $mpdf->autoMarginPadding = 5;
        $admin = User::find($this->tree()->getPreference('WEBMASTER_USER_ID'))->getRealName();
        $mpdf->setCreator($this->getTitle() . ' - a webtrees module by justcarmen.nl');
        $mpdf->SetTitle(Filter::get('title'));
        $mpdf->setAuthor($admin);
        $mpdf->SetHTMLHeader($header);
        $mpdf->setHTMLFooter($footer);
        $html_chunks = explode("\n", $html);
        $chunks = count($html_chunks);
        $i = 1;
        foreach ($html_chunks as $html_chunk) {
            // write html body parts only (option 2);
            if ($i === 1) {
                // first chunk (initialize all buffers - init=true)
                $mpdf->WriteHTML($html_chunk, 2, true, false);
            } elseif ($i === $chunks) {
                // last chunck (close all buffers - close=true)
                $mpdf->WriteHTML($html_chunk, 2, false, true);
            } else {
                // all other parts (keep the buffer open)
                $mpdf->WriteHTML($html_chunk, 2, false, false);
            }
            $i++;
        }
        $index = '
				<pagebreak type="next-odd" />
				<h2>' . I18N::translate('Index') . '</h2>
				<columns column-count="2" column-gap="5" />
				<indexinsert usedivletters="on" links="on" collation="' . WT_LOCALE . '.utf8" collationgroup="' . I18N::collation() . '" />';
        $mpdf->writeHTML($index);
        $mpdf->Output($tmp_dir . Filter::get('title') . '.pdf', 'F');
    }
Ejemplo n.º 10
0
 /** {@inheritDoc} */
 public function upgrade()
 {
     // add key 'LINK' to FTV_SETTINGS
     // change options to multidimensional array with array key = tree id.
     $module_settings = 'FTV_SETTINGS';
     $ftv_settings = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_settings))->fetchOne();
     $settings = unserialize($ftv_settings);
     if (!empty($settings)) {
         foreach ($settings as $setting) {
             if (!array_key_exists('LINK', $setting)) {
                 $setting['LINK'] = I18N::translate('Descendants of the %s family', $setting['SURNAME']);
                 $new_settings[] = $setting;
             }
         }
         if (isset($new_settings)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_settings), $module_settings));
         }
         unset($new_settings);
     }
     $module_options = 'FTV_OPTIONS';
     $ftv_options = Database::prepare("SELECT setting_value FROM `##module_setting` WHERE setting_name=?")->execute(array($module_options))->fetchOne();
     $options = unserialize($ftv_options);
     if (!empty($options)) {
         $show_places = array_key_exists('SHOW_PLACES', $options) ? $options['SHOW_PLACES'] : '1';
         $country = array_key_exists('COUNTRY', $options) ? $options['COUNTRY'] : '';
         $show_occu = array_key_exists('SHOW_OCCU', $options) ? $options['SHOW_OCCU'] : '1';
         foreach (Tree::getAll() as $tree) {
             $new_options[$tree->getTreeId()] = array('SHOW_PLACES' => $show_places, 'COUNTRY' => $country, 'SHOW_OCCU' => $show_occu);
         }
         if (isset($new_options)) {
             Database::prepare("UPDATE `##module_setting` SET setting_value=? WHERE setting_name=?")->execute(array(serialize($new_options), $module_options));
         }
         unset($new_options);
     }
 }
Ejemplo n.º 11
0
    public function pageBody()
    {
        $cache_dir = WT_DATA_DIR . 'ftv_cache/';
        define("_JPGRAPH_PATH", $cache_dir);
        define("_MPDF_TEMP_PATH", $cache_dir);
        define('_MPDF_TTFONTDATAPATH', $cache_dir);
        require_once WT_MODULES_DIR . $this->getName() . '/packages/mpdf60/mpdf.php';
        $tmpfile = $cache_dir . 'fancy-treeview-tmp.txt';
        if (file_exists($cache_dir) && is_readable($tmpfile)) {
            $stylesheet = file_get_contents($this->directory . '/css/pdf/style.css');
            $stylesheet_rtl = file_get_contents($this->directory . '/css/pdf/style-rtl.css');
            $html = file_get_contents($tmpfile);
            $header = '<header>=== ' . $this->tree->getTitleHtml() . ' ===</header>';
            $footer = '<footer>' . '<table><tr>' . '<td class="left">' . WT_BASE_URL . '</td>' . '<td class="center">{DATE d-m-Y}</td>' . '<td class="right">{PAGENO}</td>' . '</tr></table>' . '</footer>';
            $mpdf = new mPDF();
            $mpdf->simpleTables = true;
            $mpdf->shrink_tables_to_fit = 1;
            $mpdf->autoScriptToLang = true;
            if (I18N::direction() === 'rtl') {
                $mpdf->SetDirectionality('rtl');
            }
            if (I18N::direction() === 'rtl') {
                $mpdf->WriteHTML($stylesheet_rtl, 1);
            } else {
                $mpdf->WriteHTML($stylesheet, 1);
            }
            $mpdf->setAutoTopMargin = 'stretch';
            $mpdf->setAutoBottomMargin = 'stretch';
            $mpdf->autoMarginPadding = 5;
            $admin = User::find($this->tree->getPreference('WEBMASTER_USER_ID'))->getRealName();
            $mpdf->setCreator($this->getTitle() . ' - a webtrees module by justcarmen.nl');
            $mpdf->SetTitle(Filter::get('title'));
            $mpdf->setAuthor($admin);
            $mpdf->SetHTMLHeader($header);
            $mpdf->setHTMLFooter($footer);
            $html_chunks = explode("\n", $html);
            $chunks = count($html_chunks);
            $i = 1;
            foreach ($html_chunks as $html_chunk) {
                if ($i === 1) {
                    $mpdf->WriteHTML($html_chunk, 2, true, false);
                } elseif ($i === $chunks) {
                    $mpdf->WriteHTML($html_chunk, 2, false, false);
                } else {
                    $mpdf->WriteHTML($html_chunk, 2, false, true);
                }
                $i++;
            }
            $index = '
				<pagebreak type="next-odd" />
				<h2>' . I18N::translate('Index') . '</h2>
				<columns column-count="2" column-gap="5" />
				<indexinsert usedivletters="on" links="on" collation="' . WT_LOCALE . '.utf8" collationgroup="' . I18N::collation() . '" />';
            $mpdf->writeHTML($index);
            $mpdf->Output(Filter::get('title') . '.pdf', 'D');
        } else {
            echo $this->addMessage('alert', 'danger', false, I18N::translate('Error: the pdf file could not be generated.'));
        }
    }
Ejemplo n.º 12
0
 /**
  * Default buttons are update and update_all
  *
  * @param string $xref
  *
  * @return string[]
  */
 public function getActionButtons($xref)
 {
     if (Auth::user()->getPreference('auto_accept')) {
         return array(BatchUpdateModule::createSubmitButton(I18N::translate('Update'), $xref, 'update'), BatchUpdateModule::createSubmitButton(I18N::translate('Update all'), $xref, 'update_all'));
     } else {
         return array(BatchUpdateModule::createSubmitButton(I18N::translate('Update'), $xref, 'update'));
     }
 }
 /**
  * The sortname is used in the pdf index
  *
  * @param type $person
  * @return type
  */
 private function getSortName($person)
 {
     $sortname = $person->getSortName();
     $text1 = I18N::translateContext('Unknown given name', '…');
     $text2 = I18N::translateContext('Unknown surname', '…');
     $search = array(',', '@P.N.', '@N.N.');
     $replace = array(', ', $text1, $text2);
     return str_replace($search, $replace, $sortname);
 }
Ejemplo n.º 14
0
 /**
  * {@inhericDoc}
  * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
  */
 protected function renderContent()
 {
     if ($this->data->get('has_stats', false)) {
         $html = I18N::translate('%1$s visits since the beginning of %2$s<br>(%3$s today)', '<span class="odometer">' . I18N::number($this->data->get('visits_year')) . '</span>', date('Y'), '<span class="odometer">' . I18N::number($this->data->get('visits_today')) . '</span>');
     } else {
         $html = I18N::translate('No statistics could be retrieved from Piwik.');
     }
     return $html;
 }
 /**
  * Get the translatable country name for the search area.
  * 
  * @global type $WT_TREE
  * @param type $area
  * @return string
  */
 static function getSearchAreaName($area)
 {
     global $WT_TREE;
     $stats = new Stats($WT_TREE);
     $countries = $stats->getAllCountries();
     if (array_key_exists($area, $countries)) {
         $area = $countries[$area];
     } else {
         $area = I18N::translate("International");
     }
     return $area;
 }
Ejemplo n.º 16
0
 /**
  * Process <var var="">
  *
  * @param string[] $attrs
  */
 protected function varStartHandler($attrs)
 {
     if (preg_match('/^I18N::number\\((.+)\\)$/', $attrs['var'], $match)) {
         $this->text .= I18N::number($match[1]);
     } elseif (preg_match('/^I18N::translate\\(\'(.+)\'\\)$/', $attrs['var'], $match)) {
         $this->text .= I18N::translate($match[1]);
     } elseif (preg_match('/^I18N::translateContext\\(\'(.+)\', *\'(.+)\'\\)$/', $attrs['var'], $match)) {
         $this->text .= I18N::translateContext($match[1], $match[2]);
     } else {
         $this->text .= $attrs['var'];
     }
 }
Ejemplo n.º 17
0
 /**
  * get edit menu
  */
 public function getEditMenu()
 {
     if (!$this->record || $this->record->isPendingDeletion()) {
         return null;
     }
     // edit menu
     $menu = new Menu(I18N::translate('Edit'), '#', 'menu-note');
     if (Auth::isEditor($this->record->getTree())) {
         $menu->addSubmenu(new Menu(I18N::translate('Edit the note'), '#', 'menu-note-edit', array('onclick' => 'return edit_note("' . $this->record->getXref() . '");')));
         // delete
         $menu->addSubmenu(new Menu(I18N::translate('Delete'), '#', 'menu-note-del', array('onclick' => 'return delete_record("' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeJs(Filter::unescapeHtml($this->record->getFullName()))) . '", "' . $this->record->getXref() . '");')));
     }
     return $menu;
 }
Ejemplo n.º 18
0
 /**
  * This is a general purpose hook, allowing modules to respond to routes
  * of the form module.php?mod=FOO&mod_action=BAR
  *
  * @param string $mod_action
  */
 public function modAction($mod_action)
 {
     global $WT_TREE;
     switch ($mod_action) {
         case 'menu-add-favorite':
             // Process the "add to user favorites" menu item on indi/fam/etc. pages
             $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
             if (Auth::check() && $record->canShowName()) {
                 self::addFavorite(array('user_id' => Auth::id(), 'gedcom_id' => $record->getTree()->getTreeId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => null, 'title' => null));
                 FlashMessages::addMessage(I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
             }
             break;
     }
 }
Ejemplo n.º 19
0
 /**
  * Translate a code, for an optional record
  *
  * @param string $type
  *
  * @return string
  */
 public static function getValue($type)
 {
     switch ($type) {
         case '3':
             return I18N::translate('primary evidence');
         case '2':
             return I18N::translate('secondary evidence');
         case '1':
             return I18N::translate('questionable evidence');
         case '0':
             return I18N::translate('unreliable evidence');
         default:
             return $type;
     }
 }
Ejemplo n.º 20
0
    private function pageBody(PageController $controller)
    {
        ?>
		<!-- ADMIN PAGE CONTENT -->
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>
		<h2><?php 
        echo $controller->getPageTitle();
        ?>
</h2>
		<form class="form-inline" method="post">
			<?php 
        echo Filter::getCsrf();
        ?>
			<input type="hidden" name="save" value="1">
			<!-- SHOW PDF -->
			<div class="form-group">
				<label class="control-label">
					<?php 
        echo I18N::translate('Access level');
        ?>
				</label>
				<?php 
        echo FunctionsEdit::editFieldAccessLevel('NEW_FTV_PDF_ACCESS_LEVEL', $this->getSetting('FTV_PDF_ACCESS_LEVEL'), 'class="form-control"');
        ?>
			</div>
			<!-- BUTTONS -->
			<button class="btn btn-primary" type="submit">
				<i class="fa fa-check"></i>
				<?php 
        echo I18N::translate('save');
        ?>
			</button>
		</form>
		<?php 
    }
Ejemplo n.º 21
0
    /**
     * 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();
    }
Ejemplo n.º 22
0
 /**
  * Manage updates sent from the AdminConfig@index form.
  */
 protected function update()
 {
     global $WT_TREE;
     if (Auth::isAdmin()) {
         $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX'));
         $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1));
         $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE));
         $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER'));
         $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1));
         $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE));
         $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER'));
         $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1));
         $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE'));
         FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
         return;
     }
 }
Ejemplo n.º 23
0
 /**
  * print a child ascendancy
  *
  * @param Individual $individual
  * @param int        $sosa  child sosa number
  * @param int        $depth the ascendancy depth to show
  */
 public function printChildAscendancy(Individual $individual, $sosa, $depth)
 {
     echo '<li>';
     echo '<table><tbody><tr><td>';
     if ($sosa === 1) {
         echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="3" width="', Theme::theme()->parameter('chart-descendancy-indent'), '"></td><td>';
     } else {
         echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="3" width="2" alt="">';
         echo '<img src="', Theme::theme()->parameter('image-hline'), '" height="3" width="', Theme::theme()->parameter('chart-descendancy-indent') - 2, '"></td><td>';
     }
     FunctionsPrint::printPedigreePerson($individual, $this->showFull());
     echo '</td><td>';
     if ($sosa > 1) {
         FunctionsCharts::printUrlArrow('?rootid=' . $individual->getXref() . '&amp;PEDIGREE_GENERATIONS=' . $this->generations . '&amp;show_full=' . $this->showFull() . '&amp;chart_style=' . $this->chart_style . '&amp;ged=' . $individual->getTree()->getNameUrl(), I18N::translate('Ancestors of %s', $individual->getFullName()), 3);
     }
     echo '</td><td class="details1">&nbsp;<span class="person_box' . ($sosa === 1 ? 'NN' : ($sosa % 2 ? 'F' : '')) . '">', I18N::number($sosa), '</span> ';
     echo '</td><td class="details1">&nbsp;', FunctionsCharts::getSosaName($sosa), '</td>';
     echo '</tr></tbody></table>';
     // Parents
     $family = $individual->getPrimaryChildFamily();
     if ($family && $depth > 0) {
         // Marriage details
         echo '<span class="details1">';
         echo '<img src="', Theme::theme()->parameter('image-spacer'), '" height="2" width="', Theme::theme()->parameter('chart-descendancy-indent'), '" alt=""><a href="#" onclick="return expand_layer(\'sosa_', $sosa, '\');" class="top"><i id="sosa_', $sosa, '_img" class="icon-minus" title="', I18N::translate('View family'), '"></i></a>';
         echo ' <span class="person_box">', I18N::number($sosa * 2), '</span> ', I18N::translate('and');
         echo ' <span class="person_boxF">', I18N::number($sosa * 2 + 1), '</span>';
         if ($family->canShow()) {
             foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) {
                 echo ' <a href="', $family->getHtmlUrl(), '" class="details1">', $fact->summary(), '</a>';
             }
         }
         echo '</span>';
         // display parents recursively - or show empty boxes
         echo '<ul id="sosa_', $sosa, '" class="generation">';
         if ($family->getHusband()) {
             $this->printChildAscendancy($family->getHusband(), $sosa * 2, $depth - 1);
         }
         if ($family->getWife()) {
             $this->printChildAscendancy($family->getWife(), $sosa * 2 + 1, $depth - 1);
         }
         echo '</ul>';
     }
     echo '</li>';
 }
Ejemplo n.º 24
0
 /**
  * Startup activity
  */
 public function __construct()
 {
     // Automatically fix broken links
     if ($this->record && $this->record->canEdit()) {
         $broken_links = 0;
         foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
             if (!$fact->isPendingDeletion() && $fact->getTarget() === null) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         foreach ($this->record->getFacts('NOTE|SOUR|OBJE') as $fact) {
             // These can be links or inline.  Only delete links.
             if (!$fact->isPendingDeletion() && $fact->getTarget() === null && preg_match('/^@.*@$/', $fact->getValue())) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         if ($broken_links) {
             // Reload the updated family
             $this->record = GedcomRecord::getInstance($this->record->getXref(), $this->record->getTree());
         }
     }
     parent::__construct();
     // We want robots to index this page
     $this->setMetaRobots('index,follow');
     // Set a page title
     if ($this->record) {
         if ($this->record->canShowName()) {
             // e.g. "John Doe" or "1881 Census of Wales"
             $this->setPageTitle($this->record->getFullName());
         } else {
             // e.g. "Individual" or "Source"
             $record = $this->record;
             $this->setPageTitle(GedcomTag::getLabel($record::RECORD_TYPE));
         }
     } else {
         // No such record
         $this->setPageTitle(I18N::translate('Private'));
     }
 }
Ejemplo n.º 25
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $WT_TREE;
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = '<span dir="auto">' . I18N::translate('Welcome %s', Auth::user()->getRealNameHtml()) . '</span>';
     $content = '<table><tr>';
     $content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . I18N::translate('My account') . '</a></td>';
     $gedcomid = $WT_TREE->getUserPreference(Auth::user(), 'gedcomid');
     if ($gedcomid) {
         $content .= '<td><a href="pedigree.php?rootid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('My pedigree') . '</a></td>';
         $content .= '<td><a href="individual.php?pid=' . $gedcomid . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('My individual record') . '</a></td>';
     }
     $content .= '</tr></table>';
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo n.º 26
0
 /**
  * Load this sidebar synchronously.
  *
  * @return string
  */
 public function getSidebarContent()
 {
     global $controller;
     $indifacts = array();
     // The individual’s own facts
     foreach ($controller->record->getFacts() as $fact) {
         if (self::showFact($fact)) {
             $indifacts[] = $fact;
         }
     }
     ob_start();
     if (!$indifacts) {
         echo I18N::translate('There are no facts for this individual.');
     } else {
         foreach ($indifacts as $fact) {
             FunctionsPrintFacts::printFact($fact, $controller->record);
         }
     }
     return strip_tags(ob_get_clean(), '<a><div><span>');
 }
Ejemplo n.º 27
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $controller, $WT_TREE;
     $indi_xref = $controller->getSignificantIndividual()->getXref();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = $WT_TREE->getTitleHtml();
     $content = '<table><tr>';
     $content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></td>';
     $content .= '<td><a href="individual.php?pid=' . $indi_xref . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></td>';
     if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) {
         $content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . I18N::translate('Request new user account') . '</a></td>';
     }
     $content .= "</tr>";
     $content .= "</table>";
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo n.º 28
0
 /**
  * Translate a code, for an (optional) record
  *
  * @param string               $type
  * @param GedcomRecord|null $record
  *
  * @return string
  */
 public static function getValue($type, GedcomRecord $record = null)
 {
     if ($record instanceof Individual) {
         $sex = $record->getSex();
     } else {
         $sex = 'U';
     }
     switch ($type) {
         case 'BOTH':
             switch ($sex) {
                 case 'M':
                     return I18N::translateContext('MALE', 'Adopted by both parents');
                 case 'F':
                     return I18N::translateContext('FEMALE', 'Adopted by both parents');
                 default:
                     return I18N::translate('Adopted by both parents');
             }
         case 'HUSB':
             switch ($sex) {
                 case 'M':
                     return I18N::translateContext('MALE', 'Adopted by father');
                 case 'F':
                     return I18N::translateContext('FEMALE', 'Adopted by father');
                 default:
                     return I18N::translate('Adopted by father');
             }
         case 'WIFE':
             switch ($sex) {
                 case 'M':
                     return I18N::translateContext('MALE', 'Adopted by mother');
                 case 'F':
                     return I18N::translateContext('FEMALE', 'Adopted by mother');
                 default:
                     return I18N::translate('Adopted by mother');
             }
         default:
             return $type;
     }
 }
Ejemplo n.º 29
0
 /**
  * WelcomeBlock@index
  * 
  * @param PageController $parent_controller
  * @param Tree $tree
  * @param string $block_id
  * @param string $template
  * @return $string
  */
 public function index(PageController $parent_controller, Tree $tree, $block_id, $template)
 {
     $view_bag = new ViewBag();
     if ($parent_controller && $tree) {
         $view_bag->set('tree', $tree);
         $view_bag->set('indi', $parent_controller->getSignificantIndividual());
         $id = $this->module->getName() . $block_id;
         $class = $this->module->getName() . '_block';
         $parent_controller->addInlineJavascript('
             jQuery("#maj-new_passwd").hide();
             jQuery("#maj-passwd_click").click(function()
             {
                 jQuery("#maj-new_passwd").slideToggle(100, function() {
                     jQuery("#maj-new_passwd_username").focus();
 			});
 					return false;
 				  });
 			');
         if (Auth::isAdmin()) {
             $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $tree->getNameHtml() . '&amp;ctype=gedcom"></a>';
         } else {
             $title = '';
         }
         $title .= '<span dir="auto">' . $tree->getTitleHtml() . '</span>';
         $piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false);
         $view_bag->set('piwik_enabled', $piwik_enabled);
         if ($piwik_enabled) {
             $parent_controller->addInlineJavascript('$("#piwik_stats")
                     .load("module.php?mod=' . $this->module->getName() . '&mod_action=Piwik&block_id=' . $block_id . '");');
         }
         $content = ViewFactory::make('WelcomeBlock', $this, new BaseController(), $view_bag)->getHtmlPartial();
         if ($template) {
             return Theme::theme()->formatBlock($id, $title, $class, $content);
         } else {
             return $content;
         }
     }
 }
Ejemplo n.º 30
0
 /**
  * {@inhericDoc}
  * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
  */
 protected function renderContent()
 {
     return '
         <tr>
             <td class="descriptionbox wrap width33">' . I18N::translate('Enable Piwik Statistics') . '</td>
             <td class="optionbox">' . FunctionsEdit::editFieldYesNo('piwik_enabled', $this->data->get('piwik_enabled', '0')) . '</td>
         </tr>' . '<tr>
             <td class="descriptionbox wrap width33">' . I18N::translate('Piwik URL') . '</td>
             <td class="optionbox">
                 <input type="text" name="piwik_url" size="45" value="' . $this->data->get('piwik_url', '') . '" />
             </td>
         </tr>' . '<tr>
             <td class="descriptionbox wrap width33">' . I18N::translate('Piwik Token') . '</td>
             <td class="optionbox">
                 <input type="text" name="piwik_token" size="45" value="' . $this->data->get('piwik_token', '') . '" />
             </td>
         </tr>' . '<tr>
             <td class="descriptionbox wrap width33">' . I18N::translate('Piwik Site ID') . '</td>
             <td class="optionbox">
                 <input type="text" name="piwik_siteid" size="4" value="' . $this->data->get('piwik_siteid', '') . '" />
             </td>
         </tr>';
 }