3 # FILE: ControlledNameFactory.php 5 # Part of the Collection Workflow Integration System (CWIS) 6 # Copyright 2011-2013 Edward Almasy and Internet Scout Research Group 7 # http://scout.wisc.edu/cwis/ 16 # ---- PUBLIC INTERFACE -------------------------------------------------- 24 # save field ID for our later use 25 $this->FieldId = $FieldId;
27 # set up item factory base class 28 parent::__construct(
"ControlledName",
"ControlledNames",
29 "ControlledNameId",
"ControlledName", FALSE,
30 ($FieldId ?
"FieldId = ".intval($FieldId) : NULL));
40 return $this->DB->Query(
41 "SELECT COUNT(DISTINCT RNI.ResourceId) AS ResourceCount" 42 .
" FROM ResourceNameInts RNI, ControlledNames CN" 43 .
" WHERE CN.FieldId = ".intval($this->FieldId)
44 .
" AND RNI.ControlledNameId = CN.ControlledNameId" 45 .
" AND RNI.ResourceId >= 0",
60 $IdExclusions=array(), $ValueExclusions=array() )
62 # return no results if empty search string passed in 63 if (!strlen(trim($SearchString))) {
return array(); }
65 $IdExclusionSql = (count($IdExclusions)>0)
66 ?
"AND ControlledNameId NOT IN (" 67 .implode(
',', array_map(
'intval', $IdExclusions)).
")" 70 $ValueExclusionSql = (count($ValueExclusions)>0)
71 ?
"AND ControlledName NOT IN (" 72 .implode(
',', array_map(
73 function($v){
return "'".addslashes($v).
"'"; },
74 $ValueExclusions) ).
")" 77 # mark all search elements as required 78 $SearchString = preg_replace(
"%\S+%",
"+\$0", $SearchString);
81 "SELECT ControlledNameId, ControlledName FROM ControlledNames " 82 .
"WHERE FieldId=".$this->FieldId
83 .
" AND LastAssigned IS NOT NULL" 84 .
" AND MATCH(ControlledName) AGAINST ('" 85 .addslashes(trim($SearchString)).
"' IN BOOLEAN MODE)" 87 .
" ".$ValueExclusionSql
88 .
" ORDER BY LastAssigned DESC LIMIT ".$NumberOfResults;
90 $this->DB->Query($QueryString);
92 $Names = $this->DB->FetchColumn(
"ControlledName",
"ControlledNameId");
97 # ---- PRIVATE INTERFACE ------------------------------------------------- __construct($FieldId=NULL)
Constructor for ControlledNameFactory class.
Factory for manipulating ControlledName objects.
GetUsageCount()
Determine how many resources have controlled names (associated with this metadata field) assigned to ...
Common factory class for item manipulation.
FindMatchingRecentlyUsedValues($SearchString, $NumberOfResults=5, $IdExclusions=array(), $ValueExclusions=array())
Retrieve recently used items matching a search string.