Exemplo n.º 1
0
 public static function getListFormats()
 {
     $models = FileFormat::model()->findAll();
     $list = array();
     foreach ($models as $key => $model) {
         $list[$model->id] = $model->name;
         $list[$model->id . '_description'] = $model->description;
     }
     return $list;
 }
Exemplo n.º 2
0
                    ?>
                    <tr>
                        <?
                        echo $form->hiddenField($file, '[' . $i . ']extension');
                        echo $form->hiddenField($file, '[' . $i . ']id');
                        echo $form->hiddenField($file, '[' . $i . ']dataset_id');
                        echo $form->hiddenField($file, '[' . $i . ']location');
                        echo $form->hiddenField($file, '[' . $i . ']extension');
                        ?>

                        <td class="left"><?php echo $file->name ?></td>
                        <td class="left"><?= CHtml::activeDropDownList($file, '[' . $i . ']code', $samples_data, array('class' => 'span2')); ?></td>

                        <td class="left"><?= CHtml::activeDropDownList($file, '[' . $i . ']type_id', CHtml::listData(FileType::model()->findAll(), 'id', 'name'), array('class' => 'span2')); ?></td>

                        <td> <?= CHtml::activeDropDownList($file, '[' . $i . ']format_id', CHtml::listData(FileFormat::model()->findAll(), 'id', 'name'), array('class' => 'autowidth')); ?></td>
                        <td><span style="display:none"><?= File::staticGetSizeType($file->size) . ' ' . strlen($file->size) . ' ' . $file->size ?></span><?= MyHtml::encode(File::staticBytesToSize($file->size)) ?></td>

                        <td><?php echo $form->textArea($file, '[' . $i . ']description', array('rows' => 3, 'cols' => 30, 'style' => 'resize:none')); ?></td>

                        <td> <?php echo CHtml::submitButton("Update", array('class' => 'update btn', 'name' => $i)); ?> </td>
                    </tr>

                    <?
                    $i++;
                }
                ?>

            </table>
        </div>
        <div class="span12" style="text-align:center">
Exemplo n.º 3
0
 public function updateFile($f, $data)
 {
     $f->name = $data[0];
     $f->code = $data[1];
     $type = $f->type;
     $format = $f->format;
     if ($data[2] != $type->name) {
         $nt = FileType::model()->find(array('condition' => 'lower(name) = :name', 'params' => array(':name' => strtolower($data[2]))));
         if ($nt) {
             $f->type_id = $nt->id;
         } else {
             $nt = FileType::model()->findByAttributes(array('name' => 'Other'));
             if (!$nt) {
                 $nt = new FileType();
                 $nt->name = 'Other';
                 $nt->save();
             }
             $f->type_id = $nt->id;
         }
     }
     if ($data[3] != $format->name) {
         $nf = FileFormat::model()->find(array('condition' => 'lower(name) =:name', 'params' => array(':name' => strtolower($data[3]))));
         if ($nf) {
             $f->format_id = $nf->id;
         } else {
             $nf = FileFormat::model()->findByAttributes(array('name' => 'UNKNOWN'));
             if (!$nf) {
                 $nf->name = 'UNKNOWN';
                 $nf->save();
             }
             $f->format_id = $nf->id;
         }
     }
     $f->description = $data[4];
     if (!$f->save()) {
         Yii::log(print_r($f->getErrors(), true), 'debug');
     }
     return;
 }
Exemplo n.º 4
0
 public function get_image_file_formats()
 {
     $file_formats = FileFormat::find(array("conditions" => "accept ='T' AND type='image' "))->toArray();
     $image_ext = array();
     foreach ($file_formats as $file) {
         array_push($image_ext, $file['extension']);
     }
     $file_extensions = array('image_ext' => $image_ext, 'accept_file_types' => $this->get_accept_file_types($file_formats));
     return $file_extensions;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = FileFormat::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 6
0
				<?php 
echo $form->textField($model, 'date_stamp', array('class' => 'date'));
?>
				<?php 
echo $form->error($model, 'date_stamp');
?>
			</div>
		</div>

		<div class="control-group">
			<?php 
echo $form->labelEx($model, 'format_id', array('class' => 'control-label'));
?>
			<div class="controls">
	        	<?php 
echo CHtml::activeDropDownList($model, 'format_id', CHtml::listData(FileFormat::model()->findAll(), 'id', 'name'));
?>
				<?php 
echo $form->error($model, 'format_id');
?>
			</div>
		</div>

		<div class="control-group">
			<?php 
echo $form->labelEx($model, 'type_id', array('class' => 'control-label'));
?>
			<div class="controls">
	        	<?php 
echo CHtml::activeDropDownList($model, 'type_id', CHtml::listData(FileType::model()->findAll(), 'id', 'name'));
?>
Exemplo n.º 7
0
 private function getFileFormat($format)
 {
     $file_format = FileFormat::model()->find("name=?", array($format));
     if ($file_format == null) {
         $file_format = new FileFormat();
         $file_format->name = $format;
         $file_format->description = " ";
         $file_format->save(false);
     }
     return $file_format->id;
 }
Exemplo n.º 8
0
 public static function getFormatList($ids)
 {
     $crit = new CDbCriteria();
     $crit->join = "join file on file.format_id = t.id";
     $crit->addInCondition("file.id", $ids);
     return FileFormat::model()->findAll($crit);
 }