-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
finder.php
123 lines (107 loc) · 2.97 KB
/
finder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die;
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* HTML behavior class for Finder.
*
* @since 2.5
*/
abstract class JHtmlFinder
{
/**
* Creates a list of types to filter on.
*
* @return array An array containing the types that can be selected.
*
* @since 2.5
*/
public static function typeslist()
{
$lang = JFactory::getLanguage();
// Load the finder types.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT t.title AS text, t.id AS value')
->from($db->quoteName('#__finder_types') . ' AS t')
->join('LEFT', $db->quoteName('#__finder_links') . ' AS l ON l.type_id = t.id')
->order('t.title ASC');
$db->setQuery($query);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return;
}
// Compile the options.
$options = array();
foreach ($rows as $row)
{
$key = $lang->hasKey(FinderHelperLanguage::branchPlural($row->text))
? FinderHelperLanguage::branchPlural($row->text) : $row->text;
$string = JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_($key));
$options[] = JHtml::_('select.option', $row->value, $string);
}
return $options;
}
/**
* Creates a list of maps.
*
* @return array An array containing the maps that can be selected.
*
* @since 2.5
*/
public static function mapslist()
{
$lang = JFactory::getLanguage();
// Load the finder types.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('title AS text, id AS value')
->from($db->quoteName('#__finder_taxonomy'))
->where($db->quoteName('parent_id') . ' = 1')
->order('ordering, title ASC');
$db->setQuery($query);
try
{
$rows = $db->loadObjectList();
}
catch (RuntimeException $e)
{
return;
}
// Compile the options.
$options = array();
$options[] = JHtml::_('select.option', '1', JText::_('COM_FINDER_MAPS_SELECT_BRANCH'));
foreach ($rows as $row)
{
$key = $lang->hasKey(FinderHelperLanguage::branchPlural($row->text))
? FinderHelperLanguage::branchPlural($row->text) : $row->text;
$string = JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_($key));
$options[] = JHtml::_('select.option', $row->value, $string);
}
return $options;
}
/**
* Creates a list of published states.
*
* @return array An array containing the states that can be selected.
*
* @since 2.5
*/
public static function statelist()
{
$options = array();
$options[] = JHtml::_('select.option', '1', JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_('JPUBLISHED')));
$options[] = JHtml::_('select.option', '0', JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_('JUNPUBLISHED')));
return $options;
}
}