Example #1
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = sfFileGalleryPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setGroupId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUuid($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEntity($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEntityId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setName($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setMimeType($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setSize($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setSuffix($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setTitle($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setDescription($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setUploadedBy($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setCreatedAt($arr[$keys[12]]);
     }
 }
Example #2
0
  <h3><a id="files"><?php 
echo ucwords(__('Files'));
?>
</a></h3>
  <div style='background-color:#D9E1FF;border:1px solid #72BE44;padding: 4px;'>
    <?php 
if ($task->getProject()->hasPermission('create-task')) {
    ?>
<div style="border-bottom: 1px solid white; padding-bottom: 2px;margin-bottom: 4px;"> <?php 
    echo file_link_to_add('task', $task->getId(), array('icon' => 'true', 'modalbox' => 'true'));
    ?>
</div><?php 
}
?>
      <?php 
foreach (sfFileGalleryPeer::getFiles('task', $task->getId()) as $file) {
    ?>
        <div class="file-holder">
          <span style="float:right;"><?php 
    echo 'Added by ' . link_to("Sean Grove", '#') . ' on ' . format_date($file->getCreatedAt());
    ?>
</span><?php 
    echo link_to($file->getName(), "@download_file?id=" . $file->getUuid());
    ?>
          <div style="border-top:1px solid white;margin-top:2px;padding-top:4px;"><?php 
    echo $file->getDescription();
    ?>
</div>
        </div>

      <?php 
Example #3
0
 public static function retrieveByUuid($uuid)
 {
     $c = new Criteria();
     $c->add(sfFileGalleryPeer::UUID, $uuid);
     return sfFileGalleryPeer::doSelectOne($c);
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(sfFileGalleryPeer::ID, $pks, Criteria::IN);
         $objs = sfFileGalleryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #5
0
 public function countsfFileGallerys($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BasesfFileGalleryPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(sfFileGalleryPeer::UPLOADED_BY, $this->getId());
     return sfFileGalleryPeer::doCount($criteria, $distinct, $con);
 }
Example #6
0
function get_nb_files($entity, $entity_id)
{
    return sfFileGalleryPeer::getNbFiles($entity, $entity_id);
}
Example #7
0
 /**
  * Executes Download action
  *
  */
 public function executeDownload()
 {
     $this->forward404Unless($fileInfo = sfFileGalleryPeer::retrieveByUuid($this->getRequestParameter('id')));
     $filePath = sfConfig::get('sf_upload_dir') . '/files/' . $fileInfo->getUuid();
     if (!is_file($filePath)) {
         $this->forward404('No file found at [' . $filePath . ']');
     }
     $this->getResponse()->clearHttpHeaders();
     $this->getResponse()->addCacheControlHttpHeader("Cache-control", "private");
     $this->getResponse()->setHttpHeader("Content-Description", "File Transfer");
     $this->getResponse()->setContentType('application/octet-stream', TRUE);
     $this->getResponse()->setHttpHeader("Content-Length", (string) filesize($filePath), TRUE);
     $this->getResponse()->setHttpHeader('content-transfer-encoding', 'binary', TRUE);
     $this->getResponse()->setHttpHeader("Content-Disposition", "attachment; filename=" . urlencode($fileInfo->getName()), TRUE);
     $this->getResponse()->sendHttpHeaders();
     $fp = fopen($filePath, 'rb');
     while (!feof($fp)) {
         set_time_limit(0);
         $buffer = fread($fp, 1024 * 1024);
         // can set amount to read lower, this is just an example.
         echo $buffer;
         ob_flush();
         flush();
     }
     fclose($fp);
     return sfView::NONE;
 }