Example #1
0
	</head>
	<body>
		<h1>
			<?php 
echo I18N::translate('Setup wizard for webtrees');
?>
		</h1>
<?php 
echo '<form name="config" action="', WT_SCRIPT_NAME, '" method="post" onsubmit="this.btncontinue.disabled=\'disabled\';">';
echo '<input type="hidden" name="lang" value="', WT_LOCALE, '">';
////////////////////////////////////////////////////////////////////////////////
// Step one - choose language and confirm server configuration
////////////////////////////////////////////////////////////////////////////////
if (!isset($_POST['lang'])) {
    $installed_languages = array();
    foreach (I18N::installedLocales() as $locale) {
        $installed_languages[$locale->languageTag()] = $locale->endonym();
    }
    echo '<p>', I18N::translate('Change language'), ' ', FunctionsEdit::selectEditControl('change_lang', $installed_languages, null, WT_LOCALE, 'onchange="window.location=\'' . WT_SCRIPT_NAME . '?lang=\'+this.value;">'), '</p>', '<h2>', I18N::translate('Checking server configuration'), '</h2>';
    $warnings = false;
    $errors = false;
    // Mandatory functions
    $disable_functions = preg_split('/ *, */', ini_get('disable_functions'));
    foreach (array('parse_ini_file') as $function) {
        if (in_array($function, $disable_functions)) {
            echo '<p class="bad">', I18N::translate('%s is disabled on this server.  You cannot install webtrees until it is enabled.  Please ask your server’s administrator to enable it.', $function . '()'), '</p>';
            $errors = true;
        }
    }
    // Mandatory extensions
    foreach (array('pcre', 'pdo', 'pdo_mysql', 'session', 'iconv') as $extension) {
Example #2
0
    private function edit()
    {
        global $WT_TREE;
        if (webtrees\Filter::postBool('save') && webtrees\Filter::checkCsrf()) {
            $block_id = webtrees\Filter::post('block_id');
            if ($block_id) {
                webtrees\Database::prepare("UPDATE `##block` SET gedcom_id=NULLIF(?, ''), block_order=? WHERE block_id=?")->execute(array(webtrees\Filter::post('gedcom_id'), (int) webtrees\Filter::post('block_order'), $block_id));
            } else {
                webtrees\Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(?, ''), ?, ?)")->execute(array(webtrees\Filter::post('gedcom_id'), $this->getName(), (int) webtrees\Filter::post('block_order')));
                $block_id = webtrees\Database::getInstance()->lastInsertId();
            }
            $this->setBlockSetting($block_id, 'menu_title', webtrees\Filter::post('menu_title'));
            $this->setBlockSetting($block_id, 'menu_address', webtrees\Filter::post('menu_address'));
            $this->setBlockSetting($block_id, 'menu_access', webtrees\Filter::post('menu_access'));
            $languages = array();
            foreach (webtrees\I18N::installedLocales() as $locale) {
                if (webtrees\Filter::postBool('lang_' . $locale->languageTag())) {
                    $languages[] = $locale->languageTag();
                }
            }
            $this->setBlockSetting($block_id, 'languages', implode(',', $languages));
            $this->config();
        } else {
            $block_id = webtrees\Filter::get('block_id');
            $controller = new webtrees\Controller\PageController();
            $controller->restrictAccess(webtrees\Auth::isEditor($WT_TREE));
            if ($block_id) {
                $controller->setPageTitle(webtrees\I18N::translate('Edit menu'));
                $menu_title = $this->getBlockSetting($block_id, 'menu_title');
                $menu_address = $this->getBlockSetting($block_id, 'menu_address');
                $menu_access = $this->getBlockSetting($block_id, 'menu_access');
                $block_order = webtrees\Database::prepare("SELECT block_order FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
                $gedcom_id = webtrees\Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne();
            } else {
                $controller->setPageTitle(webtrees\I18N::translate('Add menu'));
                $menu_access = 1;
                $menu_title = '';
                $menu_address = '';
                $block_order = webtrees\Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne();
                $gedcom_id = $WT_TREE->getTreeId();
            }
            $controller->pageHeader();
            ?>
			
			<ol class="breadcrumb small">
				<li><a href="admin.php"><?php 
            echo webtrees\I18N::translate('Control panel');
            ?>
</a></li>
				<li><a href="admin_modules.php"><?php 
            echo webtrees\I18N::translate('Module administration');
            ?>
</a></li>
				<li><a href="module.php?mod=<?php 
            echo $this->getName();
            ?>
&mod_action=admin_config"><?php 
            echo webtrees\I18N::translate($this->getTitle());
            ?>
</a></li>
				<li class="active"><?php 
            echo $controller->getPageTitle();
            ?>
</li>
			</ol>
			
			<form class="form-horizontal" method="POST" action="#" name="menu" id="menuForm">
				<?php 
            echo webtrees\Filter::getCsrf();
            ?>
				<input type="hidden" name="save" value="1">
				<input type="hidden" name="block_id" value="<?php 
            echo $block_id;
            ?>
">
				<h3><?php 
            echo webtrees\I18N::translate('General');
            ?>
</h3>
				
				<div class="form-group">
					<label class="control-label col-sm-3" for="menu_title">
						<?php 
            echo webtrees\I18N::translate('Title');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="menu_title"
							size="90"
							name="menu_title"
							required
							type="text"
							value="<?php 
            echo webtrees\Filter::escapeHtml($menu_title);
            ?>
"
							>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('Add your menu title here');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="menu_address">
						<?php 
            echo webtrees\I18N::translate('Menu address');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="menu_address"
							size="90"
							name="menu_address"
							required
							type="text"
							value="<?php 
            echo webtrees\Filter::escapeHtml($menu_address);
            ?>
"
							>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('Add your menu address here');
            ?>
					</span>
				</div>
				
				<h3><?php 
            echo webtrees\I18N::translate('Languages');
            ?>
</h3>
				
				<div class="form-group">
					<label class="control-label col-sm-3" for="lang_*">
						<?php 
            echo webtrees\I18N::translate('Show this menu for which languages?');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            $accepted_languages = explode(',', $this->getBlockSetting($block_id, 'languages'));
            foreach (webtrees\I18N::installedLocales() as $locale) {
                ?>
								<div class="checkbox">
									<label title="<?php 
                echo $locale->languageTag();
                ?>
">
										<input type="checkbox" name="lang_<?php 
                echo $locale->languageTag();
                ?>
" <?php 
                echo in_array($locale->languageTag(), $accepted_languages) ? 'checked' : '';
                ?>
 ><?php 
                echo $locale->endonym();
                ?>
									</label>
								</div>
						<?php 
            }
            ?>
					</div>
				</div>
				
				<h3><?php 
            echo webtrees\I18N::translate('Visibility and Access');
            ?>
</h3>
				
				<div class="form-group">
					<label class="control-label col-sm-3" for="block_order">
						<?php 
            echo webtrees\I18N::translate('Menu position');
            ?>
					</label>
					<div class="col-sm-9">
						<input
							class="form-control"
							id="position"
							name="block_order"
							size="3"
							required
							type="number"
							value="<?php 
            echo webtrees\Filter::escapeHtml($block_order);
            ?>
"
						>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('This field controls the order in which the menu items are displayed.'), '<br><br>', webtrees\I18N::translate('You do not have to enter the numbers sequentially. If you leave holes in the numbering scheme, you can insert other menu items later. For example, if you use the numbers 1, 6, 11, 16, you can later insert menu items with the missing sequence numbers. Negative numbers and zero are allowed, and can be used to insert menu items in front of the first one.'), '<br><br>', webtrees\I18N::translate('When more than one menu item has the same position number, only one of these menu items will be visible.');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="block_order">
						<?php 
            echo webtrees\I18N::translate('Menu visibility');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            echo webtrees\Functions\FunctionsEdit::selectEditControl('gedcom_id', webtrees\Tree::getIdList(), webtrees\I18N::translate('All'), $WT_TREE->getTreeId(), 'class="form-control"');
            ?>
					</div>
					<span class="help-block col-sm-9 col-sm-offset-3 small text-muted">
						<?php 
            echo webtrees\I18N::translate('You can determine whether this menu item will be visible regardless of family tree, or whether it will be visible only to the current family tree.');
            ?>
					</span>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="menu_access">
						<?php 
            echo webtrees\I18N::translate('Access level');
            ?>
					</label>
					<div class="col-sm-9">
						<?php 
            echo webtrees\Functions\FunctionsEdit::editFieldAccessLevel('menu_access', $menu_access, 'class="form-control"');
            ?>
					</div>
				</div>
				
				<div class="row col-sm-9 col-sm-offset-3">
					<button class="btn btn-primary" type="submit">
						<i class="fa fa-check"></i>
						<?php 
            echo webtrees\I18N::translate('save');
            ?>
					</button>
					<button class="btn" type="button" onclick="window.location='<?php 
            echo $this->getConfigLink();
            ?>
';">
						<i class="fa fa-close"></i>
						<?php 
            echo webtrees\I18N::translate('cancel');
            ?>
					</button>
				</div>
			</form>
<?php 
        }
    }