protected function FormatQuote($Type, $ID, &$QuoteData) { $Type = strtolower($Type); $Model = FALSE; switch ($Type) { case 'comment': $Model = new CommentModel(); break; case 'discussion': $Model = new DiscussionModel(); break; default: break; } //$QuoteData = array(); if ($Model) { $Data = $Model->GetID($ID); $NewFormat = C('Garden.InputFormatter'); $QuoteFormat = $Data->Format; // Perform transcoding if possible $NewBody = $Data->Body; if ($QuoteFormat != $NewFormat) { if ($QuoteFormat == 'BBCode' && $NewFormat == 'Html') { $NewBody = Gdn_Format::BBCode($NewBody); } elseif ($QuoteFormat == 'Text' && $NewFormat == 'Html') { $NewBody = Gdn_Format::Text($NewBody); } elseif ($QuoteFormat == 'Html' && $NewFormat == 'BBCode') { $NewBody = Gdn_Format::Text($NewBody); } elseif ($QuoteFormat == 'Text' && $NewFormat == 'BBCode') { $NewBody = Gdn_Format::Text($NewBody); } else { $NewBody = Gdn_Format::PlainText($NewBody, $QuoteFormat); } Gdn::Controller()->InformMessage(sprintf(T('The quote had to be converted from %s to %s.', 'The quote had to be converted from %s to %s. Some formatting may have been lost.'), $QuoteFormat, $NewFormat)); } $Data->Body = $NewBody; $QuoteData = array_merge($QuoteData, array('status' => 'success', 'body' => $Data->Body, 'format' => C('Garden.InputFormatter'), 'authorid' => $Data->InsertUserID, 'authorname' => $Data->InsertName, 'type' => $Type, 'typeid' => $ID)); } }
protected function FormatQuote($Type, $ID, &$QuoteData) { $Model = FALSE; switch (strtolower($Type)) { case 'comment': $Model = new CommentModel(); break; case 'discussion': $Model = new DiscussionModel(); break; default: break; } //$QuoteData = array(); if ($Model !== FALSE) { $Data = $Model->GetID($ID); $NewFormat = C('Garden.InputFormatter'); $QuoteFormat = $Data->Format; $QuoteData = array_merge($QuoteData, array('status' => 'success', 'body' => $Data->Body, 'format' => C('Garden.InputFormatter'), 'authorid' => $Data->InsertUserID, 'authorname' => $Data->InsertName)); // Perform transcoding if possible $NewBody = $Data->Body; if ($QuoteFormat != $NewFormat) { if ($QuoteFormat == 'BBCode' && $NewFormat == 'Html') { $NewBody = Gdn_Format::BBCode($NewBody); } elseif ($QuoteFormat == 'Text' && $NewFormat == 'Html') { $NewBody = Gdn_Format::Text($NewBody); } elseif ($QuoteFormat == 'Html' && $NewFormat == 'BBCode') { $NewBody = Gdn_Format::Text($NewBody); } elseif ($QuoteFormat == 'Text' && $NewFormat == 'BBCode') { $NewBody = Gdn_Format::Text($NewBody); } } $Data->Body = $NewBody; } }