setup() public méthode

public setup ( Model $model, $settings = [] )
$model Model
Exemple #1
0
 /**
  * setup method
  *
  * Override defaults inherited from the upload behavior
  * Set allowed mimes to image types
  * Set allowed extension to matching mimes
  * Set versions to create tiny, small, medium and large thumbs/versions
  *
  * @param mixed $model
  * @param array $config
  * @return void
  * @access public
  */
 function setup(&$model, $config = array())
 {
     $this->_defaultSettings['allowedMime'] = array('image/jpeg', 'image/gif', 'image/png', 'image/bmp');
     $this->_defaultSettings['allowedExt'] = array('jpeg', 'jpg', 'gif', 'png', 'bmp');
     $this->_defaultSettings['versions'] = array('thumb' => array('callback' => array('resize', 50, 50)), 'small' => array('callback' => array('resize', 75, 75)), 'medium' => array('callback' => array('resize', 150, 150)), 'large' => array('callback' => array(array('resize', 600, 400))));
     parent::setup($model, $config);
 }
 /**
  * This method initiate Image Upload behavior by setting configuration options.
  *
  * @param Model &$model instance of model
  * @param array $config array of configuration settings.
  *
  * @return void
  */
 function setup(&$model, $config = array())
 {
     // Sets default mime types and extensions for images
     $this->__defaultSettings['allowedMime'] = array('image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/bmp');
     $this->__defaultSettings['allowedExt'] = array('jpeg', 'jpg', 'gif', 'png', 'bmp');
     // Calls parent class's setup method.
     parent::setup($model, $config);
 }
 /**
  * SetUp Upload behavior
  *
  * @param object $model instance of model
  * @param array $config array of configuration settings.
  * @return void
  */
 public function setup(Model $model, $config = array())
 {
     CakeLog::debug('NcUploadBehavior::setup()');
     //CakeLog::debug('NcUploadBehavior::setup() $config=' . print_r($config, true));
     if (isset($config['fileBaseUrl'])) {
         $this->fileBaseUrl = $config['fileBaseUrl'];
         unset($config['fileBaseUrl']);
     }
     if (isset($config['fileDownloadUrl'])) {
         $this->fileDownloadUrl = $config['fileDownloadUrl'];
         unset($config['fileDownloadUrl']);
     }
     if (isset($config['uploadDir'])) {
         $this->uploadDir = $config['uploadDir'];
         unset($config['uploadDir']);
     }
     if (isset($config['thumbnailSizes'])) {
         $this->thumbnailSizes = $config['thumbnailSizes'];
         unset($config['thumbnailSizes']);
     }
     if (isset($config['rootDir'])) {
         $this->rootDir = $config['rootDir'];
         unset($config['rootDir']);
     } else {
         $this->rootDir = APP . $this->uploadDir . DS;
     }
     //unset($config['fileBaseUrl'], $config['uploadDir']);
     $fields = array_keys($config);
     foreach ($fields as $field) {
         if (!isset($config[$field]['rootDir'])) {
             $config[$field]['rootDir'] = $this->rootDir;
         }
         if (!isset($config[$field]['thumbnailSizes'])) {
             $config[$field]['thumbnailSizes'] = $this->thumbnailSizes;
         }
         $config[$field] = Hash::merge($this->__default, $config[$field]);
     }
     //CakeLog::debug('NcUploadBehavior::setup() $config=' . print_r($config, true));
     CakeLog::debug('NcUploadBehavior::setup() $this->uploadDir=' . print_r($this->uploadDir, true));
     CakeLog::debug('NcUploadBehavior::setup() $this->rootDir=' . print_r($this->rootDir, true));
     parent::setup($model, $config);
 }
Exemple #4
0
 /**
  * SetUp Upload behavior
  *
  * @param object $model instance of model
  * @param array $config array of configuration settings.
  * @return void
  */
 public function setup(Model $model, $config = array())
 {
     if (isset($config['fileBaseUrl'])) {
         $this->fileBaseUrl = $config['fileBaseUrl'];
         unset($config['fileBaseUrl']);
     }
     if (isset($config['fileDownloadUrl'])) {
         $this->fileDownloadUrl = $config['fileDownloadUrl'];
         unset($config['fileDownloadUrl']);
     }
     if (isset($config['uploadDir'])) {
         $this->uploadDir = $config['uploadDir'];
         unset($config['uploadDir']);
     }
     if (isset($config['thumbnailSizes'])) {
         $this->thumbnailSizes = $config['thumbnailSizes'];
         unset($config['thumbnailSizes']);
     }
     if (isset($config['rootDir'])) {
         $this->rootDir = $config['rootDir'];
         unset($config['rootDir']);
     } else {
         $this->rootDir = APP . DS . $this->uploadDir . DS;
     }
     $fields = array_keys($config);
     foreach ($fields as $field) {
         if (!isset($config[$field]['rootDir'])) {
             $config[$field]['rootDir'] = $this->rootDir;
         }
         if (!isset($config[$field]['thumbnailSizes'])) {
             $config[$field]['thumbnailSizes'] = $this->thumbnailSizes;
         }
         $config[$field] = Hash::merge($this->__default, $config[$field]);
     }
     parent::setup($model, $config);
 }