コード例 #1
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));
 }