Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
backend_search.inc
1 <?php
31 {
32 
33 
43  public static function isAvailable()
44  {
45  return $GLOBALS['SQ_SYSTEM']->am->installed('search_manager');
46 
47  }//end isAvailable()
48 
49 
72  public static function processSearch($search_terms, $restrict_statuses=Array(), $restrict_asset_types=Array())
73  {
74  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
75 
77  $sm = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('search_manager');
78 
79  // Are we restricting statuses? If not, use all of them
80  if (empty($restrict_statuses)) {
81  $restrict_statuses = get_constant_values('SQ_STATUS_');
82  }
83 
84  $search_info = Array(
85  'fields' => Array(
86  'backend' => Array(
87  'words' => $search_terms,
88  'word_logic' => 'AND',
89  'data_sources' => Array(
90  0 => Array('type' => 'include_all'),
91  ),
92  ),
93  ),
94  'statuses' => $restrict_statuses,
95  );
96 
97  // Are we restricting by asset types? If so, add them as a condition
98  if (!empty($restrict_asset_types)) {
99  $search_info['asset_types'] = $restrict_asset_types;
100  }
101 
102  // Do the search
103  $results = $sm->processSearch($search_info, TRUE);
104 
105  if (!empty($results)) {
106  $result_limit = $GLOBALS['SQ_SYSTEM']->getUserPrefs('search_manager', 'SQ_SEARCH_BACKEND_RESULT_LIMIT');
107  $results = $sm->getCondensedResults($results);
108  if ($result_limit > 0) {
109  $results = array_slice($results, 0, $result_limit, TRUE);
110  }
111  $results = $sm->getFormattedResults($results, $search_terms, FALSE);
112 
113  }
114  } else {
115  $results = Array();
116  }
117 
118  return $results;
119 
120  }//end processSearch()
121 
122 
123 }//end class
124 
125 ?>