Esempio n. 1
0
 /**
  * Configure Uploader manually.
  *
  * @param bool|int $id
  * @param string $table
  * @param string $ds
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     $config = Configure::read('Tournament.uploads');
     $transport = $config['transport'];
     if ($transport) {
         $transport['folder'] = 'tournament/matches/';
     }
     $attachment = array('nameCallback' => 'formatFilename', 'uploadDir' => WWW_ROOT . 'files/tournament/matches/', 'finalPath' => 'files/tournament/matches/', 'overwrite' => true, 'stopSave' => true, 'allowEmpty' => false, 'transport' => $transport);
     $this->actsAs['Uploader.Attachment'] = array('screenshot' => $attachment, 'replay' => $attachment);
     $this->actsAs['Uploader.FileValidation'] = array('screenshot' => array('extension' => array('jpg', 'jpeg', 'png'), 'type' => array('image/jpg', 'image/jpeg', 'image/png'), 'required' => true), 'replay' => array('required' => true));
     parent::__construct($id, $table, $ds);
 }
Esempio n. 2
0
 /**
  * Use team slug as logo name.
  *
  * @param string $name
  * @param \Transit\File $file
  * @return string
  */
 public function formatFilename($name, $file)
 {
     if ($this->id) {
         if ($team = $this->getById($this->id)) {
             return $team['Team']['slug'];
         }
     }
     return parent::formatFilename($name, $file);
 }