当前位置: 首页>>代码示例>>PHP>>正文


PHP CJSON类代码示例

本文整理汇总了PHP中CJSON的典型用法代码示例。如果您正苦于以下问题:PHP CJSON类的具体用法?PHP CJSON怎么用?PHP CJSON使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CJSON类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的CJSON类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。