Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. <ul class="nav nav-tabs" id="myTabs">
  2. <li class="active"><a href="#profile" data-url="/Shawili/<?= $profile['username'] ?>/profile/">Profile</a></li>
  3. <li><a href="#about" data-url="/Shawili/<?= $profile['username'] ?>/about/">About</a></li>
  4. <li><a href="#wishlist" data-url="/Shawili/<?= $profile['username'] ?>/wishlists/">Wishlists <span class="badge"><?= $profile['wishlists'] ?></span></a></li>
  5. <li><a href="#following" data-url="">Following <span class="badge"><?= $profile['following'] ?></span></a></li>
  6. <li><a href="#followers" data-url="">Followers <span class="badge"><?= $profile['followers'] ?></span></a></li>
  7. </ul>
  8.  
  9. <!-- Tab panes -->
  10. <div class="tab-content">
  11. <div class="tab-pane active" id="profile">Profile</div>
  12. <div class="tab-pane" id="about">about</div>
  13. <div class="tab-pane" id="wishlist">wl</div>
  14. <div class="tab-pane" id="following">following</div>
  15. <div class="tab-pane" id="followers">followers</div>
  16. </div>
  17.  
  18. <?php
  19.  
  20. if($owner)
  21. { ?>
  22.  
  23. <div class="row">
  24. <div class="col-md-10 col-md-offset-1">
  25. <form class="form-horizontal" role="form" method="post">
  26. <fieldset><legend>Add a wishlist</legend>
  27. <?php echo $form; ?>
  28. <div class="form-group">
  29. <div class="col-sm-offset-2 col-sm-10">
  30. <button type="submit" class="btn btn-default" name="addwishlist">Add</button>
  31. </div>
  32. </div>
  33. </fieldset>
  34. </form>
  35. </div>
  36. </div>
  37. <hr />
  38.  
  39. <?php
  40. }
  41.  
  42. ?>
  43.  
  44. <div class="row">
  45. <?php
  46.  
  47. foreach($wishlists as $wishlist)
  48. { //Here we display whislists } ?>
  49.  
  50. $manager = $this->managers->getManagerOf('Wishlist');
  51.  
  52. /**
  53. * Adding a new wishlist
  54. */
  55.  
  56. if($owner)
  57. {
  58.  
  59. //Creating object. Depends on form validation
  60. if ($request->postExists('addwishlist'))
  61. {
  62. $wishlist = new LibEntitiesWishlist(array(
  63. 'title' => $request->postData('title'),
  64. 'comment' => $request->postData('comment'),
  65. 'user' => $this->app->user()->getUser(),
  66. ));
  67. }
  68. else
  69. {
  70. $wishlist = new LibEntitiesWishlist;
  71. }
  72.  
  73. //generating form
  74. $formBuilder = new LibFormsWishlistForm($wishlist);
  75. $formBuilder->build();
  76. $form = $formBuilder->form();
  77. $formHandler = new LibFormHandler($form, $manager, $request);
  78.  
  79. //if form has been validate : add the wishlist and set flash
  80. if ($formHandler->process('add'))
  81. {
  82. $this->app->user()->setFlash('Your wish list has been created !');
  83. $this->app->httpResponse()->redirect('/Shawili/'.$request->getData('user').'/wishlists/');
  84. }
  85.  
  86. $this->page->addVar('form', $form->createView());
  87.  
  88. }
  89.  
  90. /**
  91. * Displaying user's wishlists
  92. */
  93.  
  94.  
  95. $wishlists = $manager->getWishlists($request->getData('user'), $this->app->user()->getUser());
  96.  
  97.  
  98. $this->page->addVar('wishlists', $wishlists);
  99. $this->page->addVar('owner', $owner);
  100. $this->page->addVar('profile', $request->getData('user'));
  101. $this->page->addVar('cuser', $this->managers->getManagerOf('User')->getUser($this->app->user()->getUser()));
  102.  
  103. <script type='text/javascript'>
  104. $('#myTabs a').click(function (e) {
  105. e.preventDefault();
  106.  
  107. var url = $(this).attr("data-url");
  108. var href = this.hash;
  109. var pane = $(this);
  110.  
  111. // ajax load from data-url
  112. $(href).load(url,function(result){
  113. pane.tab('show');
  114. });
  115. });
  116.  
  117. // load first tab content
  118. $('#profile').load($('.active a').attr("data-url"),function(result){
  119. $('.active a').tab('show');
  120. });
  121.  
  122. </script>
  123.  
  124. $("#submit_button_id").click(function(){
  125. var formdata = $("#form_id").serializeArray();
  126. $.ajax({
  127. url: "/submit_url",
  128. data: formdata,
  129. success: function(RESPONSE){
  130. //Your code to modify page content after geting RESPONSE.
  131. }
  132. })
  133. return false; //To prevent page from reloading
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement