/** * json 형식으로 인코딩 * * @param array $jsonType 대상 이름 배열 * @return void */ public function dataEncode(array $jsonType) { foreach ($this as $key => $value) { if (in_array($key, $jsonType) === true && is_scalar($value) !== true) { $this[$key] = json_enc($value); } } }
/** * output * * @return string */ public static function output() { $newKeys = []; foreach (self::$keys as $key => $null) { $line = XeLang::getOriginalLine($key); if ($line) { $newKeys[$key] = $line; } } self::$keys = $newKeys; $output = sprintf('XE.Lang.setLocales(%s);' . 'XE.Lang.set(%s);', json_enc(XeLang::getLocales()), json_enc(self::$keys)); return $output; }
public function render() { $days = isset($this->args['days']) ? $this->args['days'] : 30; $limit = isset($this->args['limit']) ? $this->args['limit'] : 5; try { $data = $this->analytics->data_ga->get($this->getGaId(), $days . 'daysAgo', 'today', 'ga:visits', ['dimensions' => 'ga:browser', 'sort' => '-ga:visits']); } catch (Exception $e) { return View::make('ga::widget.error', ['message' => $e->getMessage()]); } $rows = $data->getRows() ?: []; $rows = array_slice($rows, 0, $limit); $jsonData = json_enc($rows); return View::make('ga::widget.browsers', ['jsonData' => $jsonData]); }
protected function loadReactComponent($container, $title, $jsonRet) { $memberSearchUrl = route('settings.member.search'); $groupSearchUrl = route('manage.group.search'); $vgroupAll = app('xe.user.virtualGroups')->all(); $uibojectKey = "__xe__permission_{$title}_uiobject_data"; $container = '__xe__uiobject_permission'; $vgroups = []; foreach ($vgroupAll as $vgroup) { $vgroups[] = $vgroup->toArray(); } $jsonVGroups = json_enc($vgroups); $htmlString = []; $htmlString[] = "<div class='{$container}' data-data='{$jsonRet}' data-title='{$title}'\n data-key='{$uibojectKey}' data-member-url='{$memberSearchUrl}' data-group-url='{$groupSearchUrl}'\n data-type='{$title}' data-vgroup-all='{$jsonVGroups}'></div>"; return implode('', $htmlString); }
/** * Dynamically set an attribute on the user. * * @param string $key key name of want set attribute * @param mixed $val match value of key name * @return void */ public function __set($key, $val) { if (in_array($key, static::$jsonType) === true) { $val = json_enc($val); } $this->meta->{$key} = $val; }
/** * renders * * @return string */ public function render() { $rule = sprintf("System.import('xecore:/common/js/validator')" . '.then(function(validator) { validator.setRules("%s", %s); });', $this->ruleName, json_enc($this->rules)) . PHP_EOL; return $rule; }
/** * 라인을 캐싱합니다 * * @param string $namespace 네임스페이스 * @param string $item 아이템 * @param string $locale 로케일 * @param string $value 번역문 * @return void */ public function set($namespace, $item, $locale, $value) { if (!$this->cachedLines) { $this->load(); } $this->cachedLines[$namespace][$item][$locale] = $value; $jsonString = json_enc($this->cachedLines); $this->cache->forever($this->transCacheKey, $jsonString); }
/** * renders * * @return string */ public function render() { $rule = sprintf('require(["validator"], function(validator) { validator.setRules("%s", %s); });', $this->ruleName, json_enc($this->rules)) . PHP_EOL; return $rule; }
/** * renders * * @return string */ public function render() { $rule = sprintf("var ruleSet = { ruleName: \"%s\", rules: %s }", $this->ruleName, json_enc($this->rules)) . PHP_EOL; return $rule; }