System_Configuration_Search - Version 0.7.0

Version Notes

Download this release

Release Info

Developer Alan Storm
Extension System_Configuration_Search
Version 0.7.0
Comparing to
See all releases


Code changes from version 0.6.3 to 0.7.0

Files changed (22) hide show
  1. app/code/{local → community}/Alanstormdotcom/Systemsearch/Block/Searchresults.php +34 -34
  2. app/code/community/Alanstormdotcom/Systemsearch/Block/Template.php +48 -0
  3. app/code/{local → community}/Alanstormdotcom/Systemsearch/Helper/Data.php +31 -32
  4. app/code/community/Alanstormdotcom/Systemsearch/Helper/Jsonconfigsearch.php +127 -0
  5. app/code/{local/Alanstormdotcom/Systemsearch/Block/Template.php → community/Alanstormdotcom/Systemsearch/Helper/Simplexml.php} +41 -34
  6. app/code/community/Alanstormdotcom/Systemsearch/Model/Configsearch.php +153 -0
  7. app/code/community/Alanstormdotcom/Systemsearch/Model/Observer.php +60 -0
  8. app/code/{local → community}/Alanstormdotcom/Systemsearch/controllers/Adminhtml/AlanstormdotcomsystemsearchController.php +1 -1
  9. app/code/{local → community}/Alanstormdotcom/Systemsearch/etc/config.xml +1 -1
  10. app/code/{local → community}/Alanstormdotcom/Systemsearch/images/left.gif +0 -0
  11. app/code/{local → community}/Alanstormdotcom/Systemsearch/images/right.gif +0 -0
  12. app/code/{local → community}/Alanstormdotcom/Systemsearch/phtml/prototype.phtml +0 -0
  13. app/code/{local → community}/Alanstormdotcom/Systemsearch/phtml/results.phtml +0 -0
  14. app/code/{local → community}/Alanstormdotcom/Systemsearch/phtml/searchform.phtml +0 -0
  15. app/code/local/Alanstormdotcom/Systemsearch/Helper/Jsonconfigsearch.php +0 -127
  16. app/code/local/Alanstormdotcom/Systemsearch/Helper/Simplexml.php +0 -55
  17. app/code/local/Alanstormdotcom/Systemsearch/Model/Configsearch.php +0 -153
  18. app/code/local/Alanstormdotcom/Systemsearch/Model/Observer.php +0 -60
  19. app/design/adminhtml/default/default/images/alanstormdotcom/left.gif +0 -0
  20. app/design/adminhtml/default/default/images/alanstormdotcom/right.gif +0 -0
  21. app/etc/modules/Alanstormdotcom_Systemsearch.xml +1 -1
  22. package.xml +1 -17
