1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: include_once dirname(__DIR__) . '/include/common.php';
24:
25: function publisher_search_show($options)
26: {
27: $block = array();
28: $xoops = Xoops::getInstance();
29: $publisher = Publisher::getInstance();
30: $categories = $publisher->getCategoryHandler()->getCategoriesForSearch();
31: if (count($categories) == 0) return $block;
32:
33: $andor = isset($_POST["andor"]) ? $_POST["andor"] : (isset($_GET["andor"]) ? $_GET["andor"] : "");
34:
35: $category = isset($_POST["category"]) ? $_POST["category"] : (isset($_GET["category"]) ? $_GET["category"] : null);
36: $username = isset($_POST["uname"]) ? $_POST["uname"] : (isset($_GET["uname"]) ? $_GET["uname"] : null);
37: $searchin = isset($_POST["searchin"]) ? $_POST["searchin"] : (isset($_GET["searchin"]) ? explode("|", $_GET["searchin"]) : array());
38: $sortby = isset($_POST["sortby"]) ? $_POST["sortby"] : (isset($_GET["sortby"]) ? $_GET["sortby"] : null);
39: $term = isset($_POST["term"]) ? $_POST["term"] : (isset($_GET["term"]) ? $_GET["term"] : "");
40:
41: if (empty($category) || (is_array($category) && in_array("all", $category))) {
42: $category = array();
43: } else {
44: $category = (!is_array($category)) ? explode(",", $category) : $category;
45: $category = array_map("intval", $category);
46: }
47:
48: $andor = (in_array(strtoupper($andor), array("OR", "AND", "EXACT"))) ? strtoupper($andor) : "OR";
49: $sortby = (in_array(strtolower($sortby), array("itemid", "datesub", "title", "categoryid"))) ? strtolower($sortby) : "itemid";
50:
51:
52: $type_select = "<select name=\"andor\">";
53: $type_select .= "<option value=\"OR\"";
54: if ("OR" === $andor) $type_select .= " selected=\"selected\"";
55: $type_select .= ">" . XoopsLocale::ANY_OR . "</option>";
56: $type_select .= "<option value=\"AND\"";
57: if ("AND" === $andor) $type_select .= " selected=\"selected\"";
58: $type_select .= ">" . XoopsLocale::ALL . "</option>";
59: $type_select .= "<option value=\"EXACT\"";
60: if ("exact" === $andor) $type_select .= " selected=\"selected\"";
61: $type_select .= ">" . XoopsLocale::EXACT_MATCH . "</option>";
62: $type_select .= "</select>";
63:
64:
65:
66: $select_category = "<select name=\"category[]\" size=\"5\" multiple=\"multiple\" width=\"150\" style=\"width:150px;\">";
67: $select_category .= "<option value=\"all\"";
68: if (empty($category) || count($category) == 0) $select_category .= "selected=\"selected\"";
69: $select_category .= ">" . XoopsLocale::ALL . "</option>";
70: foreach ($categories as $id => $cat) {
71: $select_category .= "<option value=\"" . $id . "\"";
72: if (in_array($id, $category)) $select_category .= "selected=\"selected\"";
73: $select_category .= ">" . $cat . "</option>";
74: }
75: $select_category .= "</select>";
76:
77:
78: $searchin_select = "";
79: $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\"";
80: if (in_array("title", $searchin)) $searchin_select .= " checked";
81: $searchin_select .= " />" . _CO_PUBLISHER_TITLE . " ";
82: $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"subtitle\"";
83: if (in_array("subtitle", $searchin)) $searchin_select .= " checked";
84: $searchin_select .= " />" . _CO_PUBLISHER_SUBTITLE . " ";
85: $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"summary\"";
86: if (in_array("summary", $searchin)) $searchin_select .= " checked";
87: $searchin_select .= " />" . _CO_PUBLISHER_SUMMARY . " ";
88: $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\"";
89: if (in_array("body", $searchin)) $searchin_select .= " checked";
90: $searchin_select .= " />" . _CO_PUBLISHER_BODY . " ";
91: $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"keywords\"";
92: if (in_array("meta_keywords", $searchin)) $searchin_select .= " checked";
93: $searchin_select .= " />" . _CO_PUBLISHER_ITEM_META_KEYWORDS . " ";
94: $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\"";
95: if (in_array("all", $searchin) || empty($searchin)) $searchin_select .= " checked";
96: $searchin_select .= " />" . XoopsLocale::ALL . " ";
97:
98:
99: $sortby_select = "<select name=\"sortby\">";
100: $sortby_select .= "<option value=\"itemid\"";
101: if ("itemid" === $sortby || empty($sortby)) $sortby_select .= " selected=\"selected\"";
102: $sortby_select .= ">" . XoopsLocale::NONE . "</option>";
103: $sortby_select .= "<option value=\"datesub\"";
104: if ("datesub" === $sortby) $sortby_select .= " selected=\"selected\"";
105: $sortby_select .= ">" . _CO_PUBLISHER_DATESUB . "</option>";
106: $sortby_select .= "<option value=\"title\"";
107: if ("title" === $sortby) $sortby_select .= " selected=\"selected\"";
108: $sortby_select .= ">" . _CO_PUBLISHER_TITLE . "</option>";
109: $sortby_select .= "<option value=\"categoryid\"";
110: if ("categoryid" === $sortby) $sortby_select .= " selected=\"selected\"";
111: $sortby_select .= ">" . _CO_PUBLISHER_CATEGORY . "</option>";
112: $sortby_select .= "</select>";
113:
114: $block["type_select"] = $type_select;
115: $block["searchin_select"] = $searchin_select;
116: $block["category_select"] = $select_category;
117: $block["sortby_select"] = $sortby_select;
118: $block["search_term"] = $term;
119: $block["search_user"] = $username;
120: $block["publisher_url"] = PUBLISHER_URL;
121:
122: return $block;
123: }
124: