method searchAll documentation in bbn\Appui\Ide

function(string $seek) { if (isset($seek)) { $res = []; $occourences = 0; $totalFiles = 0; $numRepositories = 0; $foundRepos = []; foreach ($this->repositories as $rep) { //temporaney if ($rep['root'] !== 'cdn') { $totalFiles += $this->fs->getNumFiles($rep['root_path']); if ($found = $this->fs->searchContents($seek, $rep['root_path'], true, false, 'js|php|less|html')) { foreach ($found as $fn => $val) { $list = []; // case file into folder if ($this->fs->isFile($fn)) { $path_file = $val; //object initialization with every single file to check the lines that contain it $file = new \SplFileObject($fn); $totLines = 0; //cycle that reads all the lines of the file, it means until it has finished reading a file while (!$file->eof()) { //current line reading $lineCurrent = $file->current(); //if we find what we are looking for in this line and that this is not '\ n' then we will take the coirispjective line number with the key function, insert it into the array and the line number if (!empty($position = strpos($lineCurrent, $seek) !== false) && (strpos($lineCurrent, '\n') === false)) { $lineNumber = $file->key() + 1; $name_path = $rep['path'] . substr(X::dirname($val), strlen($base_rep)); $line = "" . 'line ' . $lineNumber . ' : ' . ""; $text = $line; $text .= str_replace($seek, "" . $seek . "", $lineCurrent); $file_name = X::basename($path_file); $occourences = $occourences + substr_count($lineCurrent, $seek); if (in_array($rep['name'], $foundRepos) === false) { $foundRepos[] = $rep['name']; $numRepositories++; } // info for code $list[] = [ 'text' => strlen($text) > 1000 ? $line . "" . X::_('content too long to be shown') . "" : $text, 'line' => $lineNumber - 1, 'position' => $position, // 'link' => $link, 'tab' => !empty($tab) ? $tab : false, 'code' => true, 'uid' => $rep['path'] . '/' . $file_name, 'icon' => 'nf nf-fa-code' ]; } //next line $file->next(); } //if we find rows then we will create the tree structure with all the information if (count($list) > 0) { $totLines = $totLines + count($list); if (explode("/", $path_file)[1] === "public") { $tab = 'php'; } else { $tab = explode("/", $path_file)[1]; } $link = explode(".", substr($path_file, strlen(explode("/", $path_file)[0] . '/' . explode("/", $path_file)[1]) + 1))[0]; } //info file $ext = Str::fileExt($fn, 0); $fileData = [ 'text' => $rep['name'] . '/' . substr($fn, strlen($rep['root_path'])) . " " . count($list) . "", 'icon' => 'nf nf-fa-file_code_o', 'numChildren' => count($list), 'repository' => $rep['name'], 'uid' => $rep['name'] . '/' . substr($fn, strlen($rep['root_path'])), 'file' => X::basename($fn), 'items' => $list, ]; $path = explode('/', substr($fn, strlen($rep['root_path']))); //die(var_dump("sss", $path)); if ($path[0] === 'mvc') { if ($path[1] === "public") { $tab = 'php'; } else { $tab = $path[1]; } } elseif ($path[0] === 'components') { $tab = $ext; $components = true; } unset($path[1]); $path = implode('/', $path); $link = $rep['name'] . '/' . substr($path, 0, strpos($path, '.' . $ext)). ($components === true ? '/' . X::basename($path, '.' . $ext) : ''); $fileData['tab'] = !empty($tab) ? $tab : false; $fileData['link'] = $link; foreach ($fileData['items'] as &$item) { $item['link'] = $link; $item['tab'] = !empty($tab) ? $tab : false; } $result[] = $fileData; } } } } } } if (!empty($result)) { return [ 'list' => array_values($result), 'occurences' => $occourences, 'totFiles' => $totalFiles, 'filesFound' => count($result), 'repositoriesFound' => $numRepositories, 'totalRepositories' => count($this->repositories), 'totLines' => $totLines ]; } else { return ['success' => false]; } }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.