Registra uma variável para o Javascript
192523
public function jsvar($name, $value = null)
    {
        if (is_string($name)) {
            $this->jsvalues[$name] = $value;
        }
        if (is_array($name)) {
            $this->jsvalues = array_merge($this->jsvalues, $name);
        }
        return $this;
    }
567852
protected function registerClientEvents() {
		if (!empty($this->clientEvents)) {
			$id = $this->options['id'];
			$js = [];
			foreach ($this->clientEvents as $event => $handler) {
				$js[] = "jQuery('#$id').on('$event', $handler);";
			}
			$this->view->registerJs(implode("\n", $js));
		}
	}
1061804
function (v) {
/*Line 77 - 'AtomFormField.js' */                if (this._required) {
/*Line 78 - 'AtomFormField.js' */                    if (!v) {
/*Line 79 - 'AtomFormField.js' */                        AtomBinder.setValue(this, "error", this._requiredMessage);
/*Line 80 - 'AtomFormField.js' */                        this._isValid = false;
/*Line 81 - 'AtomFormField.js' */                        return;
/*Line 82 - 'AtomFormField.js' */                    }
/*Line 83 - 'AtomFormField.js' */                } else {
/*Line 84 - 'AtomFormField.js' */                    // if value is not required
/*Line 85 - 'AtomFormField.js' */                    // and if value is empty
/*Line 86 - 'AtomFormField.js' */                    // it is a valid value
/*Line 87 - 'AtomFormField.js' */                    if (!v) {
/*Line 88 - 'AtomFormField.js' */                        this._isValid = true;
/*Line 89 - 'AtomFormField.js' */                        return;
/*Line 90 - 'AtomFormField.js' */                    }
/*Line 91 - 'AtomFormField.js' */                }

/*Line 93 - 'AtomFormField.js' */                var re = null;

/*Line 95 - 'AtomFormField.js' */                if (/email/gi.test(this._dataType)) {
/*Line 96 - 'AtomFormField.js' */                    re = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
/*Line 97 - 'AtomFormField.js' */                } else {
/*Line 98 - 'AtomFormField.js' */                    if (this._regex) {
/*Line 99 - 'AtomFormField.js' */                        re = eval("(" + this._regex + ")");
/*Line 100 - 'AtomFormField.js' */                    }
/*Line 101 - 'AtomFormField.js' */                }

/*Line 103 - 'AtomFormField.js' */                if (re) {
/*Line 104 - 'AtomFormField.js' */                    if (!re.test(v)) {
/*Line 105 - 'AtomFormField.js' */                        AtomBinder.setValue(this, "error", this._invalidMessage);
/*Line 106 - 'AtomFormField.js' */                        this._isValid = false;
/*Line 107 - 'AtomFormField.js' */                        return;
/*Line 108 - 'AtomFormField.js' */                    }
/*Line 109 - 'AtomFormField.js' */                }
/*Line 110 - 'AtomFormField.js' */            }
125122
public function toArray()
    {
        // Planilhas do Gnumeric e Xlsx
        // possuem linha e colunas nulas na exportação de array
        // por isso, são removidas aqui

        $list = [];
        $array = $this->getActiveSheet()->toArray();

        // Linhas
        foreach($array as $row_id => $rows) {

            $line = array_filter($rows, function($v){ return !is_null($v); });
            if (!empty($line)) {
                $list[] = $line;
            }
        }

        return $list;
    }
