-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add setPropertyValues for DataForm and HtmlForm
- Loading branch information
Showing
2 changed files
with
73 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,90 @@ | ||
<?php | ||
|
||
namespace Ajax\php\ubiquity; | ||
|
||
use Ubiquity\controllers\Startup; | ||
use Ubiquity\utils\http\URequest; | ||
|
||
class JsUtils extends \Ajax\JsUtils{ | ||
class JsUtils extends \Ajax\JsUtils { | ||
|
||
public function getUrl($url){ | ||
public function getUrl($url) { | ||
return URequest::getUrl($url); | ||
} | ||
|
||
public function addViewElement($identifier,$content,&$view){ | ||
$controls=$view->getVar("q"); | ||
public function addViewElement($identifier, $content, &$view) { | ||
$controls = $view->getVar("q"); | ||
if (isset($controls) === false) { | ||
$controls=array (); | ||
$controls = array(); | ||
} | ||
$controls[$identifier]=$content; | ||
$controls[$identifier] = $content; | ||
$view->setVar("q", $controls); | ||
} | ||
|
||
public function createScriptVariable(&$view,$view_var, $output){ | ||
$view->setVar($view_var,$output); | ||
public function createScriptVariable(&$view, $view_var, $output) { | ||
$view->setVar($view_var, $output); | ||
} | ||
|
||
public function forward($initialController,$controller,$action,$params=array()){ | ||
return $initialController->forward($controller,$action,$params,true,true,true); | ||
public function forward($initialController, $controller, $action, $params = array()) { | ||
return $initialController->forward($controller, $action, $params, true, true, true); | ||
} | ||
|
||
public function renderContent($initialControllerInstance,$viewName, $params=NULL) { | ||
return $initialControllerInstance->loadView($viewName,$params,true); | ||
public function renderContent($initialControllerInstance, $viewName, $params = NULL) { | ||
return $initialControllerInstance->loadView($viewName, $params, true); | ||
} | ||
|
||
public function fromDispatcher($dispatcher){ | ||
public function fromDispatcher($dispatcher) { | ||
return Startup::$urlParts; | ||
} | ||
|
||
/** | ||
* Performs jQuery compilation and displays a view | ||
* | ||
* @param string $viewName | ||
* @param mixed $parameters Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br> | ||
* If an associative array is passed, the view retrieves variables from the table's key names | ||
* @param boolean $asString If true, the view is not displayed but returned as a string (usable in a variable) | ||
* @param mixed $parameters | ||
* Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br> | ||
* If an associative array is passed, the view retrieves variables from the table's key names | ||
* @param boolean $asString | ||
* If true, the view is not displayed but returned as a string (usable in a variable) | ||
*/ | ||
public function renderView($viewName,$parameters=[],$asString=false){ | ||
if(isset($this->injected)){ | ||
$view=$this->injected->getView(); | ||
public function renderView($viewName, $parameters = [], $asString = false) { | ||
if (isset($this->injected)) { | ||
$view = $this->injected->getView(); | ||
$this->compile($view); | ||
if (isset($parameters)) | ||
$view->setVars($parameters); | ||
return $view->render($viewName, $asString); | ||
} | ||
throw new \Exception(get_class()." instance is not properly instancied : you omitted the second parameter \$controller!"); | ||
throw new \Exception(get_class() . " instance is not properly instancied : you omitted the second parameter \$controller!"); | ||
} | ||
|
||
/** | ||
* Performs jQuery compilation and displays the default view | ||
* @param mixed $parameters Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br> | ||
* If an associative array is passed, the view retrieves variables from the table's key names | ||
* @param boolean $asString If true, the view is not displayed but returned as a string (usable in a variable) | ||
* | ||
* @param mixed $parameters | ||
* Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br> | ||
* If an associative array is passed, the view retrieves variables from the table's key names | ||
* @param boolean $asString | ||
* If true, the view is not displayed but returned as a string (usable in a variable) | ||
*/ | ||
public function renderDefaultView($parameters = [], $asString = false) { | ||
return $this->renderView($this->injected->getDefaultViewName(), $parameters, $asString); | ||
} | ||
|
||
/** | ||
* Loads and eventually executes a jsFile with php parameters, using the default template engine. | ||
* | ||
* @param string $jsFile | ||
* @param array $parameters | ||
* @param boolean $immediatly | ||
* @throws \Exception | ||
*/ | ||
public function renderDefaultView($parameters=[],$asString=false){ | ||
return $this->renderView($this->injected->getDefaultViewName(),$parameters,$asString); | ||
public function execJSFromFile($jsFile, $parameters = [], $immediatly = true) { | ||
if (isset($this->injected)) { | ||
$view = $this->injected->getView(); | ||
if (isset($parameters)) | ||
$view->setVars($parameters); | ||
$js = $view->render($jsFile . '.js', true); | ||
$this->exec($js, $immediatly); | ||
} | ||
throw new \Exception(get_class() . " instance is not properly instancied : you omitted the second parameter \$controller!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters