Example #1
0
 /**
  * The step 2.2
  * return result when compare content between 2 files
  *
  * @return object
  */
 function getDiffFiles()
 {
     global $jauc;
     $obj = $this->_getProduct();
     if ($obj === false) {
         return false;
     }
     $type = JRequest::getVar('diff_type');
     $file = JRequest::getVar('file');
     $version = JRequest::getVar('version');
     $obj->diffType = $type;
     $obj->diffFile = $file;
     if (count($_POST)) {
         $diff = new jaDiffTool();
         $objLeft = $diff->buildObject(stripslashes(JRequest::getVar('titleLeft', '', 'post')), stripslashes(JRequest::getVar('fileLeft', '', 'post')), stripslashes($_POST['srcLeft']), JRequest::getInt('editabledLeft', 0, 'post'));
         $objRight = $diff->buildObject(stripslashes(JRequest::getVar('titleRight', '', 'post')), stripslashes(JRequest::getVar('fileRight', '', 'post')), stripslashes($_POST['srcRight']), JRequest::getInt('editabledRight', 0, 'post'));
         $result = $diff->compare($objLeft, $objRight);
         $obj->diffInfo = $result;
         return $obj;
     } else {
         $result = $jauc->buildDiffFiles($obj, $version);
         if ($result === false) {
             return false;
         } else {
             $obj->diffInfo = $result;
             return $obj;
         }
     }
 }
Example #2
0
 function buildDiffFilesLocal($product, $newVersion)
 {
     $FileSystemHelper = new FileSystemHelper();
     if (!($productDir = $this->getLocalVersionsPath($product))) {
         return false;
     }
     $pro = new jaProducts($product, $this->config);
     $diffType = isset($product->diffType) ? $product->diffType : 'LN';
     $diffFile = $product->diffFile;
     /**
      * (L) = Files of Live version on user site.
      * (O) = Original files of live version.
      * (N) = New Version Files.
      */
     $titleLive = "Current file (The file of version {$product->version} and modified by you)";
     $titleOrig = "Original file (The file of version {$product->version})";
     $titleNew = "New file (The file of new version {$newVersion})";
     $fileLive = $pro->getFilePath($diffFile);
     $fileOrig = $FileSystemHelper->clean($productDir . $product->version . '/' . $diffFile);
     $fileNew = $FileSystemHelper->clean($productDir . $newVersion . '/' . $diffFile);
     if (!JFile::exists($fileOrig)) {
         //missing current version on local repository
         //=> using live file to compare
         $fileOrig = $fileLive;
         $titleOrig = $titleLive;
     }
     /*********/
     $arrayTypes = array('L' => 'Live', 'N' => 'New', 'O' => 'Orig');
     $suffix1 = $arrayTypes[substr($diffType, 0, 1)];
     $suffix2 = $arrayTypes[substr($diffType, 1, 1)];
     $title1 = ${'title' . $suffix1};
     $file1 = ${'file' . $suffix1};
     $title2 = ${'title' . $suffix2};
     $file2 = ${'file' . $suffix2};
     /*********/
     if (JFile::exists($file1) && JFile::exists($file2)) {
         $diff = new jaDiffTool();
         $objLeft = $diff->buildObject($title1, $file1, '', 0);
         $objRight = $diff->buildObject($title2, $file2, '', 0);
         $result = $diff->compare($objLeft, $objRight, 'file');
         return $result;
     } else {
         return false;
     }
 }