original_string: public function compare() {
          $compareContent=false;
          
          
          //Get the Main Revision
          $snippet1=Snippet::get()->byID(intval($this->urlParams['ID']));
          if(empty($snippet1) || $snippet1===false || $snippet1->ID==0) {
              $snippet1=false;
          }
          
          if($snippet1!==false) {
              //Get the Comparision Revision
              $snippet2=$snippet1->Version(intval($this->urlParams['OtherID']));
              if(empty($snippet2) || $snippet1===false || $snippet2->ID==0) {
                  $snippet2=false;
              }
              
              if($snippet2!==false) {
                  $snippet1Text=preg_replace('/\r\n|\n|\r/', "\n", $snippet1->SnippetText);
                  $snippet2Text=preg_replace('/\r\n|\n|\r/', "\n", $snippet2->Text);
                  
                  //Generate the diff file
                  $diff=new Text_Diff('auto', array(preg_split('/\n/', $snippet1Text), preg_split('/\n/', $snippet2Text)));
                  $renderer=new WP_Text_Diff_Renderer_Table();
                  
                  $renderedDiff=$renderer->render($diff);
                  if(!empty($renderedDiff)) {
                      $lTable='<table cellspacing="0" cellpadding="0" border="0" class="diff">'.
                                  '<colgroup>'.
                                      '<col class="ltype"/>'.
                                      '<col class="content"/>'.
                                  '</colgroup>'.
                                  '<tbody>';
                      $rTable=$lTable;
                      
                      header('content-type: text/plain');
                      $xml=simplexml_load_string('<tbody>'.str_replace('&nbsp;', ' ', $renderedDiff).'</tbody>');
                      foreach($xml->children() as $row) {
                          $i=0;
                          $lTable.='<tr>';
                          $rTable.='<tr>';
                          
                          foreach($row->children() as $td) {
                              $attr=$td->attributes();
                              
                              if($i==0) {
                                  $lTable.=$td->asXML();
                              }else {
                                  $rTable.=$td->asXML();
                              }
                              
                              $i++;
                          }
                          
                          $lTable.='</tr>';
                          $rTable.='</tr>';
                      }
                      
                      $lTable.='</tbody></table>';
                      $rTable.='</tbody></table>';
                      
                      $compareContent='<div class="compare leftSide">'.$lTable.'</div>'.
                                      '<div class="compare rightSide">'.$rTable.'</div>';
                  }
              }
          }
          
          
          Requirements::css(CB_DIR.'/css/CompareView.css');
          Requirements::javascript(CB_DIR.'/javascript/CodeBank.CompareView.js');
          
          
          return $this->renderWith('CodeBank_CompareView', array(
                                                                  'CompareContent'=>$compareContent
                                                              ));
      }
code: public function compare() {
          $compareContent=false;
          
          
          //Get the Main Revision
          $snippet1=Snippet::get()->byID(intval($this->urlParams['ID']));
          if(empty($snippet1) || $snippet1===false || $snippet1->ID==0) {
              $snippet1=false;
          }
          
          if($snippet1!==false) {
              //Get the Comparision Revision
              $snippet2=$snippet1->Version(intval($this->urlParams['OtherID']));
              if(empty($snippet2) || $snippet1===false || $snippet2->ID==0) {
                  $snippet2=false;
              }
              
              if($snippet2!==false) {
                  $snippet1Text=preg_replace('/\r\n|\n|\r/', "\n", $snippet1->SnippetText);
                  $snippet2Text=preg_replace('/\r\n|\n|\r/', "\n", $snippet2->Text);
                  
                  //Generate the diff file
                  $diff=new Text_Diff('auto', array(preg_split('/\n/', $snippet1Text), preg_split('/\n/', $snippet2Text)));
                  $renderer=new WP_Text_Diff_Renderer_Table();
                  
                  $renderedDiff=$renderer->render($diff);
                  if(!empty($renderedDiff)) {
                      $lTable='<table cellspacing="0" cellpadding="0" border="0" class="diff">'.
                                  '<colgroup>'.
                                      '<col class="ltype"/>'.
                                      '<col class="content"/>'.
                                  '</colgroup>'.
                                  '<tbody>';
                      $rTable=$lTable;
                      
                      header('content-type: text/plain');
                      $xml=simplexml_load_string('<tbody>'.str_replace('&nbsp;', ' ', $renderedDiff).'</tbody>');
                      foreach($xml->children() as $row) {
                          $i=0;
                          $lTable.='<tr>';
                          $rTable.='<tr>';
                          
                          foreach($row->children() as $td) {
                              $attr=$td->attributes();
                              
                              if($i==0) {
                                  $lTable.=$td->asXML();
                              }else {
                                  $rTable.=$td->asXML();
                              }
                              
                              $i++;
                          }
                          
                          $lTable.='</tr>';
                          $rTable.='</tr>';
                      }
                      
                      $lTable.='</tbody></table>';
                      $rTable.='</tbody></table>';
                      
                      $compareContent='<div class="compare leftSide">'.$lTable.'</div>'.
                                      '<div class="compare rightSide">'.$rTable.'</div>';
                  }
              }
          }
          
          
          Requirements::css(CB_DIR.'/css/CompareView.css');
          Requirements::javascript(CB_DIR.'/javascript/CodeBank.CompareView.js');
          
          
          return $this->renderWith('CodeBank_CompareView', array(
                                                                  'CompareContent'=>$compareContent
                                                              ));
      }
