Retourne une instance

@param string $p_file

@retuen \Static
10771
public static function getInstance($p_file)
    {
        if (self::$instance === null) {
            self::$instance = new static($p_file);
        }
        
        return self::$instance;
    }
1080862
public function add($p_filelist)
    {
        $v_result=1;

        // ----- Reset the error handler
        $this->privErrorReset();

        // ----- Set default values
        $v_options = array();
        $v_options[PCLZIP_OPT_NO_COMPRESSION] = false;

        // ----- Look for variable options arguments
        $v_size = func_num_args();

        // ----- Look for arguments
        if ($v_size > 1) {
            // ----- Get the arguments
            $v_arg_list = func_get_args();

            // ----- Remove form the options list the first argument
            array_shift($v_arg_list);
            $v_size--;

            // ----- Look for first arg
            if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
                // ----- Parse the options
                $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (
                    PCLZIP_OPT_REMOVE_PATH => 'optional',
                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
                    PCLZIP_OPT_ADD_PATH => 'optional',
                    PCLZIP_CB_PRE_ADD => 'optional',
                    PCLZIP_CB_POST_ADD => 'optional',
                    PCLZIP_OPT_NO_COMPRESSION => 'optional',
                    PCLZIP_OPT_COMMENT => 'optional',
                    PCLZIP_OPT_ADD_COMMENT => 'optional',
                    PCLZIP_OPT_PREPEND_COMMENT => 'optional',
                    PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
                    PCLZIP_OPT_TEMP_FILE_ON => 'optional',
                    PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
                    //, PCLZIP_OPT_CRYPT => 'optional'
                ));
                if ($v_result != 1) {
                    return 0;
                }
            } else {
                // ----- Look for 2 args
                // Here we need to support the first historic synopsis of the
                // method.
                // ----- Get the first argument
                $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];

                // ----- Look for the optional second argument
                if ($v_size == 2) {
                    $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
                } elseif ($v_size > 2) {
                    // ----- Error log
                    PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

                    // ----- Return
                    return 0;
                }
            }
        }

        // ----- Look for default option values
        $this->privOptionDefaultThreshold($v_options);

        // ----- Init
        $v_string_list = array();
        $v_att_list = array();
        $v_filedescr_list = array();
        $p_result_list = array();

        // ----- Look if the $p_filelist is really an array
        if (is_array($p_filelist)) {
            // ----- Look if the first element is also an array
            //             This will mean that this is a file description entry
            if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
                $v_att_list = $p_filelist;
            } else {
                // ----- The list is a list of string names
                $v_string_list = $p_filelist;
            }
        } elseif (is_string($p_filelist)) {
            // ----- Look if the $p_filelist is a string
            // ----- Create a list from the string
            $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
        } else {
            // ----- Invalid variable type for $p_filelist
            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
            return 0;
        }

        // ----- Reformat the string list
        if (sizeof($v_string_list) != 0) {
            foreach ($v_string_list as $v_string) {
                $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
            }
        }

        // ----- For each file in the list check the attributes
        $v_supported_attributes = array(
          PCLZIP_ATT_FILE_NAME => 'mandatory',
          PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional',
          PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional',
          PCLZIP_ATT_FILE_MTIME => 'optional',
          PCLZIP_ATT_FILE_CONTENT => 'optional',
          PCLZIP_ATT_FILE_COMMENT => 'optional',
        );
        foreach ($v_att_list as $v_entry) {
            $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes);
            if ($v_result != 1) {
                return 0;
            }
        }

        // ----- Expand the filelist (expand directories)
        $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
        if ($v_result != 1) {
            return 0;
        }

        // ----- Call the create fct
        $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
        if ($v_result != 1) {
            return 0;
        }

        // ----- Return
        return $p_result_list;
    }
