-
Notifications
You must be signed in to change notification settings - Fork 0
/
lista_complta.php
executable file
·154 lines (127 loc) · 4.9 KB
/
lista_complta.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
function ordenaMatriz($arrayPastas, $coluna)
{
$temp = $arrayPastas[0];
for ($i = 0; $i < count($arrayPastas); $i++) {
for ($j = 0; $j < count($arrayPastas); $j++) {
if ($arrayPastas[$i][$coluna] < $arrayPastas[$j][$coluna]) {
$temp = $arrayPastas[$i];
$arrayPastas[$i] = $arrayPastas[$j];
$arrayPastas[$j] = $temp;
}
}
}
return $arrayPastas;
}
function exibeVetor($array)
{
echo "<div class='list-group'>";
$caminho = "";
$classe = "";
$apelido = "";
$descricao = "";
$irPara = "";
for ($i = 0; $i < count($array); $i++) {
$projeto = getInfo($array[$i]['caminho']);
if ($projeto != null) {
$caminho = $array[$i]['caminho'];
$classe = property_exists($projeto, "classe") ? $projeto->classe : $array[$i]['classe'];
$apelido = property_exists($projeto, "nome") ? $projeto->nome : ucwords(str_replace("_", " ", $array[$i]['projeto']));
$descricao = property_exists($projeto, "descricao") ? $projeto->descricao : $caminho;
$irPara = property_exists($projeto, "redirecionarPara") ? $projeto->redirecionarPara : $caminho;
} else {
$caminho = $array[$i]['caminho'];
$classe = $array[$i]['classe'];
$apelido = ucwords(str_replace("_", " ", str_replace("-", " ", $array[$i]['projeto'])));
$descricao = $caminho;
$irPara = $caminho;
}
echo "<a href='{$irPara}' class='list-group-item'>";
echo "<h4 class='list-group-item-heading'><span class='glyphicon {$classe}'></span> {$apelido}</h4>";
echo "<p class='list-group-item-text'>" .$descricao. "</p>";
echo "</a>";
}
echo "</div>";
}
function getInfo($caminho)
{
$arquivo2 = "configs/arquivos.json";
$info = file_get_contents($arquivo2);
$lendo = json_decode($info);
$retorno = null;
foreach ($lendo->projetos as $campo) {
if ($campo->caminho == $caminho) {
$retorno = $campo;
}
}
return $retorno;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Lista Completa de Projetos</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="_lib/bootstrap-3.3.6-dist/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<?php
$pasta = '../';
$array_diretorios_ignorar = array('..', '.', '.idea', 'launcher0');
$arrayPastas = array();
$arrayArquivos = array();
if (is_dir($pasta)) {
$diretorio = dir($pasta);
$countPastas = -1;
$countArquivos = -1;
while ($arquivo = $diretorio->read()) {
if ($arquivo != "launcher0" && $arquivo != "index.php") {
if (!is_file($arquivo) && !(strpos($arquivo, ".") > -1)) {
$countPastas++;
$arrayPastas[$countPastas]['projeto'] = $arquivo;
$arrayPastas[$countPastas]['caminho'] = $pasta . $arquivo;
$arrayPastas[$countPastas]['classe'] = " glyphicon-briefcase ";
} else {
if (!is_dir($arquivo)) {
$countArquivos++;
$arrayArquivos[$countArquivos]['projeto'] = $arquivo;
$arrayArquivos[$countArquivos]['caminho'] = $pasta . $arquivo;
$arrayArquivos[$countArquivos]['classe'] = " glyphicon-file ";
}
}
}
}
$diretorio->close();
}
$arrayPastas = ordenaMatriz($arrayPastas, 'projeto');
$countArquivos = ordenaMatriz($countArquivos, 'projeto');
echo "<div class='row'>";
echo "<div class='col-md-5 col-sm-offset-1'>";
echo "<br><h1>Meus Projetos</h1>";
exibeVetor($arrayPastas);
echo "</div>";
echo "<div class='col-md-5'>";
echo "<br><h1>Meus Arquivos</h1>";
exibeVetor($arrayArquivos);
echo "</div>";
echo "</div>";
?>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="_lib/jquerry/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="_lib/bootstrap-3.3.6-dist/js/bootstrap.min.js"></script>
</body>
</html>