Author: david
Date: Wed Aug 24 13:50:24 2011
New Revision: 9580
Log:
Create method for getting absolute path to an asset. Make paths relative to
sf_upload_dir configuration setting.
Modified:
trunk/lib/model/QubitDigitalObject.php
Modified: trunk/lib/model/QubitDigitalObject.php
==============================================================================
--- trunk/lib/model/QubitDigitalObject.php Wed Aug 24 13:34:07 2011
(r9579)
+++ trunk/lib/model/QubitDigitalObject.php Wed Aug 24 13:50:24 2011
(r9580)
@@ -338,7 +338,7 @@
&& is_readable($waterMarkPathName =
sfConfig::get('sf_web_dir').'/watermark.png')
&& is_file($waterMarkPathName))
{
- $filePathName = sfConfig::get('sf_web_dir').$this->getFullPath();
+ $filePathName = $this->getAbsolutePath();
$command = 'composite -dissolve 15 -tile '.$waterMarkPathName.'
'.escapeshellarg($filePathName).' '.escapeshellarg($filePathName);
exec($command);
}
@@ -380,12 +380,9 @@
}
// Delete digital asset
- if ($assetPath = $this->getFullPath())
+ if (file_exists($this->getAbsolutePath()))
{
- if (file_exists(sfConfig::get('sf_web_dir').$assetPath))
- {
- unlink(sfConfig::get('sf_web_dir').$assetPath);
- }
+ unlink($this->getAbsolutePath());
}
// Delete self
@@ -571,7 +568,7 @@
}
/**
- * Get full path to asset, relative to the web directory
+ * Get path to asset, relative to sf_upload_dir
*
* @return string path to asset
*/
@@ -581,6 +578,16 @@
}
/**
+ * Get absolute path to asset
+ *
+ * @return string absolute path to asset
+ */
+ public function getAbsolutePath()
+ {
+ return sfConfig::get('sf_upload_dir').$this->path.$this->name;
+ }
+
+ /**
* Test that image will display in major web browsers
*
* @return boolean
@@ -954,7 +961,7 @@
}
else
{
- $command = 'identify
'.sfConfig::get('sf_web_dir').$this->getFullPath();
+ $command = 'identify '.$this->getAbsolutePath();
}
exec($command, $output, $status);
@@ -1021,7 +1028,7 @@
}
else
{
- $path = sfConfig::get('sf_web_dir').$this->getFullPath();
+ $path = $this->getAbsolutePath();
}
$filenameMinusExtension = preg_replace('/\.[a-zA-Z]{2,3}$/', '', $path);
@@ -1229,7 +1236,7 @@
}
else
{
- $originalFullPath = sfConfig::get('sf_web_dir').$this->getFullPath();
+ $originalFullPath = $this->getAbsolutePath();
}
$extension = '.'.self::THUMB_EXTENSION;
@@ -1266,7 +1273,7 @@
// Only operate on digital objects that are images
if ($this->isImage())
{
- $filename = sfConfig::get('sf_web_dir').$this->getFullPath();
+ $filename = $this->getAbsolutePath();
return QubitDigitalObject::resizeImage($filename, $maxwidth, $maxheight);
}
@@ -1531,7 +1538,7 @@
}
else
{
- $originalFullPath = sfConfig::get('sf_web_dir').$this->getFullPath();
+ $originalFullPath = $this->getAbsolutePath();
list($originalNameNoExtension) = explode('.', $this->getName());
$derivativeName = $originalNameNoExtension.'_'.$usageId.'.mp3';
@@ -1602,7 +1609,7 @@
public function createVideoDerivative($usageId, $connection = null)
{
// Build new filename and path
- $originalFullPath = sfConfig::get('sf_web_dir').$this->getFullPath();
+ $originalFullPath = $this->getAbsolutePath();
list($originalNameNoExtension) = explode('.', $this->getName());
switch ($usageId)
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.