本文整理汇总了PHP中helper::jsonEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::jsonEncode方法的具体用法?PHP helper::jsonEncode怎么用?PHP helper::jsonEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper
的用法示例。
在下文中一共展示了helper::jsonEncode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setWhitelist
/**
* Manage whitelist.
*
* @access public
* @return void
*/
public function setWhitelist()
{
$this->lang->guarder->menu = $this->lang->security->menu;
$this->lang->menuGroups->site = 'security';
if ($_POST) {
$user = $this->loadModel('user')->identify($this->app->user->account, $this->post->password);
if (!$user) {
$this->send(array('result' => 'fail', 'message' => $this->lang->user->identifyFailed));
}
$setting = fixer::input('post')->get();
/* check IP. */
$ips = explode(',', $setting->ip);
foreach ($ips as $ip) {
if (!empty($ip) and !helper::checkIP($ip)) {
$this->send(array('result' => 'fail', 'message' => $this->lang->guarder->whitelist->wrongIP));
}
}
$setting = array('whitelist' => helper::jsonEncode($setting));
$result = $this->loadModel('setting')->setItems('system.common.guarder', $setting, 'all');
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setWhitelist')));
}
$this->send(array('result' => 'fail', 'message' => dao::getError()));
}
$this->view->title = $this->lang->guarder->setWhitelist;
$this->display();
}
示例2: create
/**
* Create an order.
*
* @access public
* @return void
*/
public function create()
{
$order = fixer::input('post')->add('account', $this->app->user->account)->add('createdDate', helper::now())->add('payStatus', 'not_paid')->add('status', 'normal')->add('deliveryStatus', 'not_send')->add('type', 'shop')->get();
$address = $this->dao->select('*')->from(TABLE_ADDRESS)->where('id')->eq($this->post->deliveryAddress)->andWhere('account')->eq($this->app->user->account)->fetch();
$order->address = helper::jsonEncode($address);
if ($this->post->createAddress) {
$address = $this->createAddress();
if (!$address) {
return array('result' => 'fail', 'message' => dao::getError());
}
$order->address = helper::jsonEncode($address);
}
$this->dao->insert(TABLE_ORDER)->data($order, 'createAddress,deliveryAddress,phone,contact,zipcode,price,count,product')->autocheck()->batchCheck($this->config->order->require->create, 'notempty')->exec();
if (dao::isError()) {
return array('result' => 'fail', 'message' => dao::getError());
}
$orderID = $this->dao->lastInsertID();
$goods = new stdclass();
$goods->orderID = $orderID;
if (!$this->post->product) {
$this->clearOrder($orderID);
return array('result' => 'fail', 'message' => $this->lang->order->noProducts);
}
/* Save products of the order and compute order amount. */
$amount = 0;
foreach ($this->post->product as $product) {
$product = $this->dao->select('*')->from(TABLE_PRODUCT)->where('id')->eq($product)->fetch();
if (empty($product)) {
continue;
}
$goods->productID = $product->id;
$goods->productName = $product->name;
$goods->count = $this->post->count[$product->id];
if (isset($this->config->product->stock) && $this->config->product->stock) {
if ($product->amount < $goods->count) {
$this->clearOrder($orderID);
return array('result' => 'fail', 'message' => sprintf($this->lang->order->lowStocks, $goods->productName));
}
}
$goods->price = $product->promotion > 0 ? $product->promotion : $product->price;
if (!$goods->price) {
continue;
}
$amount += $goods->price * $goods->count;
$this->dao->insert(TABLE_ORDER_PRODUCT)->data($goods)->autoCheck()->exec();
}
/* Check valid products count. */
$productCout = $this->dao->select("count(*) as count")->from(TABLE_ORDER_PRODUCT)->where('orderID')->eq($orderID)->fetch('count');
if (!$productCout) {
return array('result' => 'fail', 'message' => $this->lang->order->noProducts);
}
$this->dao->update(TABLE_ORDER)->set('amount')->eq($amount)->where('id')->eq($orderID)->exec();
$this->dao->delete()->from(TABLE_CART)->where('account')->eq($this->app->user->account)->andWhere('product')->in($this->post->product)->exec();
if (!dao::isError()) {
return $orderID;
}
}
示例3: setOauth
/**
* set site basic info.
*
* @access public
* return void
*/
public function setOauth()
{
if (!empty($_POST)) {
$provider = $this->post->provider;
$oauth = array($provider => helper::jsonEncode($_POST));
$result = $this->loadModel('setting')->setItems('system.common.oauth', $oauth);
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$this->view->title = $this->lang->site->setOauth;
$this->display();
}
示例4: admin
/**
* Nav admin function
*
* @param string $top
* @access public
* @return void
*/
public function admin($type = '')
{
if ($type == '' and $this->config->site->type == 'portal') {
$type = $this->device . '_top';
}
if ($type == '' and $this->config->site->type == 'blog') {
$type = $this->device . '_blog';
}
foreach ($this->lang->nav->system as $module => $name) {
if (!commonModel::isAvailable($module)) {
unset($this->lang->nav->system->{$module});
}
}
if ($_POST) {
$navs = $this->post->nav;
foreach ($navs as $key => $nav) {
$navs[$key] = $this->nav->organizeNav($nav);
}
if (isset($navs[2])) {
$navs[2] = $this->nav->group($navs[2]);
if (isset($navs[3])) {
$navs[3] = $this->nav->group($navs[3]);
}
foreach ($navs[2] as &$navList) {
foreach ($navList as &$nav) {
$nav['children'] = isset($navs[3][$nav['key']]) ? $navs[3][$nav['key']] : array();
}
}
}
foreach ($navs[1] as &$nav) {
$nav['children'] = isset($navs[2][$nav['key']]) ? $navs[2][$nav['key']] : array();
}
$settings = array($type => helper::jsonEncode($navs[1]));
$result = $this->loadModel('setting')->setItems('system.common.nav', $settings);
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->failed));
}
$this->view->title = $this->lang->nav->setNav;
$this->view->navs = $this->nav->getNavs($type);
$this->view->type = $type;
$this->view->types = $this->lang->nav->types;
$this->view->articleTree = $this->loadModel('tree')->getOptionMenu('article');
$this->display();
}
示例5: setContact
/**
* set contact information.
*
* @access public
* @return void
*/
public function setContact()
{
if (!empty($_POST)) {
if (!empty($_POST['email'])) {
if (!validater::checkEmail($this->post->email)) {
$this->send(array('result' => 'fail', 'message' => $this->lang->company->error->email));
}
}
$contact = array('contact' => helper::jsonEncode($_POST));
$result = $this->loadModel('setting')->setItems('system.common.company', $contact);
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$this->view->title = $this->lang->company->setContact;
$this->view->contact = json_decode($this->config->company->contact);
$this->display();
}
示例6: others
/**
* Set others for ui.
*
* @access public
* @return void
*/
public function others()
{
/* Get configs of list number. */
$this->app->loadConfig('article');
$this->app->loadConfig('product');
$this->app->loadConfig('file');
if (strpos($this->config->site->modules, 'blog') !== false) {
$this->app->loadConfig('blog');
}
if (strpos($this->config->site->modules, 'message') !== false) {
$this->app->loadConfig('message');
}
if (strpos($this->config->site->modules, 'forum') !== false) {
$this->app->loadConfig('forum');
$this->app->loadConfig('reply');
}
if (!empty($_POST)) {
$thumbs = helper::jsonEncode($this->post->thumbs);
$result = $this->loadModel('setting')->setItem('system.common.file.thumbs', $thumbs);
if (!$result) {
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$setting = fixer::input('post')->get('productView,QRCode');
$result = $this->loadModel('setting')->setItems('system.common.ui', $setting);
if (!$result) {
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$setting = fixer::input('post')->remove('productView,QRCode,thumbs')->get();
$result = $this->loadModel('setting')->setItems('system.common.site', $setting, 'all');
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$this->view->title = $this->lang->ui->others;
$this->display();
}
示例7: fixCustomedCss
/**
* Fix customed css.
*
* @access public
* @return void
*/
public function fixCustomedCss()
{
$customedFile = $this->app->getDataRoot() . 'theme/custom.css';
if (is_file($customedFile)) {
$customPath = $this->app->getDataRoot() . 'css' . DS . 'default' . DS . 'colorful' . DS;
mkdir($customPath, 0777, true);
rename($customedFile, $customPath . 'style.css');
}
if (isset($this->config->site->themeSetting)) {
$customed = json_decode($this->config->site->themeSetting, true);
$setting['default']['colorful']['font-size'] = $customed['fontSize'];
$setting['default']['colorful']['border-radius'] = $customed['borderRadius'];
$setting['default']['colorful']['color-primary'] = $customed['primaryColor'];
$setting['default']['colorful']['background-color'] = $customed['backColor'];
return $this->loadModel('setting')->setItems('system.common.template', array('custom' => helper::jsonEncode($setting)));
}
return true;
}
示例8: appendIDForRegion
/**
* Append ID for subRegion when upgrade from 4.4.1.
*
* @access public
* @return void
*/
public function appendIDForRegion()
{
$layouts = $this->dao->select('*')->from(TABLE_LAYOUT)->fetchAll();
foreach ($layouts as $layout) {
$blocks = json_decode($layout->blocks);
foreach ($blocks as $block) {
if (!isset($block->children)) {
continue;
}
$regionID = $this->loadModel('block')->createRegion($layout->template, $layout->page, $layout->region);
$block->id = $regionID;
}
$blocks = helper::jsonEncode($blocks);
if ($blocks == $layout->blocks) {
continue;
}
$layout->blocks = $blocks;
$this->dao->replace(TABLE_LAYOUT)->data($layout)->exec();
}
}
示例9: mergeCustom
/**
* Merge custom.
*
* @param object $info
* @access public
* @return void
*/
public function mergeCustom($info)
{
$template = $info->template;
$theme = $info->theme;
$code = $info->code;
/* Merge theme custom param to current lang. */
$params = $this->dao->setAutoLang(false)->select('value')->from(TABLE_CONFIG)->where('lang')->eq('lang')->andWhere('`key`')->eq('custom')->fetch('value');
$params = json_decode($params, true);
if (!empty($params[$template][$theme])) {
$userCustom = $this->dao->setAutoLang(false)->select('*')->from(TABLE_CONFIG)->where('lang')->ne('lang')->andWhere('section')->eq('template')->andWhere('`key`')->eq('custom')->fetchAll('lang');
foreach ($userCustom as $lang => $custom) {
$setting = json_decode($custom->value, true);
if (!isset($setting[$template])) {
$setting[$template] = array();
}
$setting[$template][$code] = zget($params[$template], $theme, array());
$custom->value = helper::jsonEncode($setting);
$this->dao->replace(TABLE_CONFIG)->data($custom)->exec();
}
}
return true;
}
示例10: setYangcong
/**
* set yangcong configure.
*
* @access public
* return void
*/
public function setYangcong()
{
if (!empty($_POST)) {
$setting = fixer::input('post')->get();
$result = $this->loadModel('setting')->setItem('system.common.site.yangcong', helper::jsonEncode($setting), "all");
if ($result) {
$this->send(array('result' => 'success', 'message' => $this->lang->setSuccess));
}
$this->send(array('result' => 'fail', 'message' => $this->lang->fail));
}
$this->view->title = $this->lang->site->setYangcong;
$this->view->setting = array();
if (!empty($this->config->site->yangcong)) {
$this->view->setting = json_decode($this->config->site->yangcong);
}
$this->display();
}
示例11: install
/**
* install
*
* @param int $webappID
* @access public
* @return void
*/
public function install($webappID)
{
$webapp = $this->getAppInfoByAPI($webappID);
$webapp = $webapp->webapp;
$open = $webapp->target == 'blank' ? 'blank' : 'iframe';
$maxOrder = $this->dao->select('`order`')->from(TABLE_ENTRY)->orderBy('order_desc')->limit(1)->fetch('order');
$entry = new stdclass();
/* Save webapp's icon. */
if (!empty($webapp->icon)) {
$ext = explode('.', $webapp->icon);
$extend = $ext[count($ext) - 1];
$fileName = md5(mt_rand(0, 10000) . str_shuffle(md5($webapp->icon)) . mt_rand(0, 10000)) . '.' . $extend;
$dateInfo = date('Ym/', time());
/* mkdir if not exist. */
$savePath = $this->app->getDataRoot() . "upload/" . $dateInfo;
if (!file_exists($savePath)) {
@mkdir($savePath, 0777, true);
}
$savePath = $savePath . $fileName;
$webPath = $this->app->getWebRoot() . 'data/upload/' . $dateInfo . $fileName;
$icon = file_get_contents($this->config->webapp->url . $webapp->icon);
file_put_contents($savePath, $icon);
$entry->logo = $webPath;
}
$entry->code = $this->config->webapp->codePrefix . $webapp->id;
$entry->name = $webapp->name;
$entry->open = $open;
$entry->login = $webapp->url;
$entry->control = isset($webapp->control) ? $webapp->control : 'full';
$entry->position = isset($webapp->position) ? $webapp->position : 'center';
$entry->ip = '*';
$entry->visible = 0;
$entry->buildin = 0;
$entry->integration = 0;
$entry->key = md5(time());
$entry->order = $maxOrder + 10;
/* process size */
if ($open != 'blank') {
$entry->size = $webapp->size == '0x0' ? 'max' : 'custom';
$size = explode('x', $webapp->size);
if ($entry->size == 'custom') {
$entry->size = helper::jsonEncode(array('width' => (int) $size[0], 'height' => (int) $size[1]));
}
}
$this->app->loadConfig('entry');
$this->dao->insert(TABLE_ENTRY)->data($entry, $skip = 'files')->autoCheck()->batchCheck($this->config->entry->require->create, 'notempty')->check('code', 'unique')->check('code', 'code')->exec();
$this->addDownloadByAPI($webappID);
if (dao::isError()) {
return false;
}
return $webappID;
}
示例12: setOptionWithFile
/**
* Set UI option with file.
*
* @param int $type
* @param int $htmlTagName
* @access public
* @return void
*/
public function setOptionWithFile($section, $htmlTagName, $allowedFileType = 'jpg,jpeg,png,gif,bmp')
{
if (empty($_FILES)) {
return array('result' => false, 'message' => $this->lang->ui->noSelectedFile);
}
$fileType = substr($_FILES['files']['name'], strrpos($_FILES['files']['name'], '.') + 1);
if (strpos($allowedFileType, $fileType) === false) {
return array('result' => false, 'message' => sprintf($this->lang->ui->notAlloweFileType, $allowedFileType));
}
$fileModel = $this->loadModel('file');
if (!$this->file->checkSavePath()) {
return array('result' => false, 'message' => $this->lang->file->errorUnwritable);
}
/* Delete old files. */
if ($section != 'logo') {
$clientLang = $this->app->getClientLang();
$oldFiles = $this->dao->select('id')->from(TABLE_FILE)->where('objectType')->eq($section)->andWhere('lang')->eq($clientLang)->fetchAll('id');
foreach ($oldFiles as $file) {
$fileModel->delete($file->id);
}
if (dao::isError()) {
return array('result' => false, 'message' => $this->lang->fail);
}
}
/* Upload new logo. */
$uploadResult = $fileModel->saveUpload($htmlTagName);
if (!$uploadResult) {
return array('result' => false, 'message' => $this->lang->fail);
}
$fileIdList = array_keys($uploadResult);
$file = $fileModel->getById($fileIdList[0]);
/* Save new data. */
$setting = new stdclass();
$setting->fileID = $file->id;
$setting->pathname = $file->pathname;
$setting->webPath = $file->webPath;
$setting->addedBy = $file->addedBy;
$setting->addedDate = $file->addedDate;
if ($section == 'logo') {
$device = helper::getDevice();
$template = $this->config->template->{$device}->name;
$theme = $this->post->theme == 'all' ? 'all' : $this->config->template->{$device}->theme;
$logo = isset($this->config->site->logo) ? json_decode($this->config->site->logo, true) : array();
if (!isset($logo[$template])) {
$logo[$template] = array();
}
$logo[$template]['themes'][$theme] = $setting;
$result = $this->loadModel('setting')->setItems('system.common.site', array($section => helper::jsonEncode($logo)));
} else {
$result = $this->loadModel('setting')->setItems('system.common.site', array($section => helper::jsonEncode($setting)));
}
if ($result) {
return array('result' => true);
}
return array('result' => false, 'message' => $this->lang->fail);
}
示例13: initBlock
/**
* Init block when account use first.
*
* @param string $appName
* @access public
* @return bool
*/
public function initBlock($appName)
{
$this->app->loadLang('block', 'sys');
$blocks = $this->lang->block->default[$appName];
$account = $this->app->user->account;
/* Mark this app has init. */
$this->loadModel('setting')->setItem("{$account}.{$appName}.common.blockInited", true);
foreach ($blocks as $index => $block) {
$block['order'] = $index;
$block['app'] = $appName;
$block['account'] = $account;
$block['params'] = isset($block['params']) ? helper::jsonEncode($block['params']) : '';
if (!isset($block['source'])) {
$block['source'] = $appName;
}
$this->dao->replace(TABLE_BLOCK)->data($block)->exec();
}
return !dao::isError();
}
示例14: setDevice
/**
* Set device admin.
*
* @param string $device
* @access public
* @return void
*/
public function setDevice($device)
{
$this->session->set('device', $device);
$template = $this->config->template->{$device};
if (isset($this->config->template->{$device}) and !is_object($this->config->template->{$device})) {
$template = json_decode($this->config->template->{$device});
}
$setting['name'] = $template->name;
$setting['theme'] = $template->theme;
$setting = helper::jsonEncode($setting);
$result = $this->loadModel('setting')->setItems('system.common.template', array($device => $setting));
$this->locate($this->server->http_referer);
}
示例15: fixLogo
/**
* Fix Logo data when upgrade form 4.3.beta.
*
* @access public
* @return bool
*/
public function fixLogo()
{
$logos = $this->dao->setAutoLang(false)->select('*')->from(TABLE_CONFIG)->where('section')->eq('logo')->fetchGroup('lang');
$logosForAllThemes = $this->dao->setAutoLang(false)->select('*')->from(TABLE_CONFIG)->where('`key`')->eq('logo')->fetchGroup('lang');
$logoSetting = array();
if (!empty($logos)) {
foreach ($logos as $lang => $logoList) {
if (isset($logosForAllThemes[$lang])) {
$logoForAllThemes = $logosForAllThemes[$lang][0];
$logoSetting['default']['themes']['all'] = json_decode($logoForAllThemes->value);
}
foreach ($logoList as $logo) {
$logoSetting['default']['themes'][$logo->key] = json_decode($logo->value);
}
$result = $this->loadModel('setting')->setItems('system.common.site', array('logo' => helper::jsonEncode($logoSetting)), $lang);
if (!$result) {
return false;
}
}
} else {
if (!empty($logosForAllThemes)) {
foreach ($logosForAllThemes as $lang => $logoForAllTheme) {
$logo = $logoForAllTheme[0];
$logoSetting['default']['themes']['all'] = json_decode($logo->value);
$result = $this->loadModel('setting')->setItems('system.common.site', array('logo' => helper::jsonEncode($logoSetting)), $lang);
if (!$result) {
return false;
}
}
}
}
return true;
}