Beispiel #1
0
 public static function getByHandle($akHandle)
 {
     $ak = CacheLocal::getEntry('file_attribute_key_by_handle', $akHandle);
     if (is_object($ak)) {
         return $ak;
     } else {
         if ($ak == -1) {
             return false;
         }
     }
     $ak = -1;
     $db = Loader::db();
     $q = "SELECT ak.akID FROM AttributeKeys ak INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID  WHERE ak.akHandle = ? AND akc.akCategoryHandle = 'file'";
     $akID = $db->GetOne($q, array($akHandle));
     if ($akID > 0) {
         $ak = self::getByID($akID);
     } else {
         // else we check to see if it's listed in the initial registry
         $ia = FileTypeList::getImporterAttribute($akHandle);
         if (is_object($ia)) {
             // we create this attribute and return it.
             $at = AttributeType::getByHandle($ia->akType);
             $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable);
             $ak = static::add($at, $args);
         }
     }
     CacheLocal::set('file_attribute_key_by_handle', $akHandle, $ak);
     if ($ak === -1) {
         return false;
     }
     return $ak;
 }