<commit_before><?php

class SourceController extends BaseController {

    public function show($path = null)
    {
        if(is_dir(base_path() . "/query/" . $path)) // Check if it's a folder
            return View::make('folder')->with('path', $path);
        else
        {
            return View::make('file')
            	->with('file', $path)
            	->with('path', $path);
        }
    }

    public static function getDir($path, $exts = null)
    {
        if (!is_dir(base_path() . "/" . $path))
            return array();
    	$elements = scandir(base_path() . "/" . $path);
  		unset($elements[0]);
  		unset($elements[1]);
        if (!is_array($exts))
      		return array_values($elements);
        else {
            if (sizeof($exts) == 1)
                $rule = "/.*\." . implode('|', $exts) ."/i";
            else
                $rule = "/.*\.[" . implode('|', $exts) ."]/i";
            $out = array();
            foreach ($elements as $element) {
                if (preg_match($rule, $element))
                    $out[] = $element;
            }
        return $out;
        }
    }

    public static function linkedPath($path)
    {
    	$array = explode("/", $path);
    	$out = "";
    	$last = "/lists";
    	$lastElementKey = sizeof($array) - 1;

    	foreach ($array as $k => $v) {
    		if ($k < $lastElementKey) {
    			$url = $last . "/" . $v;
	    		$out .= "<a href=\"" . $url . "\">" . $v . "</a>/";
    			$last = $url;
    		}
    	}

    	$out .= $array[$lastElementKey];
    	return $out;
    }

    public static function cleanWikiCode($code, $prj)
    {
        $replace = '<a href="http://' . Config::get('project.' . $prj) . '/wiki/${1}">[[${0}]]</a>';
        $code = preg_replace('/\[\[(.*)\]\]/i', , $code);
        $code = preg_replace_callback('/\[\[(.*)\]\]/i', function ($matches) {
            return str_replace('_', ' ', $matches[1]);
        }, $code);
        return $code;
    }
}<commit_msg>Fix SourceController::cleanWikiCode<commit_after><?php

class SourceController extends BaseController {

    public function show($path = null)
    {
        if(is_dir(base_path() . "/query/" . $path)) // Check if it's a folder
            return View::make('folder')->with('path', $path);
        else
        {
            return View::make('file')
            	->with('file', $path)
            	->with('path', $path);
        }
    }

    public static function getDir($path, $exts = null)
    {
        if (!is_dir(base_path() . "/" . $path))
            return array();
    	$elements = scandir(base_path() . "/" . $path);
  		unset($elements[0]);
  		unset($elements[1]);
        if (!is_array($exts))
      		return array_values($elements);
        else {
            if (sizeof($exts) == 1)
                $rule = "/.*\." . implode('|', $exts) ."/i";
            else
                $rule = "/.*\.[" . implode('|', $exts) ."]/i";
            $out = array();
            foreach ($elements as $element) {
                if (preg_match($rule, $element))
                    $out[] = $element;
            }
        return $out;
        }
    }

    public static function linkedPath($path)
    {
    	$array = explode("/", $path);
    	$out = "";
    	$last = "/lists";
    	$lastElementKey = sizeof($array) - 1;

    	foreach ($array as $k => $v) {
    		if ($k < $lastElementKey) {
    			$url = $last . "/" . $v;
	    		$out .= "<a href=\"" . $url . "\">" . $v . "</a>/";
    			$last = $url;
    		}
    	}

    	$out .= $array[$lastElementKey];
    	return $out;
    }

    public static function cleanWikiCode($code, $prj)
    {
        $replace = '<a href="http://' . Config::get('project.' . $prj) . '/wiki/${1}">[[${0}]]</a>';
        $code = preg_replace('/\[\[(.*)\]\]/i', $replace, $code);
        $code = preg_replace_callback('/\[\[(.*)\]\]/i', function ($matches) {
            return str_replace('_', ' ', $matches[1]);
        }, $code);
        return $code;
    }
}
{'fraction_non_alphanumeric': 0.2150075795856493, 'fraction_numerical': 0.0035371399696816574, 'mean_word_length': 1.689538043478261, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1540902', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1316, 'n_words': 268}