示例#1
0
 public function prepare($file, $mime)
 {
     $model = parent::prepare($file, $mime);
     $info = getimagesize($file);
     if (!$info) {
         return false;
     }
     $model->width = $info[0];
     $model->height = $info[1];
     $mime = '';
     switch ($info[2]) {
         case IMAGETYPE_GIF:
             $mime = 'image/gif';
             break;
         case IMAGETYPE_JPEG:
         case IMAGETYPE_JPEG2000:
             $mime = 'image/jpeg';
             break;
         case IMAGETYPE_PNG:
             $mime = 'image/png';
             break;
         case IMAGETYPE_SWF:
         case IMAGETYPE_PSD:
         case IMAGETYPE_BMP:
         case IMAGETYPE_WBMP:
         case IMAGETYPE_XBM:
         case IMAGETYPE_TIFF_II:
         case IMAGETYPE_TIFF_MM:
         case IMAGETYPE_IFF:
         case IMAGETYPE_JB2:
         case IMAGETYPE_JPC:
         case IMAGETYPE_JP2:
         case IMAGETYPE_JPX:
         case IMAGETYPE_SWC:
         case IMAGETYPE_ICO:
             // TODO Добить типы
         // TODO Добить типы
         default:
             $mime = 'image/unknown';
     }
     $model->mimetype = $mime;
     return $model;
 }
示例#2
0
 public function make($asArray = FALSE)
 {
     $this->build();
     $this->_connection->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_NUM);
     $data = $this->_connection->prepare("SELECT {$this->_select} FROM {$this->_table} {$this->_requestQuery} {$this->_limited}");
     $resFilterLength = $this->_connection->prepare("SELECT count(*) FROM {$this->_table} {$this->_requestQuery}");
     $resTotalLength = $this->_connection->prepare("SELECT COUNT(*) FROM {$this->_table} {$this->_query}");
     $resFilterLength->execute($this->bound);
     $this->output['recordsFiltered'] = $resFilterLength->fetchColumn();
     $resTotalLength->execute();
     $this->output['recordsTotal'] = $resTotalLength->fetchColumn();
     $data->execute($this->bound);
     $this->output['data'] = $data->fetchAll();
     if ($asArray) {
         return $this->output;
     } else {
         if (parent::remoteAllowed() and $callback = $this->request('callback')) {
             return $callback . '(' . json_encode($this->output) . ');';
         } else {
             return json_encode($this->output);
         }
     }
 }
示例#3
0
 public function prapare($file, $mime)
 {
     return parent::prepare($file, $mime);
 }