1084384
protected Map<AbstractColumn, JRDesignVariable> registerChartVariable(ar.com.fdvs.dj.domain.chart.DJChart chart) {
        //FIXME aca hay que iterar por cada columna. Cambiar DJChart para que tome muchas
        JRDesignGroup group = getChartColumnsGroup(chart);
        Map<AbstractColumn, JRDesignVariable> vars = new HashMap<AbstractColumn, JRDesignVariable>();

        int serieNum = 0;
        for (Object o : chart.getDataset().getColumns()) {
            AbstractColumn col = (AbstractColumn) o;


            Class clazz;
//			try { clazz = Class.forName(col.getValueClassNameForExpression());
//			} catch (ClassNotFoundException e) {
//				throw new DJException("Exeption creating chart variable: " + e.getMessage(),e);
//			}

            JRDesignExpression expression = new JRDesignExpression();
            //FIXME Only PropertyColumn allowed?
            if (col instanceof ExpressionColumn) {
                try {
                    clazz = Class.forName(((ExpressionColumn) col).getExpression().getClassName());
                } catch (ClassNotFoundException e) {
                    throw new DJException("Exeption creating chart variable: " + e.getMessage(), e);
                }

                ExpressionColumn expCol = (ExpressionColumn) col;
                expression.setText(expCol.getTextForExpression());
                expression.setValueClassName(expCol.getExpression().getClassName());
            } else {
                try {
                    clazz = Class.forName(((PropertyColumn) col).getColumnProperty().getValueClassName());
                } catch (ClassNotFoundException e) {
                    throw new DJException("Exeption creating chart variable: " + e.getMessage(), e);
                }

                expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty() + "}");
                expression.setValueClass(clazz);
            }

            JRDesignVariable var = new JRDesignVariable();
            var.setValueClass(clazz);
            var.setExpression(expression);
            var.setCalculation(CalculationEnum.getByValue(chart.getOperation()));
            var.setResetGroup(group);
            var.setResetType(ResetTypeEnum.GROUP);

            //use the index as part of the name just because I may want 2
            //different types of chart from the very same column (with the same operation also) making the variables name to be duplicated
            int chartIndex = getReport().getNewCharts().indexOf(chart);
            var.setName("CHART_[" + chartIndex + "_s" + serieNum + "+]_" + group.getName() + "_" + col.getTitle() + "_" + chart.getOperation());

            try {
                getDesign().addVariable(var);
                vars.put(col, var);
            } catch (JRException e) {
                throw new LayoutException(e.getMessage(), e);
            }
            serieNum++;
        }
        return vars;
    }
789600
public function registerJSVariables()
    {
        $object = json_encode($this->localizationData());

        $this->app['hook.factory']->action('wp_head', function () use ($object) {
            echo "<script>var Assely = {$object};</script>";
        })->dispatch();
    }
1275711
private function createDefaultControllerMvcFile()
    {
        $moduleName = ucfirst($this->getModule());
        $moduleNameLower = strtolower($this->getModule());
        $moduleNameUpper = strtoupper($this->getModule());

        $moduleControllerFolder = MODULES_PATH . ucfirst($this->getModule()) . DS . 'src' . DS . ucfirst($this->getModule()) . DS . 'Controller';

        /* Criação do arquivo de controller padrão do módulo */
        $cityware_mvc_controller = file_get_contents(dirname(__FILE__) . DS . 'Module' . DS . 'Cityware_Mvc_Controller.tpl');
        $citywareMvcController = str_replace("%moduleName%", $moduleName, str_replace("%moduleNameUpper%", $moduleNameUpper, str_replace("%moduleNameLower%", $moduleNameLower, $cityware_mvc_controller)));
        file_put_contents($moduleControllerFolder . DS . 'AbstractActionController'.$moduleName.'.php', $citywareMvcController);
        chmod($moduleControllerFolder . DS . 'AbstractActionController'.$moduleName.'.php', 0644);
    }
693544
public function registerClientScript()
    {
        $inputId = $this->options['id'];
        $jsTreeId = $this->getJsTreeId();
        $options = $this->getClientOptions();
        $options = empty($options) ? '' : Json::encode($options);

        $onChanged = '';
        if ($this->onChanged)
            $onChanged = ".on('changed.jstree', {$this->onChanged})";

        $onSelect = '';
        if ($this->onSelect)
            $onSelect = ".on('select_node.jstree', {$this->onSelect})";

        $view = $this->getView();
        JsTreeAsset::register($view);
        $view->registerJs("
            jQuery('#$jsTreeId')
                .on('loaded.jstree', function() { jQuery(this).jstree('select_node', jQuery('#$inputId').val().split(','), true); })
                .on('changed.jstree', function(e, data) { jQuery('#$inputId').val(data.selected.join()); })
                $onChanged
                $onSelect
                .jstree($options);
        ");
    }
475308
protected function registerJs()
	{
		if (static::$JS_REGISTERED) return;

		JqueryAsset::register($this->getView());
		BootstrapAsset::register($this->getView());

		$js = new JsExpression(<<<JS
			var widgetClass = 'widget-memory-tabs';
			var storageName = 'widget-memory-tabs';

			var hasStorage = function() {
				var test = 'test';
				try {
					{$this->storageType}.setItem(test, test);
					{$this->storageType}.removeItem(test);
					return true;
				} catch(e) {
					return false;
				}
			};

			if (hasStorage) {

				var loadData = function() {
					var dataStr = {$this->storageType}.getItem(storageName);
					if (dataStr == null) return {};
					return JSON.parse(dataStr);
				};

				var saveData = function(dataObj) {
					dataStr = JSON.stringify(dataObj);
					{$this->storageType}.setItem(storageName, dataStr);
				};

				var activateIndex = function(tabId, index) {
					var tab = $('#' + tabId);
					var items = tab.children('li');
					if (items.length <= index) return;

					$('#' + tabId + ' li:eq(' + index + ') a').tab('show');
				};
				
				var getBaseUrlByAnchor = function(url) {
					var hashTagIndex = url.indexOf('#',0);
					if (hashTagIndex === -1) return null;
					return url.substring(0, hashTagIndex);
				};

				var initIndexes = function() {
					var data = loadData();
					var curUrl = window.location.href;
					if (data[curUrl] == null) {
						var baseUrl = getBaseUrlByAnchor(curUrl);
						if (baseUrl === null) {
							return;
						} else if (data[baseUrl] == null) {
							return;
						}
						curUrl = baseUrl;
					}
					var tabs = $('.' + widgetClass);
					tabs.each(function(i, el) {
						var tabId = $(this).attr('id');
						if (tabId != null) {
							var index = data[curUrl][tabId];
							activateIndex(tabId, index);
						}
					});
				};

				var setIndex = function(tabId, index) {
					var curUrl = window.location.href;
					var baseUrl = getBaseUrlByAnchor(curUrl);

					var data = loadData();
					
					if(data[curUrl] == null) {
						if (baseUrl !== null && data[baseUrl] == null) {
							data[baseUrl] = {};
						} else if (baseUrl === null) {
							data[curUrl] = {};
						} else {
							curUrl = baseUrl;
						}
					}

					data[curUrl][tabId] = index;

					saveData(data);
				};

				$('.widget-memory-tabs > li > a').mouseup(function(event) {
					var tabs = $(this).closest('.' + widgetClass);
					var selectedIndex = $(this).parent().prevAll().length;

					setIndex(tabs.attr('id'), selectedIndex);
				});

				initIndexes();
			}
JS
);
		$this->view->registerJs($js);

		static::$JS_REGISTERED = true;
	}
913675
public function index()
    {
        if($javascript = file_get_contents(PATH_PUBLIC . 'assets/sw.js')) {
            $javascript = str_replace(['{{$theme}}', '{{ $theme }}'], 'default', $javascript);

            header("Content-type: application/x-javascript");
            echo $javascript;

            exit(EXIT_SUCCESS);
        }
    }
358925
public function registerClientScript()
    {
        $view = $this->getView();
        TagsinputAsset::register($view);
        $clientOptions = Json::encode($this->clientOptions);
        $view->registerJs("jQuery(\"#{$this->options['id']}\").tagsinput({$clientOptions});");
    }
17750
static function InitStaticVars()
	{

		self::$HTML_ENTITIES_TABLE = array();
		foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity)
		{
			self::$HTML_ENTITIES_TABLE[$entity] = '&#' . ord($char) . ';';
		}

		self::$SMART_QUOTE_CHARS =
			array(
				"�" => "'",
				"�" => "'",
				"�" => "\"",
				"�" => "\"",
				chr(145) => "'",
				chr(146) => "'",
				chr(147) => "\"",
				chr(148) => "\"",
				chr(151) => "-"
			);

		self::$CONTROL_CODE_CHARS =
			array(
				chr(0) => "&#0;",
				chr(1) => "&#1;",
				chr(2) => "&#2;",
				chr(3) => "&#3;",
				chr(4) => "&#4;",
				chr(5) => "&#5;",
				chr(6) => "&#6;",
				chr(7) => "&#7;",
				chr(8) => "&#8;",
				chr(14) => "&#14;",
				chr(15) => "&#15;",
				chr(16) => "&#16;",
				chr(17) => "&#17;",
				chr(18) => "&#18;",
				chr(19) => "&#19;",
				chr(20) => "&#20;",
				chr(21) => "&#21;",
				chr(22) => "&#22;",
				chr(23) => "&#23;",
				chr(24) => "&#24;",
				chr(25) => "&#25;",
				chr(26) => "&#26;",
				chr(27) => "&#27;",
				chr(28) => "&#28;",
				chr(29) => "&#29;",
				chr(30) => "&#30;",
				chr(31) => "&#31;"
			);

		self::$INVALID_CODE_CHARS = array(
			chr(128) => '&#8364;',
			chr(130) => '&#8218;',
			chr(131) => '&#402;',
			chr(132) => '&#8222;',
			chr(133) => '&#8230;',
			chr(134) => '&#8224;',
			chr(135) => '&#8225;',
			chr(136) => '&#710;',
			chr(137) => '&#8240;',
			chr(138) => '&#352;',
			chr(139) => '&#8249;',
			chr(140) => '&#338;',
			chr(142) => '&#381;',
			chr(145) => '&#8216;',
			chr(146) => '&#8217;',
			chr(147) => '&#8220;',
			chr(148) => '&#8221;',
			chr(149) => '&#8226;',
			chr(150) => '&#8211;',
			chr(151) => '&#8212;',
			chr(152) => '&#732;',
			chr(153) => '&#8482;',
			chr(154) => '&#353;',
			chr(155) => '&#8250;',
			chr(156) => '&#339;',
			chr(158) => '&#382;',
			chr(159) => '&#376;');

		self::$XML_SPECIAL_CHARS = array(
			"&"   =>"&amp;",
			"<"   =>"&lt;"
			,">"  =>"&gt;"
			,"\"" =>"&quot;"
			,"'"  =>"&apos;"
		);

	}