code_tokens: public function compare ( ) { $ compareContent = false ; //Get the Main Revision $ snippet1 = Snippet :: get ( ) -> byID ( intval ( $ this -> urlParams [ 'ID' ] ) ) ; if ( empty ( $ snippet1 ) || $ snippet1 === false || $ snippet1 -> ID == 0 ) { $ snippet1 = false ; } if ( $ snippet1 !== false ) { //Get the Comparision Revision $ snippet2 = $ snippet1 -> Version ( intval ( $ this -> urlParams [ 'OtherID' ] ) ) ; if ( empty ( $ snippet2 ) || $ snippet1 === false || $ snippet2 -> ID == 0 ) { $ snippet2 = false ; } if ( $ snippet2 !== false ) { $ snippet1Text = preg_replace ( '/\r\n|\n|\r/' , "\n" , $ snippet1 -> SnippetText ) ; $ snippet2Text = preg_replace ( '/\r\n|\n|\r/' , "\n" , $ snippet2 -> Text ) ; //Generate the diff file $ diff = new Text_Diff ( 'auto' , array ( preg_split ( '/\n/' , $ snippet1Text ) , preg_split ( '/\n/' , $ snippet2Text ) ) ) ; $ renderer = new WP_Text_Diff_Renderer_Table ( ) ; $ renderedDiff = $ renderer -> render ( $ diff ) ; if ( ! empty ( $ renderedDiff ) ) { $ lTable = '<table cellspacing="0" cellpadding="0" border="0" class="diff">' . '<colgroup>' . '<col class="ltype"/>' . '<col class="content"/>' . '</colgroup>' . '<tbody>' ; $ rTable = $ lTable ; header ( 'content-type: text/plain' ) ; $ xml = simplexml_load_string ( '<tbody>' . str_replace ( '&nbsp;' , ' ' , $ renderedDiff ) . '</tbody>' ) ; foreach ( $ xml -> children ( ) as $ row ) { $ i = 0 ; $ lTable .= '<tr>' ; $ rTable .= '<tr>' ; foreach ( $ row -> children ( ) as $ td ) { $ attr = $ td -> attributes ( ) ; if ( $ i == 0 ) { $ lTable .= $ td -> asXML ( ) ; } else { $ rTable .= $ td -> asXML ( ) ; } $ i ++ ; } $ lTable .= '</tr>' ; $ rTable .= '</tr>' ; } $ lTable .= '</tbody></table>' ; $ rTable .= '</tbody></table>' ; $ compareContent = '<div class="compare leftSide">' . $ lTable . '</div>' . '<div class="compare rightSide">' . $ rTable . '</div>' ; } } } Requirements :: css ( CB_DIR . '/css/CompareView.css' ) ; Requirements :: javascript ( CB_DIR . '/javascript/CodeBank.CompareView.js' ) ; return $ this -> renderWith ( 'CodeBank_CompareView' , array ( 'CompareContent' => $ compareContent ) ) ; }
docstring: Handles rendering of the compare view
  @return {string} HTML to be sent to the browser
docstring_tokens: Handles rendering of the compare view