public function deleteInfoAction() { $hasDependency = false; try { $asset = Asset::getById($this->_getParam("id")); $hasDependency = $asset->getDependencies()->isRequired(); } catch (Exception $e) { Logger::err("failed to access asset with id: " . $this->_getParam("id")); } $deleteJobs = array(); // check for childs if ($asset instanceof Asset) { $deleteJobs[] = array(array("url" => "/admin/recyclebin/add", "params" => array("type" => "asset", "id" => $asset->getId()))); $hasChilds = $asset->hasChilds(); if (!$hasDependency) { $hasDependency = $hasChilds; } $childs = 0; if ($hasChilds) { // get amount of childs $list = new Asset_List(); $list->setCondition("path LIKE '" . $asset->getFullPath() . "/%'"); $childs = $list->getTotalCount(); if ($childs > 0) { $deleteObjectsPerRequest = 5; for ($i = 0; $i < ceil($childs / $deleteObjectsPerRequest); $i++) { $deleteJobs[] = array(array("url" => "/admin/asset/delete", "params" => array("step" => $i, "amount" => $deleteObjectsPerRequest, "type" => "childs", "id" => $asset->getId()))); } } } // the object itself is the last one $deleteJobs[] = array(array("url" => "/admin/asset/delete", "params" => array("id" => $asset->getId()))); } $this->_helper->json(array("hasDependencies" => $hasDependency, "childs" => $childs, "deletejobs" => $deleteJobs)); }
$allowedThumbs = explode(",", $opts->getOption("thumbnails")); } // get only images $conditions = array("type = 'image'"); if ($opts->getOption("parent")) { $parent = Asset::getById($opts->getOption("parent")); if ($parent instanceof Asset_Folder) { $conditions[] = "path LIKE '" . $parent->getFullPath() . "/%'"; } else { echo $opts->getOption("parent") . " is not a valid asset folder ID!\n"; exit; } } $list = new Asset_List(); $list->setCondition(implode(" AND ", $conditions)); $total = $list->getTotalCount(); $perLoop = 10; for ($i = 0; $i < ceil($total / $perLoop); $i++) { $list->setLimit($perLoop); $list->setOffset($i * $perLoop); $images = $list->load(); foreach ($images as $image) { foreach ($thumbnails as $thumbnail) { if (empty($allowedThumbs) || in_array($thumbnail, $allowedThumbs)) { echo "generating thumbnail for image: " . $image->getFullpath() . " | " . $image->getId() . " | Thumbnail: " . $thumbnail . " : " . formatBytes(memory_get_usage()) . " \n"; $image->getThumbnail($thumbnail); } } } Pimcore::collectGarbage(); }