1: <?php
2: /**
3: * Ansel_Search:: Provides a generic interface for various types of image
4: * searches that are to be displayed in a paged results view.
5: *
6: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Michael J. Rubinsky <mrubinsk@horde.org>
12: * @package Ansel
13: */
14: class Ansel_Search {
15:
16: /**
17: * The type of search we are performing.
18: *
19: * @var string
20: */
21: var $_type = '';
22:
23: /**
24: * The field we are searching
25: *
26: * @var string
27: */
28: var $_field = '';
29:
30: /**
31: * Parameters
32: *
33: * @var array
34: */
35: var $_params = array();
36:
37: /**
38: * Create a concrete search instance.
39: *
40: * @param string $type The type of search to perform.
41: * @param array $params Parameters for the concrete class.
42: */
43: function factory($type, $params = array())
44: {
45: $type = basename($type);
46: $class = 'Ansel_Search_' . $type;
47: if (!class_exists($class)) {
48: include dirname(__FILE__) . '/Search/' . $type . '.php';
49: }
50: if (class_exists($class)) {
51: $search = new $class($params);
52: return $search;
53: }
54:
55: return PEAR::raiseError(sprintf(_("Unable to load the definition of %s."), $class));
56: }
57:
58: /**
59: * Save the current search terms to the session
60: *
61: */
62: function save()
63: {
64: $GLOBALS['session']->set('ansel', 'search/' . $this->_type, $this->_filter);
65: }
66:
67: /**
68: * Load any search terms in the session
69: *
70: */
71: function load()
72: {
73: $this->_filter = $GLOBALS['session']->get('ansel', 'search/' . $this->_type, Horde_Session::TYPE_ARRAY);
74: }
75: /**
76: * retrieve a slice of the current search
77: *
78: * @param unknown_type $page
79: * @param unknown_type $perpage
80: */
81: function getSlice($page, $perpage)
82: {
83: }
84:
85: /**
86: * Add a search term
87: *
88: * @param array $filter value to filter.
89: */
90: function addFilter($filter)
91: {
92: }
93:
94: /**
95: * Get the total number of resources that match
96: */
97: function count()
98: {
99: }
100:
101: }
102: