public static function parse($arguments, $content=null, $parser=null) {
        //Ensure ID is pressent in the arguments
        if(!array_key_exists('id', $arguments)) {
            return '<p><b><i>'._t('CodeBankShortCode.MISSING_ID_ATTRIBUTE', '_Short Code missing the id attribute').'</i></b></p>';
        }
        
        
        //Fetch Snippet
        $snippet=Snippet::get()->byID(intval($arguments['id']));
        if(empty($snippet) || $snippet===false || $snippet->ID==0) {
            return '<p><b><i>'._t('CodeBankShortCode.SNIPPET_NOT_FOUND', '_Snippet not found').'</i></b></p>';
        }
        
        
        //Fetch Text
        $snippetText=$snippet->SnippetText;
        
        
        //If the version exists fetch it, and replace the text with that of the version
        if(array_key_exists('version', $arguments)) {
            $version=$snippet->Version(intval($arguments['version']));
            if(empty($version) || $version===false || $version->ID==0) {
                $snippetText=$version->Text;
            }
        }
        
        
        //Load CSS Requirements
        Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shCore.css');
        Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shCoreDefault.css');
        Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shThemeDefault.css');
        
        //Load JS Requirements
        Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.js');
        Requirements::javascript(CB_DIR.'/javascript/external/syntaxhighlighter/brushes/shCore.js');
        Requirements::javascript(CB_DIR.'/javascript/external/syntaxhighlighter/brushes/'.self::getBrushName($snippet->Language()->HighlightCode).'.js');
        Requirements::javascriptTemplate(CB_DIR.'/javascript/CodeBankShortCode.template.js', array('ID'=>$snippet->ID), 'snippet-highlightinit-'.$snippet->ID);
        
        
        //Render the snippet
        $obj=new ViewableData();
        return $obj->renderWith('CodeBankShortCode', array(
                                                            'ID'=>$snippet->ID,
                                                            'Title'=>$snippet->getField('Title'),
                                                            'Description'=>$snippet->getField('Description'),
                                                            'SnippetText'=>DBField::create_field('Text', $snippetText),
                                                            'HighlightCode'=>strtolower($snippet->Language()->HighlightCode)
                                                        ));
    }
public static function parse($arguments, $content=null, $parser=null) {
        //Ensure ID is pressent in the arguments
        if(!array_key_exists('id', $arguments)) {
            return '<p><b><i>'._t('CodeBankShortCode.MISSING_ID_ATTRIBUTE', '_Short Code missing the id attribute').'</i></b></p>';
        }
        
        
        //Fetch Snippet
        $snippet=Snippet::get()->byID(intval($arguments['id']));
        if(empty($snippet) || $snippet===false || $snippet->ID==0) {
            return '<p><b><i>'._t('CodeBankShortCode.SNIPPET_NOT_FOUND', '_Snippet not found').'</i></b></p>';
        }
        
        
        //Fetch Text
        $snippetText=$snippet->SnippetText;
        
        
        //If the version exists fetch it, and replace the text with that of the version
        if(array_key_exists('version', $arguments)) {
            $version=$snippet->Version(intval($arguments['version']));
            if(empty($version) || $version===false || $version->ID==0) {
                $snippetText=$version->Text;
            }
        }
        
        
        //Load CSS Requirements
        Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shCore.css');
        Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shCoreDefault.css');
        Requirements::css(CB_DIR.'/javascript/external/syntaxhighlighter/themes/shThemeDefault.css');
        
        //Load JS Requirements
        Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.js');
        Requirements::javascript(CB_DIR.'/javascript/external/syntaxhighlighter/brushes/shCore.js');
        Requirements::javascript(CB_DIR.'/javascript/external/syntaxhighlighter/brushes/'.self::getBrushName($snippet->Language()->HighlightCode).'.js');
        Requirements::javascriptTemplate(CB_DIR.'/javascript/CodeBankShortCode.template.js', array('ID'=>$snippet->ID), 'snippet-highlightinit-'.$snippet->ID);
        
        
        //Render the snippet
        $obj=new ViewableData();
        return $obj->renderWith('CodeBankShortCode', array(
                                                            'ID'=>$snippet->ID,
                                                            'Title'=>$snippet->getField('Title'),
                                                            'Description'=>$snippet->getField('Description'),
                                                            'SnippetText'=>DBField::create_field('Text', $snippetText),
                                                            'HighlightCode'=>strtolower($snippet->Language()->HighlightCode)
                                                        ));
    }
public static function parse ( $ arguments , $ content = null , $ parser = null ) { //Ensure ID is pressent in the arguments
 if ( ! array_key_exists ( 'id' , $ arguments ) ) { return '<p><b><i>' . _t ( 'CodeBankShortCode.MISSING_ID_ATTRIBUTE' , '_Short Code missing the id attribute' ) . '</i></b></p>' ; } //Fetch Snippet
 $ snippet = Snippet :: get ( ) -> byID ( intval ( $ arguments [ 'id' ] ) ) ; if ( empty ( $ snippet ) || $ snippet === false || $ snippet -> ID == 0 ) { return '<p><b><i>' . _t ( 'CodeBankShortCode.SNIPPET_NOT_FOUND' , '_Snippet not found' ) . '</i></b></p>' ; } //Fetch Text
 $ snippetText = $ snippet -> SnippetText ; //If the version exists fetch it, and replace the text with that of the version
 if ( array_key_exists ( 'version' , $ arguments ) ) { $ version = $ snippet -> Version ( intval ( $ arguments [ 'version' ] ) ) ; if ( empty ( $ version ) || $ version === false || $ version -> ID == 0 ) { $ snippetText = $ version -> Text ; } } //Load CSS Requirements
 Requirements :: css ( CB_DIR . '/javascript/external/syntaxhighlighter/themes/shCore.css' ) ; Requirements :: css ( CB_DIR . '/javascript/external/syntaxhighlighter/themes/shCoreDefault.css' ) ; Requirements :: css ( CB_DIR . '/javascript/external/syntaxhighlighter/themes/shThemeDefault.css' ) ; //Load JS Requirements
 Requirements :: javascript ( THIRDPARTY_DIR . '/jquery/jquery.js' ) ; Requirements :: javascript ( CB_DIR . '/javascript/external/syntaxhighlighter/brushes/shCore.js' ) ; Requirements :: javascript ( CB_DIR . '/javascript/external/syntaxhighlighter/brushes/' . self :: getBrushName ( $ snippet -> Language ( ) -> HighlightCode ) . '.js' ) ; Requirements :: javascriptTemplate ( CB_DIR . '/javascript/CodeBankShortCode.template.js' , array ( 'ID' => $ snippet -> ID ) , 'snippet-highlightinit-' . $ snippet -> ID ) ; //Render the snippet
 $ obj = new ViewableData ( ) ; return $ obj -> renderWith ( 'CodeBankShortCode' , array ( 'ID' => $ snippet -> ID , 'Title' => $ snippet -> getField ( 'Title' ) , 'Description' => $ snippet -> getField ( 'Description' ) , 'SnippetText' => DBField :: create_field ( 'Text' , $ snippetText ) , 'HighlightCode' => strtolower ( $ snippet -> Language ( ) -> HighlightCode ) ) ) ; }
Parses the snippet short code
@example [snippet id=123]
@example [snippet id=123 version=456]
Parses the snippet short code