phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
JsUtils.php
Go to the documentation of this file.
1<?php
2
4
5use Phalcon\DiInterface;
6use Phalcon\Di\InjectionAwareInterface;
7use Phalcon\Mvc\View;
8use Phalcon\Mvc\Controller;
9
10class JsUtils extends \Ajax\JsUtils implements InjectionAwareInterface{
11 protected $_di;
12 public function setDi(DiInterface $di) {
13 $this->_di=$di;
14 //$this->_setDi($di);
15 }
16
17 public function getDi() {
18 return $this->_di;
19 }
20
21 public function getUrl($url){
22 return $this->_di->get("url")->get($url);
23 }
24
25 public function addViewElement($identifier,$content,&$view){
26 $controls=$view->getVar("q");
27 if (isset($controls) === false) {
28 $controls=array ();
29 }
30 $controls[$identifier]=$content;
31 $view->setVar("q", $controls);
32 }
33
34 public function createScriptVariable(&$view,$view_var, $output){
35 $view->setVar($view_var,$output);
36 }
37
38 public function forward($initialController,$controller,$action,$params=array()){
39 $dispatcher = $initialController->dispatcher;
40 $dispatcher->setControllerName($controller);
41 $dispatcher->setActionName($action);
42 $dispatcher->dispatch();
43 $template=$initialController->view->getRender($dispatcher->getControllerName(), $dispatcher->getActionName(),$dispatcher->getParams(), function ($view) {
44 $view->setRenderLevel(View::LEVEL_ACTION_VIEW);
45 });
46 return $template;
47 }
48
49 public function renderContent($initialControllerInstance,$viewName, $params=NULL) {
50 list($controller,$action)=\explode("@", $viewName);
51 $template=$initialControllerInstance->view->getRender($controller, $action, $params, function ($view) {
52 $view->setRenderLevel(View::LEVEL_ACTION_VIEW);
53 });
54 return $template;
55 }
56
57 public function fromDispatcher($dispatcher){
58 $params=$dispatcher->getParams();
59 $action=$dispatcher->getActionName();
60 $items=array($dispatcher->getControllerName());
61 if(\sizeof($params)>0 || \strtolower($action)!="index" ){
62 $items[]=$action;
63 foreach ($params as $p){
64 if(\is_object($p)===false)
65 $items[]=$p;
66 }
67 }
68 return $items;
69 }
70}
JQuery PHP library.
Definition JsUtils.php:23
fromDispatcher($dispatcher)
Collects url parts from the request dispatcher : controllerName, actionName, parameters Used internal...
Definition JsUtils.php:57
getUrl($url)
Generates an URL Used internally by phpMv.
Definition JsUtils.php:21
renderContent($initialControllerInstance, $viewName, $params=NULL)
render the content of an existing view : $viewName and set the response to the modal content Used int...
Definition JsUtils.php:49
forward($initialController, $controller, $action, $params=array())
Forwards to.
Definition JsUtils.php:38
createScriptVariable(&$view, $view_var, $output)
Creates the script variable script_foot Used internally by phpMv.
Definition JsUtils.php:34
setDi(DiInterface $di)
Definition JsUtils.php:12
addViewElement($identifier, $content, &$view)
Adds the array of controls q in the $view element Used internally by phpMv.
Definition JsUtils.php:25