/** * Returns an array of IDs and Names of the categories linked to this file * not taking into account the safinstance linked to this file * (this is useful for images displayed in people that can be shared trough multiple instances) * * @param $id * @return Array */ public function getCategoriesLabels($id) { $categoryDB = new FilfoldersFilfiles(); $foldersDb = new Filfolders(); $idString = implode(',', $categoryDB->getFilfoldersLinkedTo($id)); if ($idString != '') { $where = "id IN (" . $idString . ") "; } else { return array(); } $toRetun = array(); foreach ($foldersDb->fetchAll($where) as $element) { $toRetun[$element['id']] = $element['label']; } return $toRetun; }
/** * Returns the folders linked to a file * @param int $filfilesId * @param boolean $json Return data in a JSON string containing the ids and labels * @return string */ protected function _getLinkedFolders($filfilesId, $json = true) { $elements = array(); $lDB = new FilfoldersFilfiles(); $fDB = new Filfolders(); $fileFilesIds = $lDB->getFilfoldersLinkedTo($filfilesId); if (count($fileFilesIds) > 0) { $sql = "id IN (" . implode(',', $fileFilesIds) . ") "; foreach ($fDB->fetchAll($sql) as $el) { $elements[] = array('label' => addslashes($el->label), 'val' => $el->id); } } if ($json) { return preg_replace('/"/', "'", Zend_Json::encode($elements)); } else { return $elements; } }
private function getLinkOnFolder($fileid) { // search if file has linked to a folder $linkedFiles = new FilfoldersFilfiles(); return $linkedFiles->getFilfoldersLinkedTo($fileid); }