Guest User

Untitled

a guest
Jun 24th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. // Расширение контроллера действий для обработи Ajax
  4.  
  5. class Extend_XajaxViewHelper extends Zend_View_Helper_Abstract
  6.  
  7. {
  8.  
  9. protected $xajax = null;
  10.  
  11. private static $ajaxFuncPrefix = 'ajax';
  12.  
  13. public function init()
  14. {
  15.  
  16. $this->xajax = Zend_Registry::get('xajax');
  17.  
  18. $this->registerFunctions();
  19.  
  20. $this->view->xajaxJavaScript = $this->xajax->getJavascript($this->view->baseUrl . "js/");
  21. $this->xajax->processRequest();
  22. }
  23.  
  24. public function registerFunctions()
  25. {
  26. $oRefl = new ReflectionClass(get_class($this));
  27. if (is_object($oRefl))
  28. {
  29. $methods = $oRefl->getMethods();
  30. }
  31. foreach ($methods as $m)
  32. {
  33. $p = self::$ajaxFuncPrefix;
  34. if (preg_match("/^{$p}[A-Z]/", $m->getName()))
  35. {
  36. $m2 = preg_replace("/^{$p}([A-Z])/e", "strtolower('$1')", $m->getName());
  37. $this->xajax->registerFunction(array($m2, &$this, $m->getName()));
  38. }
  39. }
  40.  
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment