<commit_before><?php
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007 <NAME> <<EMAIL>>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 */

class hktree
{
    var $name;                    //Name us ised to uniquely identify this tree within the site. Will set cookie names etc

    var $nodes = array();         //All nodes listed here out of order, with full data
    var $urls = array();          //Array of URLs for links
    var $statuses = array();      //Array of node statuses - '' is normal, or expired, protected
    var $targets = array();       //Array of Targets for links
    var $classname = array();     //Array of additional classes to add to the item
    var $onclicks = array();      //Array of OnClick Events
    var $children = array();      //The children for each node listed here
    var $bulletlist;
    var $parentnode = array();
    var $liststyletype = '';      //Deprecated
    var $liststyle = 'circle';    //The type of list style to use on plain lists
    var $selected = '';           //Selected item in select lists
    var $disabled = '';           //item in select list that should be disabled (if item has children, they get disabled to)

    var $plus = '<b>+</b>';       //image or string to use for closed elements
    var $minus = '<b>-</b>';      //image or string to use for opened elements
    var $nokids = '';             //image or string to use for elements with no kids
    var $autoclose = true;        //When a node is opened, it automatically closes other open nodes to keep the tree compact
    var $treeformat = 'windows';  // "windows" means a standard looking treemenu. "custom" means apply your own styles.
    var $showicons = true;
    var $theme = 'light';         //light or dark - changes the graphics to suit the background

    var $indent0;                 //String to use for each indent level (desireable if you style out the bullets)
    var $indent1;
    var $indent2;
    var $indent3;
    var $indent4;
    var $indent5;

    //internal variables - don't use these
    var $path = array();         //path of parent IDs to current position
    var $pathcopy = array();     //used for temporary operations
    var $depth;
    var $showdepth;              //You may want to hide items below a certain depth - default = show all items

    function hktree($name = '')
    {
        $this->name = $name;
        $depth = 0;
    }

    function addNode($id=0, $parent=0, $name = '', $url = '', $target = '', $onclick = '', $classname = '', $rollover = '', $html = '', $status = '')
    {
        $parent = str_replace("'", '', $parent);
        $parent = str_replace('"', '', $parent);
        $id = str_replace(array("'", '"'), '',  $id);
        $this->nodes[$id]                = $name;
        $this->htmls[$id]                = $html;
        $this->statuses[$id]             = $status;
        $this->urls[$id]                 = $url;
        $this->targets[$id]              = $target;
        $this->classname[$id]            = $classname;
        $this->rollovers[$id]            = $rollover;
        $this->onclicks[$id]             = $onclick;
        $this->children[$parent][]       = $id;
        $this->parentnode[$id]['parent'] = $parent;
        if ( ($onclick != '') && ($url == '') ) {$url = '#';} //If onclick event is used, we must have at least # for the URL
    }

