Classi per la configurazione upload
Cristiano Magro
2018-01-16 e3143d210800f4e51f6fb6da83881139d04f01d7
Refactor correggo i nomi delle classi e le imposto nel autoloader
2 files modified
27 ■■■■ changed files
src/UploadFile/Autoloader.php 21 ●●●● patch | view | raw | blame | history
src/UploadFile/SetupUpload.class.php 6 ●●●● patch | view | raw | blame | history
src/UploadFile/Autoloader.php
@@ -1,38 +1,39 @@
<?php
/*
 * Autoloader per la gestione delle classi Vodafone BE sul progetto backoffice
 * Autoloader per la gestione delle classi dedicate all'upload dei file.
 */
spl_autoload_register(array('Autoloader', 'autoload'));
spl_autoload_register(array('Upload_Autoloader', 'autoload'));
/**
 * Autoloader
 * Autoloader delle classi
 * Autoloader delle classi per l'upload dei file
 *
 * @author  Cristiano Magro
 * @since 0.3.1
 * @package Vola_UploadFile
 */
class Autoloader {
class Upload_Autoloader {
    /**
     * Maps classnames to files containing the class.
     * @var array Maps classnames to files containing the class.
     */
    private static $classes = array(
        'FileUpload' => 'include/class/UploadFile/FileUpload.class.php',
        'SetupUpload' => 'include/class/UploadFile/SetupUpload.class.php',
        'FileUpload' => 'FileUpload.class.php',
        'SetupUpload' => 'SetupUpload.class.php',
        'Upload_Exc_Error' => 'Upload_Exc_Error.class.php',
    );
    /**
     * Esecuzione dell'autoloader delle classi secondo la mappa statica
     * Esecuzione dell'autoloader delle classi secondo la mappa statica.
     *
     * @param string $nomeClasse richiesta
     *
     * @return boolean la classe richiesta e' stata correttamente caricata?
     */
    public static function autoload($nomeClasse) {
        $pathbase = dirname(__FILE__) . '/../../';
        $pathbase = dirname(__FILE__) . '/';
        if (isset(self::$classes[$nomeClasse])) {
            require_once($pathbase . self::$classes[$nomeClasse]);
@@ -40,7 +41,7 @@
        // Transform the class name into a path
        $file = str_replace('_', '/', $nomeClasse);
        $path = $pathbase . 'include/class/' . $file . '.php';
        $path = $pathbase . $file . '.php';
        if (file_exists($path)) {
            // Load the class file
            require $path;
src/UploadFile/SetupUpload.class.php
@@ -214,13 +214,13 @@
        //validazione
        if (strlen(trim($strSize)) === 0) {
            //una stringa vuota non può essere convertita
            throw new UploadFile_Exc();
            throw new Upload_Exc_Error();
        } elseif (strlen(trim($strValue)) === 0) {
            //se non trovo la parte del valore della stringa non posso convertire
            throw new UploadFile_Exc();
            throw new Upload_Exc_Error();
        } elseif (strlen($strUnit) >= 1 && !array_key_exists($strUnit, $Units)) {
            //l'unita' non e' nota
            throw new UploadFile_Exc();
            throw new Upload_Exc_Error();
        }
        $Exponent = isset($Units[$strUnit]) ? $Units[$strUnit] : 0;