1292141
public function registerClientScript() {
        $view = $this->getView();
        $assetBundle = $this->assetBundle instanceof AssetBundle ? $this->assetBundle : Asset::register($view);

        if (array_key_exists('language', $this->options) && $this->options['language'] !== null) {
            $assetBundle->language = $this->options['language'];
        }

        $selector = $this->selector === null ? '#' . $this->htmlOptions['id'] : $this->selector;
        $options = Json::encode($this->options);

        $view->registerJs("jQuery('$selector').gtreetable($options);");
    }
890406
public function registerClientScript()
    {
        $options = $this->getClientOptions();
        $options = empty($options) ? '' : Json::htmlEncode($options);
        $id = $this->actionOptions['id'];
        $view = $this->getView();
        EmailCaptchaAsset::register($view);
        $view->registerJs("jQuery('#$id').emailCaptcha($options);");
    }
786946
protected function registerClientScript()
	{
		$view = $this->getView();
		UMeditorAsset::register($view);
		$id = $this->options['id'];
		$options = Json::encode($this->clientOptions);
		$js = "window.um = UM.getEditor('$id', $options);";
		$view->registerJs($js, $view::POS_READY);
	}
381587
public function index() {
        $this->layout = 'Stats.default';
        $this->elementMenu = 'Stats.menu';
        
        // por default ordenar por sumatoria de dinero vendido
        $conditions['order'] = array('ventas DESC',"cant DESC");
        if ( !empty( $this->request->query ) && $this->request->query['cant_o_tot'] == 1 ) {
            // ordenado por cantidad de unidades vendidas            
            $conditions['order'] = array("cant DESC", 'ventas DESC');
        }

        

        $this->Prg->commonProcess();
        $conds = $this->DetalleComanda->parseCriteria( $this->Prg->parsedParams() );
        $conditions['conditions'] = $conds;
        $conditions['conditions']['Mesa.deleted'] = 0;


		$this->DetalleComanda->Producto->recursive = -1;        
        $conditions['group'] = array('Producto.id', 'Producto.name');        
        $conditions['joins'] = array(
            array(
                'table' => 'detalle_comandas',
                'alias' => 'DetalleComanda',
                'type' => 'left',
                'conditions' => 'Producto.id = DetalleComanda.producto_id',
            ),
            array(
                'table' => 'comandas',
                'alias' => 'Comanda',
                'type' => 'left',
                'conditions' => 'Comanda.id = DetalleComanda.comanda_id',
            ),
            array(
                'table' => 'mesas',
                'alias' => 'Mesa',
                'type' => 'left',
                'conditions' => 'Mesa.id = Comanda.mesa_id',
            ), 
        );
        $conditions['fields'] = array(
            'Producto.name', 
            'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada)*Producto.precio as "ventas"',
            'Producto.precio', 
            'sum(DetalleComanda.cant-DetalleComanda.cant_eliminada) as "cant"',
            );


        if ( empty($this->request->query['desde']) ) {
            $desde = $this->DetalleComanda->find('first', array(
                'order' => array('DetalleComanda.created' => 'ASC')
                ));
            $desde = $desde['DetalleComanda']['created'];
        } else {
            $desde = $this->request->query['desde'];
        }

        if ( empty($this->request->query['hasta']) ) {
            $hasta = $this->DetalleComanda->find('first', array(
                'order' => array('DetalleComanda.created' => 'DESC')
                ));
            $hasta = $hasta['DetalleComanda']['created'];
        } else {
            $hasta = $this->request->query['hasta'];
        }
                                

        $comandas  = $this->DetalleComanda->Producto->find('all', $conditions);
        $cantTotal = 0;
        $ventasTotal = 0;
        foreach ($comandas as $c) {
            $cantTotal += $c[0]['cant'];
            $ventasTotal += $c[0]['ventas'];
        }

        if ( !empty( $this->request->query ) && $this->request->query['cant_o_tot'] == 1 ) {
            $this->request->data['DetalleComanda']['cant_o_tot']  = 1;
        }

        $this->set('categorias', $this->DetalleComanda->Producto->Categoria->generateTreeList());
        $this->set('productos', $this->DetalleComanda->Producto->find('list', array('order' => 'name')));
        $this->set('tags', $this->DetalleComanda->Producto->Tag->find('list', array('order' => 'name')));
		$this->set(compact('comandas', 'cantTotal', 'ventasTotal','tags', 'desde', 'hasta'));
	}
103614
public function create($name, $module, $dir, $type, $author, $email)
    {
        $fs = new Filesystem();

        if (!$this->jsDir) {
            throw new \Exception('O diretório de código javascript "injector.directory.src" da aplicação não foi definido!');
        }

        $moduleDir = $this->getControllerDir($dir);

        if (!$fs->exists($moduleDir)) {
            throw new \Exception(sprintf('O módulo %s não existe!', $module));
        }

        $controllerFile = $this->getControllerFile($name, $moduleDir);

        if ($fs->exists($controllerFile)) {
            throw new \Exception(sprintf('O controlador %s já existe!', $name));
        }

        $this->createController($name, $controllerFile, $module, $type, $author, $email);
    }