You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  1. <?php
  2. /**
  3. * @file Lazy.php
  4. * This file is part of Movim.
  5. *
  6. * @brief Refresh only parts of the new page
  7. *
  8. * @author Timothée jaussoin
  9. */
  10. class Lazy {
  11. private $_current;
  12. private $_next;
  13. private $_widgets = array();
  14. public function __construct($current, $next) {
  15. $this->_current = $current;
  16. $this->_next = $next;
  17. // We grab the widgets from the current view
  18. $current_path = VIEWS_PATH . '/' . $this->_current . '.tpl';
  19. require_once $current_path;
  20. ob_clean();
  21. $current_widgets = $this->_widgets;
  22. $this->_widgets = array();
  23. // We grab the widgets from the next view
  24. $next_path = VIEWS_PATH . '/' . $this->_next . '.tpl';
  25. require_once $next_path;
  26. ob_clean();
  27. $next_widgets = $this->_widgets;
  28. $this->_widgets = array();
  29. // We compare the two lists
  30. $diff_widgets_current = array_diff($next_widgets, $current_widgets);
  31. $diff_widgets_next = array_diff($current_widgets, $next_widgets);
  32. \movim_log($diff_widgets_current);
  33. \movim_log($diff_widgets_next);
  34. $widgets = WidgetWrapper::getInstance(false);
  35. foreach($diff_widgets as $key => $name) {
  36. RPC::call('movim_fill', strtolower($name) . '_widget', $widgets->runWidget($name, 'build'));
  37. }
  38. RPC::commit();
  39. }
  40. private function widget($name) {
  41. array_push($this->_widgets, $name);
  42. }
  43. }