Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony] Komponenty i panele
blackroger
post 14.10.2009, 19:38:16
Post #1





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 8.11.2008

Ostrzeżenie: (0%)
-----


Mam problem dotyczący panelu. Otóż mam stworzyć panel, który jest widoczny cały czas podczas wędrówki po stronie. Jest to panel logowania lub, gdy użytkownik jest zalogowany to są jego dane oraz menu edycji danych.

Zrobiłem to tak:
mam moduł main, w którym mam komponent executeLoginpanel():

  1.  
  2. public function executeLoginpanel()
  3. {
  4. $this->form = new LoginForm();
  5. $this->message = $this->getUser()->getFlash('text');
  6. $this->module = $this->getRequestParameter('module');//because it has to know where redirect
  7. $this->action = $this->getRequestParameter('action');
  8.  
  9. $this->getUser()->clearCredentials();
  10. $this->getUser()->setAuthenticated(false);
  11.  
  12. if($this->getRequest()->isMethod('post'))
  13. {
  14.  
  15. $login = $this->getRequestParameter('login[login]');
  16. $pass = $this->getRequestParameter('login[pass]');
  17.  
  18. $c = new Criteria();
  19. $c->add(UsersPeer::LOGIN, $login);
  20. $c->add(UsersPeer::PASS, md5($pass));
  21. $u = UsersPeer::doSelectOne($c);
  22.  
  23. if($u)
  24. {
  25. $this->getUser()->setAuthenticated(true);
  26. $this->getUser()->addCredentials('normal_user');
  27. $this->getUser()->setAttribute('usid', $u->getUsid(),
  28. 'user');
  29. $this->getUser()->setAttribute('login', $u->getLogin(),
  30. 'user');
  31. }//if $u exist
  32. else
  33. {
  34. $this->getUser()->setFlash('text', 'Access danied');
  35.  
  36. return $this->getContext()->getController()->redirect('main/index');
  37. }
  38. }//end if($this->getRequest()->isMethod('post')
  39. }//end executeLoginpanel
  40.  
  41.  


no i partial do niego:

  1.  
  2. <div class="login_panel">
  3. <?php
  4. echo $module;
  5. echo $action;
  6.  
  7. ?>
  8. <form method="post" action="<?php echo url_for($module.'/'.$action); ?>">
  9. <table>
  10. <tr>
  11. <td><a href="/register/index">Register</a></td>
  12. <td><?php echo $form['login']->renderLabel(); ?></td>
  13. <td><?php echo $form['login']; ?></td>
  14. <td><?php echo $form['pass']->renderLabel(); ?></td>
  15. <td><?php echo $form['pass']; ?></td>
  16. <td><input type="submit" name="ok_login" class="confirm_button" value="OK" /></td>
  17. </tr>
  18. <tr>
  19. <td></td>
  20. <td>
  21. <?php echo $form['login']->renderError(); ?>
  22. </td>
  23. <td></td>
  24. <td>
  25. <?php echo $form['pass']->renderError(); ?>
  26. </td>
  27. </tr>
  28. <tr>
  29. <td></td>
  30. <td colspan="4">
  31. <?php echo $message; ?>
  32. </td>
  33. </tr>
  34. </table>
  35. </form>
  36. </div>
  37.  
  38.  


Wszystko dziala do momentu, gdy probuje go wywołać z innego modułu...powiedzmy register. Komponent się pojawia, ale gdy daje na panelu ok to przekierowuje mnie z powrotem na main i bieżąca strona powiedzmy z czymś już znika...
Jak najlepiej zrobić, żeby panel miał pełną funkcjonalność i żeby był dostępny z każdego modułu...

A wywołuję w templetach main/index i register/index tak:

  1.  
  2. <?php if ($sf_user->isAuthenticated()): ?>
  3. <?php include_component('profile', 'userpanel') ?>
  4. <?php else: ?>
  5. <?php include_component('main', 'loginpanel') ?>
  6. <?php endif; ?>
  7.  


Ten post edytował blackroger 14.10.2009, 19:43:54
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 23.06.2025 - 01:07