-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSaveSearchPlugin.php
78 lines (70 loc) · 1.67 KB
/
SaveSearchPlugin.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
<?php
namespace Craft;
/**
* Save Search @v1.1
*
* A plugin that allows your last search to be saved
* and populated in the search box's in Craft. This is
* useful when navigating away from a listings page and
* wanting to retain your search when you return.
*
* @author Peter Tell - http://page-8.com
* @package Save Search
* @copyright 2014 Page 8
* @license [MIT]
*
*/
class SaveSearchPlugin extends BasePlugin
{
/**
* Fire's on the bootstrap
*/
public function init()
{
parent::init();
if (craft()->request->isCpRequest() && !craft()->request->isAjaxRequest())
{
// Grab the specific area of the site we're in and store the search against this value.
// This way we can have different searches across different sections
$segment = craft()->request->getSegment(1);
craft()->templates->includeJs('var area = "' . $segment . '";');
craft()->templates->includeJsResource('savesearch/js/save-search.js');
}
}
/**
* Returns the plugins name
*
* @return mixed|string
*/
public function getName()
{
return Craft::t('Save Search');
}
/**
* Returns the plugin’s version.
*
* @return string
*/
public function getVersion()
{
return '1.1';
}
/**
* Returns the plugin developer's name.
*
* @return string
*/
public function getDeveloper()
{
return 'Page 8';
}
/**
* Returns the plugin developer's URL.
*
* @return string
*/
public function getDeveloperUrl()
{
return 'http://page-8.com';
}
}