Author: david
Date: 2008-11-26 13:11:11 -0800 (Wed, 26 Nov 2008)
New Revision: 1618

Modified:
   trunk/qubit/lib/model/QubitDigitalObject.php
   trunk/qubit/lib/model/QubitTerm.php
Log:
Update ->prepareStatement() -> ->prepare() from switch to PDO for symfony 1.2. 
Also update code formatting to conform with pre-commit validator.

Modified: trunk/qubit/lib/model/QubitDigitalObject.php
===================================================================
--- trunk/qubit/lib/model/QubitDigitalObject.php        2008-11-25 17:55:42 UTC 
(rev 1617)
+++ trunk/qubit/lib/model/QubitDigitalObject.php        2008-11-26 21:11:11 UTC 
(rev 1618)
@@ -42,13 +42,13 @@
     'application/vnd.ms-excel'      => 'icon-ms-excel.gif',
     'application/msword'            => 'icon-ms-word.gif',
     'application/vnd.ms-powerpoint' => 'icon-ms-powerpoint.gif'
-  );
+    );
 
-  /*
-   * Pulled the following mime-type array from the Gallery 2 project
-   * http://gallery.menalto.com
-   */
-  public static $qubitMimeTypes = array(
+    /*
+     * Pulled the following mime-type array from the Gallery 2 project
+     * http://gallery.menalto.com
+     */
+    public static $qubitMimeTypes = array(
     /* This data was lifted from Apache's mime.types listing. */
     'z' => 'application/x-compress',
     'ai' => 'application/postscript',
@@ -215,899 +215,899 @@
     'flv' => 'video/x-flv',
     'mp4' => 'video/mp4',
     'tgz' => 'application/x-compressed'
-  );
+    );
 
