This repository has been archived by the owner on Apr 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetbiblesearch.php
179 lines (143 loc) · 4.6 KB
/
getbiblesearch.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
*
* @version 1.0.1 November 7, 2014
* @package Get Bible - Search Module
* @author Llewellyn van der Merwe <[email protected]>
* @copyright Copyright (C) 2013 Vast Development Method <http://www.vdm.io>
* @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
*
**/
defined( '_JEXEC' ) or die;
jimport('joomla.application.component.helper');
jimport('joomla.application.router');
class getSearch
{
public $action;
public $uniqueId;
public $document;
public $params;
public $books;
public $versions;
protected $component;
public function __construct(&$params)
{
// get the document
$this->document = &JFactory::getDocument();
// set the getBible component defaults
$this->component = &JComponentHelper::getComponent('com_getbible');
// set the getBible component params
$this->params = &JComponentHelper::getParams('com_getbible');
// make sure all scripts are loaded
if (!$this->css_loaded('uikit')) {
$this->document->addStyleSheet(JURI::base( true ) .'/media/com_getbible/css/uikit.min.css');
}
if (!$this->js_loaded('jquery')) {
if($params->get('search_options') == 1){
JHtml::_('jquery.framework');
}
}
if (!$this->js_loaded('uikit')) {
$this->document->addScript(JURI::base( true ) .'/media/com_getbible/js/uikit.min.js');
}
// load the correct form action
$itemid = $this->getMenuItemId('app');
if($itemid){
$this->action = $this->getRouteUrl('index.php?Itemid='.$itemid);
} else {
$this->action = $this->getRouteUrl('index.php?option=com_getbible&view=app');
}
$this->uniqueId = $this->randomkey(8);
// get the versions list
$this->versions = $this->getVersions();
}
protected function getMenuItemId($view) {
$menu = JFactory::getApplication()->getMenu();
//get only com_getbible menu items
$items = $menu->getItems('component_id', $this->component->id);
foreach ($items as $item) {
if (isset($item->query['view']) && $item->query['view'] === $view) {
return $item->id;
}
}
return false;
}
protected function getRouteUrl($route) {
// Get the global site router.
$config = &JFactory::getConfig();
$router = JRouter::getInstance('site');
$router->setMode( $config->get('sef', 1) );
$uri = &$router->build($route);
$path = $uri->toString(array('path', 'query', 'fragment'));
return $path;
}
protected function randomkey($size) {
$bag = "abcefghijknop1234567890qrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrs0987654321tuvvwxyzABCEFGHIJKNOPQRSTUWXYZ";
$key = array();
$bagsize = strlen($bag) - 1;
for ($i = 0; $i < $size; $i++) {
$get = rand(0, $bagsize);
$key[] = $bag[$get];
}
return implode($key);
}
public function getVersions()
{
if ($this->params->get('jsonQueryOptions') == 1){
$path = JPATH_SITE.'/media/com_getbible/json/cpanel.json';
$cpanel = @file_get_contents($path);
if($cpanel === FALSE){
return false;
}
return json_decode($cpanel);
} elseif ($this->params->get('jsonQueryOptions') == 2) {
$path = 'https://getbible.net/media/com_getbible/json/cpanel.json';
$cpanel = @file_get_contents($path);
if($cpanel === FALSE){
return false;
}
return json_decode($cpanel);
} else {
$path = 'https://getbible.net/media/com_getbible/json/cpanel.json';
$cpanel = @file_get_contents($path);
if($cpanel === FALSE){
return false;
}
return json_decode($cpanel);
}
}
protected function js_loaded($script_name)
{
// UIkit check point
if($script_name == 'uikit'){
$getTemplateName = JFactory::getApplication()->getTemplate('template')->template;
if (strpos($getTemplateName,'yoo') !== false) {
return true;
}
}
$head_data = $this->document->getHeadData();
foreach (array_keys($head_data['scripts']) as $script) {
if (stristr($script, $script_name)) {
return true;
}
}
return false;
}
protected function css_loaded($script_name)
{
// UIkit check point
if($script_name == 'uikit'){
$getTemplateName = JFactory::getApplication()->getTemplate('template')->template;
if (strpos($getTemplateName,'yoo') !== false) {
return true;
}
}
$head_data = $this->document->getHeadData();
foreach (array_keys($head_data['styleSheets']) as $script) {
if (stristr($script, $script_name)) {
return true;
}
}
return false;
}
}