Esempio n. 1
0
 public function buildTableFromFileCollection(Collection $files, $limit = 20, $selected = NULL)
 {
     $table = Table::fromGlobals(array('autosort' => TRUE, 'limit' => $limit, 'class' => 'file-list'));
     $table->setColumns(array('title_or_name' => array('encode' => FALSE), 'file_type', 'date_added'));
     $table->setNoResultsText(lang('no_uploaded_files'));
     if (empty($_GET['sort_col'])) {
         $table->config['sort_col'] = 'date_added';
         $table->config['sort_dir'] = 'desc';
     }
     $data = array();
     foreach ($files as $file) {
         if (!$file->getUploadDestination() || $this->hasFileGroupAccessPrivileges($file->getUploadDestination()) === FALSE || !$file->exists()) {
             continue;
         }
         $column = array($file->title . '<br><em class="faded">' . $file->file_name . '</em>', $file->mime_type, ee()->localize->human_time($file->upload_date));
         $attrs = array('data-id' => $file->file_id, 'data-url' => ee('CP/URL')->make($this->controller, array('file' => $file->file_id)));
         if ($file->file_id == $selected) {
             $attrs = array('class' => 'selected');
             $column[0] = '<span></span>' . $column[0];
         }
         $data[] = array('attrs' => $attrs, 'columns' => $column);
     }
     $table->setData($data);
     return $table;
 }
Esempio n. 2
0
use EllisLab\ExpressionEngine\Service\URL;
use EllisLab\ExpressionEngine\Service\Validation;
use EllisLab\ExpressionEngine\Service\View;
use EllisLab\Addons\Spam\Service\Spam;
// TODO should put the version in here at some point ...
return array('author' => 'EllisLab', 'name' => 'ExpressionEngine', 'description' => 'The worlds most flexible content management system.', 'namespace' => 'EllisLab\\ExpressionEngine', 'services' => array('CP/EntryListing' => function ($ee, $search_value) {
    return new EntryListing\EntryListing(ee()->config->item('site_id'), ee()->session->userdata['group_id'] == 1, array_keys(ee()->session->userdata['assigned_channels']), ee()->localize->now, $search_value);
}, 'CP/Filter' => function ($ee) {
    $filters = new Filter\FilterFactory($ee->make('View', '_shared/filters'));
    $filters->setDIContainer($ee);
    return $filters;
}, 'CP/GridInput' => function ($ee, $config = array()) {
    $grid = new Library\CP\GridInput($config, ee()->cp, ee()->config, ee()->javascript);
    return $grid;
}, 'CP/Table' => function ($ee, $config = array()) {
    return Library\CP\Table::fromGlobals($config);
}, 'CP/URL' => function ($ee, $path = NULL) {
    $cp_url = ee()->config->item('cp_url');
    $site_index = ee()->functions->fetch_site_index(0, 0);
    $uri_string = ee()->uri->uri_string();
    $session_id = ee()->session->session_id();
    $default_cp_url = SELF;
    $factory = new URL\URLFactory($cp_url, $site_index, $uri_string, $session_id, $default_cp_url);
    return is_null($path) ? $factory : $factory->make($path);
}, 'CP/Pagination' => function ($ee, $total_count) {
    $view = $ee->make('View')->make('_shared/pagination');
    return new Library\CP\Pagination($total_count, $view);
}, 'CSV' => function ($ee) {
    return new Library\Data\CSV();
}, 'db' => function ($ee) {
    return $ee->make('Database')->newQuery();