-
Notifications
You must be signed in to change notification settings - Fork 1
/
jlfinder.php
157 lines (135 loc) · 4.99 KB
/
jlfinder.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* @package Joomla.Plugin
* @subpackage System.JLFinder
*
* @copyright Copyright (C) 2018 Hannes Papenberg. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomlager Finder Plugin.
*
* @since 1.0
*/
class PlgSystemJLFinder extends JPlugin
{
public function onAfterInitialise()
{
JLoader::register('FinderControllerIndexer', __DIR__ . '/admin/controllers/indexer.json.php');
JLoader::register('FinderModelSearch', __DIR__ . '/site/models/search.php');
JLoader::register('FinderIndexer', __DIR__ . '/admin/helpers/indexer/indexer.php');
JLoader::register('FinderIndexerQuery', __DIR__ . '/admin/helpers/indexer/query.php');
JLoader::register('FinderModelIndex', __DIR__ . '/admin/models/index.php');
JLoader::register('FinderModelMaps', __DIR__ . '/admin/models/maps.php');
JLoader::register('FinderViewSearch', __DIR__ . '/site/views/search/view.html.php');
JLoader::register('FinderViewIndexer', __DIR__ . '/admin/views/indexer/view.html.php');
JLoader::register('FinderViewMaps', __DIR__ . '/admin/views/maps/view.html.php');
JLoader::register('FinderIndexerAdapter', __DIR__ . '/admin/helpers/indexer/adapter.php');
require_once __DIR__ . '/admin/helpers/html/finder.php';
JLoader::register('Joomla\\Component\\Finder\\Administrator\\Table\\MapTable', __DIR__ . '/admin/tables/MapTable.php');
JLoader::registerNamespace('Wamania\\Snowball', __DIR__ . '/libraries/php-stemmer/src', false, false, 'psr4');
include_once JPATH_PLUGINS . '/system/jlfinder/site/helpers/html/filter.php';
//For unknown reasons, the FinderIndexerAdapter class is still loaded from the original component folder. Thus this ugly hack...
//JLoader::register('FinderIndexerAdapter', dirname(__FILE__) . '/admin/helpers/indexer/adapter.php');
require_once __DIR__ . '/admin/helpers/indexer/indexer.php';
require_once __DIR__ . '/admin/helpers/indexer/helper.php';
//require_once __DIR__ . '/admin/helpers/indexer/taxonomy.php';
require_once __DIR__ . '/admin/helpers/indexer/adapter.php';
}
public function onContentPrepareForm(JForm $form, $data)
{
if ($form->getName() == 'com_config.component')
{
return $this->configForm($form, $data);
}
if (strpos($form->getName(), 'com_categories.category') !== false)
{
return $this->categoriesForm($form, $data);
}
if (strpos($form->getName(), 'com_content.article') !== false)
{
return $this->contentForm($form, $data);
}
}
public function onJCalAfterSave($context, $article, $isNew)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderAfterSave event.
$dispatcher->trigger('onFinderAfterSave', array($context, $article, $isNew));
}
public function onJCalBeforeSave($context, $article, $isNew)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderBeforeSave event.
$dispatcher->trigger('onFinderBeforeSave', array($context, $article, $isNew));
}
public function onJCalAfterDelete($context, $article)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderAfterDelete event.
$dispatcher->trigger('onFinderAfterDelete', array($context, $article));
}
public function onJCalChangeState($context, $pks, $value)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderChangeState event.
$dispatcher->trigger('onFinderChangeState', array($context, $pks, $value));
}
public function onCategoryChangeState($extension, $pks, $value)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderCategoryChangeState event.
$dispatcher->trigger('onFinderCategoryChangeState', array($extension, $pks, $value));
}
protected function configForm(JForm $form, $data)
{
$app = JFactory::getApplication();
if ($app->input->get('component') != 'com_finder')
{
return;
}
$form->reset(true);
$form->loadFile(__DIR__ . '/admin/config.xml', true, '/config');
$form->bind($data);
}
protected function categoriesForm(JForm $form, $data)
{
$form->load('<form><fields name="params"><fieldset name="basic"><field
name="com_finder_dontindex"
type="radio"
label="Don\'t add to Smart Search index"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field></fieldset></fields></form>');
}
protected function contentForm(JForm $form, $data)
{
$form->load('<form>
<fields name="attribs">
<fieldset name="basic">
<field
name="finder_dontindex"
type="radio"
label="Don\'t add to Smart Search index"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>');
}
}