public function actionDiff($id, $mode)
 {
     if (!isset(Yii::app()->session['code'])) {
         $this->redirect(array('index'));
     }
     $class = Class_Prog::model()->findByPk($id);
     if ($class == null) {
         throw new CHttpException(404, 'Unable to find the requested class.');
     }
     $original = $this->renderPartial('/generator/cpp_class_decl', array('raw' => 1, 'class' => $class), true);
     $new = Yii::app()->session['code'];
     $diff = TextDiff::compare($original, $new, $mode);
     $this->render('diff', array('class' => $class, 'diff' => $diff, 'new' => $new, 'mode' => $mode));
 }
 /**
  * The code diff action.
  * This action shows up the difference between the newly generated code and the corresponding existing code.
  */
 public function actionDiff()
 {
     Yii::import('gii.components.TextDiff');
     $model = $this->prepare();
     if (isset($_GET['id']) && isset($model->files[$_GET['id']])) {
         $file = $model->files[$_GET['id']];
         if (!in_array($file->type, array('php', 'txt', 'js', 'css'))) {
             $diff = false;
         } else {
             if ($file->operation === CCodeFile::OP_OVERWRITE) {
                 $diff = TextDiff::compare(file_get_contents($file->path), $file->content);
             } else {
                 $diff = '';
             }
         }
         $this->renderPartial('/common/diff', array('file' => $file, 'diff' => $diff));
     } else {
         throw new CHttpException(404, 'Unable to find the code you requested.');
     }
 }
 /**
  * Displays difference between two page revisions
  *
  * @param string $uid unique wiki id
  * @param string $rev1 page revision
  * @param string $rev2 page revision
  */
 public function actionDiff($uid, $rev1, $rev2)
 {
     $r1 = WikiPageRevision::model()->findByPk($rev1);
     if (!$r1) {
         throw new CHttpException(404);
     }
     $r2 = WikiPageRevision::model()->findByPk($rev2);
     if (!$r2) {
         throw new CHttpException(404);
     }
     $this->render('diff', array('diff' => TextDiff::compare($r1->content, $r2->content), 'r1' => $r1, 'r2' => $r2, 'uid' => $uid));
 }