PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/halogy/application/modules/halogy/views/add.php

https://bitbucket.org/haloweb/halogy-1.0/
PHP | 202 lines | 162 code | 40 blank | 0 comment | 12 complexity | f30e6e8fe3c4fc9789c84f567ae4c5f5 MD5 | raw file
  1<script type="text/javascript">
  2$(function(){	
  3	$('a.showtab').click(function(event){
  4		event.preventDefault();
  5		var div = $(this).attr('href'); 
  6		$('div.tab').hide();
  7		$(div).show();
  8	});
  9	$('ul.innernav a').click(function(event){
 10		event.preventDefault();
 11		$(this).parent().siblings('li').removeClass('selected'); 
 12		$(this).parent().addClass('selected');
 13	});
 14	$('div.tab:not(#tab1)').hide();
 15	$('div.permissions input[type="checkbox"]').each(function(){
 16		if ($(this).attr('checked')) {
 17			$(this).parent('div').prev('div').children('input[type="checkbox"]').attr('checked', true);
 18		}
 19	});	
 20	$('input.selectall').click(function(){
 21		$el = $(this).parent('div').next('div').children('input[type="checkbox"]');
 22		$flag = $(this).attr('checked');
 23		if ($flag) {
 24			$($el).attr('checked', true);
 25		}
 26		else {
 27			$($el).attr('checked', false);
 28		}
 29	});
 30	$('.seemore').click(function(){
 31		$el = $(this).parent('div').next('div');
 32		$($el).toggle('400');
 33	});
 34	$('#siteDomain').change(function(){
 35		var domainVal = $(this).val();
 36		domainVal = domainVal.replace(/^(http)s?:\/+((w+)\.)?|^www\.|\/+/i, '');
 37		$(this).val(domainVal);
 38		$('#siteURL').val('http://www.'+domainVal);
 39	});
 40	$('#adminEmail').change(function(){
 41		$('#username').val($(this).val());
 42	});
 43	$('#siteDomain').change(function(){
 44		var domainVal = $(this).val();
 45		var tld = '';
 46		domainVal = domainVal.replace(/^(http)s?:\/+((w+)\.)?|^www\.|\/|\/(.+)/ig, '');
 47		if (tld = domainVal.match(/\.[a-z]{2,3}\.[a-z]{2}$/i)){
 48			domainVal = domainVal.replace(/\.[a-z]{2,3}\.[a-z]{2}$/i, '');
 49			domainVal = domainVal.replace(/^(.+)\./ig, '');
 50			domainVal = domainVal+tld;
 51		}
 52		else if (tld = domainVal.match(/\.[a-z]{2,4}$/i)){
 53			domainVal = domainVal.replace(/\.[a-z]{2,4}$/i, '');
 54			domainVal = domainVal.replace(/(.+)\./ig, '');
 55			domainVal = domainVal+tld;
 56		}
 57		$(this).val(domainVal);
 58		$('#siteURL').val('http://www.'+domainVal);
 59		$('#siteEmail').val('info@'+domainVal);
 60	});
 61	$('form').submit(function(){
 62		$('div.permissions input').each(function(){
 63			if($(this).attr('checked') == true){
 64				$(this).closest('form').submit();
 65			};
 66		});
 67		alert('You do not have any permissions set for this site.');
 68		return false;
 69	});
 70	$('a.selectall').click(function(event){
 71		event.preventDefault();
 72		$('input[type="checkbox"]').attr('checked', true);
 73	});
 74	$('a.deselectall').click(function(event){
 75		event.preventDefault();
 76		$('input[type="checkbox"]').attr('checked', false);
 77	});
 78});
 79</script>
 80
 81<form method="post" action="<?php echo $this->uri->uri_string(); ?>" class="default">
 82
 83<h1 class="headingleft">Add Site <small>(<a href="/halogy/sites">Back to Sites</a>)</small></h1>
 84
 85<div class="headingright">
 86	<input type="submit" value="Add Site" class="button" />
 87</div>
 88
 89<?php if ($errors = validation_errors()): ?>
 90	<div class="error clear">
 91		<?php echo $errors; ?>
 92	</div>
 93<?php endif; ?>
 94
 95<div class="clear"></div>
 96
 97<ul class="innernav clear">
 98	<li class="selected"><a href="#tab1" class="showtab">Details</a></li>
 99	<li><a href="#tab2" class="showtab">Administrator</a></li>	
