1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Grid colum filter block
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract extends Mage_Adminhtml_Block_Abstract
35: implements Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Interface
36: {
37:
38: /**
39: * Column related to filter
40: *
41: * @var Mage_Adminhtml_Block_Widget_Grid_Column
42: */
43: protected $_column;
44:
45: /**
46: * Set column related to filter
47: *
48: * @param Mage_Adminhtml_Block_Widget_Grid_Column $column
49: * @return Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract
50: */
51: public function setColumn($column)
52: {
53: $this->_column = $column;
54: return $this;
55: }
56:
57: /**
58: * Retrieve column related to filter
59: *
60: * @return Mage_Adminhtml_Block_Widget_Grid_Column
61: */
62: public function getColumn()
63: {
64: return $this->_column;
65: }
66:
67: /**
68: * Retrieve html name of filter
69: *
70: * @return string
71: */
72: protected function _getHtmlName()
73: {
74: return $this->getColumn()->getId();
75: }
76:
77: /**
78: * Retrieve html id of filter
79: *
80: * @return string
81: */
82: protected function _getHtmlId()
83: {
84: return $this->getColumn()->getGrid()->getId() . '_'
85: . $this->getColumn()->getGrid()->getVarNameFilter() . '_'
86: . $this->getColumn()->getId();
87: }
88:
89: /**
90: * Retrieve escaped value
91: *
92: * @param mixed $index
93: * @return string
94: */
95: public function getEscapedValue($index = null)
96: {
97: return htmlspecialchars($this->getValue($index));
98: }
99:
100: /**
101: * Retrieve condition
102: *
103: * @return array
104: */
105: public function getCondition()
106: {
107: $helper = Mage::getResourceHelper('core');
108: $likeExpression = $helper->addLikeEscape($this->getValue(), array('position' => 'any'));
109: return array('like' => $likeExpression);
110: }
111:
112: /**
113: * @deprecated after 1.5.0.0
114: * @param $value
115: * @return mixed
116: */
117: protected function _escapeValue($value)
118: {
119: return str_replace('_', '\_', str_replace('\\', '\\\\', $value));
120: }
121:
122: /**
123: * Retrieve filter html
124: *
125: * @return string
126: */
127: public function getHtml()
128: {
129: return '';
130: }
131:
132: }
133: