/** * Get file details. * * @param array $selected * @return array */ public function getFileInfo($selected) { if (count($selected) == 1) { try { $path = $selected[0]; $physical = self::virtualToPhysical($path); $public = self::physicalToPublic($physical); if (!is_file($physical)) { return null; } $owner = fileowner($physical); if (function_exists('posix_getpwuid')) { $owner = posix_getpwuid($owner); $owner = '<span title="' . $owner['uid'] . '">' . htmlspecialchars($owner['name']) . '</span>'; } $group = filegroup($physical); if (function_exists('posix_getgrgid')) { $group = posix_getgrgid($group); $group = '<span title="' . $group['gid'] . '">' . htmlspecialchars($group['name']) . '</span>'; } $fi = array('Name' => '<h2>' . basename($physical) . '</h2>', 'Preview' => '', 'Size' => '<strong>Size: </strong>' . Helper::humanReadableBytes(filesize($physical)), 'Writable' => '<strong>Writable: </strong>' . (self::isWritable($physical) ? 'Yes' : 'No'), 'Permissions' => '<strong>Permissions: </strong>' . PathHelper::getFilePermissions($physical), 'Owner' => '<strong>Owner: </strong>' . $owner . ' / ' . $group); switch (strtolower(pathinfo($physical, PATHINFO_EXTENSION))) { case 'jpg': case 'gif': case 'png': case 'bmp': $image = getimagesize($physical); $fi['Preview'] = '<img src="' . $public . '?' . filemtime($physical) . '" alt="" class="preview" />'; if ($image[0] > 240 || $image[1] > 240) { $fi['Preview'] = '<a href="' . $public . '?' . filemtime($physical) . '" target="_blank" class="fullscreen-preview" title="Click to toggle fullscreen">' . $fi['Preview'] . '</a>'; } $fi['Dimensions'] = '<strong>Dimension: </strong>' . $image[0] . 'x' . $image[1]; if (self::isPhysicalWritable($physical)) { $fi['Actions'] = '<a href="' . url('', array('module', 'view' => 'PixlrEdit', 'image' => $public)) . '" class="dialog" onclick="$(this).data(\'dialog\').width = $(window).width() - 20; $(this).data(\'dialog\').height = $(window).height() - 20;" data-dialog=\'{"width":"90%","height":600,"resizable":false,"draggable":false}\'>Edit with Pixlr</a>'; } break; case 'ogg': case 'ogv': case 'mp4': case 'webm': $fi['Preview'] = '<video src="' . $public . '" class="preview" controls />'; break; case 'mp3': case 'oga': case 'wav': $fi['Preview'] = '<audio src="' . $public . '" class="preview" controls />'; break; case 'swf': $size = getimagesize($physical); $flash = Flash::embed(Flash::SWFOBJECT_STATIC, $public, $size[0], $size[1], '9.0.0', array()); $fi['Preview'] = $flash['html']; break; } return $fi; } catch (Exception $e) { $this->app->logger->error($e->getMessage()); } } else { $totalSize = 0; foreach ($selected as $s) { $physical = self::virtualToPhysical($s); $totalSize += filesize($physical); } return array('Name' => '<h2>' . count($selected) . ' files</h2>', 'Size' => '<strong>Size: </strong>' . Helper::humanReadableBytes($totalSize)); } return null; }