public function portletModifiedAssetsAction() { $list = Asset::getList(["limit" => 10, "order" => "DESC", "orderKey" => "modificationDate"]); $response = []; $response["assets"] = []; foreach ($list as $doc) { $response["assets"][] = ["id" => $doc->getId(), "type" => $doc->getType(), "path" => $doc->getRealFullPath(), "date" => $doc->getModificationDate(), "condition" => "userModification = '" . $this->getUser()->getId() . "'"]; } $this->_helper->json($response); }
/** * @param null $condition * @param null $order * @param null $orderKey * @param null $offset * @param null $limit * @param null $groupBy * @throws \Exception */ public function getAssetList($condition = null, $order = null, $orderKey = null, $offset = null, $limit = null, $groupBy = null) { try { $params = array(); if (!empty($condition)) { $params["condition"] = $condition; } if (!empty($order)) { $params["order"] = $order; } if (!empty($orderKey)) { $params["orderKey"] = $orderKey; } if (!empty($offset)) { $params["offset"] = $offset; } if (!empty($limit)) { $params["limit"] = $limit; } if (!empty($groupBy)) { $params["groupBy"] = $groupBy; } $list = Asset::getList($params); $items = array(); foreach ($list as $asset) { $item = new Webservice\Data\Asset\Listing\Item(); $item->id = $asset->getId(); $item->type = $asset->getType(); $items[] = $item; } return $items; } catch (\Exception $e) { \Logger::error($e); throw $e; } }
public function getFolderContentPreviewAction() { $folder = Asset::getById($this->getParam("id")); $start = 0; $limit = 10; if ($this->getParam("limit")) { $limit = $this->getParam("limit"); } if ($this->getParam("start")) { $start = $this->getParam("start"); } $condition = "path LIKE '" . ($folder->getFullPath() == "/" ? "/%'" : $folder->getFullPath() . "/%'") . " AND type != 'folder'"; $list = Asset::getList(array("condition" => $condition, "limit" => $limit, "offset" => $start, "orderKey" => "filename", "order" => "asc")); $assets = array(); foreach ($list as $asset) { $thumbnailMethod = ""; if ($asset instanceof Asset\Image) { $thumbnailMethod = "getThumbnail"; } else { if ($asset instanceof Asset\Video && \Pimcore\Video::isAvailable()) { $thumbnailMethod = "getImageThumbnail"; } else { if ($asset instanceof Asset\Document && \Pimcore\Document::isAvailable()) { $thumbnailMethod = "getImageThumbnail"; } } } if (!empty($thumbnailMethod)) { $assets[] = array("id" => $asset->getId(), "type" => $asset->getType(), "filename" => $asset->getFilename(), "url" => "/admin/asset/get-" . $asset->getType() . "-thumbnail/id/" . $asset->getId() . "/treepreview/true", "idPath" => $data["idPath"] = Element\Service::getIdPath($asset)); } } $this->_helper->json(array("assets" => $assets, "success" => true, "total" => $list->getTotalCount())); }