app/code/{local → community}/Alanstormdotcom/Systemsearch/Block/Searchresults.php RENAMED
@@ -3,7 +3,7 @@
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
@@ -11,36 +11,36 @@
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
*/
14
- class Alanstormdotcom_Systemsearch_Block_Searchresults extends Alanstormdotcom_Systemsearch_Block_Template
15
- {
16
- protected $_resultsArray;
17
-
18
- const ARROW_SEP = ' <span style="font-family:fixed">-&gt;</span> ';
19
- public function __construct()
20
- {
21
- $this->setTemplate('results.phtml');
22
- }
23
-
24
- public function addResultsArray($array)
25
- {
26
- $array = array_unique($array);
27
- sort($array);
28
- $this->assignResultsArray($array);
29
- return $this;
30
- }
31
-
32
- protected function assignResultsArray($array)
33
- {
34
- $this->_resultsArray = $array;
35
- }
36
-
37
- protected function fetchResultsArray()
38
- {
39
- return $this->_resultsArray;
40
- }
41
-
42
- protected function fetchStyledResultsArray()
43
- {
44
- return str_replace('/',self::ARROW_SEP,$this->fetchResultsArray());
45
- }
46
- }
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
*/
14
+ class Alanstormdotcom_Systemsearch_Block_Searchresults extends Alanstormdotcom_Systemsearch_Block_Template
15
+ {
16
+ protected $_resultsArray;
17
+
18
+ const ARROW_SEP = ' <span style="font-family:fixed">-&gt;</span> ';
19
+ public function __construct()
20
+ {
21
+ $this->setTemplate('results.phtml');
22
+ }
23
+
24
+ public function addResultsArray($array)
25
+ {
26
+ $array = array_unique($array);
27
+ sort($array);
28
+ $this->assignResultsArray($array);
29
+ return $this;
30
+ }
31
+
32
+ protected function assignResultsArray($array)
33
+ {
34
+ $this->_resultsArray = $array;
35
+ }
36
+
37
+ protected function fetchResultsArray()
38
+ {
39
+ return $this->_resultsArray;
40
+ }
41
+
42
+ protected function fetchStyledResultsArray()
43
+ {
44
+ return str_replace('/',self::ARROW_SEP,$this->fetchResultsArray());
45
+ }
46
+ }
app/code/community/Alanstormdotcom/Systemsearch/Block/Template.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+ /**
3
+ * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
+ *
5
+ * The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+ class Alanstormdotcom_Systemsearch_Block_Template extends Mage_Core_Block_Template
15
+ {
16
+ protected function _checkValidScriptPath($scriptPath)
17
+ {
18
+ $paths_to_check = array(Mage::getBaseDir('design'),Mage::getModuleDir('', 'Alanstormdotcom_Systemsearch'));
19
+ $valid = false;
20
+ foreach($paths_to_check as $path)
21
+ {
22
+ if(strpos($scriptPath, realpath($path)) === 0)
23
+ {
24
+ $valid = true;
25
+ }
26
+ }
27
+ return $valid;
28
+ }
29
+
30
+ public function setScriptPath($dir)
31
+ {
32
+ $scriptPath = realpath($dir);
33
+ if ($this->_checkValidScriptPath($scriptPath)) {
34
+ $this->_viewDir = $dir;
35
+ } else {
36
+ Mage::log('Not valid script path:' . $dir, Zend_Log::CRIT, null, null, true);
37
+ }
38
+ return $this;
39
+ }
40
+
41
+ public function fetchView($fileName)
42
+ {
43
+ //ignores file name, just uses a simple include with template name
44
+ $this->setScriptPath(Mage::getConfig()->getModuleDir('','Alanstormdotcom_Systemsearch') . '/phtml');
45
+ return parent::fetchView($this->getTemplate());
46
+ }
47
+
48
+ }
app/code/{local → community}/Alanstormdotcom/Systemsearch/Helper/Data.php RENAMED
@@ -3,7 +3,7 @@
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
@@ -11,34 +11,33 @@
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
*/
14
- class Alanstormdotcom_Systemsearch_Helper_Data extends Mage_Core_Helper_Abstract
15
- {
16
- public function reverseTranslate($word)
17
- {
18
- $translated = $this->__($word);
19
- $reverse_legend = array_flip(Mage::app()->getTranslator()->getData());
20
- if(array_key_exists($translated, $reverse_legend))
21
- {
22
- return $reverse_legend[$translated];
23
- }
24
- return $word;
25
- }
26
-
27
- public function isModuleOutputEnabled($moduleName = null)
28
- {
29
- if(is_callable(array(Mage::helper('core'),'isModuleOutputEnabled')))
30
- {
31
- return parent::isModuleOutputEnabled();
32
- }
33
-
34
- if ($moduleName === null) {
35
- $moduleName = $this->_getModuleName();
36
- }
37
- if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) {
38
- return false;
39
- }
40
- return true;
41
- }
42
- }
43
-
44
-
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
*/
14
+ class Alanstormdotcom_Systemsearch_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+ public function reverseTranslate($word)
17
+ {
18
+ $translated = $this->__($word);
19
+ $reverse_legend = array_flip(Mage::app()->getTranslator()->getData());
20
+ if(array_key_exists($translated, $reverse_legend))
21
+ {
22
+ return $reverse_legend[$translated];
23
+ }
24
+ return $word;
25
+ }
26
+
27
+ public function isModuleOutputEnabled($moduleName = null)
28
+ {
29
+ if(is_callable(array(Mage::helper('core'),'isModuleOutputEnabled')))
30
+ {
31
+ return parent::isModuleOutputEnabled();
32
+ }
33
+
34
+ if ($moduleName === null) {
35
+ $moduleName = $this->_getModuleName();
36
+ }
37
+ if (Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName)) {
38
+ return false;
39
+ }
40
+ return true;
41
+ }
42
+ }
43
+
app/code/community/Alanstormdotcom/Systemsearch/Helper/Jsonconfigsearch.php ADDED
@@ -0,0 +1,127 @@
1
+ <?php
2
+ /**
3
+ * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
+ *
5
+ * The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+ class Alanstormdotcom_Systemsearch_Helper_Jsonconfigsearch extends Mage_Core_Helper_Abstract
15
+ {
16
+ public function prepareAndSendResponse($nodes, $terms)
17
+ {
18
+ $response = new stdClass();
19
+ $response->responseText = array();
20
+ $response->results = array();
21
+ $response->search_terms = $terms;
22
+ $helper = Mage::helper('adminhtml');
23
+ foreach($nodes as $type=>$all_of_type)
24
+ {
25
+ foreach($all_of_type as $value)
26
+ {
27
+ $value = $this->fetchSimpleXmlHelper()->switchFromCommentToLabel($value);
28
+
29
+ if($type == Alanstormdotcom_Systemsearch_Model_Configsearch::TYPE_SYSTEM_CONFIG_SECTION)
30
+ {
31
+ $response->responseText[] = 'Configuration/' . (string) $value;
32
+
33
+ $result = new stdClass();
34
+ $result->found = true;
35
+ $result->found_type = 'nav'; //other option is 'group'
36
+ $result->found_label = $helper->__((string) $value);
37
+ $result->type = $type;
38
+ $response->results[] = $result;
39
+ }
40
+ else if($type == Alanstormdotcom_Systemsearch_Model_Configsearch::TYPE_SYSTEM_CONFIG_GROUP)
41
+ {
42
+ $result = new stdClass();
43
+ $result->found = true;
44
+ $result->found_type = 'group'; //other option is 'group'
45
+ $result->found_label = $helper->__((string) $value);
46
+ $label_group = $result->found_label;
47
+ $result->type = $type;
48
+ $result->path = $this->fetchSimpleXmlHelper()->getPathExpression($value);
49
+
50
+ $response->results[] = $result;
51
+
52
+ //hop up three nodes to get the nav section
53
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($value);
54
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
55
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
56
+ $result = new stdClass();
57
+ $result->found = true;
58
+ $result->found_type = 'nav'; //other option is 'group'
59
+ $result->found_label = $helper->__((string) $parent->label);
60
+ $label_nav = $result->found_label;
61
+ $result->type = $type;
62
+ $response->results[] = $result;
63
+
64
+ //and also point out the nav
65
+ $response->responseText[] = 'Configuration/' .
66
+ $label_nav .
67
+ '/' .
68
+ $label_group .
69
+ '';
70
+ }
71
+ else if($type == Alanstormdotcom_Systemsearch_Model_Configsearch::TYPE_SYSTEM_CONFIG_FIELD)
72
+ {
73
+ //hop up to group
74
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($value);
75
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
76
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
77
+
78
+ $result = new stdClass();
79
+ $result->found = true;
80
+ $result->found_type = 'group'; //other option is 'group'
81
+ $result->found_label = $helper->__((string) $parent->label);
82
+ $label_group = $result->found_label;
83
+ $result->type = $type;
84
+ $response->results[] = $result;
85
+
86
+ // //hope up to section
87
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
88
+ $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
89
+
90
+ $result = new stdClass();
91
+ $result->found = true;
92
+ $result->found_type = 'nav'; //other option is 'group'
93
+ $result->found_label = $helper->__((string) $parent->label);
94
+ $label_nav = $result->found_label;
95
+ $result->type = $type;
96
+ $response->results[] = $result;
97
+
98
+ $response->responseText[] = 'Configuration/' .
99
+ $label_nav .
100
+ '/' .
101
+ $label_group .
102
+ '/' .
103
+ (string) $value;
104
+ }
105
+ }
106
+ }
107
+
108
+ $response->responseText = $this->fetchLayout()->createBlock('alanstormdotcomsystemsearch/searchresults')
109
+ ->addResultsArray($response->responseText)
110
+ ->toHtml();
111
+
112
+ header('Content-Type: application/json');
113
+ echo json_encode($response);
114
+ exit;
115
+ }
116
+
117
+ protected function fetchSimpleXmlHelper()
118
+ {
119
+ return Mage::helper('alanstormdotcomsystemsearch/simplexml');
120
+ }
121
+
122
+ private function fetchLayout()
123
+ {
124
+ return Mage::getSingleton('core/layout');;
125
+ }
126
+
127
+ }
app/code/{local/Alanstormdotcom/Systemsearch/Block/Template.php → community/Alanstormdotcom/Systemsearch/Helper/Simplexml.php} RENAMED
@@ -3,7 +3,7 @@
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
@@ -11,38 +11,45 @@
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
*/
14
- class Alanstormdotcom_Systemsearch_Block_Template extends Mage_Core_Block_Template
15
- {
16
- protected function _checkValidScriptPath($scriptPath)
17
- {
18
- $paths_to_check = array(Mage::getBaseDir('design'),Mage::getModuleDir('', 'Alanstormdotcom_Systemsearch'));
19
- $valid = false;
20
- foreach($paths_to_check as $path)
21
- {
22
- if(strpos($scriptPath, realpath($path)) === 0)
23
- {
24
- $valid = true;
25
- }
26
- }
27
- return $valid;
28
- }
29
-
30
- public function setScriptPath($dir)
31
- {
32
- $scriptPath = realpath($dir);
33
- if ($this->_checkValidScriptPath($scriptPath)) {
34
- $this->_viewDir = $dir;
35
- } else {
36
- Mage::log('Not valid script path:' . $dir, Zend_Log::CRIT, null, null, true);
37
- }
38
- return $this;
39
- }
40
-
41
- public function fetchView($fileName)
42
{
43
- //ignores file name, just uses a simple include with template name
44
- $this->setScriptPath(Mage::getConfig()->getModuleDir('','Alanstormdotcom_Systemsearch') . '/phtml');
45
- return parent::fetchView($this->getTemplate());
46
}
47
-
48
- }
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
11
*
12
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
*/
14
+ class Alanstormdotcom_Systemsearch_Helper_Simplexml extends Mage_Core_Helper_Abstract
15
+ {
16
+ public function switchFromCommentToLabel($node)
17
+ {
18
+ if($node->getName() != 'comment')
19
{
20
+ return $node;
21
}
22
+ $nodes = $node->xpath('../label');
23
+ $node = count($nodes) ? $nodes[0] : $node;
24
+ return $node;
25
+ }
26
+
27
+ public function getPathExpression($node)
28
+ {
29
+ $reverse = $this->getReversePathExpression($node);
30
+ return implode('/',array_reverse(explode('/', $reverse)));
31
+ }
32
+
33
+ public function getParentNode($node)
34
+ {
35
+ $nodes = $node->xpath('..');
36
+ if(count($nodes) > 0)
37
+ {
38
+ return $nodes[0];
39
+ }
40
+ return false;
41
+ }
42
+
43
+ public function getReversePathExpression($node,$fragment='')
44
+ {
45
+ $parent = $this->getParentNode($node);
46
+ if($parent)
47
+ {
48
+ //recursion, HO!
49
+ $fragment .= $parent->getName() . '/';
50
+ return $this->getReversePathExpression($parent, $fragment);
51
+ }
52
+ return $fragment;
53
+ }
54
+
55
+ }
app/code/community/Alanstormdotcom/Systemsearch/Model/Configsearch.php ADDED
@@ -0,0 +1,153 @@
1
+ <?php
2
+ /**
3
+ * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
+ *
5
+ * The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+ class Alanstormdotcom_Systemsearch_Model_Configsearch
15
+ {
16
+ public function searchSystemConfigForTerms($terms)
17
+ {
18
+ return $this->xPathTextSearch($terms);
19
+ }
20
+
21
+ public function xPathTextSearch($search_for = 'advanced')
22
+ {
23
+ #$search_for = Mage::helper('alanstormdotcomsystemsearch')->reverseTranslate($search_for); //more complicated
24
+ $sections = Mage::getConfig()
25
+ ->loadModulesConfiguration('system.xml')
26
+ ->getNode('sections');
27
+
28
+ // header('Content-Type: text/xml');
29
+ // echo $sections->asXml();
30
+ // exit;
31
+ $nodes = $this->getNodesWithText($search_for, $sections);
32
+ $nodes_by_type = array();
33
+ foreach($nodes as $node)
34
+ {
35
+ $type = $this->getTypeOfSystemConfigNode($node);
36
+ $nodes_by_type[$type] = array_key_exists($type, $nodes_by_type) ? $nodes_by_type[$type] : array();
37
+ $nodes_by_type[$type][] = $node;
38
+ }
39
+
40
+ return $nodes_by_type;
41
+ }
42
+
43
+ const TYPE_SYSTEM_CONFIG_UNKNOWN = 'UNKNOWN';
44
+ const TYPE_SYSTEM_CONFIG_TAB = 'TAB';
45
+ const TYPE_SYSTEM_CONFIG_SECTION = 'SECTION';
46
+ const TYPE_SYSTEM_CONFIG_GROUP = 'GROUP';
47
+ const TYPE_SYSTEM_CONFIG_FIELD = 'FIELD';
48
+ protected function getTypeOfSystemConfigNode($node)
49
+ {
50
+ $path = $this->fetchSimpleXmlHelper()->getPathExpression($node);
51
+ // var_dump($path);
52
+
53
+ $parts = explode('/',$path);
54
+ // var_dump($parts);
55
+
56
+ $parent_name = $parts[count($parts)-2];
57
+ // var_dump($parent_name);
58
+
59
+ switch($parent_name)
60
+ {
61
+ case 'sections':
62
+ return self::TYPE_SYSTEM_CONFIG_SECTION;
63
+ case 'groups':
64
+ return self::TYPE_SYSTEM_CONFIG_GROUP;
65
+ case 'fields':
66
+ return self::TYPE_SYSTEM_CONFIG_FIELD;
67
+ case 'tabs':
68
+ return self::TYPE_SYSTEM_CONFIG_TAB;
69
+ default:
70
+ return self::TYPE_SYSTEM_CONFIG_UNKNOWN;
71
+ }
72
+ }
73
+
74
+ protected function getNodesWithText($search_for, $xml)
75
+ {
76
+ $nodes = array();
77
+ #only works with us_EN, bad americano!
78
+ // $nodes = array_merge($nodes, $this->getSpecificNodeWithText('label',$search_for, $xml));
79
+ // $nodes = array_merge($nodes, $this->getSpecificNodeWithText('comment',$search_for, $xml));
80
+
81
+ //get the nodes
82
+ $nodes = array_merge($nodes,$xml->xpath('//label'));
83
+ $nodes = array_merge($nodes,$xml->xpath('//comment'));
84
+
85
+ //filter the nodes
86
+ $found = array();
87
+ $helper = Mage::helper('adminhtml');
88
+ foreach($nodes as $node)
89
+ {
90
+ if( mb_stristr($helper->__((string) $node),$search_for) !== false)
91
+ {
92
+ $found[] = $node;
93
+ }
94
+ }
95
+
96
+ return $found;
97
+ }
98
+
99
+ protected function getSpecificNodeWithText($node_name, $search_for, $xml)
100
+ {
101
+ $expression = $this->createXpathQuery($node_name, $search_for);
102
+ return $xml->xpath($expression);
103
+ }
104
+
105
+ //oh xpath 1, how I love thee
106
+ protected function createXpathQuery($node, $search_for)
107
+ {
108
+ return sprintf(
109
+ "//%s[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),translate('%s','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]",
110
+ $node,
111
+ $search_for
112
+ );
113
+ }
114
+
115
+ public function showAllConfigDebug() {
116
+ $sections = Mage::getConfig()
117
+ ->loadModulesConfiguration('system.xml')
118
+ ->getNode('sections');
119
+
120
+ $sections = $sections->xpath('//sections');
121
+ $sections = $sections[0];
122
+
123
+ foreach($sections as $section)
124
+ {
125
+ $label_section = (string) $section->label;
126
+ var_dump('Section: ' . $label_section);
127
+ $groups = $section->xpath('groups');
128
+ $groups = $groups[0];
129
+ foreach($groups as $group)
130
+ {
131
+ $label_group = (string) $group->label;
132
+ var_dump(' Group: ' . $label_group);
133
+ $fields = $group->xpath('fields');
134
+ $fields = count($fields) > 0 ? $fields[0] : array();
135
+ foreach($fields as $field)
136
+ {
137
+ $label_field = (string) $field->label;
138
+ $comment_field = (string) $field->comment;
139
+ var_dump(' Field: ' . $label_field);
140
+ if($comment_field)
141
+ {
142
+ var_dump(' Comment: ' . $comment_field);
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+
149
+ protected function fetchSimpleXmlHelper()
150
+ {
151
+ return Mage::helper('alanstormdotcomsystemsearch/simplexml');
152
+ }
153
+ }
app/code/community/Alanstormdotcom/Systemsearch/Model/Observer.php ADDED
@@ -0,0 +1,60 @@
1
+ <?php
2
+ /**
3
+ * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
+ *
5
+ * The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+ class Alanstormdotcom_Systemsearch_Model_Observer
15
+ {
16
+ public function addSystemsearchInit($observer)
17
+ {
18
+ if(!Mage::helper('alanstormdotcomsystemsearch')->isModuleOutputEnabled())
19
+ {
20
+ return;
21
+ }
22
+
23
+ $this->addFormToSystemConfigPage($observer);
24
+ }
25
+
26
+ //questionable way to inject things into the
27
+ //document, but anything to avoid Layout
28
+ protected function addFormToSystemConfigPage($observer)
29
+ {
30
+ $response = $observer->getResponse();
31
+ $block = $this->getLayout()->createBlock('alanstormdotcomsystemsearch/template')
32
+ ->setTemplate('prototype.phtml')->toHtml();
33
+ $response->setBody(
34
+ str_replace('</body>',$block.'</body>',$response->getBody(false))
35
+ );
36
+
37
+ if($this->isSystemConfigPage() && stripos($response->getBody(false),'<html') !== false)
38
+ {
39
+ $block = $this->getLayout()->createBlock('alanstormdotcomsystemsearch/template')
40
+ ->setTemplate('searchform.phtml')->toHtml();
41
+ $response->setBody(
42
+ str_replace('<div id="page:main-container">','<div id="page:main-container">'.$block,$response->getBody(false))
43
+ );
44
+ }
45
+ }
46
+
47
+ protected function isSystemConfigPage()
48
+ {
49
+ $parts = explode('/',$_SERVER['REQUEST_URI']);
50
+ return in_array('system_config',$parts);
51
+ return true;
52
+ }
53
+
54
+ private function getLayout()
55
+ {
56
+ return Mage::getSingleton('core/layout');;
57
+ }
58
+
59
+
60
+ }
app/code/{local → community}/Alanstormdotcom/Systemsearch/controllers/Adminhtml/AlanstormdotcomsystemsearchController.php RENAMED
@@ -3,7 +3,7 @@
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
3
* Open Source Initiative OSI - The MIT License (MIT):Licensing
4
*
5
* The MIT License (MIT)
6
+ * Copyright (c) 2009 - 2013 Pulse Storm LLC
7
*
8
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
*
app/code/{local → community}/Alanstormdotcom/Systemsearch/etc/config.xml RENAMED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<Alanstormdotcom_Systemsearch>
5
- <version>0.1.0</version>
6
</Alanstormdotcom_Systemsearch>
7
</modules>
8
2
<config>
3
<modules>
4
<Alanstormdotcom_Systemsearch>
5
+ <version>0.7.0</version>
6
</Alanstormdotcom_Systemsearch>
7
</modules>
8
app/code/{local → community}/Alanstormdotcom/Systemsearch/images/left.gif RENAMED
File without changes
app/code/{local → community}/Alanstormdotcom/Systemsearch/images/right.gif RENAMED
File without changes
app/code/{local → community}/Alanstormdotcom/Systemsearch/phtml/prototype.phtml RENAMED
File without changes
app/code/{local → community}/Alanstormdotcom/Systemsearch/phtml/results.phtml RENAMED
File without changes
app/code/{local → community}/Alanstormdotcom/Systemsearch/phtml/searchform.phtml RENAMED
File without changes
app/code/local/Alanstormdotcom/Systemsearch/Helper/Jsonconfigsearch.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
- /**
3
- * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
- *
5
- * The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- *
12
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- */
14
- class Alanstormdotcom_Systemsearch_Helper_Jsonconfigsearch extends Mage_Core_Helper_Abstract
15
- {
16
- public function prepareAndSendResponse($nodes, $terms)
17
- {
18
- $response = new stdClass();
19
- $response->responseText = array();
20
- $response->results = array();
21
- $response->search_terms = $terms;
22
- $helper = Mage::helper('adminhtml');
23
- foreach($nodes as $type=>$all_of_type)
24
- {
25
- foreach($all_of_type as $value)
26
- {
27
- $value = $this->fetchSimpleXmlHelper()->switchFromCommentToLabel($value);
28
-
29
- if($type == Alanstormdotcom_Systemsearch_Model_Configsearch::TYPE_SYSTEM_CONFIG_SECTION)
30
- {
31
- $response->responseText[] = 'Configuration/' . (string) $value;
32
-
33
- $result = new stdClass();
34
- $result->found = true;
35
- $result->found_type = 'nav'; //other option is 'group'
36
- $result->found_label = $helper->__((string) $value);
37
- $result->type = $type;
38
- $response->results[] = $result;
39
- }
40
- else if($type == Alanstormdotcom_Systemsearch_Model_Configsearch::TYPE_SYSTEM_CONFIG_GROUP)
41
- {
42
- $result = new stdClass();
43
- $result->found = true;
44
- $result->found_type = 'group'; //other option is 'group'
45
- $result->found_label = $helper->__((string) $value);
46
- $label_group = $result->found_label;
47
- $result->type = $type;
48
- $result->path = $this->fetchSimpleXmlHelper()->getPathExpression($value);
49
-
50
- $response->results[] = $result;
51
-
52
- //hop up three nodes to get the nav section
53
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($value);
54
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
55
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
56
- $result = new stdClass();
57
- $result->found = true;
58
- $result->found_type = 'nav'; //other option is 'group'
59
- $result->found_label = $helper->__((string) $parent->label);
60
- $label_nav = $result->found_label;
61
- $result->type = $type;
62
- $response->results[] = $result;
63
-
64
- //and also point out the nav
65
- $response->responseText[] = 'Configuration/' .
66
- $label_nav .
67
- '/' .
68
- $label_group .
69
- '';
70
- }
71
- else if($type == Alanstormdotcom_Systemsearch_Model_Configsearch::TYPE_SYSTEM_CONFIG_FIELD)
72
- {
73
- //hop up to group
74
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($value);
75
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
76
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
77
-
78
- $result = new stdClass();
79
- $result->found = true;
80
- $result->found_type = 'group'; //other option is 'group'
81
- $result->found_label = $helper->__((string) $parent->label);
82
- $label_group = $result->found_label;
83
- $result->type = $type;
84
- $response->results[] = $result;
85
-
86
- // //hope up to section
87
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
88
- $parent = $this->fetchSimpleXmlHelper()->getParentNode($parent);
89
-
90
- $result = new stdClass();
91
- $result->found = true;
92
- $result->found_type = 'nav'; //other option is 'group'
93
- $result->found_label = $helper->__((string) $parent->label);
94
- $label_nav = $result->found_label;
95
- $result->type = $type;
96
- $response->results[] = $result;
97
-
98
- $response->responseText[] = 'Configuration/' .
99
- $label_nav .
100
- '/' .
101
- $label_group .
102
- '/' .
103
- (string) $value;
104
- }
105
- }
106
- }
107
-
108
- $response->responseText = $this->fetchLayout()->createBlock('alanstormdotcomsystemsearch/searchresults')
109
- ->addResultsArray($response->responseText)
110
- ->toHtml();
111
-
112
- header('Content-Type: application/json');
113
- echo json_encode($response);
114
- exit;
115
- }
116
-
117
- protected function fetchSimpleXmlHelper()
118
- {
119
- return Mage::helper('alanstormdotcomsystemsearch/simplexml');
120
- }
121
-
122
- private function fetchLayout()
123
- {
124
- return Mage::getSingleton('core/layout');;
125
- }
126
-
127
- }
app/code/local/Alanstormdotcom/Systemsearch/Helper/Simplexml.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
- *
5
- * The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- *
12
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- */
14
- class Alanstormdotcom_Systemsearch_Helper_Simplexml extends Mage_Core_Helper_Abstract
15
- {
16
- public function switchFromCommentToLabel($node)
17
- {
18
- if($node->getName() != 'comment')
19
- {
20
- return $node;
21
- }
22
- $nodes = $node->xpath('../label');
23
- $node = count($nodes) ? $nodes[0] : $node;
24
- return $node;
25
- }
26
-
27
- public function getPathExpression($node)
28
- {
29
- $reverse = $this->getReversePathExpression($node);
30
- return implode('/',array_reverse(explode('/', $reverse)));
31
- }
32
-
33
- public function getParentNode($node)
34
- {
35
- $nodes = $node->xpath('..');
36
- if(count($nodes) > 0)
37
- {
38
- return $nodes[0];
39
- }
40
- return false;
41
- }
42
-
43
- public function getReversePathExpression($node,$fragment='')
44
- {
45
- $parent = $this->getParentNode($node);
46
- if($parent)
47
- {
48
- //recursion, HO!
49
- $fragment .= $parent->getName() . '/';
50
- return $this->getReversePathExpression($parent, $fragment);
51
- }
52
- return $fragment;
53
- }
54
-
55
- }
app/code/local/Alanstormdotcom/Systemsearch/Model/Configsearch.php DELETED
@@ -1,153 +0,0 @@
1
- <?php
2
- /**
3
- * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
- *
5
- * The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- *
12
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- */
14
- class Alanstormdotcom_Systemsearch_Model_Configsearch
15
- {
16
- public function searchSystemConfigForTerms($terms)
17
- {
18
- return $this->xPathTextSearch($terms);
19
- }
20
-
21
- public function xPathTextSearch($search_for = 'advanced')
22
- {
23
- #$search_for = Mage::helper('alanstormdotcomsystemsearch')->reverseTranslate($search_for); //more complicated
24
- $sections = Mage::getConfig()
25
- ->loadModulesConfiguration('system.xml')
26
- ->getNode('sections');
27
-
28
- // header('Content-Type: text/xml');
29
- // echo $sections->asXml();
30
- // exit;
31
- $nodes = $this->getNodesWithText($search_for, $sections);
32
- $nodes_by_type = array();
33
- foreach($nodes as $node)
34
- {
35
- $type = $this->getTypeOfSystemConfigNode($node);
36
- $nodes_by_type[$type] = array_key_exists($type, $nodes_by_type) ? $nodes_by_type[$type] : array();
37
- $nodes_by_type[$type][] = $node;
38
- }
39
-
40
- return $nodes_by_type;
41
- }
42
-
43
- const TYPE_SYSTEM_CONFIG_UNKNOWN = 'UNKNOWN';
44
- const TYPE_SYSTEM_CONFIG_TAB = 'TAB';
45
- const TYPE_SYSTEM_CONFIG_SECTION = 'SECTION';
46
- const TYPE_SYSTEM_CONFIG_GROUP = 'GROUP';
47
- const TYPE_SYSTEM_CONFIG_FIELD = 'FIELD';
48
- protected function getTypeOfSystemConfigNode($node)
49
- {
50
- $path = $this->fetchSimpleXmlHelper()->getPathExpression($node);
51
- // var_dump($path);
52
-
53
- $parts = explode('/',$path);
54
- // var_dump($parts);
55
-
56
- $parent_name = $parts[count($parts)-2];
57
- // var_dump($parent_name);
58
-
59
- switch($parent_name)
60
- {
61
- case 'sections':
62
- return self::TYPE_SYSTEM_CONFIG_SECTION;
63
- case 'groups':
64
- return self::TYPE_SYSTEM_CONFIG_GROUP;
65
- case 'fields':
66
- return self::TYPE_SYSTEM_CONFIG_FIELD;
67
- case 'tabs':
68
- return self::TYPE_SYSTEM_CONFIG_TAB;
69
- default:
70
- return self::TYPE_SYSTEM_CONFIG_UNKNOWN;
71
- }
72
- }
73
-
74
- protected function getNodesWithText($search_for, $xml)
75
- {
76
- $nodes = array();
77
- #only works with us_EN, bad americano!
78
- // $nodes = array_merge($nodes, $this->getSpecificNodeWithText('label',$search_for, $xml));
79
- // $nodes = array_merge($nodes, $this->getSpecificNodeWithText('comment',$search_for, $xml));
80
-
81
- //get the nodes
82
- $nodes = array_merge($nodes,$xml->xpath('//label'));
83
- $nodes = array_merge($nodes,$xml->xpath('//comment'));
84
-
85
- //filter the nodes
86
- $found = array();
87
- $helper = Mage::helper('adminhtml');
88
- foreach($nodes as $node)
89
- {
90
- if( mb_stristr($helper->__((string) $node),$search_for) !== false)
91
- {
92
- $found[] = $node;
93
- }
94
- }
95
-
96
- return $found;
97
- }
98
-
99
- protected function getSpecificNodeWithText($node_name, $search_for, $xml)
100
- {
101
- $expression = $this->createXpathQuery($node_name, $search_for);
102
- return $xml->xpath($expression);
103
- }
104
-
105
- //oh xpath 1, how I love thee
106
- protected function createXpathQuery($node, $search_for)
107
- {
108
- return sprintf(
109
- "//%s[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),translate('%s','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))]",
110
- $node,
111
- $search_for
112
- );
113
- }
114
-
115
- public function showAllConfigDebug() {
116
- $sections = Mage::getConfig()
117
- ->loadModulesConfiguration('system.xml')
118
- ->getNode('sections');
119
-
120
- $sections = $sections->xpath('//sections');
121
- $sections = $sections[0];
122
-
123
- foreach($sections as $section)
124
- {
125
- $label_section = (string) $section->label;
126
- var_dump('Section: ' . $label_section);
127
- $groups = $section->xpath('groups');
128
- $groups = $groups[0];
129
- foreach($groups as $group)
130
- {
131
- $label_group = (string) $group->label;
132
- var_dump(' Group: ' . $label_group);
133
- $fields = $group->xpath('fields');
134
- $fields = count($fields) > 0 ? $fields[0] : array();
135
- foreach($fields as $field)
136
- {
137
- $label_field = (string) $field->label;
138
- $comment_field = (string) $field->comment;
139
- var_dump(' Field: ' . $label_field);
140
- if($comment_field)
141
- {
142
- var_dump(' Comment: ' . $comment_field);
143
- }
144
- }
145
- }
146
- }
147
- }
148
-
149
- protected function fetchSimpleXmlHelper()
150
- {
151
- return Mage::helper('alanstormdotcomsystemsearch/simplexml');
152
- }
153
- }
app/code/local/Alanstormdotcom/Systemsearch/Model/Observer.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- /**
3
- * Open Source Initiative OSI - The MIT License (MIT):Licensing
4
- *
5
- * The MIT License (MIT)
6
- * Copyright (c) 2009 - 2011 Pulse Storm LLC
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
- *
10
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
- *
12
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- */
14
- class Alanstormdotcom_Systemsearch_Model_Observer
15
- {
16
- public function addSystemsearchInit($observer)
17
- {
18
- if(!Mage::helper('alanstormdotcomsystemsearch')->isModuleOutputEnabled())
19
- {
20
- return;
21
- }
22
-
23
- $this->addFormToSystemConfigPage($observer);
24
- }
25
-
26
- //questionable way to inject things into the
27
- //document, but anything to avoid Layout
28
- protected function addFormToSystemConfigPage($observer)
29
- {
30
- $response = $observer->getResponse();
31
- $block = $this->getLayout()->createBlock('alanstormdotcomsystemsearch/template')
32
- ->setTemplate('prototype.phtml')->toHtml();
33
- $response->setBody(
34
- str_replace('</body>',$block.'</body>',$response->getBody(false))
35
- );
36
-
37
- if($this->isSystemConfigPage() && stripos($response->getBody(false),'<html') !== false)
38
- {
39
- $block = $this->getLayout()->createBlock('alanstormdotcomsystemsearch/template')
40
- ->setTemplate('searchform.phtml')->toHtml();
41
- $response->setBody(
42
- str_replace('<div id="page:main-container">','<div id="page:main-container">'.$block,$response->getBody(false))
43
- );
44
- }
45
- }
46
-
47
- protected function isSystemConfigPage()
48
- {
49
- $parts = explode('/',$_SERVER['REQUEST_URI']);
50
- return in_array('system_config',$parts);
51
- return true;
52
- }
53
-
54
- private function getLayout()
55
- {
56
- return Mage::getSingleton('core/layout');;
57
- }
58
-
59
-
60
- }
app/design/adminhtml/default/default/images/alanstormdotcom/left.gif ADDED
Binary file
app/design/adminhtml/default/default/images/alanstormdotcom/right.gif ADDED
Binary file
app/etc/modules/Alanstormdotcom_Systemsearch.xml CHANGED
@@ -3,7 +3,7 @@
3
<modules>
4
<Alanstormdotcom_Systemsearch>
5
<active>true</active>
6
- <codePool>local</codePool>
7
</Alanstormdotcom_Systemsearch>
8
</modules>
9
</config>
3
<modules>
4
<Alanstormdotcom_Systemsearch>
5
<active>true</active>
6
+ <codePool>community</codePool>
7
</Alanstormdotcom_Systemsearch>
8
</modules>
9
</config>
package.xml CHANGED
@@ -1,18 +1,2 @@
1
<?xml version="1.0"?>
2
- <package>
3
- <name>System_Configuration_Search</name>
4
- <version>0.6.3</version>
5
- <stability>stable</stability>
6
- <license>MIT</license>
7
- <channel>community</channel>
8
- <extends/>
9
- <summary>This extension installs a search form that allows you to quickly find System Configuration fields.</summary>
10
- <description>This extension installs a search form that allows you to quickly find System Configuration fields.</description>
11
- <notes>Compile mode bug fix.</notes>
12
- <authors><author><name>Alan Storm</name><user>auto-converted</user><email>astorm@alanstorm.com</email></author></authors>
13
- <date>2012-07-04</date>
14
- <time>00:09:37</time>
15
- <contents><target name="magelocal"><dir name="Alanstormdotcom"><dir name="Systemsearch"><dir name="Block"><file name="Searchresults.php" hash="21941ec0d6d7a34a794c01d314c4d7db"/><file name="Template.php" hash="b6877cdafd960b4bf00708205108cb96"/></dir><dir name="Helper"><file name="Data.php" hash="6f36455f6f82dcc71376f692a6b7219d"/><file name="Jsonconfigsearch.php" hash="ca54f296459a78eaabfe13b5e1978608"/><file name="Simplexml.php" hash="7f537b7a30b9c3c17382d0aa108e7f0c"/></dir><dir name="Model"><file name="Configsearch.php" hash="a07be252fbb112e42b2313916555234f"/><file name="Observer.php" hash="76980697dac5ee9de397a7d445b861b2"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AlanstormdotcomsystemsearchController.php" hash="f80b12dc0b1ae7bd7bec8c336a76b80e"/></dir></dir><dir name="etc"><file name="config.xml" hash="6f62dd0b238ddf9abc6d2e181affb17b"/></dir><dir name="images"><file name="left.gif" hash="c1da3e89cc4fb46463e32f9ca6a66d3e"/><file name="right.gif" hash="1214f3e4f3689a5bc4b8468f2a757910"/></dir><dir name="phtml"><file name="prototype.phtml" hash="ed9b4dfaf14915693c209ee9aefb2d32"/><file name="results.phtml" hash="127f2400470f47a2b0b3c021a19a83ef"/><file name="searchform.phtml" hash="6d50fc769c3d046cd12d463385e5e57c"/></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Alanstormdotcom_Systemsearch.xml" hash="974e2e20ab0a6d2993dc196930136ddb"/></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="alanstormdotcom"><file name="left.gif" hash="c1da3e89cc4fb46463e32f9ca6a66d3e"/><file name="right.gif" hash="1214f3e4f3689a5bc4b8468f2a757910"/></dir></dir></dir></dir></dir></dir></target></contents>
16
- <compatible/>
17
- <dependencies/>
18
- </package>
1
<?xml version="1.0"?>
2
+ <package><name>System_Configuration_Search</name><version>0.7.0</version><stability>stable</stability><license>MIT</license><channel>community</channel><extends></extends><summary>This extension installs a search form that allows you to quickly find System Configuration fields.</summary><description>This extension installs a search form that allows you to quickly find System Configuration fields.</description><notes></notes><authors><author><name>Alan Storm</name><user>alanstorm</user><email>astorm@alanstorm.com</email></author></authors><date>2014-05-27</date><time>18:17:11</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Alanstormdotcom"><dir name="Systemsearch"><dir name="Block"><file name="Searchresults.php" hash="a118a2b8d1b530f05cecbfa887250abd"/><file name="Template.php" hash="0ce5888928775c63e7e26ec23ac6560c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AlanstormdotcomsystemsearchController.php" hash="8921a4cde58aa9d6c8a0e9b79f685191"/></dir></dir><dir name="etc"><file name="config.xml" hash="d3789f830fc93359819b200c123477b0"/></dir><dir name="Helper"><file name="Data.php" hash="21dd9b858158926e228c8f57df128c2b"/><file name="Jsonconfigsearch.php" hash="eb9c3f8690188e15775ed2e1f5c9f507"/><file name="Simplexml.php" hash="2563e53dc53cc2968b0ab6c3c7ec6863"/></dir><dir name="images"><file name="left.gif" hash="c1da3e89cc4fb46463e32f9ca6a66d3e"/><file name="right.gif" hash="1214f3e4f3689a5bc4b8468f2a757910"/></dir><dir name="Model"><file name="Configsearch.php" hash="93d310d0a4797de9f7c5948451f2a690"/><file name="Observer.php" hash="64e877ae11facc0ec498d3e55aa2741d"/></dir><dir name="phtml"><file name="prototype.phtml" hash="ed9b4dfaf14915693c209ee9aefb2d32"/><file name="results.phtml" hash="127f2400470f47a2b0b3c021a19a83ef"/><file name="searchform.phtml" hash="6d50fc769c3d046cd12d463385e5e57c"/></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="alanstormdotcom"><file name="left.gif" hash="c1da3e89cc4fb46463e32f9ca6a66d3e"/><file name="right.gif" hash="1214f3e4f3689a5bc4b8468f2a757910"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Alanstormdotcom_Systemsearch.xml" hash="d62f4bce7220a4345d9d22a15dafcae6"/></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="alanstormdotcom"><file name="left.gif" hash="c1da3e89cc4fb46463e32f9ca6a66d3e"/><file name="right.gif" hash="1214f3e4f3689a5bc4b8468f2a757910"/></dir></dir></dir></dir></dir></dir></target></contents></package>