本文整理汇总了PHP中CJSON类的典型用法代码示例。如果您正苦于以下问题:PHP CJSON类的具体用法?PHP CJSON怎么用?PHP CJSON使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CJSON类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$params = array();
$criteria = new CDbCriteria();
// $criteria->select = array('id,username,fullname,phone,address,status');
$criteria->select = '*';
if (isset($this->team_lear_id) and $this->team_lear_id != '') {
$criteria->addCondition('team_lear_id=' . $this->team_lear_id);
}
$criteria->params = $params;
$total = ATrainingTeam::model()->count($criteria);
$offset = $this->limit * ($this->page - 1);
$criteria->limit = $this->limit;
$criteria->offset = $offset;
$data = ATrainingTeam::model()->findAll($criteria);
$listTrainee = array();
if (!empty($data)) {
foreach ($data as $item) {
$listTrainee[] = CJSON::decode(CJSON::encode($item->pls_user));
}
}
$data = $listTrainee;
$pages = new CPagination($total);
$pages->pageSize = $this->limit;
$pages->applyLimit($criteria);
$this->render($this->view, array('data' => $data, 'pages' => $pages));
}
开发者ID:nguyendvphp,项目名称:onlinetraining,代码行数:27,代码来源:wg_dataUser_Team.php
示例2: decodeJson
/**
* Decodes JSON sting.
*
* @static
*
* @param string $data
* @param bool $asArray get result as array instead of object
*
* @return mixed
*/
public static function decodeJson($data, $asArray = true)
{
if (self::$json === null) {
self::$json = new CJSON();
}
return self::$json->decode($data, $asArray);
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:17,代码来源:CJs.php
示例3: encodeJson
/**
* Encodes the data as a JSON string to be used in JavaScript code.
*
* @static
*
* @param mixed $data
*
* @param bool $forceObject force all arrays to objects
*
* @return mixed
*/
public static function encodeJson($data, $forceObject = false)
{
if (self::$json === null) {
self::$json = new CJSON();
}
return self::$json->encode($data, array(), $forceObject);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:18,代码来源:CJs.php
示例4: actionIndex
public function actionIndex()
{
$entities = array_keys($this->model_class_map);
$coder = new CJSON();
$response = $coder->encode($entities);
Yii::trace($response);
echo $response;
}
开发者ID:rosko,项目名称:AlmazService,代码行数:8,代码来源:ServiceController.php
示例5: send
/**
* Output ajax response. If any error was added, 'result' is false, otherwise true.
*
* @return void
*/
public function send()
{
$json = new CJSON();
if ($this->_result) {
echo $json->encode(array('result' => true, 'data' => $this->_data));
} else {
echo $json->encode(array('result' => false, 'errors' => $this->_errors));
}
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:14,代码来源:class.ajaxresponse.php
示例6: performTest
public function performTest($testName)
{
$testUri = testCase::BASE_SERVICE . $testName . '.' . testCase::RESPONSE_FORMAT;
echo_line('<pre>');
echo_line("Request:");
echo_line("\t" . $testUri);
echo_line("\nResponse:\n");
$response = send_request($testUri, 'GET');
$coder = new CJSON();
$object = $coder->decode($response);
print_as_json('', $object);
echo_line('</pre>');
}
开发者ID:rosko,项目名称:AlmazService,代码行数:13,代码来源:testClassSheme.php
示例7: getResponse
public function getResponse($format)
{
$className = 'Unknown';
$trace = $this->getTrace();
if (count($trace) > 0) {
$place = $trace[0];
if (isset($place['class'])) {
$className = $place['class'];
}
}
$response = array('error' => array('code' => $this->getCode(), 'message' => $this->getMessage(), 'class' => $className));
$coder = new CJSON();
return $coder->encode($response);
}
开发者ID:rosko,项目名称:AlmazService,代码行数:14,代码来源:APIException.php
示例8: init
public function init()
{
//Yii::app()->setTheme('adm');
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/global.js');
$cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui.min.js');
$cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.alerts.js');
//$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/jquery.confirm.js');
//$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/jquery.blockui.js');
$cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-ui-1.8.2.custom.min.js');
//$cs->registerScriptFile(Yii::app()->theme->baseUrl.'/js/bsystemgroup.js');
$cs->registerCssFile(Yii::app()->theme->baseUrl . '/css/jquery.alerts.css');
Yii::app()->clientScript->registerScript('global', '
yii = {
urls: {
base: ' . CJSON::encode(Yii::app()->theme->baseUrl) . '
}
};
', CClientScript::POS_HEAD);
if (Yii::app()->user->id) {
$user = new ASystemUser();
$userInfo = $user->getSystemUserById(Yii::app()->user->id);
//var_dump($userInfo->cp_code);exit();
$this->group_id = $userInfo->group_id;
$this->username = $userInfo->username;
Yii::app()->session['group_id'] = $this->group_id;
Yii::app()->session['username'] = $this->username;
}
//$xmlPath = realpath($path = Yii::app()->basePath.'/../'.Yii::app()->params['config_folder'].'/');
// $xmlFile = Yii::app()->params['config_file_name'];
// $this->config = new LoadConfigXML($xmlPath,$xmlFile);
Yii::$classMap = array_merge(Yii::$classMap, array('CaptchaExtendedAction' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedAction.php', 'CaptchaExtendedValidator' => Yii::getPathOfAlias('ext.captchaExtended') . DIRECTORY_SEPARATOR . 'CaptchaExtendedValidator.php'));
}
开发者ID:nguyendvphp,项目名称:onlinetraining,代码行数:33,代码来源:AController.php
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if ($this->CanAccess('create')) {
$model = new Language();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Language'])) {
$model->attributes = $_POST['Language'];
if ($model->CanUpdate() && $model->save()) {
// if AJAX request , we should not redirect the browser
if (!Yii::app()->request->isAjaxRequest) {
$this->redirect(array('view', 'id' => $model->id));
} else {
echo CJSON::encode(array('error' => '', 'id' => $model->id));
die;
}
}
}
if (!Yii::app()->request->isAjaxRequest) {
$this->render('create', array('model' => $model, 'ajaxRendering' => false));
} else {
$this->renderPartial('create', array('model' => $model, 'ajaxRendering' => true));
}
} else {
throw new CHttpException(405, Yii::t('app', 'You do not have permissions to access this page.'));
}
}
开发者ID:lidijakralj,项目名称:bober,代码行数:31,代码来源:LanguageController.php
示例10: generateDefaultLayout
/**
* Generates a default layout from the desktop layout if available, or from the model's
* fields otherwise.
* @param string $type 'form' or 'view'
* @param string $modelName
* @return array
*/
public static function generateDefaultLayout($type, $modelName)
{
if ($type === 'form') {
$layout = FormLayout::model()->findByAttributes(array('model' => ucfirst($modelName), 'defaultForm' => 1, 'scenario' => 'Default'));
} else {
$layout = FormLayout::model()->findByAttributes(array('model' => ucfirst($modelName), 'defaultView' => 1, 'scenario' => 'Default'));
}
$layoutData = array();
if ($layout) {
$layout = CJSON::decode($layout->layout);
if (isset($layout['sections'])) {
foreach ($layout['sections'] as $section) {
foreach ($section['rows'] as $row) {
foreach ($row['cols'] as $col) {
foreach ($col['items'] as $item) {
if (isset($item['name'])) {
$fieldName = preg_replace('/^formItem_/u', '', $item['name']);
$layoutData[] = $fieldName;
}
}
}
}
}
}
} elseif (is_subclass_of($modelName, 'X2Model')) {
$layoutData = Yii::app()->db->createCommand()->select('fieldName')->from('x2_fields')->where('modelName=:modelName', array(':modelName' => $modelName))->andWhere($type === 'view' ? 'readOnly' : 'true')->queryColumn();
}
return $layoutData;
}
开发者ID:tymiles003,项目名称:X2CRM,代码行数:36,代码来源:MobileLayouts.php
示例11: _sendResponse
private function _sendResponse($raw = false, $dataType = false)
{
$status = $this->_statusCode;
if ($dataType === false) {
$contentType = $this->_contentType;
} else {
$contentType = $dataType;
}
// set the status
$status_header = 'HTTP/1.1 ' . $status . ' ' . $this->_statusText;
@header($status_header);
// and the content type
@header('Content-type: ' . $contentType);
$response = $this->data;
if ($raw) {
echo $response;
} else {
//jsonp handling
$json = CJSON::encode($response);
if (isset($_GET['callback'])) {
echo $_GET['callback'] . ' (';
echo $json;
echo ');';
} else {
echo $json;
}
}
}
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:28,代码来源:ApiController.php
示例12: makeBuilderPredefinedEmailTemplate
protected function makeBuilderPredefinedEmailTemplate($name, $unserializedData, $subject = null, $modelClassName = null, $language = null, $type = null, $isDraft = 0, $textContent = null, $htmlContent = null)
{
$emailTemplate = new EmailTemplate();
$emailTemplate->type = $type;
//EmailTemplate::TYPE_WORKFLOW;
$emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
$emailTemplate->isDraft = $isDraft;
$emailTemplate->modelClassName = $modelClassName;
$emailTemplate->name = $name;
if (empty($subject)) {
$subject = $name;
}
$emailTemplate->subject = $subject;
if (!isset($language)) {
$language = Yii::app()->languageHelper->getForCurrentUser();
}
$emailTemplate->language = $language;
$emailTemplate->htmlContent = $htmlContent;
$emailTemplate->textContent = $textContent;
$emailTemplate->serializedData = CJSON::encode($unserializedData);
$emailTemplate->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
$saved = $emailTemplate->save(false);
if (!$saved) {
throw new FailedToSaveModelException();
}
$emailTemplate = EmailTemplate::getById($emailTemplate->id);
ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailTemplate, Group::getByName(Group::EVERYONE_GROUP_NAME));
$saved = $emailTemplate->save(false);
assert('$saved');
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:30,代码来源:EmailTemplatesBaseDefaultDataMaker.php
示例13: run
/**
* Suggests models based on the current user input.
*/
public function run()
{
if (isset($_GET['term']) && ($keyword = trim($_GET['term'])) !== '') {
$suggest = $this->getModel()->{$this->methodName}($keyword, $this->limit, $_GET);
echo CJSON::encode($suggest);
}
}
开发者ID:josterricardo,项目名称:proyecto-cirugia,代码行数:10,代码来源:PSuggestAction.php
示例14: actionIndex
/**
* Returns a List of all notifications for an user
*/
public function actionIndex()
{
// the id from the last entry loaded
$lastEntryId = (int) Yii::app()->request->getParam('from');
// create database query
$criteria = new CDbCriteria();
if ($lastEntryId > 0) {
// start from last entry id loaded
$criteria->condition = 'id<:lastEntryId';
$criteria->params = array(':lastEntryId' => $lastEntryId);
}
$criteria->order = 'seen ASC, created_at DESC';
$criteria->limit = 6;
// safe query
$notifications = Notification::model()->findAllByAttributes(array('user_id' => Yii::app()->user->id), $criteria);
// variable for notification list
$output = "";
foreach ($notifications as $notification) {
// format and save all entries
$output .= $notification->getOut();
// get the id from the last entry
$lastEntryId = $notification->id;
}
// build json array
$json = array();
$json['output'] = $output;
$json['lastEntryId'] = $lastEntryId;
$json['counter'] = count($notifications);
// return json
echo CJSON::encode($json);
// compete action
Yii::app()->end();
}
开发者ID:alefernie,项目名称:intranet,代码行数:36,代码来源:ListController.php
示例15: run
/**
* Display editor
*/
public function run()
{
// Resolve name and id
list($name, $id) = $this->resolveNameID();
// Get assets dir
$baseDir = dirname(__FILE__);
$assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'ueditor1_2_5');
// Publish required assets
$cs = Yii::app()->getClientScript();
$jsFile = $this->debug ? 'editor_all.js' : 'editor_all_min.js';
$cs->registerScriptFile($assets . '/' . $jsFile);
$cs->registerScriptFile($assets . '/editor_config.js');
$this->htmlOptions['id'] = $id;
if (!array_key_exists('style', $this->htmlOptions)) {
$this->htmlOptions['style'] = "width:{$this->width};";
}
if ($this->toolbars) {
$this->editorOptions['toolbars'][] = $this->toolbars;
}
$options = CJSON::encode(array_merge(array('theme' => $this->theme, 'lang' => $this->language, 'UEDITOR_HOME_URL' => "{$assets}/", 'initialFrameWidth' => $this->width, 'initialFrameHeight' => $this->height), $this->editorOptions));
$js = <<<EOP
UE.getEditor('{$id}',{$options});
EOP;
// Register js code
$cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_READY);
// Do we have a model
if ($this->hasModel()) {
$html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
} else {
$html = CHtml::textArea($name, $this->value, $this->htmlOptions);
}
echo $html;
}
开发者ID:jumper2012,项目名称:english_learning,代码行数:36,代码来源:WDueditor.php
示例16: run
public function run($code)
{
if (Yii::app()->request->isAjaxRequest) {
$user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
$result = Coding::isValidCode($code);
$hasused = Coding::hasUsedCode($code);
if ($result['code'] == 200 && $user->status >= 3 && !$hasused) {
$code = Code::model()->findByAttributes(array('code' => $code));
$code->times--;
$code->save();
$codeused = new CodeUsed();
$codeused->codeId = $code->id;
$codeused->userId = Yii::app()->user->id;
$codeused->createTime = date('YmdHis');
$codeused->save();
$user->status = 4;
$user->save();
$ccode = new CCode();
$result = $ccode->getproduct($code->code);
echo CJSON::encode(array('code' => 200, 'mes' => 'success', 'data' => $result['data']));
} else {
echo CJSON::encode(array('code' => 500, 'mes' => 'fail'));
}
}
}
开发者ID:itliuchang,项目名称:test,代码行数:25,代码来源:CodeAuthAction.php
示例17: init
public function init()
{
$quotesAssetsUrl = $this->module->assetsUrl;
if (isset($_POST)) {
$startHidden = false;
}
if ($this->startHidden) {
if ($this->startHidden) {
Yii::app()->clientScript->registerScript('startQuotesHidden', "\$('#quotes-form').hide();", CClientScript::POS_READY);
}
// Set up the new create form:
Yii::app()->clientScript->registerScriptFile($quotesAssetsUrl . '/js/inlineQuotes.js', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($quotesAssetsUrl . '/js/LineItems.js', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFiles('InlineQuotesCss', array($quotesAssetsUrl . '/css/inlineQuotes.css', $quotesAssetsUrl . '/css/lineItemsMain.css', $quotesAssetsUrl . '/css/lineItemsWrite.css'), false);
Yii::app()->clientScript->registerCoreScript('jquery.ui');
$this->contact = X2Model::model('Contacts')->findByPk($this->contactId);
//$this->contact = Contacts::model()->findByPk($this->contactId);
$iqConfig = array('contact' => $this->contact instanceof Contacts ? CHtml::encode($this->contact->name) : '', 'account' => $this->account, 'sendingQuote' => false, 'lockedMessage' => Yii::t('quotes', 'This quote is locked. Are you sure you want to update this quote?'), 'deniedMessage' => Yii::t('quotes', 'This quote is locked.'), 'lockedDialogTitle' => Yii::t('quotes', 'Locked'), 'failMessage' => Yii::t('quotes', 'Could not save quote.'), 'reloadAction' => CHtml::normalizeUrl(array('/quotes/quotes/viewInline', 'recordId' => $this->recordId, 'recordType' => CHtml::encode($this->modelName))), 'createAction' => CHtml::normalizeUrl(array('/quotes/quotes/create', 'quick' => 1, 'recordId' => $this->recordId, 'recordType' => $this->modelName)), 'updateAction' => CHtml::normalizeUrl(array('/quotes/quotes/update', 'quick' => 1)));
Yii::app()->clientScript->registerScript('quickquote-vars', '
;(function () {
if(typeof x2 == "undefined"){
x2 = {};
}
var iqConfig = ' . CJSON::encode($iqConfig) . ';
if(typeof x2.inlineQuotes=="undefined") {
x2.inlineQuotes = iqConfig;
} else {
$.extend(x2.inlineQuotes,iqConfig);
}
}) ();', CClientScript::POS_HEAD);
}
parent::init();
}
开发者ID:dsyman2,项目名称:X2CRM,代码行数:33,代码来源:InlineQuotes.php
示例18: registerClientScript
/**
* Register required script files
* @param $id
*/
public function registerClientScript($id)
{
Yii::app()->bootstrap->registerAssetCss('redactor.css');
Yii::app()->bootstrap->registerAssetJs('redactor.min.js');
$options = CJSON::encode(CMap::mergeArray($this->editorOptions, array('lang' => $this->lang)));
Yii::app()->bootstrap->registerRedactor('#' . $id, $options);
}
开发者ID:hipogea,项目名称:test-yii,代码行数:11,代码来源:TbRedactorJs.php
示例19: cities
public function cities($params = array())
{
$cache = Yii::app()->cache;
if ($city_all = $cache->hget('city', 'cities')) {
$provices = CJSON::decode($city_all);
} else {
//获取全国省列表
$provice_obj = YhmCity::model()->findAll('class_parent_id=:id', array(':id' => '1'));
$provices = array();
if ($provice_obj) {
foreach ($provice_obj as $key => $val) {
$provices[$val->class_id] = array('id' => $val->class_id, 'name' => $val->class_name);
}
}
$obj = YhmCity::model()->findAll('class_parent_id >:id and class_type = :type', array(':id' => 1, ':type' => 2));
if ($obj) {
foreach ($obj as $key => $val) {
if ($val->class_parent_id > 1) {
}
$provices[$val->class_parent_id]['cites'][] = array('id' => $val->class_id, 'name' => $val->class_name);
}
$cache->hset('city', 'cities', json_encode($provices, JSON_UNESCAPED_UNICODE));
}
}
$result = array('cities' => $provices);
return $this->notice('OK', 0, '成功', $result);
}
开发者ID:kl0428,项目名称:urtime,代码行数:27,代码来源:CityService.php
示例20: run
public function run()
{
// Создать модель и указать ей, что используется сценарий регистрации
$model = new RegistrationForm();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'RegistrationForm') {
//echo CActiveForm::validate($model);
$error = CActiveForm::validate($model);
if ($error != '[]') {
echo $error;
}
Yii::app()->end();
}
// Если пришли данные для сохранения
if (isset($_POST['RegistrationForm'])) {
// Безопасное присваивание значений атрибутам
$model->attributes = $_POST['RegistrationForm'];
// Проверка данных
if ($model->validate() && $model->signUp()) {
echo CJSON::encode(array('status' => 'success'));
Yii::app()->end();
} else {
$error = CActiveForm::validate($model);
if ($error != '[]') {
echo $error;
}
Yii::app()->end();
}
}
// вивести форму
//$this->controller->redirect(Yii::app()->user->returnUrl);
//$this->renderPartial('registration', array('model'=>$model));
}
开发者ID:vasia-ostapchuk,项目名称:source,代码行数:33,代码来源:SignUpAction.php
注:本文中的CJSON类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论