Ejemplo n.º 1
0
 /**
  * Word wraps the text if enabled.
  *
  * @param	string	Text to wrap
  *
  * @return	string	Wrapped text
  */
 protected function doWordWrap($text)
 {
     if (self::$wordWrap != 0) {
         $text = vB_String::fetchWordWrappedString($text, self::$wordWrap, '  ');
     }
     return $text;
 }
Ejemplo n.º 2
0
 public function fetchHistoryComparison($nodeid, $oldpost, $newpost)
 {
     if (!$this->canViewPostHistory($nodeid)) {
         throw new Exception('no_permission');
     }
     $_posthistory = vB::getDbAssertor()->getRows('vBForum:postedithistory', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => array('nodeid' => $nodeid, 'postedithistoryid' => array($oldpost, $newpost)), vB_dB_Query::COLUMNS_KEY => array('postedithistoryid', 'reason', 'dateline', 'username', 'original', 'pagetext')), array('field' => 'postedithistoryid', 'direction' => vB_dB_Query::SORT_ASC));
     if (!$_posthistory) {
         throw new Exception('no_permission');
     }
     $posthistory = array();
     $key = 1;
     foreach ($_posthistory as $info) {
         $posthistory['post' . $key] = $info;
         $key++;
     }
     require_once DIR . '/includes/class_diff.php';
     if ($posthistory['post2']) {
         $textdiff_obj = new vB_Text_Diff($posthistory['post1']['pagetext'], $posthistory['post2']['pagetext']);
     } else {
         $textdiff_obj = new vB_Text_Diff($posthistory['post1']['pagetext'], $posthistory['post1']['pagetext']);
     }
     $results = array();
     $diff = $textdiff_obj->fetch_diff();
     foreach ($diff as $diffrow) {
         $compare_show = array();
         if ($diffrow->old_class == 'unchanged' and $diffrow->new_class == 'unchanged') {
             // no change
             $results[] = array('unchanged_olddata' => vB_String::fetchWordWrappedString(nl2br(vB_String::htmlSpecialCharsUni(implode("\n", $diffrow->fetch_data_old())))));
         } else {
             // something has changed
             $results[] = array('changed_olddata' => vB_String::fetchWordWrappedString(nl2br(vB_String::htmlSpecialCharsUni(implode("\n", $diffrow->fetch_data_old())))), 'changed_newdata' => vB_String::fetchWordWrappedString(nl2br(vB_String::htmlSpecialCharsUni(implode("\n", $diffrow->fetch_data_new())))));
         }
     }
     return $results;
 }