468211
protected function recupInputs($p_arrayIn, $p_arrayInOpt=array()) {
        try {
            $arrayOut = array ();
            $strError = null;

            //recup les gets
            $arrayGetAll = array ();
            if(isset($_GET)) {
                foreach($_GET as $key=>$val) {
                    $arrayGetAll[$key] = $val;
                }
            }

            //recup les posts
            $arrayPostAll = array ();
            if(isset($_POST)) {
                foreach($_POST as $key=>$val) {
                    $arrayPostAll[$key] = $val;
                }
            }

            //On init les inputs du framework
            if(isset($arrayPostAll["keyAuthODA"])){
                $arrayOut["keyAuthODA"] = $arrayPostAll["keyAuthODA"];
            }else if(isset($arrayGetAll["keyAuthODA"])){
                $arrayOut["keyAuthODA"] = $arrayGetAll["keyAuthODA"];
            }else{
                $arrayOut["keyAuthODA"] = null;
            }

            if(isset($arrayPostAll["ODAFileType"])){
                $arrayOut["ODAFileType"] = $arrayPostAll["ODAFileType"];
            }else if(isset($arrayGetAll["ODAFileType"])){
                $arrayOut["ODAFileType"] = $arrayGetAll["ODAFileType"];
            }else{
                $arrayOut["ODAFileType"] = null;
            }

            if(isset($arrayPostAll["ODAFileName"])){
                $arrayOut["ODAFileName"] = $arrayPostAll["ODAFileName"];
            }else if(isset($arrayGetAll["ODAFileName"])){
                $arrayOut["ODAFileName"] = $arrayGetAll["ODAFileName"];
            }else{
                $arrayOut["ODAFileName"] = null;
            }

            //on recupére les inputs déclarés en option
            foreach($p_arrayInOpt as $key=>$val) {
                if(isset($_POST[$key])){
                    $arrayOut[$key] = $arrayPostAll[$key];
                }else if(isset($_GET[$key])){
                    $arrayOut[$key] = $arrayGetAll[$key];
                }else{
                    $arrayOut[$key] = $val;
                }
            }

            //on recupére les inputs déclarés
            foreach($p_arrayIn as $val) {
                if(isset($_POST[$val])){
                    $arrayOut[$val] = $arrayPostAll[$val];
                }else if(isset($_GET[$val])){
                    $arrayOut[$val] = $arrayGetAll[$val];
                } else {
                    $arrayOut[$val] = null;
                    $strError .= $val.", ";
                }
            }

            if(!empty($arrayOut["ODAFileName"])){
                $this->fileName = $arrayOut["ODAFileName"];
            }

            if(!empty($arrayOut["ODAFileType"])){
                $this->modeSortie = $arrayOut["ODAFileType"];
            }

            if(!empty($arrayOut["keyAuthODA"])){
                $this->keyAuth = $arrayOut["keyAuthODA"];
            }

            //Erreur dans les inputs obligatoire
            if($strError != null){
                $this->inputs = $arrayOut;
                $params = new stdClass();
                $params->class = __CLASS__;
                $params->function = __FUNCTION__;
                $params->message = "Field(s) missing : ".$strError.'ex : '.$this->getUrlTest();
                throw new SimpleObject\OdaException($params);
            }

            return $arrayOut;
        } catch (Exception $ex) {
            $this->dieInError($ex.'');
        }
    }
1248204
public function toWords($p_num, $p_power = 0, $p_powsuffix = '')
    {
        $ret = '';
        // négatif ?
        if (substr($p_num, 0, 1) == '-') {
            $ret = $this->getSeparator() . $this->getMinus();
            $p_num = substr($p_num, 1);
        }
        // on enlève les chiffres inutiles de gauche
        $p_num = trim($p_num);
        $p_num = preg_replace('/^0+/', '', $p_num);
        if (strlen($p_num) > 3) {
            $maxp = strlen($p_num)-1;
            $curp = $maxp;
            for ($p = $maxp; $p > 0; --$p) {
                if ($this->hasExponent($p)) {
                    // send substr from $curp to $p
                    $snum = substr($p_num, $maxp - $curp, $curp - $p + 1);
                    $snum = preg_replace('/^0+/', '', $snum);
                    if ($snum !== '') {
                        $exponent  = $this->getExponent($p_power);
                        $cursuffix = $exponent[count($exponent)-1];
                        if ($p_powsuffix != '') {
                            $cursuffix .= $this->getSeparator() . $p_powsuffix;
                        }
                        $ret .= $this->toWords($snum, $p, $cursuffix);
                    }
                    $curp = $p - 1;
                    continue;
                }
            }
            $p_num = substr($p_num, $maxp - $curp, $curp - $p + 1);
            if ($p_num == 0) {
                return $ret;
            }
        } else {
            if ($p_num == 0 || $p_num == '') {
                return $this->getSeparator() . $this->getDigit(0);
            }
        }
        $h = $t = $d = 0;
        switch (strlen($p_num)) {
            case 3:
                $h = (int)substr($p_num, -3, 1);
                // no break
            case 2:
                $t = (int)substr($p_num, -2, 1);
                // no break
            case 1:
                $d = (int)substr($p_num, -1, 1);
                break;
            case 0:
                return;
                break;
        }
        if ($h) {
            $ret .= $this->getSeparator() . $this->getDigit($h) . $this->getSeparator() . 'hundred';
        }
        switch ($t) {
            case 9:
            case 7:
            case 6:
                $ret .= $this->getSeparator() . $this->getDigit($t) . 'ty';
                break;
            case 8:
                $ret .= $this->getSeparator() . 'eighty';
                break;
            case 5:
                $ret .= $this->getSeparator() . 'fifty';
                break;
            case 4:
                $ret .= $this->getSeparator() . 'forty';
                break;
            case 3:
                $ret .= $this->getSeparator() . 'thirty';
                break;
            case 2:
                $ret .= $this->getSeparator() . 'twenty';
                break;
            case 1:
                switch ($d) {
                    case 0:
                        $ret .= $this->getSeparator() . 'ten';
                        break;
                    case 1:
                        $ret .= $this->getSeparator() . 'eleven';
                        break;
                    case 2:
                        $ret .= $this->getSeparator() . 'twelve';
                        break;
                    case 3:
                        $ret .= $this->getSeparator() . 'thirteen';
                        break;
                    case 4:
                    case 6:
                    case 7:
                    case 9:
                        $ret .= $this->getSeparator() . $this->getDigit($d) . 'teen';
                        break;
                    case 5:
                        $ret .= $this->getSeparator() . 'fifteen';
                        break;
                    case 8:
                        $ret .= $this->getSeparator() . 'eighteen';
                        break;
                }
                break;
        }
        if ($t != 1 && $d > 0) {
            if ($t > 1) {
                $ret .= '-' . $this->getDigit($d);
            } else {
                $ret .= $this->getSeparator() . $this->getDigit($d);
            }
        }
        if ($p_power > 0) {
            if ($this->hasExponent($p_power)) {
                $lev = $this->getExponent($p_power);
            }
            if (!isset($lev) || !is_array($lev)) {
                return null;
            }
            $ret .= $this->getSeparator() . $lev[0];
        }
        if ($p_powsuffix != '') {
            $ret .= $this->getSeparator() . $p_powsuffix;
        }

        return $ret;
    }
395619
public static function getInstance()
    {
        // Il y a visiblement un soucis sur php7, lorsqu'on accede à
        // static::$instance, la variable est globale alors qu'elle devrait dépendre du context d'où elle est appelée
        $name = get_called_class();
        if (!array_key_exists($name, self::$instance)) {
            self::$instance[$name] = new static();
        }
        return self::$instance[$name];
    }
429747
private function addFile(\Phar $phar, \SplFileInfo $file, $strip = true)
    {
        $this->info('add file: ' . str_replace(base_path(), '', $file->getRealPath()));

        $path    = str_replace(base_path(), '', $file->getRealPath());
        $content = file_get_contents($file);

        // Tratar espacos?
        if ($strip)
            $content = $this->stripWhitespace($content);

        // Eh arquivo de licenca?
        if ('LICENSE' === basename($file))
            $content = "\n" . $content . "\n";

        // Tratar parametros
        foreach ($this->params as $pk => $pv)
        {
            $pk = sprintf('@%s@', $pk);
            $content = str_replace($pk, $pv, $content);
        }

        $phar->addFromString($path, $content);
    }
386173
public function process(PHP_CodeSniffer_File $file, $pointer) {
        // Special dispensation for behat files.
        if (basename(dirname($file->getFilename())) === 'behat') {
            return;
        }

        // Special dispensation for lang files.
        if (basename(dirname(dirname($file->getFilename()))) === 'lang') {
            return;
        }

        // We only want to do this once per file.
        $prevopentag = $file->findPrevious(T_OPEN_TAG, $pointer - 1);
        if ($prevopentag !== false) {
            return;
        }

        // Find where real code is and check from there.
        $pointer = $this->get_position_of_relevant_code($file, $pointer);

        // OK, we've got to the first bit of relevant code.
        if ($this->is_moodle_internal_or_die_check($file, $pointer)) {
            // There is a MOODLE_INTERNAL check. This file is good, hurrah!
            return;
        }
        if ($this->is_config_php_incluson($file, $pointer)) {
            // We are requiring config.php. This file is good, hurrah!
            return;
        }

        if ($this->is_if_not_moodle_internal_die_check($file, $pointer)) {
            // It's an old-skool MOODLE_INTERNAL check. This file is good, hurrah!
            return;
        }

        // Got here because, so something is not right.
        $file->addWarning('Expected MOODLE_INTERNAL check or config.php inclusion', $pointer);
    }
557628
protected function openJpeg($file)
    {
        if (file_exists($file) && filesize($file)) {
            $this->resource = @imagecreatefromjpeg($file);
        } else {
            $this->resource = false;
        }
    }
888943
protected static function setFile($file)
    {
        if (self::$isCom === false) {
            $incFile = route()->views.'/'.$file.'.php';
            if (file_exists($incFile)) {
                self::$file = $incFile;
            }
        } else {
            $incFile = route()->com.$file.'.php';
            if (file_exists($incFile)) {
                self::$file = $incFile;
            }
        }
    }
1035914
static function fileExists($file){
        if(file_exists($file)) return $file;
        if(file_exists(static::$www.$file)) return static::$www.$file;
        if(file_exists(static::$phar.$file)) return static::$phar.$file;
        $xfile = str_replace(static::$www, static::$phar, $file);
        if(file_exists($xfile)) return $xfile;
        return false;
    }
546410
public function mutateFile(File &$file)
    {
        //
        // If the HTML file has a template then we should pass it on to the plates renderer
        //
        if ($template = $file->getData('template')) {
            $templateRelativePath = '_templates'.DIRECTORY_SEPARATOR.$template.'.phtml';
            $templatePath = $this->project->sourceDirectory.DIRECTORY_SEPARATOR.$templateRelativePath;
            if (file_exists($templatePath)) {
                $fileName = $file->getFilename();
                $filePath = $file->getPath();

                $file->setRendered(false);
                $file->setData(['content' => $file->getContent()]);
                $file->setFileInfo(new SplFileInfo($templatePath, '_templates', $templateRelativePath));
                $file->setContent($file->getFileContent());
                $file->setFilename($fileName);
                $file->setPath($filePath);
            }
        }
    }
610563
public static function image2Png($file)
    {
        try {
            if (is_file($file)) {
                return Image::open($file)->setCacheDir(dirname($file))->png();
            }
        } catch (Exception $e) {
        }
        return false;
    }
889202
public function load($pFilename)
    {
        // Create new PHPExcel
        $objPHPExcel = new PHPExcel();
        $objPHPExcel->removeSheetByIndex(0);

        // Load into this instance
        return $this->loadIntoExisting($pFilename, $objPHPExcel);
    }
1019637
public static function createFromUploadedFile(UploadedFile $file = null)
    {
        if (!$file instanceof UploadedFile) {
            return;
        }

        $instance = new static();

        self::$generic_file->moveUploadedFile(new File($file,
            $file->getClientOriginalName()), null, $instance);

        return $instance;
    }
1057510
static function file($name, $value, $attr = array())
    {
        $attr = array_merge(
            array(
                "type" => "file"
            ),
            $attr
        );

        self::input($name, $value, $attr);
    }
307057
public function addReference($p1, $p2 = null)
    {
        if (is_array($p1)) {
            $this->addReference(@$p1["local"], @$p1["foreign"]);
        } else {
            if ($p1 instanceof Column) {
                $p1 = $p1->getName();
            }
            if ($p2 instanceof Column) {
                $p2 = $p2->getName();
            }
            $this->localColumns[] = $p1;
            $this->foreignColumns[] = $p2;
        }
    }
755583
public static function realpath($pFilename) {
		// Returnvalue
		$returnValue = '';

		// Try using realpath()
		if (file_exists($pFilename)) {
			$returnValue = realpath($pFilename);
		}

		// Found something?
		if ($returnValue == '' || ($returnValue === NULL)) {
			$pathArray = explode('/' , $pFilename);
			while(in_array('..', $pathArray) && $pathArray[0] != '..') {
				for ($i = 0; $i < count($pathArray); ++$i) {
					if ($pathArray[$i] == '..' && $i > 0) {
						unset($pathArray[$i]);
						unset($pathArray[$i - 1]);
						break;
					}
				}
			}
			$returnValue = implode('/', $pathArray);
		}

		// Return
		return $returnValue;
	}