/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. </script>
  62. <form method="post" action="<?php echo $this->uri->uri_string(); ?>" class="default">
  63. <h1 class="headingleft">Edit Site: <?php echo $data['siteDomain']; ?> <small>(<a href="/halogy/sites">Back to Sites</a>)</small></h1></h1>
  64. <div class="headingright">
  65. <input type="submit" value="Edit Site" class="button" />
  66. </div>
  67. <?php if ($errors = validation_errors()): ?>
  68. <div class="error clear">
  69. <?php echo $errors; ?>
  70. </div>
  71. <?php endif; ?>
  72. <div class="clear"></div>
  73. <ul class="innernav clear">
  74. <li class="selected"><a href="#tab1" class="showtab">Details</a></li>
  75. <li><a href="#tab2" class="showtab">Permissions</a></li>
  76. </ul>
  77. <br class="clear" />
  78. <div id="tab1" class="tab">
  79. <h2>Domains</h2>
  80. <label for="siteDomain">Domain:</label>
  81. <?php echo @form_input('siteDomain', set_value('siteDomain', $data['siteDomain']), 'id="siteDomain" class="formelement"'); ?>
  82. <span class="tip">For example 'mysite.com' (no sub-domains, www or trailing slashes)</span><br class="clear" />
  83. <label for="altDomain">Staging Domain:</label>
  84. <?php echo @form_input('altDomain', set_value('altDomain', $data['altDomain']), 'id="altDomain" class="formelement"'); ?>
  85. <span class="tip">Optional alternative domain for staging sites.</span><br class="clear" /><br />
  86. <h2>Site Details</h2>
  87. <label for="siteName">Name of Site:</label>
  88. <?php echo @form_input('siteName', set_value('siteName', $data['siteName']), 'id="siteName" class="formelement"'); ?>
  89. <span class="tip">The name of the site</span><br class="clear" />
  90. <label for="siteURL">URL:</label>
  91. <?php echo @form_input('siteURL', set_value('siteURL', $data['siteURL']), 'id="siteURL" class="formelement"'); ?>
  92. <span class="tip">The full URL to the site</span><br class="clear" />
  93. <label for="siteEmail">Email:</label>
  94. <?php echo @form_input('siteEmail', set_value('siteEmail', $data['siteEmail']), 'id="siteEmail" class="formelement"'); ?>
  95. <span class="tip">The site contact email</span><br class="clear" />
  96. <label for="siteTel">Telephone:</label>
  97. <?php echo @form_input('siteTel', set_value('siteTel', $data['siteTel']), 'id="siteTel" class="formelement"'); ?>
  98. <span class="tip">The site contact telephone number</span><br class="clear" />
  99. <br class="clear" />
  100. <label for="active">Status:</label>
  101. <?php
  102. $actives = array(
  103. 1 => 'Active',
  104. 0 => 'Suspended',
  105. );
  106. echo @form_dropdown('active', $actives, $data['active'], 'id="active" class="formelement"');
  107. ?>
  108. <span class="tip">You cannot delete sites, but you can suspend them and take them offline here.</span>
  109. <br class="clear" />
  110. </div>
  111. <div id="tab2" class="tab">
  112. <h2>Permissions</h2>
  113. <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>
  114. <?php if ($permissions): ?>
  115. <?php foreach ($permissions as $cat => $perms): ?>
  116. <div class="perm-heading">
  117. <label for="<?php echo strtolower($cat); ?>_all" class="radio"><?php echo $cat; ?></label>
  118. <input type="checkbox" class="selectall checkbox" id="<?php echo strtolower($cat); ?>_all" />
  119. <input type="button" value="See more" class="seemore small-button" />
  120. </div>
  121. <div class="permissions">
  122. <?php foreach ($perms as $perm): ?>
  123. <label for="<?php echo 'perm_'.$perm['key']; ?>" class="radio"><?php echo $perm['permission']; ?></label>
  124. <?php echo @form_checkbox('perm'.$perm['permissionID'], 1, set_value('perm'.$perm['permissionID'], $data['perm'.$perm['permissionID']]), 'id="'.'perm_'.$perm['key'].'" class="checkbox"'); ?>
  125. <br class="clear" />
  126. <?php endforeach; ?>
  127. </div>
  128. <?php endforeach; ?>
  129. <?php endif; ?>
  130. </div>
  131. <p class="clear" style="text-align: right;"><a href="#" class="button grey" id="totop">Back to top</a></p>
  132. </form>