100	<li><a href="#tab3" class="showtab">Permissions</a></li>
101</ul>
102
103<br class="clear" />
104
105<div id="tab1" class="tab">
106
107	<h2>Domains</h2>
108
109	<label for="siteDomain">Domain:</label>
110	<?php echo @form_input('siteDomain', set_value('siteDomain', $data['siteDomain']), 'id="siteDomain" class="formelement"'); ?>
111	<span class="tip">For example 'mysite.com' (no sub-domains, www or trailing slashes)</span><br class="clear" />
112	
113	<label for="altDomain">Staging Domain:</label>
114	<?php echo @form_input('altDomain', set_value('altDomain', $data['altDomain']), 'id="altDomain" class="formelement"'); ?>
115	<span class="tip">Optional alternative domain for staging sites.</span><br class="clear" /><br />
116
117	<h2>Site Details</h2>
118
119	<label for="siteName">Name of Site:</label>
120	<?php echo @form_input('siteName', set_value('siteName', $data['siteName']), 'id="siteName" class="formelement"'); ?>
121	<span class="tip">The name of the site</span><br class="clear" />
122
123	<label for="siteURL">URL:</label>
124	<?php echo @form_input('siteURL', set_value('siteURL', $data['siteURL']), 'id="siteURL" class="formelement"'); ?>
125	<span class="tip">The full URL to the site</span><br class="clear" />
126
127	<label for="siteEmail">Email:</label>
128	<?php echo @form_input('siteEmail', set_value('siteEmail', $data['siteEmail']), 'id="siteEmail" class="formelement"'); ?>
129	<span class="tip">The site contact email</span><br class="clear" />
130
131	<label for="siteTel">Telephone:</label>
132	<?php echo @form_input('siteTel', set_value('siteTel', $data['siteTel']), 'id="siteTel" class="formelement"'); ?>
133	<br class="clear" />
134
135</div>
136
137<div id="tab2" class="tab">
138
139	<h2>Administrator Details</h2>
140
141	<label for="adminEmail">Email:</label>
142	<?php echo @form_input('adminEmail', set_value('adminEmail', $data['adminEmail']), 'id="adminEmail" class="formelement"'); ?>
143	<span class="tip">The email / username for the main administrator</span>
144	<br class="clear" />
145
146	<label for="username">Username:</label>
147	<?php echo @form_input('username', set_value('username', $data['username']), 'id="username" class="formelement"'); ?>
148	<br class="clear" />
149
150	<label for="password">Password:</label>
151	<?php echo @form_password('password', set_value('password', $data['password']), 'id="password" class="formelement"'); ?>
152	<br class="clear" />
153
154	<label for="confirmPassword">Confirm Password:</label>
155	<?php echo @form_password('confirmPassword', set_value('confirmPassword', $data['confirmPassword']), 'id="confirmPassword" class="formelement"'); ?>
156	<br class="clear" />
157
158	<label for="firstName">First Name:</label>
159	<?php echo @form_input('firstName',set_value('firstName', $data['firstName']), 'id="firstName" class="formelement"'); ?>
160	<br class="clear" />
161
162	<label for="lastName">Last Name:</label>
163	<?php echo @form_input('lastName',set_value('lastName', $data['lastName']), 'id="lastName" class="formelement"'); ?>
164	<br class="clear" /><br />
165
166</div>
167
168<div id="tab3" class="tab">
169
170	<h2>Permissions</h2>
171
172	<p><a href="#" class="selectall button small nolabel grey">Select All</a> <a href="#" class="deselectall button small nolabel grey">De-Select All</a></p>
173
174	<?php if ($permissions): ?>
175	<?php foreach ($permissions as $cat => $perms): ?>
176
177		<div class="perm-heading">
178			<label for="<?php echo strtolower($cat); ?>_all" class="radio"><?php echo $cat; ?></label>
179			<input type="checkbox" class="selectall checkbox" id="<?php echo strtolower($cat); ?>_all" />
180			<input type="button" value="See more" class="seemore small-button" />
181		</div>
182
183		<div class="permissions">
184
185		<?php foreach ($perms as $perm): ?>
186
187			<label for="<?php echo 'perm_'.$perm['key']; ?>" class="radio"><?php echo $perm['permission']; ?></label>
188			<?php echo @form_checkbox('perm'.$perm['permissionID'], 1, set_value('perm'.$perm['permissionID'], $data['perm'.$perm['permissionID']]), 'id="'.'perm_'.$perm['key'].'" class="checkbox"'); ?>
189			<br class="clear" />
190
191		<?php endforeach; ?>
192
193		</div>
194
195	<?php endforeach; ?>
196	<?php endif; ?>
197	
198</div>
199
200<p class="clear" style="text-align: right;"><a href="#" class="button grey" id="totop">Back to top</a></p>
201	
202</form>