Ejemplo n.º 1
0
 public static function initialize($idM, $idS, $taula, $idExtern, $i = 0)
 {
     $OM = MultimediaPeer::retrieveByPK($idM);
     if (!$OM instanceof Multimedia) {
         $OM = new Multimedia();
         $OM->setTaula($taula);
         $OM->setIdextern($idExtern);
         $OM->setSiteId($idS);
         $OM->setActiu(true);
     }
     return new MultimediaForm($OM, array('I' => $i, 'IDS' => $idS));
 }
 public function visualizarAdminMultimedia()
 {
     $response = 0;
     $noticia = Noticia::buscar_noticia($id_noticia);
     if (count($noticia) != 0) {
         $tipos = TipoMultimedia::lists('descripcion_tipo_multimedia', 'id_tipo_multimedia');
         if (count($tipos) != 0) {
             return View::make('pruebas.multimedia')->withMultimedias(Multimedia::listar_multimedias(3, $id_noticia))->withTipos($tipos)->withNoticia($noticia);
         } else {
             return View::make('pruebas.multimedia')->with('error', 'No existen tipos de multimedia');
         }
     } else {
         return View::make('pruebas.multimedia')->with('error', 'No existe una noticia para ingresar multimedia');
     }
 }
 private function saveFile($src, $file)
 {
     $tempfilepath = sfConfig::get("dw_tempFilePath", "/tmp/temp_file");
     $dest = fopen($tempfilepath, 'a');
     if (stream_copy_to_stream($src, $dest)) {
         $this->multimedia_data['uri'] = sha1(substr($file, strrpos($file, '/', strlen($file))) . rand());
         $this->multimedia_data['title'] = substr($file, strrpos($file, '/') + 1, strlen($file));
         $this->multimedia_data['mime_type'] = mime_content_type('/tmp/temp_file');
         $this->multimedia_data['type'] = "." . array_search($this->multimedia_data['mime_type'], Multimedia::$allowed_mime_type);
         if (!Multimedia::CheckMimeType($this->multimedia_data['mime_type'])) {
             throw new Exception('mauvais mime_type');
         }
         rename($tempfilepath, sfConfig::get('sf_upload_dir') . "/multimedia/temp/" . $this->multimedia_data['uri']);
     } else {
         return false;
     }
     fclose($dest);
 }
Ejemplo n.º 4
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Multimedia $value A Multimedia object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Multimedia $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getMultimediaId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 5
0
 public function executeDownloadFile(sfWebRequest $request)
 {
     $this->setLayout(false);
     $report = Doctrine::getTable('Reports')->find($request->getParameter('id'));
     if (!in_array($report->getName(), array_keys(Reports::getGlobalReports($this->getUser())))) {
         return $this->forwardToSecureAction();
     }
     $this->forward404Unless(file_exists($uri = sfConfig::get('sf_upload_dir') . $report->getUri()), sprintf('This file does not exist'));
     $response = $this->getResponse();
     // First clear HTTP headers
     $response->clearHttpHeaders();
     // Then define the necessary headers
     $response->setContentType(Multimedia::getMimeTypeFor($report->getFormat()));
     $response->setHttpHeader('Content-Disposition', 'attachment; filename="' . $report->getName() . "." . $report->getFormat() . '"');
     $response->setHttpHeader('Content-Description', 'File Transfer');
     $response->setHttpHeader('Content-Transfer-Encoding', 'binary');
     $response->setHttpHeader('Content-Length', filesize($uri));
     $response->setHttpHeader('Cache-Control', 'public, must-revalidate');
     // if https then always give a Pragma header like this  to overwrite the "pragma: no-cache" header which
     // will hint IE8 from caching the file during download and leads to a download error!!!
     $response->setHttpHeader('Pragma', 'public');
     $response->sendHttpHeaders();
     ob_end_flush();
     return $this->renderText(readfile($uri));
 }
Ejemplo n.º 6
0
 public function executeAdd(sfWebRequest $request)
 {
     if ($this->getUser()->isA(Users::REGISTERED_USER)) {
         $this->forwardToSecureAction();
     }
     $file_record = null;
     if ($request->hasParameter('rid')) {
         $file_record = Doctrine::getTable('Multimedia')->find($request->getParameter('rid'));
     }
     if (!$file_record) {
         $this->forward404Unless($request->hasParameter('id') && $request->hasParameter('table') && $request->hasParameter('file_id'));
         $file = $this->getUser()->getAttribute($request->getParameter('file_id'));
         $file_record = new Multimedia();
         $file_record->fromArray($file);
         $file_record->setReferencedRelation($request->getParameter('table'));
         $file_record->setRecordId($request->getParameter('id'));
     }
     $this->form = new MultimediaForm($file_record);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('multimedia'));
         if ($this->form->isValid()) {
             try {
                 if ($this->form->getObject()->isNew()) {
                     $this->form->setRecordRef($request->getParameter('table'), $request->getParameter('id'));
                 }
                 $this->form->save();
                 $this->form->getObject()->refreshRelated();
                 $this->form = new MultimediaForm($this->form->getObject());
                 //Ugly refresh
                 return $this->renderText('ok');
             } catch (Doctrine_Exception $ne) {
                 $e = new DarwinPgErrorParser($ne);
                 $error = new sfValidatorError(new savedValidator(), $e->getMessage());
                 $this->form->getErrorSchema()->addError($error);
             }
         }
     }
 }
Ejemplo n.º 7
0
 function getList($pagina = 1, $orden = "", $nrpp = Constants::NRPP)
 {
     //Valor predeterminado -> Constante, si se lo paso, coge el valor.
     $ordenPredeterminado = "{$orden}, id, titulo, titulo_original, anio, numero_capitulos";
     if ($orden === "" || $orden === null) {
         $ordenPredeterminado = "id, titulo, titulo_original, anio, numero_capitulos";
     }
     $registroInicial = ($pagina - 1) * $nrpp;
     $this->bd->select($this->tabla, "*", "1=1", array(), $ordenPredeterminado, " {$registroInicial}, {$nrpp}");
     $r = array();
     while ($fila = $this->bd->getRow()) {
         $multimedia = new Multimedia();
         $multimedia->set($fila);
         $r[] = $multimedia;
     }
     return $r;
     //Devuelve un array de multimedia.
 }
Ejemplo n.º 8
0
 public function buscarMultimedia()
 {
     $response = 0;
     $id = e(Input::get('id_multimedia'));
     $response = Multimedia::buscar_multimedia($id);
     if (count($response) != 0) {
         return Redirect::to(URL::previous())->withMensaje($response->id_multimedia);
     } else {
         return Redirect::to(URL::previous())->withMensaje('No se ha encontrado multimedia!');
     }
 }
Ejemplo n.º 9
0
          $(this).closest('table.related_files').find('thead').hide();
        }
      });
    </script>
  </td>
</tr>
<tr class="row_num_<?php 
echo $row_num;
?>
">
  <td>
    <?php 
if (isset($edit)) {
    ?>
      <?php 
    if (Multimedia::canBePreviewed($form['mime_type']->getValue())) {
        ?>
        <a href="<?php 
        echo url_for('multimedia/downloadFile?id=' . $form['id']->getValue());
        ?>
"><img src="<?php 
        echo url_for('multimedia/preview?id=' . $form['id']->getValue());
        ?>
" width="100" /></a>
      <?php 
    } else {
        ?>
        <?php 
        echo link_to($form['filename']->getValue() . " " . image_tag('criteria.png'), 'multimedia/downloadFile?id=' . $form['id']->getValue());
        ?>
      <?php