Options
Fatal Error Success
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.
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.
1
Comments
Vanilla Forums COO [GitHub, Twitter, About.me]
<?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! } } ?>
This is just a first draft of the code. Once it works im slimming it down a little bit.
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); } }