Exemple #1
0
 /**
  * Prints out a Table of all media items
  */
 function LibraryGrid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     //Get the input params and store them
     $filter_type = Kit::GetParam('filter_type', _REQUEST, _WORD);
     $filter_name = Kit::GetParam('filter_name', _REQUEST, _STRING);
     $filterId = Kit::GetParam('filterId', _REQUEST, _INT);
     $filter_userid = Kit::GetParam('filter_owner', _REQUEST, _INT);
     $filter_retired = Kit::GetParam('filter_retired', _REQUEST, _INT);
     $filter_duration_in_seconds = Kit::GetParam('filter_duration_in_seconds', _REQUEST, _CHECKBOX);
     $filter_showThumbnail = Kit::GetParam('filter_showThumbnail', _REQUEST, _CHECKBOX);
     $showTags = Kit::GetParam('showTags', _REQUEST, _CHECKBOX);
     setSession('content', 'filter_type', $filter_type);
     setSession('content', 'filter_name', $filter_name);
     setSession('content', 'filterId', $filterId);
     setSession('content', 'filter_owner', $filter_userid);
     setSession('content', 'filter_retired', $filter_retired);
     setSession('content', 'filter_duration_in_seconds', $filter_duration_in_seconds);
     setSession('content', 'filter_showThumbnail', $filter_showThumbnail);
     setSession('content', 'showTags', $showTags);
     setSession('content', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
     // Reset the mediaId filter if it is empty (we have to do this after we have stored it in the session)
     $filterId = $filterId == 0 ? -1 : $filterId;
     // Construct the SQL
     $mediaList = $user->MediaList(NULL, array('type' => $filter_type, 'name' => $filter_name, 'mediaId' => $filterId, 'ownerid' => $filter_userid, 'retired' => $filter_retired, 'showTags' => $showTags));
     $cols = array();
     $cols[] = array('name' => 'mediaid', 'title' => __('ID'));
     $cols[] = array('name' => 'tags', 'title' => __('Tag'), 'hidden' => $showTags == 0, 'colClass' => 'group-word');
     $cols[] = array('name' => 'media', 'title' => __('Name'));
     $cols[] = array('name' => 'mediatype', 'title' => __('Type'));
     if ($filter_showThumbnail == 1) {
         $cols[] = array('name' => 'thumbnail', 'title' => __('Thumbnail'));
     }
     $cols[] = array('name' => 'duration_text', 'title' => __('Duration'));
     $cols[] = array('name' => 'size_text', 'title' => __('Size'), 'sorter' => 'filesize');
     $cols[] = array('name' => 'owner', 'title' => __('Owner'));
     $cols[] = array('name' => 'permissions', 'title' => __('Permissions'));
     $cols[] = array('name' => 'revised', 'title' => __('Revised?'), 'icons' => true);
     $cols[] = array('name' => 'filename', 'title' => __('File Name'));
     Theme::Set('table_cols', $cols);
     $rows = array();
     // Add some additional row content
     foreach ($mediaList as $row) {
         $row['duration_text'] = $filter_duration_in_seconds == 1 ? $row['duration'] : sec2hms($row['duration']);
         $row['owner'] = $user->getNameFromID($row['ownerid']);
         $row['permissions'] = $group = $this->GroupsForMedia($row['mediaid']);
         $row['revised'] = $row['parentid'] != 0 ? 1 : 0;
         // Display a friendly file size
         $row['size_text'] = Kit::FormatBytes($row['filesize']);
         // Thumbnail URL
         $row['thumbnail'] = '';
         if ($row['mediatype'] == 'image') {
             $row['thumbnail'] = '<a class="img-replace" data-toggle="lightbox" data-type="image" data-img-src="index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $row['mediaid'] . '&width=100&height=100&dynamic=true&thumb=true" href="index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $row['mediaid'] . '"><i class="fa fa-file-image-o"></i></a>';
         }
         $row['buttons'] = array();
         // Buttons
         if ($row['edit'] == 1) {
             // Edit
             $row['buttons'][] = array('id' => 'content_button_edit', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=EditForm&mediaid=' . $row['mediaid'], 'text' => __('Edit'));
         }
         if ($row['del'] == 1) {
             // Delete
             $row['buttons'][] = array('id' => 'content_button_delete', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=DeleteForm&mediaid=' . $row['mediaid'], 'text' => __('Delete'));
         }
         if ($row['modifyPermissions'] == 1) {
             // Permissions
             $row['buttons'][] = array('id' => 'content_button_permissions', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=PermissionsForm&mediaid=' . $row['mediaid'], 'text' => __('Permissions'));
         }
         // Download
         $row['buttons'][] = array('id' => 'content_button_download', 'linkType' => '_self', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=GetResource&download=1&downloadFromLibrary=1&mediaid=' . $row['mediaid'], 'text' => __('Download'));
         // Add to the collection
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('table_render');
     $response->SetGridResponse($output);
     $response->initialSortColumn = 2;
     $response->Respond();
 }
Exemple #2
0
 /**
  * Prints out a Table of all media items
  */
 function LibraryGrid()
 {
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     //Get the input params and store them
     $filter_type = Kit::GetParam('filter_type', _REQUEST, _WORD);
     $filter_name = Kit::GetParam('filter_name', _REQUEST, _STRING);
     $filter_userid = Kit::GetParam('filter_owner', _REQUEST, _INT);
     $filter_retired = Kit::GetParam('filter_retired', _REQUEST, _INT);
     $filter_duration_in_seconds = Kit::GetParam('filter_duration_in_seconds', _REQUEST, _CHECKBOX);
     setSession('content', 'filter_type', $filter_type);
     setSession('content', 'filter_name', $filter_name);
     setSession('content', 'filter_owner', $filter_userid);
     setSession('content', 'filter_retired', $filter_retired);
     setSession('content', 'filter_duration_in_seconds', $filter_duration_in_seconds);
     setSession('content', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off'));
     // Construct the SQL
     $mediaList = $user->MediaList($filter_type, $filter_name, $filter_userid, $filter_retired);
     $rows = array();
     // Add some additional row content
     foreach ($mediaList as $row) {
         $row['duration_text'] = $filter_duration_in_seconds == 1 ? $row['duration'] : sec2hms($row['duration']);
         $row['owner'] = $user->getNameFromID($row['ownerid']);
         $row['permissions'] = $group = $this->GroupsForMedia($row['mediaid']);
         $row['revised'] = $row['parentid'] != 0 ? Theme::Image('act.gif') : '';
         // Display a friendly file size
         $row['size_text'] = Kit::FormatBytes($row['filesize']);
         $row['buttons'] = array();
         // Buttons
         if ($row['edit'] == 1) {
             // Edit
             $row['buttons'][] = array('id' => 'content_button_edit', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=EditForm&mediaid=' . $row['mediaid'], 'text' => __('Edit'));
         }
         if ($row['del'] == 1) {
             // Delete
             $row['buttons'][] = array('id' => 'content_button_delete', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=DeleteForm&mediaid=' . $row['mediaid'], 'text' => __('Delete'));
         }
         if ($row['modifyPermissions'] == 1) {
             // Permissions
             $row['buttons'][] = array('id' => 'content_button_permissions', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=PermissionsForm&mediaid=' . $row['mediaid'], 'text' => __('Permissions'));
         }
         // Download
         $row['buttons'][] = array('id' => 'content_button_download', 'url' => 'index.php?p=module&mod=' . $row['mediatype'] . '&q=Exec&method=GetResource&download=1&mediaid=' . $row['mediaid'], 'text' => __('Download'));
         // Add to the collection
         $rows[] = $row;
     }
     Theme::Set('table_rows', $rows);
     $output = Theme::RenderReturn('library_page_grid');
     $response->SetGridResponse($output);
     $response->initialSortColumn = 2;
     $response->Respond();
 }