Skip to content

Commit cca661f

Browse files
authored
Add files via upload
1 parent 3a80021 commit cca661f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

url.class.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,17 @@ public function addRegra($nome, $posicao) {
126126
* @return int $id Retorna a Id que pode estar na URL
127127
*/
128128
public function getId($posicao = false) {
129-
$id = null;
129+
$id = 0;
130130
if ($posicao === false) {
131131
$last = (count($this->partes))-1;
132132
$aux = array_reverse(explode("-",$this->partes[$last]));
133-
return (int) $aux[0];
133+
$id = (int) $aux[0];
134134
} else {
135-
if (is_int($posicao) and $this->get($posicao)!=="") {
136-
return array_reverse(explode('-',$this->get($posicao)))[0];
137-
}
138-
if (is_string($posicao) and $this->get($posicao)!=="") {
139-
return array_reverse(explode('-',$this->get($posicao)))[0];
135+
if ((is_int($posicao) || is_string($posicao)) and $this->get($posicao)!=="") {
136+
$id = (int) array_reverse(explode('-',$this->get($posicao)))[0];
140137
}
141138
}
139+
return $id;
142140
}
143141

144142
/**
@@ -156,6 +154,7 @@ public function getApos($palavra,$onlyKey = false) {
156154
}
157155
return ($onlyKey?(isset($this->partes[$wordKey+1])?$wordKey+1:""):(isset($this->partes[$wordKey+1])?$this->partes[$wordKey+1]:""));
158156
}
157+
return false;
159158
}
160159

161160
/**
@@ -177,6 +176,7 @@ public function getURLApos($palavra) {
177176
}
178177
return implode("/",$url);
179178
}
179+
return false;
180180
}
181181

182182
/**
@@ -202,6 +202,7 @@ public function getAntes($palavra,$onlyKey = false) {
202202
}
203203
return ($onlyKey?(isset($this->partes[$wordKey-1])?$wordKey-1:""):(isset($this->partes[$wordKey-1])?$this->partes[$wordKey-1]:""));
204204
}
205+
return false;
205206
}
206207

207208
/**
@@ -229,6 +230,7 @@ public function getURLAntes($palavra) {
229230
return false;
230231
}
231232
}
233+
return false;
232234
}
233235

234236

@@ -244,7 +246,7 @@ public function getIdAntes($palavra) {
244246
* @param string $string Recebe um texto para converter em URL.
245247
* @return string $novaUrl Esta função gera uma url para um link. Só deve ser usada para links diretos (sem "/")
246248
*/
247-
public function tratar($string) {
249+
public function URLizer($string) {
248250
$string = preg_replace('/[áàãâä]/ui', 'a', $string);
249251
$string = preg_replace('/[éèêë]/ui', 'e', $string);
250252
$string = preg_replace('/[íìîï]/ui', 'i', $string);
@@ -263,7 +265,7 @@ public function tratar($string) {
263265
* @return string Retorna o Link gerado.
264266
*/
265267
public function gerarLink($texto, $id = false) {
266-
$texto = $this->tratar($texto);
268+
$texto = $this->URLizer($texto);
267269
if (strlen($texto) > 50) {
268270
$texto = substr($texto, 0, 50);
269271
}

0 commit comments

Comments
 (0)