standardLib – PHP framework
standardTools
Dipendenze: nessuna.
Descrizione
Il modello standardTools fornisce cinque utili strumenti:
- Un generatore di stringhe casuali
- Un normalizzatore di stringhe
- Una funzione “testo introduttivo”
- Un convertitore di timestamp in stringa
- Un converitore di datetime mysql in stringa
Lista dei parametri
| Parametro | Descrizione | Default |
|---|---|---|
| char | Il set di caratteri per la generazione di strighe casuali | aAbBcCdDeEfFgGhHiIlLj JkKmMnNoOpPqQrRsStTu UvVwWxXyYzZ0123456789 |
| isPassword | Se settato a 1 indica che la stringa casuale dovrà essere una password e dunque aggiungerà al set di caratteri (char) il contenuto di plusChar | 0 |
| plusChar | Set di caratteri supplementari per la stringa casuale | !$%&/()=?[]{}@#+*-_. |
| separator | Indica l’eventuale separatore da utilizzare nella normalizzazione delle stringhe (si veda il metodo normalizeString() | FALSE |
Lista dei metodi e delle proprietà
| Proprietà – Metodo | Descrizione | Return |
|---|---|---|
| randString($len) | Ritorna una stringa casuale di $len caratteri | Stringa |
| normailzeString($string) | Ritorna la stringa $string normailzzata (sostituzione dei caratteri accentati con caratteri standard, rimozione di caratteri speciali, apostrofi, eccetera). Se in fase di inizializzazione è stato impostato un separatore, sostituisce gli spazi con il separatore. | Stringa |
| introText($text,$maxLen,$link,$linkText) | Dato un testo $text, questo testo viene trocato a $maxLen caratteri (salvaguardando la completezza della parola) ed aggiunge un link che punta a $link il cui testo è $linkText | Stringa |
| timestamp2date($timestamp,$format) | Passa uno UNIX timestamp ed una stringa di formato e restituisce una data formattata | Stringa |
| mysql2date($datetime,$format) | Passa un DATETIME di mysql ed una stringa di formato e restituisce una data formattata | Stringa |
Esempi minimi
Creazione di una password di 10 caratteri:
include 'standardLib/engine.php';
_setOptions("isPassword" =>true);
echo $model->randString(10);
Normalizzazione di un titolo
include 'standardLib/engine.php';
$titolo = "All'alba berrò un bicchiere di château la crue da 60$ la bottiglia";
_setOptions("separator" => "-");
echo $model->normalizeString($titolo);
//Risultato: All-alba-berro-un-bicchiere-di-chteau-la-crue-da-60-la-bottiglia
Testo introduttivo
include 'standardLib/engine.php'; $testo = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."; echo $model->introText($testo, 100, "testoCompleto.php?id=idtesto", "[leggi tutto]"); // Risultato: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been [leggi tutto]

