PageRenderTime 32ms CodeModel.GetById 14ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 1ms

/halogy/application/modules/halogy/views/edit.php

https://bitbucket.org/haloweb/halogy-1.0/
PHP | 165 lines | 132 code | 33 blank | 0 comment | 9 complexity | f0711da9f2320e3c8766c597fef92eff 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		var tld = '';
 37		domainVal = domainVal.replace(/^(http)s?:\/+((w+)\.)?|^www\.|\/|\/(.+)/ig, '');
 38		if (tld = domainVal.match(/\.[a-z]{2,3}\.[a-z]{2}$/i)){
 39			domainVal = domainVal.replace(/\.[a-z]{2,3}\.[a-z]{2}$/i, '');
 40			domainVal = domainVal.replace(/^(.+)\./ig, '');
 41			domainVal = domainVal+tld;
 42		}
 43		else if (tld = domainVal.match(/\.[a-z]{2,4}$/i)){
 44			domainVal = domainVal.replace(/\.[a-z]{2,4}$/i, '');
 45			domainVal = domainVal.replace(/(.+)\./ig, '');
 46			domainVal = domainVal+tld;
 47		}
 48		$(this).val(domainVal);
 49		$('#siteURL').val('http://www.'+domainVal);
 50		$('#siteEmail').val('info@'+domainVal);
 51	});
 52	$('a.selectall').click(function(event){
 53		event.preventDefault();
 54		$('input[type="checkbox"]').attr('checked', true);
 55	});	
 56	$('a.deselectall').click(function(event){
 57		event.preventDefault();
 58		$('input[type="checkbox"]').attr('checked', false);
 59	});	
 60
 61});
 62</script>
 63
 64<form method="post" action="<?php echo $this->uri->uri_string(); ?>" class="default">
 65
 66<h1 class="headingleft">Edit Site: <?php echo $data['siteDomain']; ?> <small>(<a href="/halogy/sites">Back to Sites</a>)</small></h1></h1>
 67
 68<div class="headingright">
 69	<input type="submit" value="Edit Site" class="button" />
 70</div>
 71
 72<?php if ($errors = validation_errors()): ?>
 73	<div class="error clear">
 74		<?php echo $errors; ?>
 75	</div>
 76<?php endif; ?>
 77
 78<div class="clear"></div>
 79
 80<ul class="innernav clear">
 81	<li class="selected"><a href="#tab1" class="showtab">Details</a></li>
 82	<li><a href="#tab2" class="showtab">Permissions</a></li>
 83</ul>
 84
 85<br class="clear" />
 86
 87<div id="tab1" class="tab">
 88
 89	<h2>Domains</h2>
 90
 91	<label for="siteDomain">Domain:</label>
 92	<?php echo @form_input('siteDomain', set_value('siteDomain', $data['siteDomain']), 'id="siteDomain" class="formelement"'); ?>
 93	<span class="tip">For example 'mysite.com' (no sub-domains, www or trailing slashes)</span><br class="clear" />
 94	
 95	<label for="altDomain">Staging Domain:</label>
 96	<?php echo @form_input('altDomain', set_value('altDomain', $data['altDomain']), 'id="altDomain" class="formelement"'); ?>
 97	<span class="tip">Optional alternative domain for staging sites.</span><br class="clear" /><br />
 98
 99	<h2>Site Details</h2>
100
101	<label for="siteName">Name of Site:</label>
102	<?php echo @form_input('siteName', set_value('siteName', $data['siteName']), 'id="siteName" class="formelement"'); ?>
103	<span class="tip">The name of the site</span><br class="clear" />
104
105	<label for="siteURL">URL:</label>
106	<?php echo @form_input('siteURL', set_value('siteURL', $data['siteURL']), 'id="siteURL" class="formelement"'); ?>
107	<span class="tip">The full URL to the site</span><br class="clear" />
108
109	<label for="siteEmail">Email:</label>
110	<?php echo @form_input('siteEmail', set_value('siteEmail', $data['siteEmail']), 'id="siteEmail" class="formelement"'); ?>
111	<span class="tip">The site contact email</span><br class="clear" />
112
113	<label for="siteTel">Telephone:</label>
114	<?php echo @form_input('siteTel', set_value('siteTel', $data['siteTel']), 'id="siteTel" class="formelement"'); ?>
115	<span class="tip">The site contact telephone number</span><br class="clear" />
116	<br class="clear" />
117
118	<label for="active">Status:</label>
119	<?php
120		$actives = array(
121			1 => 'Active',
122			0 => 'Suspended',			
123		);	
124		echo @form_dropdown('active', $actives, $data['active'], 'id="active" class="formelement"');
125	?>
126	<span class="tip">You cannot delete sites, but you can suspend them and take them offline here.</span>
127	<br class="clear" />
128
129</div>
130
131<div id="tab2" class="tab">
132
133	<h2>Permissions</h2>
134
135	<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>
136
137	<?php if ($permissions): ?>
138	<?php foreach ($permissions as $cat => $perms): ?>
139
140		<div class="perm-heading">
141			<label for="<?php echo strtolower($cat); ?>_all" class="radio"><?php echo $cat; ?></label>
142			<input type="checkbox" class="selectall checkbox" id="<?php echo strtolower($cat); ?>_all" />
143			<input type="button" value="See more" class="seemore small-button" />
144		</div>
145
146		<div class="permissions">
147
148		<?php foreach ($perms as $perm): ?>
149
150			<label for="<?php echo 'perm_'.$perm['key']; ?>" class="radio"><?php echo $perm['permission']; ?></label>
151			<?php echo @form_checkbox('perm'.$perm['permissionID'], 1, set_value('perm'.$perm['permissionID'], $data['perm'.$perm['permissionID']]), 'id="'.'perm_'.$perm['key'].'" class="checkbox"'); ?>
152			<br class="clear" />
153
154		<?php endforeach; ?>
155
156		</div>
157
158	<?php endforeach; ?>
159	<?php endif; ?>
160	
161</div>
162
163<p class="clear" style="text-align: right;"><a href="#" class="button grey" id="totop">Back to top</a></p>
164	
165</form>