/**
  * Return all Tutorials
  */
 public function actionIndex()
 {
     $response = array();
     $response['VideoPath'] = Yii::app()->params['siteDomain'] . Yii::app()->params['videoPath'];
     $response['Entries'] = array();
     $tutorials = Tutorial::model()->findAll();
     if ($tutorials != null) {
         // Have something to return..
         // Get images for each entry.
         foreach ($tutorials as $tutorial) {
             // Get all images for current tutorial entry.
             $response['Entries'][] = array('Id' => $tutorial->Id, 'Name' => $tutorial->Name, 'Description' => $tutorial->Description, 'VideoName' => $tutorial->VideoName);
         }
     }
     $this->sendResponse(200, CJSON::encode($response));
 }
예제 #2
0
 protected function loadTutorial($tutId)
 {
     if ($this->_tutorial === null) {
         $this->_tutorial = Tutorial::model()->findByPk($tutId);
         if ($this->_tutorial === null) {
             throw new CHttpException(404, 'The requested Tutorial does not exists');
         }
     }
     return $this->_tutorial;
 }
예제 #3
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Tutorial::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }