Ejemplo n.º 1
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)
 {
     switch ($mod_action) {
         case 'delete':
             $stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
             foreach (Filter::postArray('message_id') as $id) {
                 $stmt->execute(array('message_id' => $id, 'user_id' => Auth::id()));
             }
     }
     $ged = Filter::post('ged');
     $ctype = Filter::post('ctype', 'user|gedcom', 'user');
     header('Location: ' . WT_BASE_URL . 'index.php?ged=' . Filter::escapeUrl($ged) . '&ctype=' . $ctype);
 }
Ejemplo n.º 2
0
                        $tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', null);
                    }
                }
            }
        }
        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
        return;
}
switch (Filter::get('action')) {
    case 'load_json':
        // Generate an AJAX/JSON response for datatables to load a block of rows
        $search = Filter::postArray('search');
        $search = $search['value'];
        $start = Filter::postInteger('start');
        $length = Filter::postInteger('length');
        $order = Filter::postArray('order');
        $sql_select = "SELECT SQL_CACHE SQL_CALC_FOUND_ROWS '', u.user_id, user_name, real_name, email, us1.setting_value, us2.setting_value, us2.setting_value, us3.setting_value, us3.setting_value, us4.setting_value, us5.setting_value" . " FROM `##user` u" . " LEFT JOIN `##user_setting` us1 ON (u.user_id=us1.user_id AND us1.setting_name='language')" . " LEFT JOIN `##user_setting` us2 ON (u.user_id=us2.user_id AND us2.setting_name='reg_timestamp')" . " LEFT JOIN `##user_setting` us3 ON (u.user_id=us3.user_id AND us3.setting_name='sessiontime')" . " LEFT JOIN `##user_setting` us4 ON (u.user_id=us4.user_id AND us4.setting_name='verified')" . " LEFT JOIN `##user_setting` us5 ON (u.user_id=us5.user_id AND us5.setting_name='verified_by_admin')" . " WHERE u.user_id > 0";
        $args = array();
        if ($search) {
            $sql_select .= " AND (user_name LIKE CONCAT('%', :search_1, '%') OR real_name LIKE CONCAT('%', :search_2, '%') OR email LIKE CONCAT('%', :search_3, '%'))";
            $args['search_1'] = $search;
            $args['search_2'] = $search;
            $args['search_3'] = $search;
        }
        if ($order) {
            $sql_select .= " ORDER BY ";
            foreach ($order as $key => $value) {
                if ($key > 0) {
                    $sql_select .= ',';
                }
                // Datatables numbers columns 0, 1, 2
Ejemplo n.º 3
0
 if ($AUTH) {
     $newgedrec .= "\n1 AUTH " . $AUTH;
 }
 $PUBL = Filter::post('PUBL');
 if ($PUBL) {
     $newgedrec .= "\n1 PUBL " . preg_replace('/\\r?\\n/', "\n2 CONT ", $PUBL);
 }
 $REPO = Filter::post('REPO', WT_REGEX_XREF);
 if ($REPO) {
     $newgedrec .= "\n1 REPO @" . $REPO . '@';
     $CALN = Filter::post('CALN');
     if ($CALN) {
         $newgedrec .= "\n1 CALN " . $CALN;
     }
 }
 $EVEN = Filter::postArray('EVEN', WT_REGEX_TAG);
 if ($EVEN) {
     $newgedrec .= "\n1 DATA";
     $newgedrec .= "\n2 EVEN " . implode(',', $EVEN);
     $EVEN_DATE = Filter::post('EVEN_DATE');
     if ($EVEN_DATE) {
         $newgedrec .= "\n3 EVEN_DATE " . $EVEN_DATE;
     }
     $EVEN_PLAC = Filter::post('EVEN_PLAC');
     if ($EVEN_PLAC) {
         $newgedrec .= "\n3 EVEN_PLAC " . $EVEN_PLAC;
     }
     $AGNC = Filter::post('AGNC');
     if ($AGNC) {
         $newgedrec .= "\n2 AGNC " . $AGNC;
     }
Ejemplo n.º 4
0
    case 'tracking':
        if (Filter::checkCsrf()) {
            Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
            Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
            Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
            Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
            Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
            Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
            Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
        return;
    case 'languages':
        if (Filter::checkCsrf()) {
            Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
        return;
}
// Lists of options for <select> controls.
$SMTP_SSL_OPTIONS = array('none' => I18N::translate('none'), 'ssl' => I18N::translate('ssl'), 'tls' => I18N::translate('tls'));
$SMTP_ACTIVE_OPTIONS = array('internal' => I18N::translate('Use PHP mail to send messages'), 'external' => I18N::translate('Use SMTP to send messages'));
$WELCOME_TEXT_AUTH_MODE_OPTIONS = array(0 => I18N::translate('No predefined text'), 1 => I18N::translate('Predefined text that states all users can request a user account'), 2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'), 3 => I18N::translate('Predefined text that states only family members can request a user account'), 4 => I18N::translate('Choose user defined welcome text typed below'));
$language_tags = array();
foreach (I18N::activeLocales() as $active_locale) {
    $language_tags[] = $active_locale->languageTag();
}
switch (Filter::get('action')) {
    case 'site':
Ejemplo n.º 5
0
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\Query\QueryMedia;
define('WT_SCRIPT_NAME', 'addmedia.php');
require './includes/session.php';
$NO_UPDATE_CHAN = $WT_TREE->getPreference('NO_UPDATE_CHAN');
$MEDIA_DIRECTORY = $WT_TREE->getPreference('MEDIA_DIRECTORY');
$pid = Filter::get('pid', WT_REGEX_XREF, Filter::post('pid', WT_REGEX_XREF));
// edit this media object
$linktoid = Filter::get('linktoid', WT_REGEX_XREF, Filter::post('linktoid', WT_REGEX_XREF));
// create a new media object, linked to this record
$action = Filter::get('action', null, Filter::post('action'));
$filename = Filter::get('filename', null, Filter::post('filename'));
$text = Filter::postArray('text');
$tag = Filter::postArray('tag', WT_REGEX_TAG);
$islink = Filter::postArray('islink');
$glevels = Filter::postArray('glevels', '[0-9]');
$folder = Filter::post('folder');
$update_CHAN = !Filter::postBool('preserve_last_changed');
$controller = new SimpleController();
$controller->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();')->restrictAccess(Auth::isMember($WT_TREE));
$disp = true;
$media = Media::getInstance($pid, $WT_TREE);
if ($media) {
    $disp = $media->canShow();
}
if ($action == 'update' || $action == 'create') {
    if ($linktoid) {
        $disp = GedcomRecord::getInstance($linktoid, $WT_TREE)->canShow();
    }
}
if (!Auth::isEditor($WT_TREE) || !$disp) {
    /**
     * Action from the configuration page
     */
    private function edit()
    {
        global $WT_TREE;
        if (Filter::postBool('save') && Filter::checkCsrf()) {
            $block_id = Filter::postInteger('block_id');
            if ($block_id) {
                Database::prepare("UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'block_order' => Filter::postInteger('block_order'), 'block_id' => $block_id));
            } else {
                Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'module_name' => $this->getName(), 'block_order' => Filter::postInteger('block_order')));
                $block_id = Database::getInstance()->lastInsertId();
            }
            $this->setBlockSetting($block_id, 'header', Filter::post('header'));
            $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody'));
            $languages = Filter::postArray('lang');
            $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
            $this->config();
        } else {
            $block_id = Filter::getInteger('block_id');
            $controller = new PageController();
            if ($block_id) {
                $controller->setPageTitle(I18N::translate('Edit FAQ item'));
                $header = $this->getBlockSetting($block_id, 'header');
                $faqbody = $this->getBlockSetting($block_id, 'faqbody');
                $block_order = Database::prepare("SELECT block_order FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne();
                $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne();
            } else {
                $controller->setPageTitle(I18N::translate('Add an FAQ item'));
                $header = '';
                $faqbody = '';
                $block_order = Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name")->execute(array('module_name' => $this->getName()))->fetchOne();
                $gedcom_id = $WT_TREE->getTreeId();
            }
            $controller->pageHeader();
            if (Module::getModuleByName('ckeditor')) {
                CkeditorModule::enableEditor($controller);
            }
            ?>
			<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><a
						href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&mod_action=admin_config"><?php 
            echo I18N::translate('Frequently asked questions');
            ?>
</a>
				</li>
				<li class="active"><?php 
            echo $controller->getPageTitle();
            ?>
</li>
			</ol>
			<h1><?php 
            echo $controller->getPageTitle();
            ?>
</h1>

			<form name="faq" class="form-horizontal" method="post" action="module.php?mod=<?php 
            echo $this->getName();
            ?>
&amp;mod_action=admin_edit">
			<?php 
            echo Filter::getCsrf();
            ?>
			<input type="hidden" name="save" value="1">
			<input type="hidden" name="block_id" value="<?php 
            echo $block_id;
            ?>
">

			<div class="form-group">
				<label for="header" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Question');
            ?>
				</label>

				<div class="col-sm-9">
					<input type="text" class="form-control" name="header" id="header"
					       value="<?php 
            echo Filter::escapeHtml($header);
            ?>
">
				</div>
			</div>

			<div class="form-group">
				<label for="faqbody" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Answer');
            ?>
				</label>

				<div class="col-sm-9">
					<textarea name="faqbody" id="faqbody" class="form-control html-edit"
					          rows="10"><?php 
            echo Filter::escapeHtml($faqbody);
            ?>
</textarea>
				</div>
			</div>

			<div class="form-group">
				<label for="xref" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('Show this block for which languages?');
            ?>
				</label>

				<div class="col-sm-9">
					<?php 
            echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages')));
            ?>
				</div>
			</div>

			<div class="form-group">
				<label for="block_order" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('FAQ position');
            ?>
				</label>

				<div class="col-sm-9">
					<input type="text" name="block_order" id="block_order" class="form-control" value="<?php 
            echo $block_order;
            ?>
">
				</div>
			</div>

			<div class="form-group">
				<label for="gedcom_id" class="col-sm-3 control-label">
					<?php 
            echo I18N::translate('FAQ visibility');
            ?>
				</label>

				<div class="col-sm-9">
					<?php 
            echo FunctionsEdit::selectEditControl('gedcom_id', Tree::getIdList(), I18N::translate('All'), $gedcom_id, 'class="form-control"');
            ?>
					<p class="small text-muted">
						<?php 
            echo I18N::translate('A FAQ item can be displayed on just one of the family trees, or on all the family trees.');
            ?>
					</p>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-3 col-sm-9">
					<button type="submit" class="btn btn-primary">
						<i class="fa fa-check"></i>
						<?php 
            echo I18N::translate('save');
            ?>
					</button>
				</div>
			</div>

		</form>
		<?php 
        }
    }
Ejemplo n.º 7
0
 $WT_TREE->setPreference('REPO_ID_PREFIX', Filter::post('REPO_ID_PREFIX'));
 $WT_TREE->setPreference('SAVE_WATERMARK_IMAGE', Filter::postBool('SAVE_WATERMARK_IMAGE'));
 $WT_TREE->setPreference('SAVE_WATERMARK_THUMB', Filter::postBool('SAVE_WATERMARK_THUMB'));
 $WT_TREE->setPreference('SHOW_COUNTER', Filter::postBool('SHOW_COUNTER'));
 $WT_TREE->setPreference('SHOW_EST_LIST_DATES', Filter::postBool('SHOW_EST_LIST_DATES'));
 $WT_TREE->setPreference('SHOW_FACT_ICONS', Filter::postBool('SHOW_FACT_ICONS'));
 $WT_TREE->setPreference('SHOW_GEDCOM_RECORD', Filter::postBool('SHOW_GEDCOM_RECORD'));
 $WT_TREE->setPreference('SHOW_HIGHLIGHT_IMAGES', Filter::postBool('SHOW_HIGHLIGHT_IMAGES'));
 $WT_TREE->setPreference('SHOW_LAST_CHANGE', Filter::postBool('SHOW_LAST_CHANGE'));
 $WT_TREE->setPreference('SHOW_LDS_AT_GLANCE', Filter::postBool('SHOW_LDS_AT_GLANCE'));
 $WT_TREE->setPreference('SHOW_MEDIA_DOWNLOAD', Filter::post('SHOW_MEDIA_DOWNLOAD'));
 $WT_TREE->setPreference('SHOW_NO_WATERMARK', Filter::post('SHOW_NO_WATERMARK'));
 $WT_TREE->setPreference('SHOW_PARENTS_AGE', Filter::postBool('SHOW_PARENTS_AGE'));
 $WT_TREE->setPreference('SHOW_PEDIGREE_PLACES', Filter::post('SHOW_PEDIGREE_PLACES'));
 $WT_TREE->setPreference('SHOW_PEDIGREE_PLACES_SUFFIX', Filter::postBool('SHOW_PEDIGREE_PLACES_SUFFIX'));
 $WT_TREE->setPreference('SHOW_RELATIVES_EVENTS', implode(',', Filter::postArray('SHOW_RELATIVES_EVENTS')));
 $WT_TREE->setPreference('SOURCE_ID_PREFIX', Filter::post('SOURCE_ID_PREFIX'));
 $WT_TREE->setPreference('SOUR_FACTS_ADD', str_replace(' ', '', Filter::post('SOUR_FACTS_ADD')));
 $WT_TREE->setPreference('SOUR_FACTS_QUICK', str_replace(' ', '', Filter::post('SOUR_FACTS_QUICK')));
 $WT_TREE->setPreference('SOUR_FACTS_UNIQUE', str_replace(' ', '', Filter::post('SOUR_FACTS_UNIQUE')));
 $WT_TREE->setPreference('SUBLIST_TRIGGER_I', Filter::post('SUBLIST_TRIGGER_I', WT_REGEX_INTEGER, 200));
 $WT_TREE->setPreference('SURNAME_LIST_STYLE', Filter::post('SURNAME_LIST_STYLE'));
 $WT_TREE->setPreference('SURNAME_TRADITION', Filter::post('SURNAME_TRADITION'));
 $WT_TREE->setPreference('THEME_DIR', Filter::post('THEME_DIR'));
 $WT_TREE->setPreference('THUMBNAIL_WIDTH', Filter::post('THUMBNAIL_WIDTH'));
 $WT_TREE->setPreference('USE_SILHOUETTE', Filter::postBool('USE_SILHOUETTE'));
 $WT_TREE->setPreference('WATERMARK_THUMB', Filter::postBool('WATERMARK_THUMB'));
 $WT_TREE->setPreference('WEBMASTER_USER_ID', Filter::post('WEBMASTER_USER_ID'));
 $WT_TREE->setPreference('WEBTREES_EMAIL', Filter::post('WEBTREES_EMAIL'));
 $WT_TREE->setPreference('title', Filter::post('title'));
 // Only accept valid folders for MEDIA_DIRECTORY
Ejemplo n.º 8
0
    /**
     * An HTML form to edit block settings
     *
     * @param int $block_id
     */
    public function configureBlock($block_id)
    {
        global $WT_TREE;
        if (Filter::postBool('save') && Filter::checkCsrf()) {
            $languages = Filter::postArray('lang');
            $this->setBlockSetting($block_id, 'gedcom', Filter::post('gedcom'));
            $this->setBlockSetting($block_id, 'title', Filter::post('title'));
            $this->setBlockSetting($block_id, 'html', Filter::post('html'));
            $this->setBlockSetting($block_id, 'show_timestamp', Filter::postBool('show_timestamp'));
            $this->setBlockSetting($block_id, 'timestamp', Filter::post('timestamp'));
            $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
        }
        $templates = array(I18N::translate('Keyword examples') => '#getAllTagsTable#', I18N::translate('Narrative description') => I18N::translate('This family tree was last updated on #gedcomUpdated#. There are #totalSurnames# surnames in this family tree. The earliest recorded event is the #firstEventType# of #firstEventName# in #firstEventYear#. The most recent event is the #lastEventType# of #lastEventName# in #lastEventYear#.<br><br>If you have any comments or feedback please contact #contactWebmaster#.'), I18N::translate('Statistics') => '<div class="gedcom_stats">
				<span style="font-weight: bold;"><a href="index.php?command=gedcom">#gedcomTitle#</a></span><br>
				' . I18N::translate('This family tree was last updated on %s.', '#gedcomUpdated#') . '
				<table id="keywords">
					<tr>
						<td valign="top" class="width20">
							<table cellspacing="1" cellpadding="0">
								<tr>
									<td class="facts_label">' . I18N::translate('Individuals') . '</td>
									<td class="facts_value" align="right"><a href="indilist.php?surname_sublist=no">#totalIndividuals#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Males') . '</td>
									<td class="facts_value" align="right">#totalSexMales#<br>#totalSexMalesPercentage#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Females') . '</td>
									<td class="facts_value" align="right">#totalSexFemales#<br>#totalSexFemalesPercentage#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Total surnames') . '</td>
									<td class="facts_value" align="right"><a href="indilist.php?show_all=yes&amp;surname_sublist=yes&amp;ged=' . $WT_TREE->getNameUrl() . '">#totalSurnames#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Families') . '</td>
									<td class="facts_value" align="right"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalFamilies#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Sources') . '</td>
									<td class="facts_value" align="right"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalSources#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Media objects') . '</td>
									<td class="facts_value" align="right"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalMedia#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Repositories') . '</td>
									<td class="facts_value" align="right"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">#totalRepositories#</a></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Total events') . '</td>
									<td class="facts_value" align="right">#totalEvents#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Total users') . '</td>
									<td class="facts_value" align="right">#totalUsers#</td>
								</tr>
							</table>
						</td>
						<td><br></td>
						<td valign="top">
							<table cellspacing="1" cellpadding="0" border="0">
								<tr>
									<td class="facts_label">' . I18N::translate('Earliest birth year') . '</td>
									<td class="facts_value" align="right">#firstBirthYear#</td>
									<td class="facts_value">#firstBirth#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Latest birth year') . '</td>
									<td class="facts_value" align="right">#lastBirthYear#</td>
									<td class="facts_value">#lastBirth#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Earliest death year') . '</td>
									<td class="facts_value" align="right">#firstDeathYear#</td>
									<td class="facts_value">#firstDeath#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Latest death year') . '</td>
									<td class="facts_value" align="right">#lastDeathYear#</td>
									<td class="facts_value">#lastDeath#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Individual who lived the longest') . '</td>
									<td class="facts_value" align="right">#longestLifeAge#</td>
									<td class="facts_value">#longestLife#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Average age at death') . '</td>
									<td class="facts_value" align="right">#averageLifespan#</td>
									<td class="facts_value"></td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Family with the most children') . '</td>
									<td class="facts_value" align="right">#largestFamilySize#</td>
									<td class="facts_value">#largestFamily#</td>
								</tr>
								<tr>
									<td class="facts_label">' . I18N::translate('Average number of children per family') . '</td>
									<td class="facts_value" align="right">#averageChildren#</td>
									<td class="facts_value"></td>
								</tr>
							</table>
						</td>
					</tr>
				</table><br>
				<span style="font-weight: bold;">' . I18N::translate('Most common surnames') . '</span><br>
				#commonSurnames#
			</div>');
        $title = $this->getBlockSetting($block_id, 'title');
        $html = $this->getBlockSetting($block_id, 'html');
        $gedcom = $this->getBlockSetting($block_id, 'gedcom');
        $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
        $languages = explode(',', $this->getBlockSetting($block_id, 'languages'));
        echo '<tr><td class="descriptionbox wrap">', GedcomTag::getLabel('TITL'), '</td><td class="optionbox"><input type="text" name="title" size="30" value="', Filter::escapeHtml($title), '"></td></tr>';
        // templates
        echo '<tr><td class="descriptionbox wrap">', I18N::translate('Templates'), '</td><td class="optionbox wrap">';
        // The CK editor needs lots of help to load/save data :-(
        if (Module::getModuleByName('ckeditor')) {
            $ckeditor_onchange = 'CKEDITOR.instances.html.setData(document.block.html.value);';
        } else {
            $ckeditor_onchange = '';
        }
        echo '<select name="template" onchange="document.block.html.value=document.block.template.options[document.block.template.selectedIndex].value;', $ckeditor_onchange, '">';
        echo '<option value="', Filter::escapeHtml($html), '">', I18N::translate('Custom'), '</option>';
        foreach ($templates as $title => $template) {
            echo '<option value="', Filter::escapeHtml($template), '">', $title, '</option>';
        }
        echo '</select>';
        if (!$html) {
            echo '<p>', I18N::translate('To assist you in getting started with this block, we have created several standard templates. When you select one of these templates, the text area will contain a copy that you can then alter to suit your site’s requirements.'), '</p>';
        }
        echo '</td></tr>';
        if (count(Tree::getAll()) > 1) {
            if ($gedcom == '__current__') {
                $sel_current = 'selected';
            } else {
                $sel_current = '';
            }
            if ($gedcom == '__default__') {
                $sel_default = 'selected';
            } else {
                $sel_default = '';
            }
            echo '<tr><td class="descriptionbox wrap">', I18N::translate('Family tree'), '</td><td class="optionbox">', '<select name="gedcom">', '<option value="__current__" ', $sel_current, '>', I18N::translate('Current'), '</option>', '<option value="__default__" ', $sel_default, '>', I18N::translate('Default'), '</option>';
            foreach (Tree::getAll() as $tree) {
                if ($tree->getName() === $gedcom) {
                    $sel = 'selected';
                } else {
                    $sel = '';
                }
                echo '<option value="', $tree->getNameHtml(), '" ', $sel, '>', $tree->getTitleHtml(), '</option>';
            }
            echo '</select>';
            echo '</td></tr>';
        }
        // html
        echo '<tr><td colspan="2" class="descriptionbox">', I18N::translate('Content');
        if (!$html) {
            echo '<p>', I18N::translate('As well as using the toolbar to apply HTML formatting, you can insert database fields which are updated automatically. These special fields are marked with <b>#</b> characters. For example <b>#totalFamilies#</b> will be replaced with the actual number of families in the database. Advanced users may wish to apply CSS classes to their text, so that the formatting matches the currently selected theme.'), '</p>';
        }
        echo '</td></tr><tr>', '<td colspan="2" class="optionbox">';
        echo '<textarea name="html" class="html-edit" rows="10" style="width:98%;">', Filter::escapeHtml($html), '</textarea>';
        echo '</td></tr>';
        echo '<tr><td class="descriptionbox wrap">';
        echo I18N::translate('Show the date and time of update');
        echo '</td><td class="optionbox">';
        echo FunctionsEdit::editFieldYesNo('show_timestamp', $show_timestamp);
        echo '<input type="hidden" name="timestamp" value="', WT_TIMESTAMP, '">';
        echo '</td></tr>';
        echo '<tr><td class="descriptionbox wrap">';
        echo I18N::translate('Show this block for which languages?');
        echo '</td><td class="optionbox">';
        echo FunctionsEdit::editLanguageCheckboxes('lang', $languages);
        echo '</td></tr>';
    }
Ejemplo n.º 9
0
 * Defined in session.php
 *
 * @global Tree $WT_TREE
 */
global $WT_TREE;
use Fisharebest\Webtrees\Controller\PageController;
use Fisharebest\Webtrees\Functions\FunctionsDb;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
define('WT_SCRIPT_NAME', 'admin_site_merge.php');
require './includes/session.php';
$controller = new PageController();
$controller->restrictAccess(Auth::isManager($WT_TREE))->setPageTitle(I18N::translate('Merge records') . ' — ' . $WT_TREE->getTitleHtml())->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();');
$gid1 = Filter::post('gid1', WT_REGEX_XREF, Filter::get('gid1', WT_REGEX_XREF));
$gid2 = Filter::post('gid2', WT_REGEX_XREF, Filter::get('gid2', WT_REGEX_XREF));
$keep1 = Filter::postArray('keep1');
$keep2 = Filter::postArray('keep2');
$rec1 = GedcomRecord::getInstance($gid1, $WT_TREE);
$rec2 = GedcomRecord::getInstance($gid2, $WT_TREE);
if ($gid1 && !$rec1) {
    FlashMessages::addMessage(I18N::translate('%1$s does not exist.', $gid1), 'danger');
}
if ($gid2 && !$rec2) {
    FlashMessages::addMessage(I18N::translate('%1$s does not exist.', $gid2), 'danger');
}
if ($rec1 && $rec2 && $rec1->getXref() === $rec2->getXref()) {
    FlashMessages::addMessage(I18N::translate('You entered the same IDs. You cannot merge the same records.'), 'danger');
}
if ($rec1 && $rec2 && $rec1::RECORD_TYPE !== $rec2::RECORD_TYPE) {
    FlashMessages::addMessage(I18N::translate('Records are not the same type. Cannot merge records that are not the same type.'), 'danger');
}
// Facts found both records
 /**
  * Action from the configuration page
  */
 private function editSave()
 {
     if (Filter::checkCsrf()) {
         $block_id = Filter::postInteger('block_id');
         if ($block_id) {
             Database::prepare("UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'block_order' => Filter::postInteger('block_order'), 'block_id' => $block_id));
         } else {
             Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'module_name' => $this->getName(), 'block_order' => Filter::postInteger('block_order')));
             $block_id = Database::getInstance()->lastInsertId();
         }
         $this->setBlockSetting($block_id, 'header', Filter::post('header'));
         $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody'));
         $languages = Filter::postArray('lang');
         $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
     }
 }
Ejemplo n.º 11
0
    /**
     * Show and process a form to edit a story.
     */
    private function edit()
    {
        global $WT_TREE;
        if (Auth::isEditor($WT_TREE)) {
            if (Filter::postBool('save') && Filter::checkCsrf()) {
                $block_id = Filter::postInteger('block_id');
                if ($block_id) {
                    Database::prepare("UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?")->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $block_id));
                } else {
                    Database::prepare("INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)")->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $this->getName(), 0));
                    $block_id = Database::getInstance()->lastInsertId();
                }
                $this->setBlockSetting($block_id, 'title', Filter::post('title'));
                $this->setBlockSetting($block_id, 'story_body', Filter::post('story_body'));
                $languages = Filter::postArray('lang');
                $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
                $this->config();
            } else {
                $block_id = Filter::getInteger('block_id');
                $controller = new PageController();
                if ($block_id) {
                    $controller->setPageTitle(I18N::translate('Edit story'));
                    $title = $this->getBlockSetting($block_id, 'title');
                    $story_body = $this->getBlockSetting($block_id, 'story_body');
                    $xref = Database::prepare("SELECT xref FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
                } else {
                    $controller->setPageTitle(I18N::translate('Add a story'));
                    $title = '';
                    $story_body = '';
                    $xref = Filter::get('xref', WT_REGEX_XREF);
                }
                $controller->pageHeader()->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();');
                if (Module::getModuleByName('ckeditor')) {
                    CkeditorModule::enableEditor($controller);
                }
                $individual = Individual::getInstance($xref, $WT_TREE);
                ?>
				<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><a href="module.php?mod=<?php 
                echo $this->getName();
                ?>
&mod_action=admin_config"><?php 
                echo $this->getTitle();
                ?>
</a></li>
					<li class="active"><?php 
                echo $controller->getPageTitle();
                ?>
</li>
				</ol>

				<h1><?php 
                echo $controller->getPageTitle();
                ?>
</h1>

				<form class="form-horizontal" method="post" action="module.php?mod=<?php 
                echo $this->getName();
                ?>
&amp;mod_action=admin_edit">
					<?php 
                echo Filter::getCsrf();
                ?>
					<input type="hidden" name="save" value="1">
					<input type="hidden" name="block_id" value="<?php 
                echo $block_id;
                ?>
">
					<input type="hidden" name="gedcom_id" value="<?php 
                echo $WT_TREE->getTreeId();
                ?>
">

					<div class="form-group">
						<label for="title" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Story title');
                ?>
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="title" id="title" value="<?php 
                echo Filter::escapeHtml($title);
                ?>
">
						</div>
					</div>

					<div class="form-group">
						<label for="story_body" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Story');
                ?>
						</label>
						<div class="col-sm-9">
							<textarea name="story_body" id="story_body" class="html-edit form-control" rows="10"><?php 
                echo Filter::escapeHtml($story_body);
                ?>
</textarea>
						</div>
					</div>

					<div class="form-group">
						<label for="xref" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Individual');
                ?>
						</label>
						<div class="col-sm-9">
							<input data-autocomplete-type="INDI" type="text" name="xref" id="xref" size="4" value="<?php 
                echo $xref;
                ?>
">
							<?php 
                echo FunctionsPrint::printFindIndividualLink('xref');
                ?>
							<?php 
                if ($individual) {
                    ?>
								<?php 
                    echo $individual->formatList('span');
                    ?>
							<?php 
                }
                ?>
						</div>
					</div>

					<div class="form-group">
						<label for="xref" class="col-sm-3 control-label">
							<?php 
                echo I18N::translate('Show this block for which languages?');
                ?>
						</label>
						<div class="col-sm-9">
							<?php 
                echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages')));
                ?>
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-3 col-sm-9">
							<button type="submit" class="btn btn-primary">
								<i class="fa fa-check"></i>
								<?php 
                echo I18N::translate('save');
                ?>
							</button>
						</div>
					</div>

				</form>
				<?php 
            }
        } else {
            header('Location: ' . WT_BASE_URL);
        }
    }
Ejemplo n.º 12
0
 /** {@inheritdoc} */
 public function modAction($mod_action)
 {
     Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
     switch ($mod_action) {
         case 'admin_config':
             $template = new AdminTemplate();
             return $template->pageContent();
         case 'admin_search':
             // new settings
             $surname = Filter::post('SURNAME');
             $pid = Filter::post('PID');
             if ($surname) {
                 $soundex_std = Filter::postBool('soundex_std');
                 $soundex_dm = Filter::postBool('soundex_dm');
                 $indis = $this->module()->indisArray($surname, $soundex_std, $soundex_dm);
                 usort($indis, 'Fisharebest\\Webtrees\\Individual::compareBirthDate');
                 if (isset($indis) && count($indis) > 0) {
                     $pid = $indis[0]->getXref();
                 } else {
                     $result['error'] = I18N::translate('Error: The surname you entered doesn’t exist in this tree.');
                 }
             }
             if (isset($pid)) {
                 $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
                 if ($this->module()->searchArray($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree')), 'PID', $pid)) {
                     if ($surname) {
                         $result['error'] = I18N::translate('Error: The root person belonging to this surname already exists');
                     } else {
                         $result['error'] = I18N::translate('Error: A root person with ID %s already exists', $pid);
                     }
                 } else {
                     $record = Individual::getInstance($pid, $this->tree);
                     if ($record) {
                         $root = $record->getFullName() . ' (' . $record->getLifeSpan() . ')';
                         $title = $this->module()->getPageLink($pid);
                         $result = array('access_level' => '2', 'pid' => $pid, 'root' => $root, 'sort' => count($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree'))) + 1, 'surname' => $this->module()->getSurname($pid), 'title' => $title, 'tree' => Filter::getInteger('tree'));
                     } else {
                         if (empty($result['error'])) {
                             $result['error'] = I18N::translate('Error: A person with ID %s does not exist in this tree', $pid);
                         }
                     }
                 }
             }
             echo json_encode($result);
             break;
         case 'admin_add':
             $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
             $NEW_FTV_SETTINGS = $FTV_SETTINGS;
             $NEW_FTV_SETTINGS[] = array('TREE' => Filter::getInteger('tree'), 'SURNAME' => Filter::post('surname'), 'PID' => Filter::post('pid'), 'ACCESS_LEVEL' => Filter::postInteger('access_level'), 'SORT' => Filter::postInteger('sort'));
             $this->setSetting('FTV_SETTINGS', serialize(array_values($NEW_FTV_SETTINGS)));
             Log::addConfigurationLog($this->getTitle() . ' config updated');
             break;
         case 'admin_update':
             $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
             $new_surname = Filter::postArray('surname');
             $new_access_level = Filter::postArray('access_level');
             $new_sort = Filter::postArray('sort');
             foreach ($new_surname as $key => $new_surname) {
                 $FTV_SETTINGS[$key]['SURNAME'] = $new_surname;
             }
             foreach ($new_access_level as $key => $new_access_level) {
                 $FTV_SETTINGS[$key]['ACCESS_LEVEL'] = $new_access_level;
             }
             foreach ($new_sort as $key => $new_sort) {
                 $FTV_SETTINGS[$key]['SORT'] = $new_sort;
             }
             $NEW_FTV_SETTINGS = $this->module()->sortArray($FTV_SETTINGS, 'SORT');
             $this->setSetting('FTV_SETTINGS', serialize($NEW_FTV_SETTINGS));
             break;
         case 'admin_save':
             $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS'));
             $FTV_OPTIONS[Filter::getInteger('tree')] = Filter::postArray('NEW_FTV_OPTIONS');
             $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS));
             Log::addConfigurationLog($this->getTitle() . ' config updated');
             // the cache has to be recreated because the image options could have been changed
             $this->module()->emptyCache();
             break;
         case 'admin_reset':
             $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS'));
             unset($FTV_OPTIONS[Filter::getInteger('tree')]);
             $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS));
             Log::addConfigurationLog($this->getTitle() . ' options set to default');
             break;
         case 'admin_delete':
             $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
             unset($FTV_SETTINGS[Filter::getInteger('key')]);
             $this->setSetting('FTV_SETTINGS', serialize($FTV_SETTINGS));
             Log::addConfigurationLog($this->getTitle() . ' item deleted');
             break;
         case 'page':
             $template = new PageTemplate();
             return $template->pageContent();
             // See mediafirewall.php
         // See mediafirewall.php
         case 'thumbnail':
             $mid = Filter::get('mid', WT_REGEX_XREF);
             $media = Media::getInstance($mid, $this->tree);
             $mimetype = $media->mimeType();
             $cache_filename = $this->module()->cacheFileName($media);
             $filetime = filemtime($cache_filename);
             $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';
             $expireOffset = 3600 * 24 * 7;
             // tell browser to cache this image for 7 days
             $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $expireOffset) . ' GMT';
             $etag = $media->getEtag();
             $filesize = filesize($cache_filename);
             // parse IF_MODIFIED_SINCE header from client
             $if_modified_since = 'x';
             if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
                 $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
             }
             // parse IF_NONE_MATCH header from client
             $if_none_match = 'x';
             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 $if_none_match = str_replace('"', '', $_SERVER['HTTP_IF_NONE_MATCH']);
             }
             // add caching headers.  allow browser to cache file, but not proxy
             header('Last-Modified: ' . $filetimeHeader);
             header('ETag: "' . $etag . '"');
             header('Expires: ' . $expireHeader);
             header('Cache-Control: max-age=' . $expireOffset . ', s-maxage=0, proxy-revalidate');
             // if this file is already in the user’s cache, don’t resend it
             // first check if the if_modified_since param matches
             if ($if_modified_since === $filetimeHeader) {
                 // then check if the etag matches
                 if ($if_none_match === $etag) {
                     http_response_code(304);
                     return;
                 }
             }
             // send headers for the image
             header('Content-Type: ' . $mimetype);
             header('Content-Disposition: filename="' . basename($cache_filename) . '"');
             header('Content-Length: ' . $filesize);
             // Some servers disable fpassthru() and readfile()
             if (function_exists('readfile')) {
                 readfile($cache_filename);
             } else {
                 $fp = fopen($cache_filename, 'rb');
                 if (function_exists('fpassthru')) {
                     fpassthru($fp);
                 } else {
                     while (!feof($fp)) {
                         echo fread($fp, 65536);
                     }
                 }
                 fclose($fp);
             }
             break;
         case 'show_pdf':
             $template = new PdfTemplate();
             return $template->pageBody();
         case 'pdf_data':
             $template = new PdfTemplate();
             return $template->pageData();
         case 'pdf_thumb_data':
             $xref = Filter::get('mid');
             $mediaobject = Media::getInstance($xref, $this->tree);
             $thumb = Filter::get('thumb');
             if ($thumb === '2') {
                 // Fancy thumb
                 echo $this->module()->cacheFileName($mediaobject);
             } else {
                 echo $mediaobject->getServerFilename('thumb');
             }
             break;
         default:
             http_response_code(404);
             break;
     }
 }
Ejemplo n.º 13
0
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
namespace JustCarmen\WebtreesAddOns\JustLight;

use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Filter;
define('WT_SCRIPT_NAME', 'action.php');
chdir('../../../');
// change the directory to the root of webtrees to load the required files from session.php.
require './includes/session.php';
header('Content-type: text/html; charset=UTF-8');
if (!Filter::checkCsrf()) {
    header('HTTP/1.0 406 Not Acceptable');
    exit;
}
$action = Filter::get('action');
switch ($action) {
    case 'imagetype':
        $xrefs = Filter::postArray('xrefs');
        $data = array();
        foreach ($xrefs as $xref) {
            $row = Database::prepare("SELECT m_type as imagetype FROM `##media` WHERE m_id=?")->execute(array($xref))->fetchOneRow();
            $data[$xref] = $row->imagetype;
        }
        header("Content-Type: application/json; charset=UTF-8");
        echo json_encode((object) $data);
        break;
    default:
        header('HTTP/1.0 404 Not Found');
        break;
}
Ejemplo n.º 14
0
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
namespace Fisharebest\Webtrees;

use Fisharebest\Webtrees\Controller\PageController;
use Rhumsaa\Uuid\Uuid;
define('WT_SCRIPT_NAME', 'admin_site_clean.php');
require './includes/session.php';
$to_delete = Filter::postArray('to_delete');
if ($to_delete && Filter::checkCsrf()) {
    foreach ($to_delete as $path) {
        $is_dir = is_dir(WT_DATA_DIR . $path);
        if (File::delete(WT_DATA_DIR . $path)) {
            if ($is_dir) {
                FlashMessages::addMessage(I18N::translate('The folder %s has been deleted.', Filter::escapeHtml($path)), 'success');
            } else {
                FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', Filter::escapeHtml($path)), 'success');
            }
        } else {
            if ($is_dir) {
                FlashMessages::addMessage(I18N::translate('The folder %s could not be deleted.', Filter::escapeHtml($path)), 'danger');
            } else {
                FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', Filter::escapeHtml($path)), 'danger');
            }
Ejemplo n.º 15
0
 /**
  * AdminConfig@jsonTasksList
  */
 public function jsonTasksList()
 {
     global $WT_TREE;
     $controller = new JsonController();
     $controller->restrictAccess(Auth::isAdmin());
     // Generate an AJAX/JSON response for datatables to load a block of rows
     $search = Filter::postArray('search');
     if ($search) {
         $search = $search['value'];
     }
     $start = Filter::postInteger('start');
     $length = Filter::postInteger('length');
     $order = Filter::postArray('order');
     $order_by_name = false;
     foreach ($order as $key => &$value) {
         switch ($value['column']) {
             case 3:
                 $order_by_name = true;
                 unset($order[$key]);
                 break;
             case 4:
                 $value['column'] = 'majat_last_run';
                 break;
             case 4:
                 $value['column'] = 'majat_last_result';
                 break;
             default:
                 unset($order[$key]);
         }
     }
     $list = $this->provider->getFilteredTasksList($search, $order, $start, $length);
     if ($order_by_name) {
         usort($list, function (AbstractTask $a, AbstractTask $b) {
             return I18N::strcasecmp($a->getTitle(), $b->getTitle());
         });
     }
     $recordsFiltered = count($list);
     $recordsTotal = $this->provider->getTasksCount();
     $data = array();
     foreach ($list as $task) {
         $datum = array();
         $datum[0] = '
             <div class="btn-group">
                 <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                     <i class="fa fa-pencil"></i><span class="caret"></span>
                 </button>
                 <ul class="dropdown-menu" role="menu">
                    <li>
                         <a href="#" onclick="return set_admintask_status(\'' . $task->getName() . '\', ' . ($task->isEnabled() ? 'false' : 'true') . ');">
                             <i class="fa fa-fw ' . ($task->isEnabled() ? 'fa-times' : 'fa-check') . '"></i> ' . ($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . '
                         </a>
                    </li>
                     <li>
                         <a href="module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task=' . $task->getName() . '">
                             <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . '
                         </a>
                    </li>
                 </ul>
             </div>';
         $datum[1] = $task->getName();
         $datum[2] = $task->isEnabled() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Enabled') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Disabled') . '</span>';
         $datum[3] = $task->getTitle();
         $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s';
         $datum[4] = $task->getLastUpdated()->format($date_format);
         $datum[5] = $task->isLastRunSuccess() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Yes') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('No') . '</span>';
         $dtF = new \DateTime('@0');
         $dtT = new \DateTime('@' . $task->getFrequency() * 60);
         $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m'));
         $datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited');
         $datum[8] = $task->isRunning() ? '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">' . I18N::translate('Running') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Not running') . '</span>';
         if ($task->isEnabled() && !$task->isRunning()) {
             $datum[9] = '
 			    <button id="bt_runtask_' . $task->getName() . '" class="btn btn-primary" href="#" onclick="return run_admintask(\'' . $task->getName() . '\')">
 			         <div id="bt_runtasktext_' . $task->getName() . '"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div>
 			    </button>';
         } else {
             $datum[9] = '';
         }
         $data[] = $datum;
     }
     $controller->pageHeader();
     $controller->encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
 }
Ejemplo n.º 16
0
 /**
  * AdminConfig@jsonGeoAnalysisList
  */
 public function jsonGeoAnalysisList()
 {
     global $WT_TREE;
     $controller = new JsonController();
     $controller->restrictAccess(Auth::isManager($WT_TREE));
     // Generate an AJAX/JSON response for datatables to load a block of rows
     $search = Filter::postArray('search');
     if ($search) {
         $search = $search['value'];
     }
     $start = Filter::postInteger('start');
     $length = Filter::postInteger('length');
     $order = Filter::postArray('order');
     foreach ($order as $key => &$value) {
         switch ($value['column']) {
             case 3:
                 $value['column'] = 'majgd_descr';
                 break;
             case 5:
                 $value['column'] = 'majgd_sublevel';
                 break;
             default:
                 unset($order[$key]);
         }
     }
     /** @var GeoAnalysisProvider $provider */
     $provider = $this->module->getProvider();
     $list = $provider->getFilteredGeoAnalysisList($search, $order, $start, $length);
     $recordsFiltered = count($list);
     $recordsTotal = $this->provider->getGeoAnalysisCount();
     $data = array();
     $place_hierarchy = $this->provider->getPlacesHierarchy();
     foreach ($list as $ga) {
         /** @var GeoAnalysis $ga */
         $datum = array();
         $options = $ga->getOptions();
         $datum[0] = '
             <div class="btn-group">
                 <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                     <i class="fa fa-pencil"></i><span class="caret"></span>
                 </button>
                 <ul class="dropdown-menu" role="menu">
                    <li>
                         <a href="#" onclick="return set_geoanalysis_status(' . $ga->getId() . ', ' . ($ga->isEnabled() ? 'false' : 'true') . ', \'' . Filter::escapeJs($WT_TREE->getName()) . '\');">
                             <i class="fa fa-fw ' . ($ga->isEnabled() ? 'fa-times' : 'fa-check') . '"></i> ' . ($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . '
                         </a>
                    </li>
                     <li>
                         <a href="module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id=' . $ga->getId() . '&ged=' . $WT_TREE->getName() . '">
                             <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . '
                         </a>
                    </li>
                    <li class="divider" />
                    <li>
                         <a href="#" onclick="return delete_geoanalysis(' . $ga->getId() . ', \'' . Filter::escapeJs($WT_TREE->getName()) . '\');">
                             <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . '
                         </a>
                    </li>
                 </ul>
             </div>';
         $datum[1] = $ga->getId();
         $datum[2] = $ga->isEnabled() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Enabled') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Disabled') . '</span>';
         $datum[3] = $ga->getTitle();
         $analysis_level = $ga->getAnalysisLevel();
         if ($place_hierarchy['type'] == 'header') {
             $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1];
         } else {
             $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')';
         }
         $datum[5] = $ga->getAnalysisLevel();
         $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('None') . '</span>';
         $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('None') . '</span>';
         if ($ga->hasMap()) {
             $datum[6] = $options->getMap()->getDescription();
             $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />';
             $top_level = $options->getMapLevel();
             if ($place_hierarchy['type'] == 'header') {
                 $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1];
             } else {
                 $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')';
             }
             $datum[7] .= '</span>';
         }
         $datum[8] = $options->isUsingFlags() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Yes') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('No') . '</span>';
         $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All');
         $data[] = $datum;
     }
     $controller->pageHeader();
     $controller->encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
 }