Passed
Push — master ( eb013e...37f747 )
by Jonathan
04:35
created

SosaConfigView::renderContent()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 50
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 43
nc 3
nop 0
dl 0
loc 50
rs 9.232
c 0
b 0
f 0
1
<?php
2
/**
3
 * webtrees-lib: MyArtJaub library for webtrees
4
 *
5
 * @package MyArtJaub\Webtrees
6
 * @subpackage Sosa
7
 * @author Jonathan Jaubart <[email protected]>
8
 * @copyright Copyright (c) 2009-2016, Jonathan Jaubart
9
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
10
 */
11
namespace MyArtJaub\Webtrees\Module\Sosa\Views;
12
13
use Fisharebest\Webtrees\Filter;
14
use Fisharebest\Webtrees\Functions\FunctionsPrint;
15
use Fisharebest\Webtrees\I18N;
16
use MyArtJaub\Webtrees\Mvc\View\AbstractView;
17
18
/**
19
 * View for SosaConfig@index
20
 */
21
class SosaConfigView extends AbstractView {
22
        
23
	/**
24
	 * {@inhericDoc}
25
	 * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
26
	 */
27
    protected function renderContent() {
28
        
29
        ?>        
30
        
31
        <div id="maj-sosa-config-page">
32
			<h2><?php echo $this->data->get('title'); ?></h2>
33
			
34
			<form name="maj-sosa-config-form" method="post" action="<?php echo $this->data->get('form_url'); ?>">
35
				<input type="hidden" name="action" value="update">
36
				<?php echo Filter::getCsrf(); ?>
37
				<div id="maj-sosa-config-page-table">
38
					<div class="label">
39
        				<?php echo I18N::translate('Tree'); ?>
40
        			</div>
41
        			<div class="value">
42
    					<label><?php echo $this->data->get('tree')->getTitleHtml(); ?></label>
43
        			</div>
44
        			<div class="label">
45
        				<?php echo I18N::translate('For user'); ?>
46
        			</div>
47
        			<div class="value">
48
        				<?php 
49
        				    $users = $this->data->get('users_settings');
50
        				    if(count($users) == 1) {
51
        				        $root_indi = $users[0]['rootid'];  ?>
52
        					<label>
53
        						<input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" />
54
        						<?php echo $users[0]['user']->getRealNameHtml() ?>
55
        					</label>
56
        				<?php  } else if(count($users) > 1) { ?>
57
        					<select id='maj-sosa-config-select' name="userid">
58
        					<?php 
59
        					   $root_indi = $users[0]['rootid'];
60
        					   foreach ($this->data->get('users_settings') as $user) { ?>
61
        						<option value="<?php echo $user['user']->getUserId(); ?>"><?php echo $user['user']->getRealNameHtml() ?></option>
62
        					<?php  } ?>
63
        					</select>
64
        				<?php } ?>
65
        			</div>
66
        			<div class="label">
67
        				<?php echo I18N::translate('Root individual'); ?>
68
        			</div>
69
        			<div class="value">
70
        				<input data-autocomplete-type="INDI" type="text" name="rootid" id="rootid" size="3" value="<?php echo $root_indi; ?>">
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $root_indi does not seem to be defined for all execution paths leading up to this point.
Loading history...
71
						<?php echo FunctionsPrint::printFindIndividualLink('rootid'); ?>
72
        			</div>
73
        			<div class="label"></div>
74
        			<div class="value">
75
        				<input type="submit" value="<?php echo /* I18N: button label */ I18N::translate('save'); ?>">
76
        				<input type="button" value="<?php echo /* I18N: button label */ I18N::translate('Compute'); ?>" id="bt_sosa_compute">
77
        				<span id="bt_sosa_computing"></span>
78
        			</div>
79
				</div>
80
			</form>	
81
		
82
		<?php        
83
    }
84
    
85
}
86