Code

Code 2.2.0

No permission to download
I get many of these errors
Code:
ErrorException: [E_NOTICE] Undefined index: lang src/addons/CMTV/Code/XF/BbCode/Renderer/Html.php:36
Any idea what is causing them?
I'm getting them now too:
  • ErrorException: [E_NOTICE] Undefined index: lang
  • src/addons/CMTV/Code/XF/BbCode/Renderer/Html.php:36
 
I just rebuilt the caches but "foxpro" and "FoxPro" are still missing. Is there some kind of documentation that might help?
 
Nope, answered my own question by working through the documentation except for the missing PrismJS Component for FoxPro and got no where. At least my users can put "FoxPro" into the Code Block Title by hand and have it appear which is better than nothing which I had before.

Perhaps the missing index: lang errors I'm getting has to do WITH THE MISSING PRISMJS file. omg. I may have answered that question as well. But I don't like errors...
 
Perhaps there is a way to get FoxPro included in the PrismJS Component list. I bet not because it was killed off my MS a long time ago, which is what my forum is all about. The company where I work has moved from Fox on some apps, but not all. I'm picking up the work on one I designed originally...
 
Hello, this is a fantastic addon.
How Can I add new languages?
I need VBA(Visual Basic for Application)

Where/How can I add it?
Thanks!!!
 
Sorry, you'll find Visual Basic way down near the bottom here: https://github.com/PrismJS/prism/tree/gh-pages/components

With that and these directions, you may be able to get coloring to work yourself: https://xenforo.com/community/resources/additional-language-for-code-bbcode.5985/

And thanks for your posts. It prompted me to look again for FoxPro and I found a FoxPro json file here, so maybe I can get mine working now too:

 
Last edited:
Turns out the Code addon needs a .js file which is a JavaScript file. What I found for FoxPro coloring is a json file which is Java Script Object Notation file. They're not interchangeable. I'm going to keep working on this as it would be really cool to colorize the FoxPro code for visitors to my site.

The Code addon is working better. I now have 'FoxPro' set up as the default which is ok since C# is also in the list nearby. 'FoxPro' is in two places, under "Common Languages" and "Other Languages", which I don't mind at all. It would be nice if I could get "FoxPro" in the other languages list to be right next to C#, but the addon/xf wants to put 'FoxPro' at the end. Don't know why.

Will be digging into the syntax coloring myself soon.
 
Last edited:
Getting back to the server error log, I found that the first line of the stack trace:

ErrorException: [E_NOTICE] Undefined index: lang, src/addons/CMTV/Code/XF/BbCode/Renderer/Html.php:36

Led me to line 36 of html.php which says:

$language = $option['lang'];

That index, 'lang' is undefined. Don't know PHP or I'd fix it myself. Anybody?

PHP:
<?php
/**
* Code xF2 addon by CMTV
* Enjoy!
*/

namespace CMTV\Code\XF\BbCode\Renderer;

class Html extends XFCP_Html
{
    public function renderTagCode(array $children, $option, array $tag, array $options)
    {
        if (!is_array($option))
        {
            if (strpos($option, '|') && \XF::options()->CMTV_Code_backComp)
            {
                $strrstr = function ($h, $n, $before = false)
                {
                    $rpos = strrpos($h, $n);
                    if($rpos === false) return false;
                    if($before == false) return substr($h, $rpos);
                    else return substr($h, 0, $rpos);
                };

                $option = [
                    'title' => $strrstr($option, '|', true),
                    'lang' => substr($strrstr($option, '|'), 1)
                ];
            }
            else
            {
                return $this->CMTV_Code_getRenderedCode([], parent::renderTagCode($children, $option, $tag, $options));
            }
        }

        $language = $option['lang'];
        unset($option['lang']);

        return $this->CMTV_Code_getRenderedCode($option, parent::renderTagCode($children, $language, $tag, $options));
    }

    protected function getRenderedCode($content, $language, array $config = [])
    {
        return [
            'content' => $content,
            'language' => $language,
            'config' => $config
        ];
    }

    protected function CMTV_Code_getRenderedCode($option, array $getRenderedCode)
    {
        return $this->templater->renderTemplate('public:bb_code_tag_code', [
            'content' => new \XF\PreEscaped($getRenderedCode['content']),
            'language' => $getRenderedCode['language'],
            'config' => $getRenderedCode['config'],
            'options' => $option
        ]);
    }
}
 
Last edited:
I changed ever occurrence of 'lang' to 'language' and have not seen the error in 11 days which is good because I was seeing it several times a week.
 
Is this warning:
WARNING: after unistalling all code blocks with custom titles/highlighting/class will not be rendered as code blocks!
Still valid on the latest version? :|
 
Top Bottom