    function recursivePath($start = 0, $path = '')
    {
        $keys = array_keys($this->nodes);
        $results = array();
        $results["$start "] = $path . '/' . $start;
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            foreach ($this->children[$start] as $id) {
                $results = array_merge($results, $this->recursivePath($id, $path . '/' . $start));
            }
        }
        return $results;
    }

    /* used for bulk edit functionality */
    function displaynode_array($start=0)
    {

        if ( ($start!='0') && ($start!='') ) {
            //$this->bulletlist .= "<li>";


            $this->bulletlist[]= array('id'=>$start,'depth'=>($this->depth-1));//$this->nodes[$start];

        }
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            $this->depth = $this->depth + 1;
            for ($i=0;$i<count($this->children[$start]);$i++) {
                $this->displaynode_array($this->children[$start][$i]);
            }
            $this->depth = $this->depth - 1;
        }

    }


    function displaynode_plain($start=0)
    {

        if ( ($start!='0') && ($start!='') ) {
            $this->bulletlist .= "<li>";
            $class = $this->classname[$start] == '' ? '' : ' class="' . $this->classname[$start].'"';
            $url = $this->urls[$start];
            if ($this->onclicks[$start] != '') {$onclick = ' onclick="' . $this->onclicks[$start].'"';} else {$onclick = "";}
            if ($url != '') {$this->bulletlist .= "<a href=\"$url\"" . $onclick.$class . ">";} //start link
            $this->bulletlist .= $this->nodes[$start];
            if ($url != '') {$this->bulletlist .= "</a>";} //finish link
        }
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            $this->depth = $this->depth + 1;
            $this->bulletlist .= "<ul";
            $this->bulletlist .= ($this->liststyle) ? ' style="list-style-type: ' . $this->liststyle . ';"' : '';
            $this->bulletlist .= ">\n";
            for ($i=0;$i<count($this->children[$start]);$i++) {
                $this->displaynode_plain($this->children[$start][$i]);
            }
            $this->bulletlist .= "</ul>\n";
            $this->depth = $this->depth - 1;
        }
        if ( ($start!='0') && ($start!='') ) {
            $this->bulletlist .= "</li>\n";
        }
    }

    function displaynode_h3list($start=0,$h=3)
    {
        if ( ($start!='0') && ($start!='') ) {
            $this->bulletlist .= ($this->depth == 1) ? "<h$h>" : "<li>";
            $class = $this->classname[$start] == '' ? '' : ' class="' . $this->classname[$start].'"';
            $url = $this->urls[$start];
            if ($this->onclicks[$start] != '') {$onclick = ' onclick="' . $this->onclicks[$start].'"';} else {$onclick = "";}
            if ($url != '') {$this->bulletlist .= "<a href=\"$url\"" . $onclick.$class . ">";} //start link
            $this->bulletlist .= $this->htmls[$start] ? $this->htmls[$start] : $this->nodes[$start];
            if ($url != '') {$this->bulletlist .= "</a>";} //finish link
            $this->bulletlist .= ($this->depth == 1) ? "</h$h>" : "";
        }
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            $this->depth = $this->depth + 1;
            if ($this->depth > 1) {
                $this->bulletlist .= "<ul";
                $this->bulletlist .= ($this->liststyle) ? ' style="list-style-type: ' . $this->liststyle . ';"' : '';
                $this->bulletlist .= ">\n";
            }
            for ($i=0;$i<count($this->children[$start]);$i++) {
                $this->displaynode_h3list($this->children[$start][$i],$h);<commit_msg>External - HKTree: Add class property for styling by class rather than inline<commit_after><?php
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007-2008 <NAME> <<EMAIL>>
 * Copyright 2007 <NAME> <<EMAIL>>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @author  <NAME> <<EMAIL>>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 */

class hktree
{
    var $name;                    //Name us ised to uniquely identify this tree within the site. Will set cookie names etc

    var $nodes = array();         //All nodes listed here out of order, with full data
    var $urls = array();          //Array of URLs for links
    var $statuses = array();      //Array of node statuses - '' is normal, or expired, protected
    var $targets = array();       //Array of Targets for links
    var $classname = array();     //Array of additional classes to add to the item
    var $onclicks = array();      //Array of OnClick Events
    var $children = array();      //The children for each node listed here
    var $bulletlist;
    var $parentnode = array();
    var $liststyletype = '';      //Deprecated
    var $liststyle = 'circle';    //The type of list style to use on plain lists
    var $listclass = '';          //The class use on plain lists
    var $selected = '';           //Selected item in select lists
    var $disabled = '';           //item in select list that should be disabled (if item has children, they get disabled to)

    var $plus = '<b>+</b>';       //image or string to use for closed elements
    var $minus = '<b>-</b>';      //image or string to use for opened elements
    var $nokids = '';             //image or string to use for elements with no kids
    var $autoclose = true;        //When a node is opened, it automatically closes other open nodes to keep the tree compact
    var $treeformat = 'windows';  // "windows" means a standard looking treemenu. "custom" means apply your own styles.
    var $showicons = true;
    var $theme = 'light';         //light or dark - changes the graphics to suit the background

    var $indent0;                 //String to use for each indent level (desireable if you style out the bullets)
    var $indent1;
    var $indent2;
    var $indent3;
    var $indent4;
    var $indent5;

    //internal variables - don't use these
    var $path = array();         //path of parent IDs to current position
    var $pathcopy = array();     //used for temporary operations
    var $depth;
    var $showdepth;              //You may want to hide items below a certain depth - default = show all items

    function hktree($name = '')
    {
        $this->name = $name;
        $depth = 0;
    }

    function addNode($id=0, $parent=0, $name = '', $url = '', $target = '', $onclick = '', $classname = '', $rollover = '', $html = '', $status = '')
    {
        $parent = str_replace("'", '', $parent);
        $parent = str_replace('"', '', $parent);
        $id = str_replace(array("'", '"'), '',  $id);
        $this->nodes[$id]                = $name;
        $this->htmls[$id]                = $html;
        $this->statuses[$id]             = $status;
        $this->urls[$id]                 = $url;
        $this->targets[$id]              = $target;
        $this->classname[$id]            = $classname;
        $this->rollovers[$id]            = $rollover;
        $this->onclicks[$id]             = $onclick;
        $this->children[$parent][]       = $id;
        $this->parentnode[$id]['parent'] = $parent;
        if ( ($onclick != '') && ($url == '') ) {$url = '#';} //If onclick event is used, we must have at least # for the URL
    }

    function recursivePath($start = 0, $path = '')
    {
        $keys = array_keys($this->nodes);
        $results = array();
        $results["$start "] = $path . '/' . $start;
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            foreach ($this->children[$start] as $id) {
                $results = array_merge($results, $this->recursivePath($id, $path . '/' . $start));
            }
        }
        return $results;
    }

    /* used for bulk edit functionality */
    function displaynode_array($start=0)
    {

        if ( ($start!='0') && ($start!='') ) {
            //$this->bulletlist .= "<li>";


            $this->bulletlist[]= array('id'=>$start,'depth'=>($this->depth-1));//$this->nodes[$start];

        }
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            $this->depth = $this->depth + 1;
            for ($i=0;$i<count($this->children[$start]);$i++) {
                $this->displaynode_array($this->children[$start][$i]);
            }
            $this->depth = $this->depth - 1;
        }

    }


    function displaynode_plain($start=0)
    {

        if ( ($start!='0') && ($start!='') ) {
            $this->bulletlist .= "<li>";
            $class = $this->classname[$start] == '' ? '' : ' class="' . $this->classname[$start].'"';
            $url = $this->urls[$start];
            if ($this->onclicks[$start] != '') {$onclick = ' onclick="' . $this->onclicks[$start].'"';} else {$onclick = "";}
            if ($url != '') {$this->bulletlist .= "<a href=\"$url\"" . $onclick.$class . ">";} //start link
            $this->bulletlist .= $this->nodes[$start];
            if ($url != '') {$this->bulletlist .= "</a>";} //finish link
        }
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            $this->depth = $this->depth + 1;
            $this->bulletlist .= "<ul";
            $this->bulletlist .= ($this->listclass) ? ' class="' . $this->listclass . '"' : '';
            $this->bulletlist .= ($this->liststyle) ? ' style="list-style-type: ' . $this->liststyle . ';"' : '';
            $this->bulletlist .= ">\n";
            for ($i=0;$i<count($this->children[$start]);$i++) {
                $this->displaynode_plain($this->children[$start][$i]);
            }
            $this->bulletlist .= "</ul>\n";
            $this->depth = $this->depth - 1;
        }
        if ( ($start!='0') && ($start!='') ) {
            $this->bulletlist .= "</li>\n";
        }
    }

    function displaynode_h3list($start=0,$h=3)
    {
        if ( ($start!='0') && ($start!='') ) {
            $this->bulletlist .= ($this->depth == 1) ? "<h$h>" : "<li>";
            $class = $this->classname[$start] == '' ? '' : ' class="' . $this->classname[$start].'"';
            $url = $this->urls[$start];
            if ($this->onclicks[$start] != '') {$onclick = ' onclick="' . $this->onclicks[$start].'"';} else {$onclick = "";}
            if ($url != '') {$this->bulletlist .= "<a href=\"$url\"" . $onclick.$class . ">";} //start link
            $this->bulletlist .= $this->htmls[$start] ? $this->htmls[$start] : $this->nodes[$start];
            if ($url != '') {$this->bulletlist .= "</a>";} //finish link
            $this->bulletlist .= ($this->depth == 1) ? "</h$h>" : "";
        }
        if (isset($this->children[$start]) && is_array($this->children[$start])) {
            $this->depth = $this->depth + 1;
            if ($this->depth > 1) {
                $this->bulletlist .= "<ul";
                $this->bulletlist .= ($this->listclass) ? ' class="' . $this->listclass . '"' : '';
                $this->bulletlist .= ($this->liststyle) ? ' style="list-style-type: ' . $this->liststyle . ';"' : '';
                $this->bulletlist .= ">\n";
            }
            for ($i=0;$i<count($this->children[$start]);$i++) {
                $this->displaynode_h3list($this->children[$start][$i],$h);
{'fraction_non_alphanumeric': 0.19997413848839465, 'fraction_numerical': 0.006723993017391867, 'mean_word_length': 2.0733161136499105, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 251, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248987', 'n_tokens_mistral': 4720, 'n_tokens_neox': 4560, 'n_words': 1186}