CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

ItemFactory.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: ItemFactory.php
4 #
5 # Part of the ScoutLib application support library
6 # Copyright 2007-2016 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu
8 #
9
17 abstract class ItemFactory
18 {
19
20 # ---- PUBLIC INTERFACE --------------------------------------------------
21
37 public function __construct($ItemClassName, $ItemTableName, $ItemIdColumnName,
38 $ItemNameColumnName = NULL, $OrderOpsAllowed = FALSE, $SqlCondition = NULL)
39 {
40 # save item access names
41 $this->ItemClassName = $ItemClassName;
42 $this->ItemTableName = $ItemTableName;
43 $this->ItemIdColumnName = $ItemIdColumnName;
44 $this->ItemNameColumnName = $ItemNameColumnName;
45
46 # save flag indicating whether item type allows ordering operations
47 $this->OrderOpsAllowed = $OrderOpsAllowed;
48 if ($OrderOpsAllowed)
49 {
50 $this->OrderList = new PersistentDoublyLinkedList(
51 $ItemTableName, $ItemIdColumnName);
52 $this->SetOrderOpsCondition(NULL);
53 }
54
55 # save database operation conditional
56 $this->SqlCondition = $SqlCondition;
57
58 # grab our own database handle
59 $this->DB = new Database();
60 }
61
66 public function GetItemClassName()
67 {
68 return $this->ItemClassName;
69 }
70
78 public function CleanOutStaleTempItems($MinutesUntilStale = 10080)
79 {
80 # load array of stale items
81 $MinutesUntilStale = max($MinutesUntilStale, 1);
82 $this->DB->Query("SELECT ".$this->ItemIdColumnName." FROM ".$this->ItemTableName
83 ." WHERE ".$this->ItemIdColumnName." < 0"
84 ." AND DateLastModified < DATE_SUB(NOW(), "
85 ." INTERVAL ".intval($MinutesUntilStale)." MINUTE)"
86 .($this->SqlCondition ? " AND ".$this->SqlCondition : ""));
87 $ItemIds = $this->DB->FetchColumn($this->ItemIdColumnName);
88
89 # delete stale items
90 foreach ($ItemIds as $ItemId)
91 {
92 $Item = new $this->ItemClassName($ItemId);
93 $Item->Delete();
94 }
95
96 # report number of items deleted to caller
97 return count($ItemIds);
98 }
99
105 public function GetNextItemId()
106 {
107 # if no highest item ID found
108 $HighestItemId = $this->GetHighestItemId(TRUE);
109 if ($HighestItemId <= 0)
110 {
111 # start with item ID 1
112 $ItemId = 1;
113 }
114 else
115 {
116 # else use next ID available after highest
117 $ItemId = $HighestItemId + 1;
118 }
119
120 # return next ID to caller
121 return $ItemId;
122 }
123
131 public function GetHighestItemId($IgnoreSqlCondition = FALSE)
132 {
133 # use class-wide condition if set
134 $ConditionString = ($this->SqlCondition && !$IgnoreSqlCondition)
135 ? " WHERE ".$this->SqlCondition : "";
136
137 # return highest item ID to caller
138 return $this->DB->Query("SELECT ".$this->ItemIdColumnName
139 ." FROM ".$this->ItemTableName
140 .$ConditionString
141 ." ORDER BY ".$this->ItemIdColumnName
142 ." DESC LIMIT 1",
143 $this->ItemIdColumnName);
144 }
145
150 public function GetNextTempItemId()
151 {
152 $LowestItemId = $this->DB->Query("SELECT ".$this->ItemIdColumnName
153 ." FROM ".$this->ItemTableName
154 ." ORDER BY ".$this->ItemIdColumnName
155 ." ASC LIMIT 1",
156 $this->ItemIdColumnName);
157 if ($LowestItemId > 0)
158 {
159 $ItemId = -1;
160 }
161 else
162 {
163 $ItemId = $LowestItemId - 1;
164 }
165 return $ItemId;
166 }
167
176 public function GetItemCount($Condition = NULL, $IncludeTempItems = FALSE)
177 {
178 # use condition if supplied
179 $ConditionString = ($Condition != NULL) ? " WHERE ".$Condition : "";
180
181 # if temp items are to be excluded
182 if (!$IncludeTempItems)
183 {
184 # if a condition was previously set
185 if (strlen($ConditionString))
186 {
187 # add in condition to exclude temp items
188 $ConditionString .= " AND (".$this->ItemIdColumnName." >= 0)";
189 }
190 else
191 {
192 # use condition to exclude temp items
193 $ConditionString = " WHERE ".$this->ItemIdColumnName." >= 0";
194 }
195 }
196
197 # add class-wide condition if set
198 if ($this->SqlCondition)
199 {
200 if (strlen($ConditionString))
201 {
202 $ConditionString .= " AND ".$this->SqlCondition;
203 }
204 else
205 {
206 $ConditionString = " WHERE ".$this->SqlCondition;
207 }
208 }
209
210 # retrieve item count
211 $Count = $this->DB->Query("SELECT COUNT(*) AS RecordCount"
212 ." FROM ".$this->ItemTableName
213 .$ConditionString,
214 "RecordCount");
215
216 # return count to caller
217 return intval($Count);
218 }
219
233 public function GetItemIds($Condition = NULL, $IncludeTempItems = FALSE,
234 $SortField = NULL, $SortAscending = TRUE)
235 {
236 # if temp items are supposed to be included
237 if ($IncludeTempItems)
238 {
239 # condition is only as supplied
240 $ConditionString = ($Condition == NULL) ? "" : " WHERE ".$Condition;
241 }
242 else
243 {
244 # condition is non-negative IDs plus supplied condition
245 $ConditionString = " WHERE ".$this->ItemIdColumnName." >= 0"
246 .(($Condition == NULL) ? "" : " AND ".$Condition);
247 }
248
249 # add class-wide condition if set
250 if ($this->SqlCondition)
251 {
252 if (strlen($ConditionString))
253 {
254 $ConditionString .= " AND ".$this->SqlCondition;
255 }
256 else
257 {
258 $ConditionString = " WHERE ".$this->SqlCondition;
259 }
260 }
261
262 # add sorting if specified
263 if ($SortField !== NULL)
264 {
265 $ConditionString .= " ORDER BY `".addslashes($SortField)."` "
266 .($SortAscending ? "ASC" : "DESC");
267 }
268
269 # get item IDs
270 $this->DB->Query("SELECT ".$this->ItemIdColumnName
271 ." FROM ".$this->ItemTableName
272 .$ConditionString);
273 $ItemIds = $this->DB->FetchColumn($this->ItemIdColumnName);
274
275 # return IDs to caller
276 return $ItemIds;
277 }
278
286 public function GetLatestModificationDate($Condition = NULL)
287 {
288 # set up SQL condition if supplied
289 $ConditionString = ($Condition == NULL) ? "" : " WHERE ".$Condition;
290
291 # add class-wide condition if set
292 if ($this->SqlCondition)
293 {
294 if (strlen($ConditionString))
295 {
296 $ConditionString .= " AND ".$this->SqlCondition;
297 }
298 else
299 {
300 $ConditionString = " WHERE ".$this->SqlCondition;
301 }
302 }
303
304 # return modification date for item most recently changed
305 return $this->DB->Query("SELECT MAX(DateLastModified) AS LastChangeDate"
306 ." FROM ".$this->ItemTableName.$ConditionString,
307 "LastChangeDate");
308 }
309
316 public function GetItem($ItemId)
317 {
318 return new $this->ItemClassName($ItemId);
319 }
320
328 public function ItemExists($ItemId, $IgnoreSqlCondition = FALSE)
329 {
330 if (!is_numeric($ItemId))
331 {
332 return FALSE;
333 }
334 $Condition = $IgnoreSqlCondition ? ""
335 : ($this->SqlCondition ? " AND ".$this->SqlCondition : "");
336 $ItemCount = $this->DB->Query("SELECT COUNT(*) AS ItemCount"
337 ." FROM ".$this->ItemTableName
338 ." WHERE ".$this->ItemIdColumnName." = ".intval($ItemId)
339 .$Condition, "ItemCount");
340 return ($ItemCount > 0) ? TRUE : FALSE;
341 }
342
350 public function GetItemByName($Name, $IgnoreCase = FALSE)
351 {
352 # get item ID
353 $ItemId = $this->GetItemIdByName($Name, $IgnoreCase);
354
355 # if item not found
356 if ($ItemId === FALSE)
357 {
358 # report error to caller
359 return NULL;
360 }
361 else
362 {
363 # load object and return to caller
364 return $this->GetItem($ItemId);
365 }
366 }
367
376 public function GetItemIdByName($Name, $IgnoreCase = FALSE)
377 {
378 # error out if this is an illegal operation for this item type
379 if ($this->ItemNameColumnName == NULL)
380 {
381 throw new Exception("Attempt to get item ID by name on item type"
382 ."(".$this->ItemClassName.") that has no name field specified.");
383 }
384
385 # if caching is off or item ID is already loaded
386 if (($this->CachingEnabled != TRUE)
387 || !isset($this->ItemIdByNameCache[$this->SqlCondition][$Name]))
388 {
389 # query database for item ID
390 $Comparison = $IgnoreCase
391 ? "LOWER(".$this->ItemNameColumnName.") = '"
392 .addslashes(strtolower($Name))."'"
393 : $this->ItemNameColumnName." = '" .addslashes($Name)."'";
394 $ItemId = $this->DB->Query("SELECT ".$this->ItemIdColumnName
395 ." FROM ".$this->ItemTableName
396 ." WHERE ".$Comparison
397 .($this->SqlCondition
398 ? " AND ".$this->SqlCondition
399 : ""),
400 $this->ItemIdColumnName);
401 $this->ItemIdByNameCache[$this->SqlCondition][$Name] =
402 ($this->DB->NumRowsSelected() == 0) ? FALSE : $ItemId;
403 }
404
405 # return ID or error indicator to caller
406 return $this->ItemIdByNameCache[$this->SqlCondition][$Name];
407 }
408
415 public function GetItemNames($SqlCondition = NULL)
416 {
417 # error out if this is an illegal operation for this item type
418 if ($this->ItemNameColumnName == NULL)
419 {
420 throw new Exception("Attempt to get array of item names"
421 ." on item type (".$this->ItemClassName.") that has no"
422 ." name field specified.");
423 }
424
425 # query database for item names
426 $Condition = "";
427 if ($SqlCondition)
428 {
429 $Condition = "WHERE ".$SqlCondition;
430 }
431 if ($this->SqlCondition)
432 {
433 if (strlen($Condition))
434 {
435 $Condition .= " AND ".$this->SqlCondition;
436 }
437 else
438 {
439 $Condition = " WHERE ".$this->SqlCondition;
440 }
441 }
442 $this->DB->Query("SELECT ".$this->ItemIdColumnName
443 .", ".$this->ItemNameColumnName
444 ." FROM ".$this->ItemTableName." "
445 .$Condition
446 ." ORDER BY ".$this->ItemNameColumnName);
447 $Names = $this->DB->FetchColumn(
448 $this->ItemNameColumnName, $this->ItemIdColumnName);
449
450 # return item names to caller
451 return $Names;
452 }
453
460 public function GetItems($SqlCondition = NULL)
461 {
462 $Items = array();
463 $Ids = $this->GetItemIds($SqlCondition);
464 foreach ($Ids as $Id)
465 {
466 $Items[$Id] = $this->GetItem($Id);
467 }
468 return $Items;
469 }
470
487 public function GetItemsAsOptionList(
488 $OptionListName, $SelectedItemId = NULL, $SqlCondition = NULL,
489 $DisplaySize = 1, $SubmitOnChange = FALSE, $Disabled = FALSE)
490 {
491 # retrieve requested fields
492 $ItemNames = $this->GetItemNames($SqlCondition);
493
494 # create option list
495 $OptList = new HtmlOptionList(
496 $OptionListName, $ItemNames, $SelectedItemId);
497
498 # set list attributes
499 $OptList->SubmitOnChange($SubmitOnChange);
500 $OptList->Size($DisplaySize);
501 $OptList->Disabled($Disabled);
502
503 # return generated HTML for list to caller
504 return $OptList->GetHtml();
505 }
506
513 public function NameIsInUse($Name, $IgnoreCase = FALSE)
514 {
515 $Condition = $IgnoreCase
516 ? "LOWER(".$this->ItemNameColumnName.")"
517 ." = '".addslashes(strtolower($Name))."'"
518 : $this->ItemNameColumnName." = '".addslashes($Name)."'";
519 if ($this->SqlCondition)
520 {
521 $Condition .= " AND ".$this->SqlCondition;
522 }
523 $NameCount = $this->DB->Query("SELECT COUNT(*) AS RecordCount FROM "
524 .$this->ItemTableName." WHERE ".$Condition, "RecordCount");
525 return ($NameCount > 0) ? TRUE : FALSE;
526 }
527
545 public function SearchForItemNames($SearchString, $NumberOfResults = 100,
546 $IncludeVariants = FALSE, $UseBooleanMode = TRUE, $Offset=0,
547 $IdExclusions = array(), $ValueExclusions=array())
548 {
549 # error out if this is an illegal operation for this item type
550 if ($this->ItemNameColumnName == NULL)
551 {
552 throw new Exception("Attempt to search for item names on item type"
553 ."(".$this->ItemClassName.") that has no name field specified.");
554 }
555
556 # return no results if empty search string passed in
557 if (!strlen(trim($SearchString))) { return array(); }
558
559 # construct SQL query
560 $DB = new Database();
561 $QueryString = "SELECT ".$this->ItemIdColumnName.",".$this->ItemNameColumnName
562 ." FROM ".$this->ItemTableName." WHERE "
563 .$this->ConstructSqlConditionsForSearch(
564 $SearchString, $IncludeVariants, $UseBooleanMode, $IdExclusions,
565 $ValueExclusions) ;
566
567 # limit response set
568 $QueryString .= " LIMIT ".intval($NumberOfResults)." OFFSET "
569 .intval($Offset);
570
571 # perform query and retrieve names and IDs of items found by query
572 $DB->Query($QueryString);
573 $Names = $DB->FetchColumn($this->ItemNameColumnName, $this->ItemIdColumnName);
574
575 # remove excluded words that were shorter than the MinWordLength
576 # (these will always be returned as mysql effectively ignores them)
577 $MinWordLen = $DB->Query(
578 "SHOW VARIABLES WHERE variable_name='ft_min_word_len'", "Value");
579
580 # explode the search string into whitespace delimited tokens,
581 # iterate over each token
582 $Words = preg_split("/[\s]+/", trim($SearchString));
583 foreach ($Words as $Word)
584 {
585 # if this token was an exclusion
586 if ($Word[0] == "-")
587 {
588 # remove the - prefix to get the TgtWord
589 $TgtWord = substr($Word, 1);
590
591 # if this token was an exclusion shorter than MindWordLen
592 if (strlen($TgtWord) < $MinWordLen)
593 {
594 # filter names that match this exclusion from results
595 $NewNames = array();
596 foreach ($Names as $Id => $Name)
597 {
598 if (! preg_match('/\b'.$TgtWord.'/i', $Name))
599 {
600 $NewNames[$Id] = $Name;
601 }
602 }
603 $Names = $NewNames;
604 }
605 }
606 }
607
608 # return names to caller
609 return $Names;
610 }
611
625 public function GetCountForItemNames($SearchString, $IncludeVariants = FALSE,
626 $UseBooleanMode = TRUE, $IdExclusions = array(), $ValueExclusions=array())
627 {
628 # return no results if empty search string passed in
629 if (!strlen(trim($SearchString))) { return 0; }
630
631 # construct SQL query
632 $DB = new Database();
633 $QueryString = "SELECT COUNT(*) as ItemCount FROM "
634 .$this->ItemTableName." WHERE "
635 .$this->ConstructSqlConditionsForSearch(
636 $SearchString, $IncludeVariants, $UseBooleanMode, $IdExclusions,
637 $ValueExclusions);
638
639 # perform query and retrieve names and IDs of items found by query
640 $DB->Query($QueryString);
641 return intval($DB->FetchField("ItemCount"));
642 }
643
650 public function CachingEnabled($NewValue = NULL)
651 {
652 if ($NewValue !== NULL)
653 {
654 $this->CachingEnabled = $NewValue ? TRUE : FALSE;
655 }
656 return $this->CachingEnabled;
657 }
658
663 public function ClearCaches()
664 {
665 unset($this->ItemIdByNameCache);
666 }
667
668
669 # ---- Ordering Operations -----------------------------------------------
670
677 public function SetOrderOpsCondition($Condition)
678 {
679 # condition is non-negative IDs (non-temp items) plus supplied condition
680 $NewCondition = $this->ItemIdColumnName." >= 0"
681 .($Condition ? " AND ".$Condition : "")
682 .($this->SqlCondition ? " AND ".$this->SqlCondition : "");
683 $this->OrderList->SqlCondition($NewCondition);
684 }
685
693 public function InsertBefore($TargetItem, $NewItem)
694 {
695 # error out if ordering operations are not allowed for this item type
696 if (!$this->OrderOpsAllowed)
697 {
698 throw new Exception("Attempt to perform order operation on item"
699 ." type (".$this->ItemClassName.") that does not support"
700 ." ordering.");
701 }
702
703 # insert/move item
704 $this->OrderList->InsertBefore($TargetItem, $NewItem);
705 }
706
714 public function InsertAfter($TargetItem, $NewItem)
715 {
716 # error out if ordering operations are not allowed for this item type
717 if (!$this->OrderOpsAllowed)
718 {
719 throw new Exception("Attempt to perform order operation on item"
720 ." type (".$this->ItemClassName.") that does not support"
721 ." ordering.");
722 }
723
724 # insert/move item
725 $this->OrderList->InsertAfter($TargetItem, $NewItem);
726 }
727
733 public function Prepend($Item)
734 {
735 # error out if ordering operations are not allowed for this item type
736 if (!$this->OrderOpsAllowed)
737 {
738 throw new Exception("Attempt to perform order operation on item"
739 ." type (".$this->ItemClassName.") that does not support"
740 ." ordering.");
741 }
742
743 # prepend item
744 $this->OrderList->Prepend($Item);
745 }
746
752 public function Append($Item)
753 {
754 # error out if ordering operations are not allowed for this item type
755 if (!$this->OrderOpsAllowed)
756 {
757 throw new Exception("Attempt to perform order operation on item"
758 ." type (".$this->ItemClassName.") that does not support"
759 ." ordering.");
760 }
761
762 # add/move item
763 $this->OrderList->Append($Item);
764 }
765
770 public function GetItemIdsInOrder()
771 {
772 # error out if ordering operations are not allowed for this item type
773 if (!$this->OrderOpsAllowed)
774 {
775 throw new Exception("Attempt to perform order operation on item"
776 ." type (".$this->ItemClassName.") that does not support"
777 ." ordering.");
778 }
779
780 # retrieve list of IDs
781 return $this->OrderList->GetIds();
782 }
783
790 public function RemoveItemFromOrder($ItemId)
791 {
792 # error out if ordering operations are not allowed for this item type
793 if (!$this->OrderOpsAllowed)
794 {
795 throw new Exception("Attempt to perform order operation on item"
796 ." type (".$this->ItemClassName.") that does not support"
797 ." ordering.");
798 }
799
800 # remove item
801 $this->OrderList->Remove($ItemId);
802 }
803
804
805 # ---- PRIVATE INTERFACE -------------------------------------------------
806
822 private function ConstructSqlConditionsForSearch(
823 $SearchString, $IncludeVariants = FALSE,
824 $UseBooleanMode = TRUE, $IdExclusions = array(), $ValueExclusions=array() )
825 {
826 $QueryString = "";
827
828 # If the search string is valid but shorter than the minimum word length
829 # indexed by the FTS, just do a normal equality test instead of using
830 # the index. Otherwise, FTS away.
831 $DB = new Database();
832 $MinWordLen = $DB->Query(
833 "SHOW VARIABLES WHERE variable_name='ft_min_word_len'", "Value");
834 if (strlen($SearchString) < $MinWordLen)
835 {
836 $QueryString .= " ".$this->ItemNameColumnName
837 ."='".addslashes($SearchString)."'";
838 }
839 else if ($UseBooleanMode)
840 {
841 # When we're in boolean mode, construct a search string to use in our
842 # query. Include quoted strings verbatim. Make sure that each
843 # non-quoted word is prefixed with either + or -, so that it is
844 # either explicitly included or explicitily excluded.
845 # Keep track of stopwords in the search query (these will not
846 # match in the boolean search because FTS indexes ignores them).
847 # Append 'REGEXP' queries to match, so that our search results
848 # pay *some* attention to stopwords.
849 $SearchString = preg_replace("/[)\(><]+/", "", $SearchString);
850 $Words = preg_split("/[\s]+/", trim($SearchString));
851 $NewSearchString = "";
852 $SearchedStopwords = array();
853 $InQuotedString = FALSE;
854 $SqlVarObj = new MysqlSystemVariables($DB);
855 $StopWordList = $SqlVarObj->GetStopWords();
856 $MinWordLen = $SqlVarObj->Get("ft_min_word_len");
857 foreach ($Words as $Word)
858 {
859 # remove any query-specific terms, punctuation, etc.
860 $JustTheWord = preg_replace("/[^a-zA-Z-]/", "", $Word);
861
862 # require (boolean AND) certain words
863 if ($InQuotedString == FALSE
864 && !in_array($JustTheWord, $StopWordList)
865 && strlen($JustTheWord) >= $MinWordLen
866 && $Word{0} != "+"
867 && $Word{0} != "-")
868 {
869 $NewSearchString .= "+";
870 }
871
872 if (preg_match("/^\"/", $Word)) { $InQuotedString = TRUE; }
873 if (preg_match("/\"$/", $Word)) { $InQuotedString = FALSE; }
874 $NewSearchString .= $Word." ";
875
876 if (in_array($JustTheWord, $StopWordList))
877 {
878 $SearchedStopwords[]= $JustTheWord;
879 }
880 }
881
882 # Build onto our query string by appending the boolean search
883 # conditions
884 $QueryString .= " MATCH (".$this->ItemNameColumnName.")"
885 ." AGAINST ('".addslashes(trim($NewSearchString))."'"
886 ." IN BOOLEAN MODE)";
887
888 # If there were any stopwords included in the search string,
889 # append REGEXP conditions to match those.
890 foreach ($SearchedStopwords as $Stopword)
891 {
892 $QueryString .= " AND ".$this->ItemNameColumnName
893 ." REGEXP '".addslashes(preg_quote($Stopword))."'";
894 }
895 }
896 else
897 {
898 # If we weren't in boolean mode, just include the search
899 # string verbatim as a match condition:
900 $QueryString .= " MATCH (".$this->ItemNameColumnName.")"
901 ." AGAINST ('".addslashes(trim($SearchString))."')";
902 }
903
904 # add each ID exclusion
905 foreach ($IdExclusions as $IdExclusion)
906 {
907 $QueryString .= " AND ".$this->ItemIdColumnName." != '"
908 .addslashes($IdExclusion)."' ";
909 }
910
911 # add each value exclusion
912 foreach ($ValueExclusions as $ValueExclusion)
913 {
914 $QueryString .= " AND ".$this->ItemNameColumnName." != '"
915 .addslashes($ValueExclusion)."' ";
916 }
917
918 # add class-wide condition if set
919 if ($this->SqlCondition)
920 {
921 $QueryString .= " AND ".$this->SqlCondition;
922 }
923
924 return $QueryString;
925 }
926
927 protected $DB;
928
929 private $CachingEnabled = TRUE;
930 private $ItemClassName;
931 private $ItemTableName;
932 private $ItemIdByNameCache;
933 private $ItemIdColumnName;
934 private $ItemNameColumnName;
935 private $OrderOpsAllowed;
936 private $OrderList;
937 private $SqlCondition;
938 }
ItemFactory\GetHighestItemId
GetHighestItemId($IgnoreSqlCondition=FALSE)
Retrieve highest item ID in use.
Definition: ItemFactory.php:131
ItemFactory\GetItemIdsInOrder
GetItemIdsInOrder()
Retrieve list of item IDs in order.
Definition: ItemFactory.php:770
ItemFactory\RemoveItemFromOrder
RemoveItemFromOrder($ItemId)
Remove item from existing order.
Definition: ItemFactory.php:790
ItemFactory\Prepend
Prepend($Item)
Add item to beginning of order.
Definition: ItemFactory.php:733
ItemFactory\GetItemClassName
GetItemClassName()
Get class name of items manipulated by factory.
Definition: ItemFactory.php:66
ItemFactory\GetItemIdByName
GetItemIdByName($Name, $IgnoreCase=FALSE)
Retrieve item ID by name.
Definition: ItemFactory.php:376
Database
SQL database abstraction object with smart query caching.
Definition: Database.php:22
ItemFactory\GetItemNames
GetItemNames($SqlCondition=NULL)
Retrieve item names.
Definition: ItemFactory.php:415
ItemFactory\GetItemCount
GetItemCount($Condition=NULL, $IncludeTempItems=FALSE)
Get count of items.
Definition: ItemFactory.php:176
ItemFactory\SearchForItemNames
SearchForItemNames($SearchString, $NumberOfResults=100, $IncludeVariants=FALSE, $UseBooleanMode=TRUE, $Offset=0, $IdExclusions=array(), $ValueExclusions=array())
Retrieve items with names matching search string.
Definition: ItemFactory.php:545
ItemFactory\GetItemsAsOptionList
GetItemsAsOptionList($OptionListName, $SelectedItemId=NULL, $SqlCondition=NULL, $DisplaySize=1, $SubmitOnChange=FALSE, $Disabled=FALSE)
Retrieve items of specified type as HTML option list with item names as labels and item IDs as value ...
Definition: ItemFactory.php:487
ItemFactory\GetItem
GetItem($ItemId)
Retrieve item by item ID.
Definition: ItemFactory.php:316
ItemFactory\GetItemByName
GetItemByName($Name, $IgnoreCase=FALSE)
Retrieve item by name.
Definition: ItemFactory.php:350
ItemFactory\GetLatestModificationDate
GetLatestModificationDate($Condition=NULL)
Get newest modification date (based on values in "DateLastModified" column in database table)...
Definition: ItemFactory.php:286
ItemFactory\GetCountForItemNames
GetCountForItemNames($SearchString, $IncludeVariants=FALSE, $UseBooleanMode=TRUE, $IdExclusions=array(), $ValueExclusions=array())
Retrieve count of items with names matching search string.
Definition: ItemFactory.php:625
ItemFactory\CleanOutStaleTempItems
CleanOutStaleTempItems($MinutesUntilStale=10080)
Clear out (call the Delete() method) for any temp items more than specified number of minutes old...
Definition: ItemFactory.php:78
ItemFactory\ItemExists
ItemExists($ItemId, $IgnoreSqlCondition=FALSE)
Check that item exists with specified ID.
Definition: ItemFactory.php:328
MysqlSystemVariables
Class that allows permits easier access to MySQL system variables.
Definition: MysqlSystemVariables.php:13
ItemFactory\InsertBefore
InsertBefore($TargetItem, $NewItem)
Insert item into order before specified item.
Definition: ItemFactory.php:693
ItemFactory\CachingEnabled
CachingEnabled($NewValue=NULL)
Enable/disable caching of item information.
Definition: ItemFactory.php:650
ItemFactory\InsertAfter
InsertAfter($TargetItem, $NewItem)
Insert item into order after specified item.
Definition: ItemFactory.php:714
ItemFactory\$DB
$DB
Definition: ItemFactory.php:927
PHP
PHP
Definition: RSSClient--Test.php:12
ItemFactory\ClearCaches
ClearCaches()
Clear item information caches.
Definition: ItemFactory.php:663
PersistentDoublyLinkedList
Persistent doubly-linked-list data structure, with its data stored in a specified database table...
Definition: PersistentDoublyLinkedList.php:21
ItemFactory\GetItems
GetItems($SqlCondition=NULL)
Retrieve items.
Definition: ItemFactory.php:460
ItemFactory\GetNextTempItemId
GetNextTempItemId()
Return next available temporary item ID.
Definition: ItemFactory.php:150
ItemFactory\Append
Append($Item)
Add item to end of order.
Definition: ItemFactory.php:752
ItemFactory\SetOrderOpsCondition
SetOrderOpsCondition($Condition)
Set SQL condition (added to WHERE clause) used to select items for ordering operations.
Definition: ItemFactory.php:677
ItemFactory
Common factory class for item manipulation.
Definition: ItemFactory.php:17
ItemFactory\GetItemIds
GetItemIds($Condition=NULL, $IncludeTempItems=FALSE, $SortField=NULL, $SortAscending=TRUE)
Return array of item IDs.
Definition: ItemFactory.php:233
ItemFactory\NameIsInUse
NameIsInUse($Name, $IgnoreCase=FALSE)
Check whether item name is currently in use.
Definition: ItemFactory.php:513
HtmlOptionList
Convenience class for generating an HTML select/option form element.
Definition: HtmlOptionList.php:13
ItemFactory\__construct
__construct($ItemClassName, $ItemTableName, $ItemIdColumnName, $ItemNameColumnName=NULL, $OrderOpsAllowed=FALSE, $SqlCondition=NULL)
Class constructor.
Definition: ItemFactory.php:37
ItemFactory\GetNextItemId
GetNextItemId()
Retrieve next available (non-temp) item ID.
Definition: ItemFactory.php:105
$Items
$Items
Definition: RSSClient--Test.php:26