-  public function save($connection = null)
-  {
-    // TODO: $cleanInformationObject = $this->getInformationObject()->clean();
-    $cleanInformationObjectId = $this->columnValues['information_object_id'];
+    public function save($connection = null)
+    {
+      // TODO: $cleanInformationObject = 
$this->getInformationObject()->clean();
+      $cleanInformationObjectId = $this->columnValues['information_object_id'];
 
-    parent::save($connection);
+      parent::save($connection);
 
-    if ($cleanInformationObjectId != $this->getInformationObjectId() && 
QubitInformationObject::getById($cleanInformationObjectId) !== null)
-    {
-      
SearchIndex::updateTranslatedLanguages(QubitInformationObject::getById($cleanInformationObjectId));
+      if ($cleanInformationObjectId != $this->getInformationObjectId() && 
QubitInformationObject::getById($cleanInformationObjectId) !== null)
+      {
+        
SearchIndex::updateTranslatedLanguages(QubitInformationObject::getById($cleanInformationObjectId));
+      }
+
+      if ($this->getInformationObject() !== null)
+      {
+        SearchIndex::updateTranslatedLanguages($this->getInformationObject());
+      }
     }
 
-    if ($this->getInformationObject() !== null)
+    /**
+     * Override base delete method to unlink related digital assets (thumbnail
+     * and file)
+     *
+     * @param  sfConnection  A database connection
+     */
+    public function delete($connection = null)
     {
-      SearchIndex::updateTranslatedLanguages($this->getInformationObject());
-    }
-  }
+      $criteria = new Criteria;
+      $criteria->add(QubitDigitalObject::PARENT_ID, $this->getId());
 
-  /**
-   * Override base delete method to unlink related digital assets (thumbnail
-   * and file)
-   *
-   * @param  sfConnection  A database connection
-   */
-  public function delete($connection = null)
-  {
-    $criteria = new Criteria;
-    $criteria->add(QubitDigitalObject::PARENT_ID, $this->getId());
+      $children = QubitDigitalObject::get($criteria);
 
-    $children = QubitDigitalObject::get($criteria);
+      // Delete children
+      foreach ($children as $child)
+      {
+        $child->delete();
+      }
 
-    // Delete children
-    foreach ($children as $child)
-    {
-      $child->delete();
-    }
+      // Delete digital asset
+      if ($assetPath = $this->getFullPath())
+      {
+        if (file_exists(sfConfig::get('sf_web_dir').$assetPath))
+        {
+          unlink(sfConfig::get('sf_web_dir').$assetPath);
+        }
+      }
 
-    // Delete digital asset
-    if ($assetPath = $this->getFullPath())
-    {
-      if (file_exists(sfConfig::get('sf_web_dir').$assetPath))
+      // Delete self
+      parent::delete($connection);
+
+      if ($this->getInformationObject() !== null)
       {
-        unlink(sfConfig::get('sf_web_dir').$assetPath);
+        SearchIndex::updateTranslatedLanguages($this->getInformationObject());
       }
     }
 
-    // Delete self
-    parent::delete($connection);
 
-    if ($this->getInformationObject() !== null)
+    /**
+     * Get a list of digital objects for an icon table
+     *
+     * @param integer  $mediaTypeId Media-type foreign key
+     * @param integer  $page current Pager page
+     * @return QubitPager paginated list of digital objects
+     */
+    public static function getIconList($mediaTypeId=null, $page=1)
     {
-      SearchIndex::updateTranslatedLanguages($this->getInformationObject());
-    }
-  }
-  
-  
-  /**
-   * Get a list of digital objects for an icon table
-   *
-   * @param integer  $mediaTypeId Media-type foreign key
-   * @param integer  $page current Pager page
-   * @return QubitPager paginated list of digital objects
-   */
-  public static function getIconList($mediaTypeId=null, $page=1)
-  {
-    $criteria = new Criteria;
-    
-    if (isset($mediaTypeId))
-    {
-      $criteria->add(QubitDigitalObject::MEDIA_TYPE_ID, $mediaTypeId);
-    }
-    
-    // Don't show derivative Digital Objects
-    $criteria->add(QubitDigitalObject::INFORMATION_OBJECT_ID, null, 
Criteria::ISNOTNULL);
-    
-    // Sort by name ascending
-    $criteria->addAscendingOrderByColumn(QubitDigitalObject::NAME);
-    
-    $pager = new QubitPager('QubitDigitalObject', '8'); // 8 thumbs per page
-    $pager->setCriteria($criteria);
-    $pager->setPage($page);
-    $pager->init();
-    
-    return $pager;
-  }
-  
-  /**
-   * Get count of digital objects by media-type
-   */
-  public static function getCount($mediaTypeId=null)
-  {
-    $sql = 'SELECT COUNT(*) as hits FROM '.QubitDigitalObject::TABLE_NAME.'
-      WHERE '.QubitDigitalObject::PARENT_ID.' IS NULL';
-    
-    if (isset($mediaTypeId))
-    {
-      $sql .= ' AND '.QubitDigitalObject::MEDIA_TYPE_ID.'='.$mediaTypeId;
-    }
-    
-    $conn = Propel::getConnection();
-    $stmt = $conn->prepareStatement($sql);
-    $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
-    $rs->next();
-    
-    return $rs->getInt(1);
-  }
-  
-  /**
-   * Get full path to asset, relative to the web directory
-   *
-   * @return string  path to asset
-   */
-  public function getFullPath()
-  {
-    return $this->getPath().$this->getName();
-  }
+      $criteria = new Criteria;
 
-  /**
-   * Set Mime-type and Filetype all at once
-   *
-   */
-  public function setMimeAndMediaType()
-  {
-    $this->setMimeType(QubitDigitalObject::deriveMimeType($this->getName()));
-    $this->setDefaultMediaType();
-  }
+      if (isset($mediaTypeId))
+      {
+        $criteria->add(QubitDigitalObject::MEDIA_TYPE_ID, $mediaTypeId);
+      }
 
-  /**
-   * Set default mediaTypeId based on digital asset's mime-type.  Media types
-   * id's are defined in the QubitTerms db
-   *
-   * @return mixed  integer if mediatype mapped, null if no valid mapping
-   */
-  public function setDefaultMediaType()
-  {
-    // Make sure we have a valid mime-type (with a forward-slash).
-    if (!strlen($this->getMimeType()) || !strpos($this->getMimeType(), '/'))
-    {
-      return null;
-    }
+      // Don't show derivative Digital Objects
+      $criteria->add(QubitDigitalObject::INFORMATION_OBJECT_ID, null, 
Criteria::ISNOTNULL);
 
-    $mimePieces = explode('/',$this->getMimeType());
+      // Sort by name ascending
+      $criteria->addAscendingOrderByColumn(QubitDigitalObject::NAME);
 
-    switch($mimePieces[0])
-    {
-      case 'audio':
-        $mediaTypeId = QubitTerm::AUDIO_ID;
-        break;
-      case 'image':
-        $mediaTypeId = QubitTerm::IMAGE_ID;
-        break;
-      case 'text':
-        $mediaTypeId = QubitTerm::TEXT_ID;
-        break;
-      case 'video':
-        $mediaTypeId = QubitTerm::VIDEO_ID;
-        break;
-      case 'application':
-        switch ($mimePieces[1])
-        {
-          case 'pdf':
-            $mediaTypeId = QubitTerm::TEXT_ID;
-            break;
-          default:
-            $mediaTypeId = QubitTerm::OTHER_ID;
-        }
-        break;
-      default:
-       $mediaTypeId = QubitTerm::OTHER_ID;
+      $pager = new QubitPager('QubitDigitalObject', '8'); // 8 thumbs per page
+      $pager->setCriteria($criteria);
+      $pager->setPage($page);
+      $pager->init();
+
+      return $pager;
     }
 
-    $this->setMediaTypeId($mediaTypeId);
-  }
+    /**
+     * Get count of digital objects by media-type
+     */
+    public static function getCount($mediaTypeId=null)
+    {
+      $sql = 'SELECT COUNT(*) as hits FROM '.QubitDigitalObject::TABLE_NAME.'
+      WHERE '.QubitDigitalObject::PARENT_ID.' IS NULL';
 
-  /**
-   * Get this object's top ancestor, or self if it is the top of the branch
-   *
-   * return QubitInformationObject  Closest InformationObject ancestor
-   */
-  public function getTopAncestorOrSelf ()
-  {
-    // Get the ancestor at array index "0"
-    return $this->getAncestors()->andSelf()->offsetGet(0);
-  }
+      if (isset($mediaTypeId))
+      {
+        $sql .= ' AND '.QubitDigitalObject::MEDIA_TYPE_ID.'='.$mediaTypeId;
+      }
 
-  /**
-   * Find *first* child of current digital object that matches $usageid.
-   *
-   * @param integer  Constant value from QubitTerm (THUMBNAIL_ID, REFERENCE_ID)
-   */
-  public function getChildByUsageId($usageId)
-  {
-    $criteria = new Criteria;
-    $criteria->add(QubitDigitalObject::PARENT_ID, $this->getId());
-    $criteria->add(QubitDigitalObject::USAGE_ID, $usageId);
+      $conn = Propel::getConnection();
+      $stmt = $conn->prepare($sql);
+      $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
+      $rs->next();
 
-    $result = QubitDigitalObject::getOne($criteria);
-
-    return $result;
-  }
-
-  /**
-   * Get a representation for the given $usageId.  Currently only searches
-   * direct children of current digital object.
-   *
-   * @param integer $usageId
-   * @return mixed DigitalObject on success
-   *
-   * @todo look for matching usage id up and down object tree?
-   */
-  public function getRepresentationByUsage($usageId)
-  {
-    if ($usageId == $this->getUsageId())
-    {
-      return $this;
+      return $rs->getInt(1);
     }
-    else
-    {
-      return $this->getChildByUsageId($usageId);
-    }
-  }
 
-  /**
-   * Determine if this digital object is an image, based on mimetype
-   *
-   * @return boolean
-   */
-  public function isImage()
-  {
-    return self::isImageFile($this->getName());
-  }
-
-  /**
-   * Resize this digital object (image)
-   *
-   * @param integer $maxwidth  Max width of resized image
-   * @param integer $maxheight Max height of resized image
-   *
-   * @return boolean success or failure
-   */
-  public function resize($maxwidth, $maxheight=null)
-  {
-    // Only operate on digital objects that are images
-    if ($this->isImage())
+    /**
+     * Get full path to asset, relative to the web directory
+     *
+     * @return string  path to asset
+     */
+    public function getFullPath()
     {
-      $filename = sfConfig::get('sf_web_dir').$this->getFullPath();
-      return QubitDigitalObject::resizeImage($filename, $filename, $maxwidth, 
$maxheight);
+      return $this->getPath().$this->getName();
     }
 
-    return false;
-  }
-
-  /**
-   * Resize current digital object according to a specific usage type
-   *
-   * @param integer $usageId
-   * @return boolean success or failure
-   */
-  public function resizeByUsageId($usageId)
-  {
-    if ($usageId == QubitTerm::REFERENCE_ID)
+    /**
+     * Set Mime-type and Filetype all at once
+     *
+     */
+    public function setMimeAndMediaType()
     {
-      $maxwidth = (sfConfig::get('app_reference_image_maxwidth')) ? 
sfConfig::get('app_reference_image_maxwidth') : 480;
-      $maxheight = null;
+      $this->setMimeType(QubitDigitalObject::deriveMimeType($this->getName()));
+      $this->setDefaultMediaType();
     }
-    else if ($usageId == QubitTerm::THUMBNAIL_ID)
-    {
-      $maxwidth = 100;
-      $maxheight = 100;
-    }
-    else
-    {
-      return false;
-    }
 
-    return $this->resize($maxwidth, $maxheight);
-  }
-
-  /**
-   * Get a human-readable filesize for this digital asset
-   *
-   * @return string  bytesize of digital asset + best match for units
-   */
-  public function getHRfileSize()
-  {
-    $suffix = array( 'B', 'KB', 'MB', 'GB', 'TB' );
-    $bytes = parent::getByteSize();
-    for ($i = 0; $bytes >= 1024 && $i < (count($suffix)-1); $bytes /= 1024, 
$i++)
+    /**
+     * Set default mediaTypeId based on digital asset's mime-type.  Media types
+     * id's are defined in the QubitTerms db
+     *
+     * @return mixed  integer if mediatype mapped, null if no valid mapping
+     */
+    public function setDefaultMediaType()
     {
-    }
+      // Make sure we have a valid mime-type (with a forward-slash).
+      if (!strlen($this->getMimeType()) || !strpos($this->getMimeType(), '/'))
+      {
+        return null;
+      }
 
-    return round($bytes, 2).' '.$suffix[$i];
-  }
+      $mimePieces = explode('/',$this->getMimeType());
 
-  /**
-   * Set a related row in the DigitalObjectMetaData db, identified by $name, to
-   * $value. If the element doesn't already exist, create it
-   *
-   * @param string    key for meta-data element
-   * @param string    new value for meta-data element
-   * @return integer  return primary key value
-   */
-  public function setMetaDataValue($name, $value)
-  {
-    // Test for existing element with $name
-    $criteria = new Criteria;
-    $criteria->add(QubitDigitalObjectMetadata::DIGITAL_OBJECT_ID, 
$this->getId());
-    $criteria->add(QubitDigitalObjectMetadata::ELEMENT, $name);
-    $foundElement = QubitDigitalObjectMetadata::get($criteria);
+      switch($mimePieces[0])
+      {
+        case 'audio':
+          $mediaTypeId = QubitTerm::AUDIO_ID;
+          break;
+        case 'image':
+          $mediaTypeId = QubitTerm::IMAGE_ID;
+          break;
+        case 'text':
+          $mediaTypeId = QubitTerm::TEXT_ID;
+          break;
+        case 'video':
+          $mediaTypeId = QubitTerm::VIDEO_ID;
+          break;
+        case 'application':
+          switch ($mimePieces[1])
+          {
+            case 'pdf':
+              $mediaTypeId = QubitTerm::TEXT_ID;
+              break;
+            default:
+              $mediaTypeId = QubitTerm::OTHER_ID;
+          }
+          break;
+            default:
+              $mediaTypeId = QubitTerm::OTHER_ID;
+      }
 
-    // Get existing meta-data element, else create a new one
-    if (is_array($foundElement))
-    {
-      $metaData = $foundElement;
+      $this->setMediaTypeId($mediaTypeId);
     }
-    else
+
+    /**
+     * Get this object's top ancestor, or self if it is the top of the branch
+     *
+     * return QubitInformationObject  Closest InformationObject ancestor
+     */
+    public function getTopAncestorOrSelf()
     {
-      $metaData = new QubitDigitalObjectMetadata;
+      // Get the ancestor at array index "0"
+      return $this->getAncestors()->andSelf()->offsetGet(0);
     }
 
-    // Update database
-    $metaData->setDigitalObjectId($this->getId());
-    $metaData->setElement($name);
-    $metaData->setValue($value);
-    $metaData->save();
+    /**
+     * Find *first* child of current digital object that matches $usageid.
+     *
+     * @param integer  Constant value from QubitTerm (THUMBNAIL_ID, 
REFERENCE_ID)
+     */
+    public function getChildByUsageId($usageId)
+    {
+      $criteria = new Criteria;
+      $criteria->add(QubitDigitalObject::PARENT_ID, $this->getId());
+      $criteria->add(QubitDigitalObject::USAGE_ID, $usageId);
 
-    return $metaData->getId();
-  }
+      $result = QubitDigitalObject::getOne($criteria);
 
-  /**
-   * Get the current value of the meta-data row identified by $name
-   * in the DigitalObjectMetaData db
-   *
-   * @param string  key for meta-data element
-   * @return mixed  string value on success, false on failure
-   */
-  public function getMetadataValue($elementName = null)
-  {
-    $criteria = new Criteria;
-    $criteria->add(QubitDigitalObjectMetadata::DIGITAL_OBJECT_ID, 
$this->getId());
+      return $result;
+    }
 
-    if (!is_null($elementName))
+    /**
+     * Get a representation for the given $usageId.  Currently only searches
+     * direct children of current digital object.
+     *
+     * @param integer $usageId
+     * @return mixed DigitalObject on success
+     *
+     * @todo look for matching usage id up and down object tree?
+     */
+    public function getRepresentationByUsage($usageId)
     {
-      $criteria->add(QubitDigitalObjectMetadata::ELEMENT, $elementName);
+      if ($usageId == $this->getUsageId())
+      {
+        return $this;
+      }
+      else
+      {
+        return $this->getChildByUsageId($usageId);
+      }
     }
-    $results = QubitDigitalObjectMetadata::getOne($criteria);
 
-    if ($results)
+    /**
+     * Determine if this digital object is an image, based on mimetype
+     *
+     * @return boolean
+     */
+    public function isImage()
     {
-      return $results->getValue();
+      return self::isImageFile($this->getName());
     }
-    else
+
+    /**
+     * Resize this digital object (image)
+     *
+     * @param integer $maxwidth  Max width of resized image
+     * @param integer $maxheight Max height of resized image
+     *
+     * @return boolean success or failure
+     */
+    public function resize($maxwidth, $maxheight=null)
     {
+      // Only operate on digital objects that are images
+      if ($this->isImage())
+      {
+        $filename = sfConfig::get('sf_web_dir').$this->getFullPath();
+        return QubitDigitalObject::resizeImage($filename, $filename, 
$maxwidth, $maxheight);
+      }
+
       return false;
     }
-  }
 
-  /**
-   * Derive file path for a digital object asset.  All digital object paths are
-   * keyed by information object id that is the nearest ancestor of the current
-   * digital object. Because we may not know the id of the current digital
-   * object yet (i.e. it hasn't been saved to the database yet), we pass
-   * the parent digital object or information object.
-   *
-   * @param mixed    Parent (QubitDigitalObject or QubitInformationObject)
-   * @return string  asset file path
-   */
-  public static function getAssetPathfromParent($parentObject)
-  {
-    $uploadPathRelative = sfConfig::get('app_upload_dir');
+    /**
+     * Resize current digital object according to a specific usage type
+     *
+     * @param integer $usageId
+     * @return boolean success or failure
+     */
+    public function resizeByUsageId($usageId)
+    {
+      if ($usageId == QubitTerm::REFERENCE_ID)
+      {
+        $maxwidth = (sfConfig::get('app_reference_image_maxwidth')) ? 
sfConfig::get('app_reference_image_maxwidth') : 480;
+        $maxheight = null;
+      }
+      else if ($usageId == QubitTerm::THUMBNAIL_ID)
+      {
+        $maxwidth = 100;
+        $maxheight = 100;
+      }
+      else
+      {
+        return false;
+      }
 
-    if (get_class($parentObject) == 'QubitDigitalObject')
-    {
-      $infoObject = $parentObject->getAncestorInformationObject();
-      $infoObjectId = (string) $infoObject->getId();
+      return $this->resize($maxwidth, $maxheight);
     }
-    else if (get_class($parentObject) == 'QubitInformationObject')
+
+    /**
+     * Get a human-readable filesize for this digital asset
+     *
+     * @return string  bytesize of digital asset + best match for units
+     */
+    public function getHRfileSize()
     {
-      $infoObjectId = (string) $parentObject->getId();
+      $suffix = array( 'B', 'KB', 'MB', 'GB', 'TB' );
+      $bytes = parent::getByteSize();
+      for ($i = 0; $bytes >= 1024 && $i < (count($suffix)-1); $bytes /= 1024, 
$i++)
+      {
+      }
+
+      return round($bytes, 2).' '.$suffix[$i];
     }
-    else
+
+    /**
+     * Set a related row in the DigitalObjectMetaData db, identified by $name, 
to
+     * $value. If the element doesn't already exist, create it
+     *
+     * @param string    key for meta-data element
+     * @param string    new value for meta-data element
+     * @return integer  return primary key value
+     */
+    public function setMetaDataValue($name, $value)
     {
-      return false;
-    }
+      // Test for existing element with $name
+      $criteria = new Criteria;
+      $criteria->add(QubitDigitalObjectMetadata::DIGITAL_OBJECT_ID, 
$this->getId());
+      $criteria->add(QubitDigitalObjectMetadata::ELEMENT, $name);
+      $foundElement = QubitDigitalObjectMetadata::get($criteria);
 
-    // To keep to a minimum the number of sub-directories in the uploads dir,
-    // we break up information object path by using first and second digits of
-    // the information object id as sub-directories.
-    // e.g. if infoObjectId=3235 then path='uploads/3/2/3235/'
-    $assetPath = 
'/'.$uploadPathRelative.'/'.$infoObjectId[0].'/'.$infoObjectId[1].'/'.$infoObjectId;
+      // Get existing meta-data element, else create a new one
+      if (is_array($foundElement))
+      {
+        $metaData = $foundElement;
+      }
+      else
+      {
+        $metaData = new QubitDigitalObjectMetadata;
+      }
 
-    return $assetPath;
-  }
+      // Update database
+      $metaData->setDigitalObjectId($this->getId());
+      $metaData->setElement($name);
+      $metaData->setValue($value);
+      $metaData->save();
 
-  /**
-   * Get path to the appropriate generic icon for $mimeType
-   *
-   * @param string $mimeType
-   * @return string
-   */
-  private static function getGenericIconPath($mimeType)
-  {
-    $genericIconDir  = self::GENERIC_ICON_DIR;
-    $genericIconList = QubitDigitalObject::$qubitGenericIcons;
+      return $metaData->getId();
+    }
 
-    // Check the list for a generic icon matching this mime-type
-    if (array_key_exists($mimeType,$genericIconList))
+    /**
+     * Get the current value of the meta-data row identified by $name
+     * in the DigitalObjectMetaData db
+     *
+     * @param string  key for meta-data element
+     * @return mixed  string value on success, false on failure
+     */
+    public function getMetadataValue($elementName = null)
     {
-      $genericIconPath = $genericIconDir.'/'.$genericIconList[$mimeType];
-    }
-    else
-    {
-      // Use "blank" icon for unknown file types
-      $genericIconPath = $genericIconDir.'/blank.png';
-    }
+      $criteria = new Criteria;
+      $criteria->add(QubitDigitalObjectMetadata::DIGITAL_OBJECT_ID, 
$this->getId());
 
-    return $genericIconPath;
-  }
+      if (!is_null($elementName))
+      {
+        $criteria->add(QubitDigitalObjectMetadata::ELEMENT, $elementName);
+      }
+      $results = QubitDigitalObjectMetadata::getOne($criteria);
 
-  /**
-   * Get a generic representation for the current digital object.
-   *
-   * @param string $mimeType
-   * @return QubitDigitalObject
-   */
-  public static function getGenericRepresentation($mimeType)
-  {
-    $representation = new QubitDigitalObject;
-    $genericIconPath = QubitDigitalObject::getGenericIconPath($mimeType);
+      if ($results)
+      {
+        return $results->getValue();
+      }
+      else
+      {
+        return false;
+      }
+    }
 
-    $representation->setPath(dirname($genericIconPath).'/');
-    $representation->setName(basename($genericIconPath));
+    /**
+     * Derive file path for a digital object asset.  All digital object paths 
are
+     * keyed by information object id that is the nearest ancestor of the 
current
+     * digital object. Because we may not know the id of the current digital
+     * object yet (i.e. it hasn't been saved to the database yet), we pass
+     * the parent digital object or information object.
+     *
+     * @param mixed    Parent (QubitDigitalObject or QubitInformationObject)
+     * @return string  asset file path
+     */
+    public static function getAssetPathfromParent($parentObject)
+    {
+      $uploadPathRelative = sfConfig::get('app_upload_dir');
 
-    return $representation;
-  }
+      if (get_class($parentObject) == 'QubitDigitalObject')
+      {
+        $infoObject = $parentObject->getAncestorInformationObject();
+        $infoObjectId = (string) $infoObject->getId();
+      }
+      else if (get_class($parentObject) == 'QubitInformationObject')
+      {
+        $infoObjectId = (string) $parentObject->getId();
+      }
+      else
+      {
+        return false;
+      }
 
-  /**
-   * Derive a file's mime-type from it's filename extension.  The extension may
-   * lie, but this should be "good enough" for the majority of cases.
-   *
-   * @param string   name of the file
-   * @return string  mime-type of file (or "unknown" if no match)
-   */
-  public static function deriveMimeType($filename)
-  {
-    $mimeType     = 'unknown';
-    $mimeTypeList = QubitDigitalObject::$qubitMimeTypes; // point to "master" 
mime-type array
+      // To keep to a minimum the number of sub-directories in the uploads dir,
+      // we break up information object path by using first and second digits 
of
+      // the information object id as sub-directories.
+      // e.g. if infoObjectId=3235 then path='uploads/3/2/3235/'
+      $assetPath = 
'/'.$uploadPathRelative.'/'.$infoObjectId[0].'/'.$infoObjectId[1].'/'.$infoObjectId;
 
-    $filePieces = explode('.', basename($filename));
-    array_splice($filePieces, 0, 1); // cut off "name" part of filename, leave 
extension(s)
-    $rfilePieces = array_reverse($filePieces);  // Reverse the extension list
+      return $assetPath;
+    }
 
-    // Go through extensions backwards, return value based on first hit
-    // (assume last extension is most significant)
-    foreach ($rfilePieces as $key => $ext)
+    /**
+     * Get path to the appropriate generic icon for $mimeType
+     *
+     * @param string $mimeType
+     * @return string
+     */
+    private static function getGenericIconPath($mimeType)
     {
-      $ext = strtolower($ext);  // Convert uppercase extensions to lowercase
-      
-      // Try to match this extension to a mime-type
-      if (array_key_exists($ext, $mimeTypeList))
+      $genericIconDir  = self::GENERIC_ICON_DIR;
+      $genericIconList = QubitDigitalObject::$qubitGenericIcons;
+
+      // Check the list for a generic icon matching this mime-type
+      if (array_key_exists($mimeType,$genericIconList))
       {
-         $mimeType = $mimeTypeList[$ext];
-         break;
+        $genericIconPath = $genericIconDir.'/'.$genericIconList[$mimeType];
       }
+      else
+      {
+        // Use "blank" icon for unknown file types
+        $genericIconPath = $genericIconDir.'/blank.png';
+      }
+
+      return $genericIconPath;
     }
 
-    return $mimeType;
-  }
+    /**
+     * Get a generic representation for the current digital object.
+     *
+     * @param string $mimeType
+     * @return QubitDigitalObject
+     */
+    public static function getGenericRepresentation($mimeType)
+    {
+      $representation = new QubitDigitalObject;
+      $genericIconPath = QubitDigitalObject::getGenericIconPath($mimeType);
 
-  /**
-   * Generic method for:
-   * - creating a new derivative object,
-   * - building a derivative asset filename,
-   * - creating the derived asset,
-   * - saving the derived asset's metadata
-   *
-   * @param callback $mechanism   callback function for creating derivative 
asset
-   * @param string $extension     extension for derivative filename
-   * @param integer $usageId      usage type for derivative
-   * @param array $parameters     an array of parameters to pass to $mechanism
-   *
-   * @return mixed QubitDigitalObject on success, false on failure
-   */
-  public function createDerivative($mechanism, $extension, $parameters=array())
-  {
-    // Create new digital object for thumbnail (derivative)
-    // And save it to db so we can put primary key in derivative name
-    $derivative = new QubitDigitalObject;
-    $derivative->setParentId($this->getId());
-    $derivative->save();
+      $representation->setPath(dirname($genericIconPath).'/');
+      $representation->setName(basename($genericIconPath));
 
-    // Build new filename and path
-    $originalFullPath = sfConfig::get('sf_web_dir').$this->getFullPath();
-    list($originalNameNoExtension) = explode('.', $this->getName());
-    $derivativeName = 
$originalNameNoExtension.'_'.$derivative->getId().$extension;
-    $derivativeFullPath = 
sfConfig::get('sf_web_dir').$this->getPath().$derivativeName;
+      return $representation;
+    }
 
-    // Build array of parameters to pass to mechanism for creating derivative 
asset
-    $parameters = array_merge(array($originalFullPath, $derivativeFullPath), 
$parameters);
-
-    // Create the derivative
-    if (!call_user_func_array($mechanism, $parameters))
+    /**
+     * Derive a file's mime-type from it's filename extension.  The extension 
may
+     * lie, but this should be "good enough" for the majority of cases.
+     *
+     * @param string   name of the file
+     * @return string  mime-type of file (or "unknown" if no match)
+     */
+    public static function deriveMimeType($filename)
     {
-      $derivative->delete();
+      $mimeType     = 'unknown';
+      $mimeTypeList = QubitDigitalObject::$qubitMimeTypes; // point to 
"master" mime-type array
 
-      return false;
-    }
+      $filePieces = explode('.', basename($filename));
+      array_splice($filePieces, 0, 1); // cut off "name" part of filename, 
leave extension(s)
+      $rfilePieces = array_reverse($filePieces);  // Reverse the extension list
 
-    // Set permissions on output file
-    chmod($derivativeFullPath, 0644);
+      // Go through extensions backwards, return value based on first hit
+      // (assume last extension is most significant)
+      foreach ($rfilePieces as $key => $ext)
+      {
+        $ext = strtolower($ext);  // Convert uppercase extensions to lowercase
 
-    // Update digital object with thumbnail information
-    $derivative->setName($derivativeName);
-    $derivative->setPath($this->getPath());
-    $derivative->setByteSize(filesize($derivativeFullPath));
-    $derivative->setMimeAndMediaType();
+        // Try to match this extension to a mime-type
+        if (array_key_exists($ext, $mimeTypeList))
+        {
+          $mimeType = $mimeTypeList[$ext];
+          break;
+        }
+      }
 
-    // Save the digital object
-    $derivative->save();
+      return $mimeType;
+    }
 
-    return $derivative;
-  }
+    /**
+     * Generic method for:
+     * - creating a new derivative object,
+     * - building a derivative asset filename,
+     * - creating the derived asset,
+     * - saving the derived asset's metadata
+     *
+     * @param callback $mechanism   callback function for creating derivative 
asset
+     * @param string $extension     extension for derivative filename
+     * @param integer $usageId      usage type for derivative
+     * @param array $parameters     an array of parameters to pass to 
$mechanism
+     *
+     * @return mixed QubitDigitalObject on success, false on failure
+     */
+    public function createDerivative($mechanism, $extension, 
$parameters=array())
+    {
+      // Create new digital object for thumbnail (derivative)
+      // And save it to db so we can put primary key in derivative name
+      $derivative = new QubitDigitalObject;
+      $derivative->setParentId($this->getId());
+      $derivative->save();
 
-  /*
-   * -----------------------------------------------------------------------
-   * IMAGE MANIPULATION METHODS
-   * -----------------------------------------------------------------------
-   */
+      // Build new filename and path
+      $originalFullPath = sfConfig::get('sf_web_dir').$this->getFullPath();
+      list($originalNameNoExtension) = explode('.', $this->getName());
+      $derivativeName = 
$originalNameNoExtension.'_'.$derivative->getId().$extension;
+      $derivativeFullPath = 
sfConfig::get('sf_web_dir').$this->getPath().$derivativeName;
 
-  /**
-   * Create a thumbnail derivative for the current digital object
-   *
-   * @return QubitDigitalObject
-   */
-  public function createThumbnail()
-  {
-    // Create a thumbnail
-    $derivative = $this->createImageDerivative(QubitTerm::THUMBNAIL_ID);
+      // Build array of parameters to pass to mechanism for creating 
derivative asset
+      $parameters = array_merge(array($originalFullPath, $derivativeFullPath), 
$parameters);
 
-    return $derivative;
-  }
+      // Create the derivative
+      if (!call_user_func_array($mechanism, $parameters))
+      {
+        $derivative->delete();
 
-  /**
-   * Create a reference derivative for the current digital object
-   *
-   * @return QubitDigitalObject  The new derived reference digital object
-   */
-  public function createReferenceImage()
-  {
-    // Create derivative
-    $derivative = $this->createImageDerivative(QubitTerm::REFERENCE_ID);
+        return false;
+      }
 
-    return $derivative;
-  }
+      // Set permissions on output file
+      chmod($derivativeFullPath, 0644);
 
-  /**
-   * Image file wrapper for calling createDerivative()
-   *
-   * @param integer  $usageId  usage type id
-   * @return mixed QubitDigitalObject on success, false on failure
-   *
-   * @see QubitDigitalObject::createDerivative()
-   */
-  public function createImageDerivative($usageId)
-  {
-    $mechanism = array('QubitDigitalObject', 'resizeImage');
-    $extension = '.'.self::THUMB_EXTENSION;
+      // Update digital object with thumbnail information
+      $derivative->setName($derivativeName);
+      $derivative->setPath($this->getPath());
+      $derivative->setByteSize(filesize($derivativeFullPath));
+      $derivative->setMimeAndMediaType();
 
-    // Get max dimensions
-    $maxDimensions = self::getImageMaxDimensions($usageId);
-
-    if ($derivative = $this->createDerivative($mechanism, $extension, 
$maxDimensions))
-    {
-      $derivative->setUsageId($usageId);
+      // Save the digital object
       $derivative->save();
 
       return $derivative;
     }
 
-    return false;
-  }
+    /*
+     * -----------------------------------------------------------------------
+     * IMAGE MANIPULATION METHODS
+     * -----------------------------------------------------------------------
+     */
 
-  /**
-   * Allow multiple ways of getting the max dimensions for image by usage
-   *
-   * @param integer $usageId  the usage type
-   * @return array $maxwidth, $maxheight
-   *
-   * @todo Add THUMBNAIL_MAX_DIMENSION to Qubit Settings
-   */
-  public static function getImageMaxDimensions($usageId)
-  {
-    $maxwidth = $maxheight = null;
+    /**
+     * Create a thumbnail derivative for the current digital object
+     *
+     * @return QubitDigitalObject
+     */
+    public function createThumbnail()
+    {
+      // Create a thumbnail
+      $derivative = $this->createImageDerivative(QubitTerm::THUMBNAIL_ID);
 
-    switch ($usageId)
-    {
-      case QubitTerm::REFERENCE_ID:
-        // Backwards compatiblity - if maxwidth Qubit setting doesn't exist
-        if (!$maxwidth = sfConfig::get('app_reference_image_maxwidth'))
-        {
-          $maxwidth = 480;
-        }
-        break;
-      case QubitTerm::THUMBNAIL_ID:
-        $maxwidth = 100;
-        $maxheight = 100;
-        break;
+      return $derivative;
     }
 
-    return array($maxwidth, $maxheight);
-  }
+    /**
+     * Create a reference derivative for the current digital object
+     *
+     * @return QubitDigitalObject  The new derived reference digital object
+     */
+    public function createReferenceImage()
+    {
+      // Create derivative
+      $derivative = $this->createImageDerivative(QubitTerm::REFERENCE_ID);
 
-  /**
-   * Resize an image using the sfThubmnail Plugin.
-   *
-   * @param string $originalImageName
-   * @param string $newImageName
-   * @param integer $width
-   * @param integer $height
-   *
-   * @return boolean  success or failure
-   */
-  private static function resizeImage($originalImageName, $newImageName, 
$width=null, $height=null)
-  {
-    $mimeType = QubitDigitalObject::deriveMimeType($originalImageName);
-
-    // Get thumbnail adapter
-    if (!$adapter = self::getThumbnailAdapter())
-    {
-      return false;
+      return $derivative;
     }
 
-    // Check that this file can be thumbnailed, or return false
-    if (self::canThumbnailMimeType($mimeType) == false)
+    /**
+     * Image file wrapper for calling createDerivative()
+     *
+     * @param integer  $usageId  usage type id
+     * @return mixed QubitDigitalObject on success, false on failure
+     *
+     * @see QubitDigitalObject::createDerivative()
+     */
+    public function createImageDerivative($usageId)
     {
-      return false;
-    }
+      $mechanism = array('QubitDigitalObject', 'resizeImage');
+      $extension = '.'.self::THUMB_EXTENSION;
 
-    // Create a thumbnail
-    $newImage = new sfThumbnail($width, $height, true, false, 75, $adapter, 
array('extract' => 1));
-    $newImage->loadFile($originalImageName);
-    $newImage->save($newImageName, self::THUMB_MIME_TYPE);
+      // Get max dimensions
+      $maxDimensions = self::getImageMaxDimensions($usageId);
 
-    // Test that file was created
-    if (!file_exists($newImageName))
-    {
+      if ($derivative = $this->createDerivative($mechanism, $extension, 
$maxDimensions))
+      {
+        $derivative->setUsageId($usageId);
+        $derivative->save();
+
+        return $derivative;
+      }
+
       return false;
     }
 
-    // Set access to thumbnail
-    chmod($newImageName, 0744);
+    /**
+     * Allow multiple ways of getting the max dimensions for image by usage
+     *
+     * @param integer $usageId  the usage type
+     * @return array $maxwidth, $maxheight
+     *
+     * @todo Add THUMBNAIL_MAX_DIMENSION to Qubit Settings
+     */
+    public static function getImageMaxDimensions($usageId)
+    {
+      $maxwidth = $maxheight = null;
 
-    // Return true on success
-    return true;
-  }
+      switch ($usageId)
+      {
+        case QubitTerm::REFERENCE_ID:
+          // Backwards compatiblity - if maxwidth Qubit setting doesn't exist
+          if (!$maxwidth = sfConfig::get('app_reference_image_maxwidth'))
+          {
+            $maxwidth = 480;
+          }
+          break;
+        case QubitTerm::THUMBNAIL_ID:
+          $maxwidth = 100;
+          $maxheight = 100;
+          break;
+      }
 
-  /**
-   * Get a valid adapter for the sfThumbnail library (either GD or ImageMagick)
-   *
-   * @return mixed  name of adapter on success, false on failure
-   */
-  public static function getThumbnailAdapter()
-  {
-    $adapter = false;
-    if (QubitDigitalObject::hasImageMagick())
-    {
-      $adapter = 'sfImageMagickAdapter';
+      return array($maxwidth, $maxheight);
     }
-    else if (QubitDigitalObject::hasGdExtension())
+
+    /**
+     * Resize an image using the sfThubmnail Plugin.
+     *
+     * @param string $originalImageName
+     * @param string $newImageName
+     * @param integer $width
+     * @param integer $height
+     *
+     * @return boolean  success or failure
+     */
+    private static function resizeImage($originalImageName, $newImageName, 
$width=null, $height=null)
     {
-      $adapter = 'sfGDAdapter';
-    }
+      $mimeType = QubitDigitalObject::deriveMimeType($originalImageName);
 
-    return $adapter;
-  }
+      // Get thumbnail adapter
+      if (!$adapter = self::getThumbnailAdapter())
+      {
+        return false;
+      }
 
-  /**
-   * Test if ImageMagick library is installed
-   *
-   * @return boolean  true if ImageMagick is found
-   */
-  public static function hasImageMagick()
-  {
-    $found = false;
+      // Check that this file can be thumbnailed, or return false
+      if (self::canThumbnailMimeType($mimeType) == false)
+      {
+        return false;
+      }
 
-    exec('convert -version', $stdout);
-    if (count($stdout) && strpos($stdout[0], 'ImageMagick') !== false)
-    {
-       $found = true;
-    }
+      // Create a thumbnail
+      $newImage = new sfThumbnail($width, $height, true, false, 75, $adapter, 
array('extract' => 1));
+      $newImage->loadFile($originalImageName);
+      $newImage->save($newImageName, self::THUMB_MIME_TYPE);
 
-    return $found;
-  }
+      // Test that file was created
+      if (!file_exists($newImageName))
+      {
+        return false;
+      }
 
-  /**
-   * Test if GD Extension for PHP is installed
-   *
-   * @return boolean true if GD extension found
-   */
-  public static function hasGdExtension()
-  {
-    $found = false;
-    if (extension_loaded('gd'))
-    {
-      $found = true;
+      // Set access to thumbnail
+      chmod($newImageName, 0744);
+
+      // Return true on success
+      return true;
     }
 
-    return $found;
-  }
+    /**
+     * Get a valid adapter for the sfThumbnail library (either GD or 
ImageMagick)
+     *
+     * @return mixed  name of adapter on success, false on failure
+     */
+    public static function getThumbnailAdapter()
+    {
+      $adapter = false;
+      if (QubitDigitalObject::hasImageMagick())
+      {
+        $adapter = 'sfImageMagickAdapter';
+      }
+      else if (QubitDigitalObject::hasGdExtension())
+      {
+        $adapter = 'sfGDAdapter';
+      }
 
-  /**
-   * Wrapper for canThumbnailMimeType() for use on instantiated objects
-   *
-   * @return boolean
-   * @see canThumbnailMimeType
-   */
-  public function canThumbnail()
-  {
-    return self::canThumbnailMimeType($this->getMimeType());
-  }
+      return $adapter;
+    }
 
-  /**
-   * Test if current digital object can be thumbnailed
-   *
-   * @param string    The current thumbnailing adapter
-   * @return boolean  true if thumbnail is possible
-   */
-  public static function canThumbnailMimeType($mimeType)
-  {
-    if (!$adapter = self::getThumbnailAdapter())
+    /**
+     * Test if ImageMagick library is installed
+     *
+     * @return boolean  true if ImageMagick is found
+     */
+    public static function hasImageMagick()
     {
-      return false;
-    }
+      $found = false;
 
-    $canThumbnail = false;
+      exec('convert -version', $stdout);
+      if (count($stdout) && strpos($stdout[0], 'ImageMagick') !== false)
+      {
+        $found = true;
+      }
 
-    // For Images, we can create thumbs with either GD or ImageMagick
-    if (substr($mimeType, 0, 5) == 'image' && strlen($adapter))
-    {
-      $canThumbnail = true;
+      return $found;
     }
 
-    // For PDFs we can only create thumbs with ImageMagick
-    else if ($mimeType == 'application/pdf' && $adapter == 
'sfImageMagickAdapter')
+    /**
+     * Test if GD Extension for PHP is installed
+     *
+     * @return boolean true if GD extension found
+     */
+    public static function hasGdExtension()
     {
-      $canThumbnail = true;
+      $found = false;
+      if (extension_loaded('gd'))
+      {
+        $found = true;
+      }
+
+      return $found;
     }
 
-    return $canThumbnail;
-  }
-
-  /**
-   * Return true if derived mimeType is "image/*"
-   *
-   * @param string $filename
-   * @return boolean
-   */
-  public static function isImageFile($filename)
-  {
-    $mimeType = self::deriveMimeType($filename);
-    if (strtolower(substr($mimeType, 0, 5)) == 'image')
+    /**
+     * Wrapper for canThumbnailMimeType() for use on instantiated objects
+     *
+     * @return boolean
+     * @see canThumbnailMimeType
+     */
+    public function canThumbnail()
     {
-      return true;
+      return self::canThumbnailMimeType($this->getMimeType());
     }
-    else
+
+    /**
+     * Test if current digital object can be thumbnailed
+     *
+     * @param string    The current thumbnailing adapter
+     * @return boolean  true if thumbnail is possible
+     */
+    public static function canThumbnailMimeType($mimeType)
     {
-      return false;
-    }
-  }
+      if (!$adapter = self::getThumbnailAdapter())
+      {
+        return false;
+      }
 
-  /*
-   * -----------------------------------------------------------------------
-   * VIDEO
-   * -----------------------------------------------------------------------
-   */
+      $canThumbnail = false;
 
-  /**
-   * Video file wrapper for calling createDerivative()
-   *
-   * @param integer  $usageId  usage type id
-   * @return mixed QubitDigitalObject on success, false on failure
-   *
-   * @see QubitDigitalObject::createDerivative()
-   */
-  public function createVideoDerivative($usageId)
-  {
-    switch ($usageId)
-    {
-      case QubitTerm::REFERENCE_ID:
-        $mechanism = array('QubitDigitalObject', 'convertVideoToFlash');
-        $extension = '.flv';
-        $maxDimensions = array(null, null);
-        break;
-      case QubitTerm::THUMBNAIL_ID:
-      default:
-        $mechanism = array('QubitDigitalObject', 'convertVideoToThumbnail');
-        $extension = '.'.self::THUMB_EXTENSION;
-        $maxDimensions = self::getImageMaxDimensions($usageId);
-        break;
+      // For Images, we can create thumbs with either GD or ImageMagick
+      if (substr($mimeType, 0, 5) == 'image' && strlen($adapter))
+      {
+        $canThumbnail = true;
+      }
+
+      // For PDFs we can only create thumbs with ImageMagick
+      else if ($mimeType == 'application/pdf' && $adapter == 
'sfImageMagickAdapter')
+      {
+        $canThumbnail = true;
+      }
+
+      return $canThumbnail;
     }
 
-    if ($derivative = $this->createDerivative($mechanism, $extension, 
$maxDimensions))
+    /**
+     * Return true if derived mimeType is "image/*"
+     *
+     * @param string $filename
+     * @return boolean
+     */
+    public static function isImageFile($filename)
     {
-      $derivative->setUsageId($usageId);
-      $derivative->save();
-
-      return $derivative;
+      $mimeType = self::deriveMimeType($filename);
+      if (strtolower(substr($mimeType, 0, 5)) == 'image')
+      {
+        return true;
+      }
+      else
+      {
+        return false;
+      }
     }
 
-    return false;
-  }
+    /*
+     * -----------------------------------------------------------------------
+     * VIDEO
+     * -----------------------------------------------------------------------
+     */
 
-  /**
-   * Test if ImageMagick library is installed
-   *
-   * @return boolean  true if ImageMagick is found
-   */
-  public static function hasFfmpeg()
-  {
-    $found = true;
-
-    exec('ffmpeg -version', $stdout);
-    if (count($stdout) && strpos($stdout[0], 'FFmpeg') !== false)
+    /**
+     * Video file wrapper for calling createDerivative()
+     *
+     * @param integer  $usageId  usage type id
+     * @return mixed QubitDigitalObject on success, false on failure
+     *
+     * @see QubitDigitalObject::createDerivative()
+     */
+    public function createVideoDerivative($usageId)
     {
-       $found = true;
-    }
+      switch ($usageId)
+      {
+        case QubitTerm::REFERENCE_ID:
+          $mechanism = array('QubitDigitalObject', 'convertVideoToFlash');
+          $extension = '.flv';
+          $maxDimensions = array(null, null);
+          break;
+        case QubitTerm::THUMBNAIL_ID:
+        default:
+          $mechanism = array('QubitDigitalObject', 'convertVideoToThumbnail');
+          $extension = '.'.self::THUMB_EXTENSION;
+          $maxDimensions = self::getImageMaxDimensions($usageId);
+          break;
+      }
 
-    return $found;
-  }
+      if ($derivative = $this->createDerivative($mechanism, $extension, 
$maxDimensions))
+      {
+        $derivative->setUsageId($usageId);
+        $derivative->save();
 
-  /**
-   * Create a flash video derivative using the FFmpeg library.
-   *
-   * @param string  $originalPath path to original video
-   * @param string  $newPath      path to derivative video
-   * @param integer $maxwidth     derivative video maximum width
-   * @param integer $maxheight    derivative video maximum height
-   *
-   * @return boolean  success or failure
-   *
-   * @todo implement $maxwidth and $maxheight constraints on video
-   */
-  public static function convertVideoToFlash($originalPath, $newPath, 
$width=null, $height=null)
-  {
-    // Test for FFmpeg library
-    if (!self::hasFfmpeg())
-    {
+        return $derivative;
+      }
+
       return false;
     }
 
-    exec('ffmpeg -y -i '.$originalPath.' '.$newPath.' 2>&1', $stdout, 
$returnValue);
+    /**
+     * Test if ImageMagick library is installed
+     *
+     * @return boolean  true if ImageMagick is found
+     */
+    public static function hasFfmpeg()
+    {
+      $found = true;
 
-    // If return value is non-zero, an error occured
-    if ($returnValue)
-    {
-      return false;
+      exec('ffmpeg -version', $stdout);
+      if (count($stdout) && strpos($stdout[0], 'FFmpeg') !== false)
+      {
+        $found = true;
+      }
+
+      return $found;
     }
 
-    return true;
-  }
+    /**
+     * Create a flash video derivative using the FFmpeg library.
+     *
+     * @param string  $originalPath path to original video
+     * @param string  $newPath      path to derivative video
+     * @param integer $maxwidth     derivative video maximum width
+     * @param integer $maxheight    derivative video maximum height
+     *
+     * @return boolean  success or failure
+     *
+     * @todo implement $maxwidth and $maxheight constraints on video
+     */
+    public static function convertVideoToFlash($originalPath, $newPath, 
$width=null, $height=null)
+    {
+      // Test for FFmpeg library
+      if (!self::hasFfmpeg())
+      {
+        return false;
+      }
 
-  /**
-   * Create a flash video derivative using the FFmpeg library.
-   *
-   * @param string  $originalPath path to original video
-   * @param string  $newPath      path to derivative video
-   * @param integer $maxwidth     derivative video maximum width
-   * @param integer $maxheight    derivative video maximum height
-   *
-   * @return boolean  success or failure
-   *
-   * @todo implement $maxwidth and $maxheight constraints on video
-   */
-  public static function convertVideoToThumbnail($originalPath, $newPath, 
$width=null, $height=null)
-  {
-    // Test for FFmpeg library
-    if (!self::hasFfmpeg())
-    {
-      return false;
+      exec('ffmpeg -y -i '.$originalPath.' '.$newPath.' 2>&1', $stdout, 
$returnValue);
+
+      // If return value is non-zero, an error occured
+      if ($returnValue)
+      {
+        return false;
+      }
+
+      return true;
     }
 
-    // Do conversion to jpeg
-    $cmd = 'ffmpeg -i '.$originalPath.' -vcodec jpeg -vframes 1 -an -f 
rawvideo -s '.$width.'x'.$height.' '.$newPath;
-    exec($cmd.' 2>&1', $stdout, $returnValue);
+    /**
+     * Create a flash video derivative using the FFmpeg library.
+     *
+     * @param string  $originalPath path to original video
+     * @param string  $newPath      path to derivative video
+     * @param integer $maxwidth     derivative video maximum width
+     * @param integer $maxheight    derivative video maximum height
+     *
+     * @return boolean  success or failure
+     *
+     * @todo implement $maxwidth and $maxheight constraints on video
+     */
+    public static function convertVideoToThumbnail($originalPath, $newPath, 
$width=null, $height=null)
+    {
+      // Test for FFmpeg library
+      if (!self::hasFfmpeg())
+      {
+        return false;
+      }
 
-    // If return value is non-zero, an error occured
-    if ($returnValue)
-    {
-      return false;
+      // Do conversion to jpeg
+      $cmd = 'ffmpeg -i '.$originalPath.' -vcodec jpeg -vframes 1 -an -f 
rawvideo -s '.$width.'x'.$height.' '.$newPath;
+      exec($cmd.' 2>&1', $stdout, $returnValue);
+
+      // If return value is non-zero, an error occured
+      if ($returnValue)
+      {
+        return false;
+      }
+
+      return true;
     }
-
-    return true;
-  }
 }

Modified: trunk/qubit/lib/model/QubitTerm.php
===================================================================
--- trunk/qubit/lib/model/QubitTerm.php 2008-11-25 17:55:42 UTC (rev 1617)
+++ trunk/qubit/lib/model/QubitTerm.php 2008-11-26 21:11:11 UTC (rev 1618)
@@ -407,7 +407,7 @@
       WHERE '.QubitObjectTermRelation::TERM_ID.' = '.$this->getId().';';
 
     $conn = Propel::getConnection();
-    $stmt = $conn->prepareStatement($sql);
+    $stmt = $conn->prepare($sql);
     $rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
     $rs->next();
 


--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to