Пример #1
0
 public function getAttributeValue($avID, $method = 'getValue')
 {
     $av = FileAttributeValue::getByID($avID);
     if (is_object($av)) {
         $av->setAttributeKey($this);
         return $av->{$method}();
     }
 }
Пример #2
0
 public function getAttributeValueObject($ak, $createIfNotFound = false)
 {
     $db = Database::get();
     $av = false;
     $v = array($this->getFileID(), $this->getFileVersionID(), $ak->getAttributeKeyID());
     $avID = $db->GetOne("SELECT avID FROM FileAttributeValues WHERE fID = ? AND fvID = ? AND akID = ?", $v);
     if ($avID > 0) {
         $av = FileAttributeValue::getByID($avID);
         if (is_object($av)) {
             $av->setFile($this->getFile());
             $av->setAttributeKey($ak);
         }
     }
     if ($createIfNotFound) {
         $cnt = 0;
         // Is this avID in use ?
         if (is_object($av)) {
             $cnt = $db->GetOne("SELECT count(avID) FROM FileAttributeValues WHERE avID = ?", $av->getAttributeValueID());
         }
         if (!is_object($av) || $cnt > 1) {
             $newAV = $ak->addAttributeValue();
             $av = FileAttributeValue::getByID($newAV->getAttributeValueID());
             $av->setFile($this->getFile());
         }
     }
     return $av;
 }
Пример #3
0
 public function getAttributeValueObject($ak, $createIfNotFound = false)
 {
     $db = Loader::db();
     $av = false;
     $v = array($this->getFileID(), $this->getFileVersionID(), $ak->getAttributeKeyID());
     $avID = $db->GetOne("select avID from FileAttributeValues where fID = ? and fvID = ? and akID = ?", $v);
     if ($avID > 0) {
         $av = FileAttributeValue::getByID($avID);
         if (is_object($av)) {
             $av->setFile($this->getFile());
             $av->setAttributeKey($ak);
         }
     }
     if ($createIfNotFound) {
         $cnt = 0;
         // Is this avID in use ?
         if (is_object($av)) {
             $cnt = $db->GetOne("select count(avID) from FileAttributeValues where avID = ?", $av->getAttributeValueID());
         }
         if (!is_object($av) || $cnt > 1) {
             $newAV = $ak->addAttributeValue();
             $av = FileAttributeValue::getByID($newAV->getAttributeValueID());
             $av->setFile($this->getFile());
         }
     }
     return $av;
 }