Exemple #1
0
 $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'), '');
         if ($media->isImage()) {
             $icon = '<img src="' . $media->getPath() . '" />';
         } else {
             $icon = '<i class="fa fa-file"></i>';
         }
         $table->addRow()->addCell($checkbox->get())->addCell($icon)->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]);
 }