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


PHP Subject::getLiveData方法代码示例

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


在下文中一共展示了Subject::getLiveData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionGetall

 public function actionGetall($subject_id = 0, $comment_id = 0)
 {
     global $arr_response;
     //in case params are sent via POST
     $subject_id = $_REQUEST['subject_id'];
     $comment_id = $_REQUEST['comment_id'];
     $width = $_REQUEST['width'];
     $height = $_REQUEST['height'];
     $keepratio = isset($_REQUEST['keepratio']) ? $_REQUEST['keepratio'] : 1;
     //Default to true
     //PHP casts any string to 0. so its ok. We need to cast in case we receive a string.
     $subject_id = (int) $subject_id;
     $comment_id = (int) $comment_id;
     $width = (int) $width;
     $height = (int) $height;
     $keepratio = $keepratio ? true : false;
     $arr_response = array_merge($arr_response, Subject::getLiveData($subject_id, $comment_id, $width, $height, $keepratio));
     //TODO: Add log/counter statistics for API requests
 }
开发者ID:jjsub,项目名称:samesub,代码行数:19,代码来源:LiveController.php

示例2: actionFetch

 /**
  * Fetch data about a subject.
  * This action does NOT return a html web page. 
  * This action returns data about a subject in an encoded format for data interchange(JSON,XML,etc.)
  * It can be used for API implementation.
  */
 public function actionFetch($subject_id = 0, $comment_id = 0)
 {
     //in case params are sent via POST
     if (isset($_POST['subject_id'])) {
         $subject_id = $_POST['subject_id'];
     }
     if (isset($_POST['comment_id'])) {
         $comment_id = $_POST['comment_id'];
     }
     //PHP casts any string to 0. so its ok. We need to cast in case we receive a string.
     $subject_id = (int) $subject_id;
     $comment_id = (int) $comment_id;
     $data = NULL;
     $data = Subject::getLiveData($subject_id, $comment_id, false);
     if ($data['new_sub'] == 0) {
         $this->no_log = true;
     }
     //This is just to control the logging functionality(client dont receive this info)
     if ($data['new_sub'] != 0) {
         if (isset($_GET['subject_id'])) {
             //Only if its not comming from site.php js(that script does not sends that param)
             if ($data['subject_id']) {
                 $this->model = $this->loadModel($data['subject_id']);
             }
             //Track each unique view of the subject in homepage as subjects passes by
             if (!Yii::app()->session['subject_view_live']) {
                 Yii::app()->session['subject_view_live'] = array('1' => 1);
             }
             //just in case start it with something
             if (!in_array($this->model->id, Yii::app()->session['subject_view_live'])) {
                 //buggy we need to reasign a new array as we can not modify an array on the fly in a session var
                 $arr_sv = Yii::app()->session['subject_view_live'];
                 $arr_sv[] = $this->model->id;
                 Yii::app()->session['subject_view_live'] = $arr_sv;
                 $this->model->live_views += 1;
                 $this->model->save();
             }
         }
     }
     echo json_encode($data);
 }
开发者ID:jjsub,项目名称:samesub,代码行数:47,代码来源:SubjectController.php


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