PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/blog/www/system/module/system/library/System/Upload.php

https://bitbucket.org/vmihailenco/vladimirwebdev
PHP | 33 lines | 29 code | 4 blank | 0 comment | 0 complexity | 02d6090d439c5f7680a52a2841c0aeef MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. class System_Upload extends DoctrineX_Record
  3. {
  4. public function setTableDefinition()
  5. {
  6. $this->hasColumn('id', 'integer', null, array('autoincrement' => true, 'primary' => true));
  7. $this->hasColumn('name', 'string', 64);
  8. $this->hasColumn('hash', 'string', 32);
  9. $this->hasColumn('size', 'integer');
  10. $this->hasColumn('mimeType', 'string', 32);
  11. $this->actAs(new DoctrineX_Template_Owner());
  12. }
  13. public function preDelete()
  14. {
  15. $filename = $this->getUser()->getUploadsPath($this->user_id) . '/' . $this->name;
  16. IO_File::delete($filename);
  17. }
  18. public function fromFile(Zend_Form_Element_File $file)
  19. {
  20. $this->name = $file->getFileName(null, false);
  21. $this->hash = $file->getHash('md5');
  22. $this->size = $file->getFileSize();
  23. $this->mimeType = $file->getMimeType();
  24. }
  25. public function fetchUserUploadsAsPairs($id, $key = 'id', $value = 'name', $options = array(), Doctrine_Query $query = null)
  26. {
  27. return $this->fetchAllAsPairs($key, $value, $options, $this->getBaseQuery($query)->where('user_id = ?', $id));
  28. }
  29. }