CMS  Version 3.9
searchable.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2011 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
44 interface Searchable
45 {
51  function search($params, $range = null);
52 }
53 
54 
55 abstract class AbstractSearchResult
56 {
57  // Provide access to the properties of the underlying class
58  abstract function getPrimaryKey();
59  abstract function get($field);
60  abstract function prettifyClassName($plural = false);
61 
62  abstract function relevance();
63  abstract function title();
64  abstract function date();
65 
66  abstract function format($format);
67 
76  abstract function summary();
77 
78  function formatIcon($icon, $alt)
79  {
80  return "<img class='search_result_icon' src='$icon' alt='$alt'/>\n";
81  }
82 
83 }
84 ?>
$range
Definition: error_log.inc:13
$icon
Definition: upload.inc:92
summary()
Display the item title and any other essential details for the item such as author and a create date.
formatIcon($icon, $alt)
Definition: searchable.inc:78
prettifyClassName($plural=false)
The Searchable interface must be implemented by any DataItem classes that want to be searchable via t...
Definition: searchable.inc:45
search($params, $range=null)
DataItems must implement this method to provide search functionality.