Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Commit

Permalink
changed static call to configuration items
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Book committed Apr 23, 2012
1 parent 7609e7d commit 6bd0f36
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions cloudlib/helpers/Uploader.php
Expand Up @@ -221,7 +221,7 @@ protected function process($name, $tmp, $error, $key)
$this->data[$key]['origname'] = $name; $this->data[$key]['origname'] = $name;


// Valid filesize? // Valid filesize?
if($tempObj->getSize() > static::$config['filesize']) if($tempObj->getSize() > $this->config['filesize'])
{ {
$this->errors[$key] = array( $this->errors[$key] = array(
'name' => $name, 'name' => $name,
Expand All @@ -233,9 +233,9 @@ protected function process($name, $tmp, $error, $key)
$this->data[$key]['size'] = $tempObj->getSize(); $this->data[$key]['size'] = $tempObj->getSize();


// Valid file extension? // Valid file extension?
if(isset(static::$config['filetypes']) && is_array(static::$config['filetypes'])) if(isset($this->config['filetypes']) && is_array($this->config['filetypes']))
{ {
if( ! in_array($nameObj->getExtension(), static::$config['filetypes'])) if( ! in_array($nameObj->getExtension(), $this->config['filetypes']))
{ {
$this->error[$key] = array( $this->error[$key] = array(
'name' => $name, 'name' => $name,
Expand All @@ -253,9 +253,9 @@ protected function process($name, $tmp, $error, $key)
list($width, $height) = getimagesize($tmp); list($width, $height) = getimagesize($tmp);


// Check width // Check width
if(isset(static::$config['width'])) if(isset($this->config['width']))
{ {
if($width > static::$config['width']) if($width > $this->config['width'])
{ {
$this->error[$key] = array( $this->error[$key] = array(
'name' => $name, 'name' => $name,
Expand All @@ -266,9 +266,9 @@ protected function process($name, $tmp, $error, $key)
} }


// Check height // Check height
if(isset(static::$config['height'])) if(isset($this->config['height']))
{ {
if($height > static::$config['height']) if($height > $this->config['height'])
{ {
$this->error[$key] = array( $this->error[$key] = array(
'name' => $name, 'name' => $name,
Expand All @@ -290,11 +290,11 @@ protected function process($name, $tmp, $error, $key)
} }


// Set name // Set name
$prefix = isset(static::$config['prefix']) ? static::$config['prefix'] : ''; $prefix = isset($this->config['prefix']) ? $this->config['prefix'] : '';


if(isset(static::$config['filename'])) if(isset($this->config['filename']))
{ {
$newName = sprintf('%s%s.%s', $prefix, static::$config['filename'], $newName = sprintf('%s%s.%s', $prefix, $this->config['filename'],
$nameObj->getExtension()); $nameObj->getExtension());
} }
else else
Expand All @@ -306,12 +306,12 @@ protected function process($name, $tmp, $error, $key)


// If we should replace the existing file, if not - check it it exists and // If we should replace the existing file, if not - check it it exists and
// prepend the filename with copy_(number) // prepend the filename with copy_(number)
if(static::$config['replace'] == false) if($this->config['replace'] == false)
{ {
$copy = ''; $copy = '';
$counter = 1; $counter = 1;


while(file_exists(static::$config['directory'] . $copy . $newName)) while(file_exists($this->config['directory'] . $copy . $newName))
{ {
$copy = sprintf('copy(%s)_', $counter); $copy = sprintf('copy(%s)_', $counter);
$counter++; $counter++;
Expand All @@ -322,7 +322,7 @@ protected function process($name, $tmp, $error, $key)


$this->data[$key]['name'] = $newName; $this->data[$key]['name'] = $newName;


$dir = rtrim(static::$config['directory'], '/') . '/'; $dir = rtrim($this->config['directory'], '/') . '/';


if( ! move_uploaded_file($tmp, $dir . $newName)) if( ! move_uploaded_file($tmp, $dir . $newName))
{ {
Expand Down

0 comments on commit 6bd0f36

Please sign in to comment.