Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Fatal Error Success

edited October 2010 in Vanilla 2.0 - 2.8
Im creating aplugin but it generate an error on enable.
The error is 'Success'

Does anybody know what causes this error or how i can track it down.
will post code for plugin later today if that helps.

Comments

  • TimTim Vanilla Staff
    The code would definitely help. Zip it up :)

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • edited October 2010
    Code below. Only one file n the plugin as that is all that should be needed.
    <?php $PluginInfo['DTable'] = array( 'Name' => 'DTable', 'Description' => "This plugin shows table in the comments", 'Version' => '0.1', 'RequiredApplications' => FALSE, 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'RegisterPermissions' => FALSE, 'Author' => "David Wylie", 'AuthorEmail' => 'wylieonbike@googlemail.com' ); class TablePlugin extends Gdn_Plugin { public function DiscussionController_BeforeCommentDisplay_Handler(&$Sender) { $this->RenderTable($Sender); } public function PostController_BeforeCommentDisplay_Handler(&$Sender) { $this->RenderTable($Sender); } protected function RenderTable(&$Sender) { if (isset($Sender->EventArguments['Discussion'])) $Data = $Sender->EventArguments['Discussion']; if (isset($Sender->EventArguments['Comment'])) $Data = $Sender->EventArguments['Comment']; $startpos = stripos($Data->Body,'[table]'); $endpos = stripos($Data->Body,'[/table]'); if (($startpos!=False)&&($endpos!=False)) { $tableText = substr($Data->Body,$startpos+strlen('[table]'),$endpos-$startpos); $tableRows = strTok($tableText,chr(13)); $l = sizeOf($tableRows); for ($i=0;$i<$l;$i++) { $tableRows[i] = strTok($tableRows[i],chr(9)); } $tableText ="<table>"; for($i=0;Si<$l;$i++) { $tableText.="<tr>"; $c = sizeOf($tableRows[i]); for($j=0;$j<$c;$j++) { $tableText.="<td>".$tableRows[i][j].""; } $tableText.=""; } $tableText.=""; $Data->Body = str_replace(substr($Data->Body,$startpos,$endpos+strlen('[table]')-$startpos),$tableText,$Data->Body); } } public function Setup() { // Nothing to do here! } public function Structure() { // Nothing to do here! } } ?>
  • The idea is to take a table pasted by the user from excell and turn it into a html table.
    This is just a first draft of the code. Once it works im slimming it down a little bit.
  • edited October 2010
    Corrected some bugs in the code but still getting the error. Any idea what cuases a success error?

    protected function RenderTable(&$Sender) { if (isset($Sender->EventArguments['Discussion'])) $Data = $Sender->EventArguments['Discussion']; if (isset($Sender->EventArguments['Comment'])) $Data = $Sender->EventArguments['Comment']; $startpos = stripos($Data->Body,'[table]'); $endpos = stripos($Data->Body,'[/table]'); if (!($startpos ==False) && !($endPos==false)){ $Data->Body = str_replace('[table]','',$Data->Body); $Data->Body = str_replace('[/table]','',$Data->Body); $Data->Body = str_replace(chr(13),'',$Data->Body); $Data->Body = str_replace(chr(9),'',$Data->Body); } }
Sign In or Register to comment.