Exemple #1
0
 /**
  * @param int $parentFolder  parent folder_pk
  * @return string HTML of the folder tree
  */
 public function showFolderTree($parentFolder)
 {
     $uri = Traceback_uri();
     $sql = $this->folderDao->getFolderTreeCte($parentFolder) . " SELECT folder_pk, folder_name, folder_desc, depth, name_path FROM folder_tree ORDER BY name_path";
     $stmt = __METHOD__;
     $this->dbManager->prepare($stmt, $sql);
     $res = $this->dbManager->execute($stmt, array($parentFolder));
     $out = '';
     $lastDepth = -1;
     while ($row = $this->dbManager->fetchArray($res)) {
         for (; $row['depth'] < $lastDepth; $lastDepth--) {
             $out .= '</li></ul>';
         }
         if ($row['depth'] == $lastDepth) {
             $out .= "</li>\n<li>";
         }
         if ($row['depth'] == 0) {
             $out .= '<ul id="tree"><li>';
             $lastDepth++;
         }
         for (; $row['depth'] > $lastDepth; $lastDepth++) {
             $out .= '<ul><li>';
         }
         $out .= $this->getFormattedItem($row, $uri);
     }
     for (; -1 < $lastDepth; $lastDepth--) {
         $out .= '</li></ul>';
     }
     return $out;
 }
Exemple #2
0
 /**
  * @brief kludge for plugins not supplying a folder parameter.
  * Find what folder this upload is in.
  */
 private function getFolderId($uploadId)
 {
     $rootFolder = $this->folderDao->getRootFolder(Auth::getUserId());
     if (empty($uploadId)) {
         return $rootFolder->getId();
     }
     global $container;
     /* @var $dbManager DbManager */
     $dbManager = $container->get('db.manager');
     $uploadExists = $dbManager->getSingleRow("SELECT count(*) cnt FROM upload WHERE upload_pk=\$1", array($uploadId));
     if ($uploadExists['cnt'] < 1) {
         throw new Exception("This upload no longer exists on this system.");
     }
     $folderTreeCte = $this->folderDao->getFolderTreeCte($rootFolder);
     $parent = $dbManager->getSingleRow($folderTreeCte . " SELECT ft.folder_pk FROM foldercontents fc LEFT JOIN folder_tree ft ON fc.parent_fk=ft.folder_pk " . "WHERE child_id=\$2 AND foldercontents_mode=\$3 ORDER BY depth LIMIT 1", array($rootFolder->getId(), $uploadId, FolderDao::MODE_UPLOAD), __METHOD__ . '.parent');
     if (!$parent) {
         throw new Exception("Upload {$uploadId} missing from foldercontents in your foldertree.");
     }
     return $parent['folder_pk'];
 }