60 abstract public function getUrl($url);
94 abstract public function forward($initialController, $controller, $action, $params);
105 abstract public function renderContent($initialControllerInstance, $viewName, $params = NULL);
126 $bs = $this->bootstrap();
141 if ($bootstrap !== NULL) {
142 $this->_bootstrap = $bootstrap;
143 $bootstrap->setJs($this);
149 return $this->_bootstrap;
159 if ($semantic !== NULL) {
160 $this->_semantic = $semantic;
161 $semantic->setJs($this);
167 return $this->_semantic;
176 if ($config === NULL) {
177 if ($this->config === NULL) {
180 } elseif (\is_array($config)) {
181 $this->config =
new Config($config);
182 } elseif ($config instanceof
Config) {
183 $this->config = $config;
185 return $this->config;
195 public function __construct($params = array(), $injected = NULL) {
197 'ajaxTransition' =>
null,
199 'historize' =>
false,
200 'jsCallback' =>
null,
202 'jqueryDone' =>
'html',
206 'jsCondition' =>
null,
207 'ajaxLoader' =>
null,
213 'ajax' => $ajaxDefault,
215 'autoActiveLinks' => true
217 foreach ($defaults as $key => $val) {
218 if (isset($params[$key]) ===
false || $params[$key] ===
"") {
219 $params[$key] = $defaults[$key];
222 foreach ($ajaxDefault as $key => $val) {
223 if (isset($params[
"ajax"][$key]) ===
false || $params[
"ajax"][$key] ===
"") {
224 $params[
"ajax"][$key] = $ajaxDefault[$key];
228 if (\array_key_exists(
"semantic", $params)) {
231 if (\array_key_exists(
"bootstrap", $params)) {
234 if (isset($params[
"ajax"])) {
235 if (isset($params[
"ajax"][
"ajaxTransition"])) {
236 $this->ajaxTransition = $this->setAjaxDataCall($params[
"ajax"][
"ajaxTransition"]);
238 if ($params[
"ajax"][
"historize"]) {
239 $params[
"historize"] =
true;
241 if ($params[
"ajax"][
"csrf"]) {
242 $this->exec($this->addCsrf(),
true);
245 if ($params[
"historize"]) {
246 $this->execAtLast($this->onPopstate());
248 if ($params[
"autoActiveLinks"]) {
249 $this->exec($this->autoActiveLinks(),
true);
252 $this->params = $params;
253 $this->injected = $injected;
254 if (isset($params[
'gc'])) {
265 public function __set($property, $value) {
268 $this->bootstrap($value);
271 $this->semantic(value);
277 throw new \Exception(
'Unknown property !');
286 if (isset($this->params[$key]))
287 return $this->params[$key];
298 if (! is_array($array_js)) {
304 foreach ($array_js as $js) {
305 $this->jquery_code_for_compile[] =
"\t$js\n";
318 public function compile(&$view = NULL, $view_var =
'script_foot', $script_tags = TRUE) {
319 if (isset($this->_ui)) {
320 $this->_compileLibrary($this->_ui, $view);
322 if (isset($this->_bootstrap)) {
323 $this->_compileLibrary($this->_bootstrap, $view);
325 if (isset($this->_semantic)) {
326 $this->_compileLibrary($this->_semantic, $view);
329 $this->jquery_code_for_compile = \array_merge($this->jquery_code_for_compile, $this->jquery_code_for_compile_at_last);
331 if (\count($this->jquery_code_for_compile) == 0) {
336 $script = $this->ready(implode(
'', $this->jquery_code_for_compile));
337 if ($this->params[
"defer"]) {
338 $script = $this->defer($script);
342 $this->jquery_code_for_compile = $this->jquery_code_for_compile_at_last = [];
343 if ($this->params[
"debug"] ===
false) {
344 $script = $this->minify($script);
346 $output = ($script_tags === FALSE) ? $script : $this->
inline($script);
348 if ($view !== NULL) {
349 $this->createScriptVariable($view, $view_var, $output);
361 $this->jquery_code_for_compile = $this->jquery_code_for_compile_at_last = [];
365 $code = \array_merge($this->jquery_code_for_compile, $this->jquery_code_for_compile_at_last);
367 $code = \array_slice($code, $offset);
369 return \implode(
'', $code);
373 return \count($this->jquery_code_for_compile);
384 public function inline($script, $cdata = TRUE) {
385 $str = $this->_open_script();
386 $str .= ($cdata) ?
"\n// <![CDATA[\n{$script}\n// ]]>\n" :
"\n{$script}\n";
387 $str .= $this->_close_script();
403 if (! is_null($result)) {
404 if (is_object($result)) {
405 $json_result = $result->result_array();
406 } elseif (\is_array($result)) {
407 $json_result = $result;
409 return $this->_prep_args($result);
414 return $this->_create_json($json_result, $match_array_type);
420 if (! is_array($json_result) && empty($json_result)) {
421 show_error(
"Generate JSON Failed - Illegal key, value pair.");
422 } elseif ($match_array_type) {
423 $_is_assoc = JArray::isAssociative($json_result);
425 foreach ($json_result as $k => $v) {
427 $json[] = $this->_prep_args($k, TRUE) .
':' . $this->generate_json($v, $match_array_type);
429 $json[] = $this->generate_json($v, $match_array_type);
432 $json = implode(
',', $json);
433 return $_is_assoc ?
"{" . $json .
"}" :
"[" . $json .
"]";
444 if (is_null($result)) {
446 } elseif (is_bool($result)) {
447 return ($result === TRUE) ?
'true' :
'false';
448 } elseif (is_string($result) || $is_key) {
449 return '"' . str_replace(array(
464 } elseif (is_scalar($result)) {
488 public function _add_event($element, $js, $event, $preventDefault =
false, $stopPropagation =
false, $immediatly =
true, $listenerOn =
false) {
489 if (\is_array($js)) {
490 $js = implode(
"\n\t\t", $js);
492 if ($preventDefault ===
true) {
493 $js = Javascript::$preventDefault . $js;
495 if ($stopPropagation ===
true) {
496 $js = Javascript::$stopPropagation . $js;
498 if (\is_string($listenerOn)) {
499 $event =
"\n\t$(" . Javascript::prep_element($listenerOn) .
").on('{$event}'," . Javascript::prep_element($element) .
",function(event){\n\t\t{$js}\n\t});\n";
501 if (\array_search($event, $this->jquery_events) ===
false) {
502 $event =
"\n\t$(" . Javascript::prep_element($element) .
").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n";
504 $event =
"\n\t$(" . Javascript::prep_element($element) .
").{$event}(function(event){\n\t\t{$js}\n\t});\n";
508 $this->jquery_code_for_compile[] = $event;
513 return $this->injected;
517 $this->params[$param]=$value;
JQuery UI Phalcon library.
forward($initialController, $controller, $action, $params)
Forwards to.
_prep_args($result, $is_key=FALSE)
Ensures a standard json value and escapes values.
setParam(string $param, $value)
output($array_js)
Outputs the called javascript to the screen.
fromDispatcher($dispatcher)
Collects url parts from the request dispatcher : controllerName, actionName, parameters Used internal...
getUrl($url)
Generates an URL Used internally by phpMv.
_create_json($json_result, $match_array_type)
clear_compile()
Clears the array of script events collected for output.
renderContent($initialControllerInstance, $viewName, $params=NULL)
render the content of an existing view : $viewName and set the response to the modal content Used int...
compile(&$view=NULL, $view_var='script_foot', $script_tags=TRUE)
gather together all script needing to be output
ui(JqueryUI $ui=NULL)
getter or setter of the jQuery-UI variable
_add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false)
Constructs the syntax for an event, and adds to into the array for compilation.
initialize()
To override for special initialization of the component.
bootstrap(Bootstrap $bootstrap=NULL)
getter or setter of the Twitter Bootstrap variable
createScriptVariable(&$view, $view_var, $output)
Creates the script variable script_foot Used internally by phpMv.
generate_json($result=NULL, $match_array_type=FALSE)
Can be passed a database result or associative array and returns a JSON formatted string.
__construct($params=array(), $injected=NULL)
addViewElement($identifier, $content, &$view)
Adds the array of controls q in the $view element Used internally by phpMv.
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable