elFinder::error PHP Метод

error() публичный Метод

Normalize error messages
Автор: Dmitry (dio) Levashov
public error ( ) : array
Результат array
    public function error()
    {
        $errors = array();
        foreach (func_get_args() as $msg) {
            if (is_array($msg)) {
                $errors = array_merge($errors, $msg);
            } else {
                $errors[] = $msg;
            }
        }
        return count($errors) ? $errors : array(self::ERROR_UNKNOWN);
    }

Usage Example

 /**
  * Execute elFinder command and output result
  *
  * @return void
  * @author Dmitry (dio) Levashov
  **/
 public function run()
 {
     $isPost = $_SERVER["REQUEST_METHOD"] == 'POST';
     $src = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
     $cmd = isset($src['cmd']) ? $src['cmd'] : '';
     $args = array();
     if (!function_exists('json_encode')) {
         $error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON);
         $this->output(array('error' => '{"error":["' . implode('","', $error) . '"]}', 'raw' => true));
     }
     if (!$this->elFinder->loaded()) {
         $this->output(array('error' => $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_VOL), 'debug' => $this->elFinder->mountErrors));
     }
     // telepat_mode: on
     if (!$cmd && $isPost) {
         $this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UPLOAD, elFinder::ERROR_UPLOAD_TOTAL_SIZE), 'header' => 'Content-Type: text/html'));
     }
     // telepat_mode: off
     if (!$this->elFinder->commandExists($cmd)) {
         $this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UNKNOWN_CMD)));
     }
     // collect required arguments to exec command
     foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
         $arg = $name == 'FILES' ? $_FILES : (isset($src[$name]) ? $src[$name] : '');
         if (!is_array($arg)) {
             $arg = trim($arg);
         }
         if ($req && (!isset($arg) || $arg === '')) {
             $this->output(array('error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)));
         }
         $args[$name] = $arg;
     }
     $args['debug'] = isset($src['debug']) ? !!$src['debug'] : false;
     $this->output($this->elFinder->exec($cmd, $args));
 }
All Usage Examples Of elFinder::error