Exemplo n.º 1
0
 /**
  * @return array
  */
 public function getChilds()
 {
     if ($this->childs === null) {
         $list = new Asset_List();
         $list->setCondition("parentId = ?", $this->getId());
         $list->setOrderKey("filename");
         $list->setOrder("asc");
         $this->childs = $list->load();
     }
     return $this->childs;
 }
Exemplo n.º 2
0
 public function downloadAsZipAction()
 {
     $asset = Asset::getById($this->_getParam("id"));
     if ($asset->isAllowed("view")) {
         $archive_name = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/download.zip";
         if (is_file($archive_name)) {
             unlink($archive_name);
         }
         $archive_folder = $asset->getFileSystemPath();
         $zip = new ZipArchive();
         if ($zip->open($archive_name, ZipArchive::CREATE) === TRUE) {
             $assetList = new Asset_List();
             $assetList->setCondition("path LIKE ?", $asset->getFullPath() . "/%");
             $assetList->setOrderKey("LENGTH(path)", false);
             $assetList->setOrder("ASC");
             foreach ($assetList->load() as $a) {
                 if ($a->isAllowed("view")) {
                     if (!$a instanceof Asset_Folder) {
                         $zip->addFile($a->getFileSystemPath(), substr($a->getFullPath(), 1));
                     }
                 }
             }
             $zip->close();
         }
         $this->getResponse()->setHeader("Content-Type", "application/zip", true);
         $this->getResponse()->setHeader("Content-Disposition", 'attachment; filename="' . $asset->getFilename() . '.zip"');
         echo file_get_contents($archive_name);
         unlink($archive_name);
     }
     $this->removeViewRenderer();
 }
Exemplo n.º 3
0
 public function copyInfoAction()
 {
     $transactionId = time();
     $pasteJobs = array();
     $session = new Zend_Session_Namespace("pimcore_copy");
     $session->{$transactionId} = array();
     if ($this->_getParam("type") == "recursive") {
         $asset = Asset::getById($this->_getParam("sourceId"));
         // first of all the new parent
         $pasteJobs[] = array(array("url" => "/admin/asset/copy", "params" => array("sourceId" => $this->_getParam("sourceId"), "targetId" => $this->_getParam("targetId"), "type" => "child", "transactionId" => $transactionId, "saveParentId" => true)));
         if ($asset->hasChilds()) {
             // get amount of childs
             $list = new Asset_List();
             $list->setCondition("path LIKE '" . $asset->getFullPath() . "/%'");
             $list->setOrderKey("LENGTH(path)", false);
             $list->setOrder("ASC");
             $childIds = $list->loadIdList();
             if (count($childIds) > 0) {
                 foreach ($childIds as $id) {
                     $pasteJobs[] = array(array("url" => "/admin/asset/copy", "params" => array("sourceId" => $id, "targetParentId" => $this->_getParam("targetId"), "sourceParentId" => $this->_getParam("sourceId"), "type" => "child", "transactionId" => $transactionId)));
                 }
             }
         }
     } else {
         if ($this->_getParam("type") == "child" || $this->_getParam("type") == "replace") {
             // the object itself is the last one
             $pasteJobs[] = array(array("url" => "/admin/asset/copy", "params" => array("sourceId" => $this->_getParam("sourceId"), "targetId" => $this->_getParam("targetId"), "type" => $this->_getParam("type"), "transactionId" => $transactionId)));
         }
     }
     $this->_helper->json(array("pastejobs" => $pasteJobs));
 }