| 
					
				 | 
			
			
				@@ -1,53 +1,211 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <?php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * Provides the page with a list of files uploaded by the user. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * @param $uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- *   The user ID. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- *   A Drupal render array. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- function tripal_user_files_page($uid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   // Get all of the files that have been uploaded by the user. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   // TODO: we should make this a paged query in case a user has a huge 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   // numbef of uploaded files. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   $sql = " 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-     SELECT FM.fid, FM.filename, TGEF.expiration_date 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function tripal_user_get_files($uid){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $directory = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Get all of the files that have been uploaded by the user. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $sql = " 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     SELECT FM.fid, FM.filename, FM.uri, FM.uid, FM.filesize, TGEF.expiration_date 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      FROM {file_managed} FM 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        INNER JOIN {file_usage} FU on FM.fid = FU.fid and FM.uid = :user_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        LEFT JOIN {tripal_expiration_files} TGEF on TGEF.fid = FU.fid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      WHERE FU.module = 'tripal' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      ORDER BY FM.filename 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   $files = db_query($sql, array(':user_id' => $uid)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   $rows = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   While ($entry = $files->fetchObject()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $file = file_load($entry->fid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $files = db_query($sql, array(':user_id' => $uid)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $rows = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  While ($file = $files->fetchObject()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Don't list files that don't exist on the file system. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (!file_exists($file->uri)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Files have to be in the User's directory. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!preg_match('/^public:\/\/tripal\/users\//', $file->uri)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // If the expiration date is somehow not set, then set it. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!$file->expiration_date) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $file->expiration_date = tripal_reset_file_expiration($file->fid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // Organize the file into it's directory structure. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rpath = preg_replace('/^public:\/\/tripal\/users\/'. $uid . '\//', '', $file->uri);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $paths = explode('/', $rpath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _tripal_user_build_files_dir($directory, $paths, $file);  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return $directory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/**  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * A recursive helper function for building the directory file tree. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $directory 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   The $directory array into which the file will be placed. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $paths 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   An containing the directory path of the file. Each Directory 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   is a separate element of the array. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $file 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   The file object to add to the $directory object. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function _tripal_user_build_files_dir(&$directory, $paths, $file) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $path = array_shift($paths); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (count($paths) == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $directory[$path] = $file; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    _tripal_user_build_files_dir($directory[$path], $paths, $file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $date_uploaded = date('Y-m-d H:i:s', $file->timestamp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $expiration = $entry->expiration_date ? date('Y-m-d H:i:s', $entry->expiration_date) : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $actions = l('Delete', "user/$uid/files/$file->fid/delete") . ' | ' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-               l('Renew', "user/$uid/files/$file->fid/renew"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/**  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * Generates an item list of the files. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * The results from this function can be passed to the theme_item_list function 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * and then themed as a file tree.. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $files_list 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   The array as returned by tripal_user_get_files(). 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @return  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   An item list. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function tripal_user_get_files_item_list($files_list, &$i = 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $items = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Add a header row 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if ($i == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $items[] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'data' => '<span><b>File</b></span>' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '<span class="file-expires"><b>Expires</b></span>' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '<span class="file-size"><b>Size</b></span>' , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Iterate through each file and recursively add it to our items array. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  foreach ($files_list as $filename => $file) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $i++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // If this is a folder then recurse. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (is_array($file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $items[] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => $filename, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'children' => tripal_user_get_files_item_list($file, $i), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'class' => ['tree-node-folder', 'tree-node-closed', ($i % 2 == 0) ? 'even' : 'odd'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // If this is a file then give details for it. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $datediff = $file->expiration_date - time(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $dayleft = round($datediff / (60 * 60 * 24)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if ($dayleft < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $dayleft = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $expiration = $file->expiration_date ? date('Y-m-d', $file->expiration_date) : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $items[] = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => '<span class="file-name">' . $filename . '</span>' .  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          '<span class="file-expires">' . $dayleft . ' days</span>' .  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          '<span class="file-size">' . tripal_format_bytes($file->filesize) . '</span>' , 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'class' => ['tree-node-file', ($i % 2 == 0) ? 'even' : 'odd'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'fid' => $file->fid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'uid' => $file->uid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return $items; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $entry->fid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      l($file->filename,"/user/$uid/files/$file->fid"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $date_uploaded, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $expiration, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      tripal_format_bytes($file->filesize), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      $actions, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * Gets the list of collections that have not yet generated files. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   The ID of the user. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function tripal_user_files_get_pending_collections_table($uid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collections = db_select('tripal_collection', 'tc') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->fields('tc', array('collection_id')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->condition('uid', $uid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->orderBy('tc.collection_name') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ->execute(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $headers = array('Name', 'Download Formats', 'Actions'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $rows = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  while ($collection_id = $collections->fetchField()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $collection = new TripalEntityCollection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $collection->load($collection_id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $downloads = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $formatters = $collection->getFormatters(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $formatter_labels = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $status = 'complete'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    foreach ($formatters as $class_name => $label) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $formatter_labels[] = $label; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $outfile = $collection->getOutfilePath($class_name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (file_exists($outfile)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $status = 'pending'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if ($status == 'pending') {     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $collection->getName(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          implode(', ', $formatters), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          l('Create Files', 'user/' . $uid . '/data-collections/generate/' . $collection_id) . ' | ' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          l('View', 'user/' . $uid . '/data-collections/' . $collection_id . '/view') . ' | ' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          l('Delete', 'user/' . $uid . '/data-collections/' . $collection_id . '/delete'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  $header = array('ID', 'File Name', 'Upload Date', 'Expiration', 'Size', 'Actions'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  return theme_table(array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'header' => $headers, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'rows' => $rows, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'attributes' => array(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'caption' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'colgroups' => array(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'sticky' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'empty' => t('You currently have no pending data collections.') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * Provides the page with a list of files uploaded by the user. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @param $uid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   The user ID. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *   A Drupal render array. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ function tripal_user_files_page($uid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  drupal_add_css(drupal_get_path('module', 'tripal') . '/theme/css/tripal_user_files.css'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  drupal_add_js(drupal_get_path('module', 'tripal') . '/theme/js/tripal.user_files.js', 'file'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $user_files = tripal_user_get_files($uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $items = tripal_user_get_files_item_list($user_files);   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $theme_files = theme_item_list([ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'items' => $items, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'title' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'type' => 'ul', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'attributes' => [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'id' => 'tripal-user-file-tree' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $data_collections = tripal_user_files_get_pending_collections_table($uid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Get the user quota settings. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $quota = tripal_get_user_quota($uid); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -56,11 +214,11 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $content = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     'page_title' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'markup', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#markup' => '<h2>Your Uploaded Files</h2>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#markup' => '<h2>Your Files</h2>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     'page_description' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'markup', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#markup' => '<p>' . t('Each user is allowed to consume a limited amount of space with uploaded files. This page provides details about your current usage, your limits and files you\'ve uploaded.') . '</p>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#markup' => '<p>' . t('Each user is allowed to consume a limited amount of space for files. This page provides details about your current usage, your limits and files in your account.') . '</p>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     'usage' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'item', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -78,20 +236,26 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'item', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#title' => 'Current Days to Expire', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#markup' => $quota->custom_expiration, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#description' => t('The number of days a file will remain on the server before deletion. The expiration of date of a file can be renewed using the "Renew" link in the table below.') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#description' => t('The number of days a file will remain on the server before deletion. The expiration of date of a file can be renewed by selecting the file name and then selecting the "Renew" link in the file details table.') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'data_collections' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#type' => 'item', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#title' => 'Pending Data Collections', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#markup' => $data_collections, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#description' =>  t('Data collections allow you to store custom sets of data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       for use on this site.  Typically data collections are created using search  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       tools.  The above data collections are waiting to be generated. You must 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       generate the files before you can use them.'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     'file_list' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       '#type' => 'item', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#title' => 'Uploaded Files', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#markup' => theme_table(array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'header' => $header, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'rows' => $rows, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'attributes' => array(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'caption' => t('Click a file name for more details.'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'colgroups' => array(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'sticky' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'empty' => 'You currently have no uploaded files.', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      )), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#title' => 'File Browser', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#markup' => $theme_files, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'file_details' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#type' => 'item', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#title' => 'File Details', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      '#markup' => '<div id="tripal-user-file-details">Click a file above for details.</div>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -211,12 +375,59 @@ function tripal_delete_file_form_submit($form, &$form_state) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function tripal_view_file($uid, $fid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $file = file_load($fid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $usage = file_usage_list($file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Check to see if this is a data collection.   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collection = NULL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collection_ctypes = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collection_field_list = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collection_formatters = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collection_entities = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (array_key_exists('tripal', $usage)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (array_key_exists('data_collection', $usage['tripal'])) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $collection_id = array_keys($usage['tripal']['data_collection'])[0]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $collection = new TripalEntityCollection(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $collection->load($collection_id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // Get the content types for this data collection. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $cbundles = $collection->getBundles();      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      foreach ($cbundles as $cbundle) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $eids = $collection->getEntityIDs($cbundle->bundle_name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $fields = $collection->getFieldIDs($cbundle->bundle_name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Convert local field IDs to their names. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!$cbundle->site_id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $bundle = tripal_load_bundle_entity(array('name' => $cbundle->bundle_name)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          $collection_ctypes[] = $bundle->label; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          foreach ($fields as $field_id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $field = field_info_field_by_id($field_id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $instance = field_info_instance('TripalEntity', $field['field_name'], $bundle->name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $collection_field_list[] = $instance['label']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $field_formatters = tripal_get_field_field_formatters($field, $instance); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            foreach ($field_formatters as $class_name => $label) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              tripal_load_include_downloader_class($class_name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              $collection_formatters[] = $class_name::$label . ' (' . $class_name::$full_label . ')'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Convert remote field IDs to their names. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // TODO: add in retrieval of remote details. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $collection_entities += count($eids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $headers = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $rows = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $actions = l('Delete', "user/$uid/files/$file->fid/delete") . '<br>' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-             l('Download', "user/$uid/files/$file->fid/download"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             l('Download', "user/$uid/files/$file->fid/download") . '<br>' . 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+             l('Renew', "user/$uid/files/$file->fid/renew"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // Name row 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $rows[] = array( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -231,7 +442,7 @@ function tripal_view_file($uid, $fid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $date_uploaded = date('Y-m-d H:i:s', $file->timestamp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      'data' => 'Upload Date', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'data' => 'Create Date', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ), 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -252,7 +463,18 @@ function tripal_view_file($uid, $fid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $expiration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $md5_file = $file->uri . '.md5'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if (file_exists($md5_file)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'MD5', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      file_get_contents($md5_file), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       'data' => 'Actions', 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -262,29 +484,82 @@ function tripal_view_file($uid, $fid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     $actions 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  $content = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    'description' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#type' => 'markup', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#markup' => '<p>' . t('The following file has been uploaded.') . '</p>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    'return' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#type' => 'markup', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#markup' => '<p>' . l('View all Uploaded Files', "user/$uid/files") . '</p>', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    'file_details' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#type' => 'markup', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      '#markup' => theme_table(array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'header' => $headers, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'rows' => $rows, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'attributes' => array(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'sticky' => FALSE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'caption' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'colgroups' => array(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        'empty' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      )), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  return $content; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $file_content = theme_table([ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'header' => $headers, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'rows' => $rows, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'attributes' => [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'sticky' => FALSE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'caption' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'colgroups' => [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    'empty' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $collection_content = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  if ($collection) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'Description', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      $collection->getDescription(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'Content types', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      join(', ', $collection_ctypes), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'Fields', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      join(', ', array_unique($collection_field_list)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'Supported File Types', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      join(', ', array_unique($collection_formatters)), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'Records', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      number_format($collection_entities), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $rows[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'data' => 'Actions', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'header' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'width' => '20%', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      l('Delete', 'user/' . $uid . '/data-collections/' . $collection->getCollectionID() . '/delete') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $collection_content = '<b>Collection Details</b>' . theme_table([ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'header' => $headers, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'rows' => $rows, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'attributes' => [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'sticky' => FALSE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'caption' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'colgroups' => [], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'empty' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  drupal_json_output($file_content . $collection_content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |