Ejemplo n.º 1
0
 public static function saveFile($file, $form)
 {
     if (!is_uploaded_file($file['tmp_name'])) {
         return $form;
     }
     $fileName = mediaUtils::fixFileName($file['name']);
     $fileDir = dir::media($fileName);
     $extension = substr(strrchr($fileName, '.'), 1);
     // z.B. jpg
     $badExtensions = dyn::get('addons')['badExtensions'];
     // Wenn die Datei eine "verbotene" Datei ist
     if (in_array($extension, $badExtensions)) {
         $form->setSave(false);
         $form->setErrorMessage(sprintf(lang::get('media_error_bad_extension'), $file['name']));
         return $form;
     }
     if ($form->isEditMode()) {
         $media = new media(type::super('id', 'int', 0));
     }
     // Wenn Datei nicht Existiert
     // Oder man möchte sie überspeichern
     if ($form->isEditMode() && $media->get('filename') != $fileName || !$form->isEditMode() && file_exists($fileDir)) {
         $form->setSave(false);
         $form->setErrorMessage(sprintf(lang::get('media_error_already_exist'), $file['name']));
         return $form;
     }
     if (!move_uploaded_file($file['tmp_name'], $fileDir)) {
         $form->setSave(false);
         $form->setErrorMessage(sprintf(lang::get('media_error_move'), $file['name']));
         return $form;
     }
     $form->addPost('filename', $fileName);
     $form->addPost('size', filesize($fileDir));
     return $form;
 }
Ejemplo n.º 2
0
function getFile($id)
{
    $thisMedia = new media("files");
    $thisMedia->idMedia = $id;
    $media = $thisMedia->get();
    return current($media);
}
Ejemplo n.º 3
0
 public function query($debug = "")
 {
     global $thisSite;
     $mySelect = new mySelect(__FILE__);
     $mySelect->tables = $thisSite->PREFIXE_TBL_GEN . "articles";
     if ($this->fields == "") {
         $mySelect->fields = "*";
     } else {
         $mySelect->fields = $this->fields;
     }
     $mySelect->where = "actif=1 AND art = '" . $this->article . "'";
     if ($this->lg != "" && $this->lg != "all") {
         // si une langue est indiqué on l'utilise
         $mySelect->where .= " AND lg='" . $this->lg . "'";
     } else {
         if ($this->lg == "") {
             $mySelect->where .= " AND lg='" . $thisSite->current_lang . "'";
         }
     }
     if ($this->id != "") {
         $mySelect->where .= " AND id=" . $this->id;
     }
     if ($this->where != "") {
         $mySelect->where .= " AND " . $this->where;
     }
     if ($this->orderby == "") {
         $mySelect->orderby = "id ASC";
     } else {
         $mySelect->orderby = $this->orderby;
     }
     if ($this->limit != "") {
         $mySelect->limit = $this->limit;
     }
     $result = $mySelect->query($debug);
     // on ajoute les médias si demandé
     $whatMedias = explode(",", $this->medias);
     if (count($whatMedias) > 0) {
         foreach ($result as $x => $row) {
             foreach ($whatMedias as $media) {
                 $thisMedia = new media($this->article . "_" . $media);
                 $thisMedia->idParent = $row["id"];
                 $dataMedias = $thisMedia->get();
                 $result[$x][$media] = $dataMedias;
             }
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 public function getOutValue($sql)
 {
     $this->getDynValue($sql);
     foreach ($this->outVars[1] as $key => $type) {
         if (!$this->isType($type, $this->outVars[2][$key])) {
             continue;
         }
         $sqlEntry = strtolower($this->DynType) . $this->outVars[2][$key];
         $sqlEntry = $sql->get($sqlEntry);
         //DYN_MEDIA_ID bleibt unberührt
         if ($type == $this->DynType . '_ID') {
             //nothing
         } else {
             $class = new media($sqlEntry);
             $sqlEntry = $class->get('filename');
         }
         $this->content = str_replace($this->outVars[0][$key], $sqlEntry, $this->content);
     }
     return $this;
 }
Ejemplo n.º 5
0
    $table = table::factory(['class' => ['media-table']]);
    $table->setSql('SELECT * FROM ' . sql::table('media') . ' WHERE `category` = ' . $catId);
    $table->addRow()->addCell()->addCell()->addCell(lang::get('title'))->addCell(lang::get('file_type'))->addCell(lang::get('action'));
    $table->addCollsLayout('20, 50,*,100,110');
    $table->addSection('tbody');
    if ($table->numSql()) {
        while ($table->isNext()) {
            $media = new media($table->getSql());
            if (dyn::get('user')->hasPerm('media[edit]')) {
                $edit = '<a href="' . url::backend('media', ['subpage' => 'files', 'action' => 'edit', 'id' => $table->get('id')]) . '" class="btn btn-sm btn-default fa fa-pencil-square-o"></a>';
            }
            if (dyn::get('user')->hasPerm('media[delete]')) {
                $delete = '<a href="' . url::backend('media', ['subpage' => 'files', 'action' => 'delete', 'id' => $table->get('id')]) . '" class="btn btn-sm btn-danger fa fa-trash-o delete"></a>';
            }
            $checkbox = formCheckbox::factory('file[]', 0);
            $checkbox->add($media->get('id'), '');
            $table->addRow()->addCell($checkbox->get())->addCell($media->getIcon())->addCell($media->get('title'))->addCell($media->getExtension())->addCell('<span class="btn-group">' . $edit . $delete . '</span>');
            $table->next();
        }
        $button = formButton::factory('submit', lang::get('delete'));
        $button->addClass('btn');
        $button->addClass('btn-sm');
        $button->addClass('btn-default');
        $table->addRow(['class' => 'active'])->addCell('', ['colspan' => 4])->addCell($button->get());
    } else {
        $table->addRow()->addCell(lang::get('no_entries'), ['colspan' => 5]);
    }
    ?>
	
	<div class="row">
        <div class="col-lg-12">
Ejemplo n.º 6
0
if (!$catId) {
    $sql = sql::factory();
    $sql->query('SELECT id FROM ' . sql::table('media_cat') . ' ORDER BY id LIMIT 1')->result();
    $catId = $sql->get('id');
}
type::addSession('media_cat', $catId);
$table = table::factory(['class' => ['media-table']]);
$table->setSql('SELECT * FROM ' . sql::table('media') . ' WHERE `category` = ' . $catId);
$table->addRow()->addCell()->addCell(lang::get('title'))->addCell(lang::get('file_type'))->addCell(lang::get('action'));
$table->addCollsLayout('50,*,100,250');
$table->addSection('tbody');
if ($table->numSql()) {
    while ($table->isNext()) {
        $media = new media($table->getSql());
        $select = '<button data-id="' . $table->get('id') . '" data-name="' . $table->get('filename') . '" data-loading-text="' . lang::get('selected') . '" class="btn btn-sm btn-warning dyn-media-select">' . lang::get('select') . '</button>';
        $table->addRow()->addCell($media->getIcon())->addCell($media->get('title'))->addCell($media->getExtension())->addCell('<span class="btn-group">' . $select . '</span>');
        $table->next();
    }
} else {
    $table->addRow()->addCell(lang::get('no_entries'), ['colspan' => 4]);
}
?>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title pull-left"><?php 
echo lang::get('media');
?>
</h3>
                    <?php