Skip to content

Commit 39ac807

Browse files
authored
Merge branch 'main' into drop-php7
2 parents e2232a7 + ec284ac commit 39ac807

File tree

6 files changed

+200
-11
lines changed

6 files changed

+200
-11
lines changed

.rector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
1919
__DIR__ . '/shell/translations.php',
2020
__DIR__ . '/shell/update-copyright.php.php',
21+
__DIR__ . '/tests/unit/Mage/Reports/Model/Resource/Report/CollectionTest.php',
22+
])
23+
->withSets([
24+
PHPUnitSetList::PHPUNIT_90,
25+
SetList::PRIVATIZATION,
26+
SetList::PHP_52,
2127
])
2228
->withRules([
2329
CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class,

app/code/core/Mage/Adminhtml/Block/Page/Menu.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent, $path = '',
133133

134134
$menuArr = [];
135135

136+
$menuArr['id'] = str_replace(['/'], ['-'], $aclResource);
137+
136138
$menuArr['label'] = $this->_getHelperValue($child);
137139

138140
$menuArr['sort_order'] = $child->sort_order ? (int) $child->sort_order : $sortOrder;
@@ -269,6 +271,7 @@ public function getMenuLevel($menu, $level = 0)
269271
. (!empty($item['children']) ? ' parent' : '')
270272
. (!empty($level) && !empty($item['last']) ? ' last' : '')
271273
. ' level' . $level . '"> <a href="' . $item['url'] . '" '
274+
. (!empty($item['id']) ? 'id="nav-' . $item['id'] . '"' : '') . ' '
272275
. (!empty($item['title']) ? 'title="' . $item['title'] . '"' : '') . ' '
273276
. (!empty($item['target']) ? 'target="' . $item['target'] . '"' : '') . ' '
274277
. (!empty($item['click']) ? 'onclick="' . $item['click'] . '"' : '') . ' class="'

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
"phpunit:coverage": "XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --testdox",
158158
"phpunit:coverage-local": "XDEBUG_MODE=coverage php vendor/bin/phpunit --configuration .phpunit.dist.xml --coverage-html build/coverage",
159159
"rector:test": "vendor/bin/rector process --config .rector.php --dry-run",
160-
"rector:fix": "vendor/bin/rector --config .rector.php process",
160+
"rector:fix": "vendor/bin/rector process --config .rector.php",
161161
"test": [
162162
"@php-cs-fixer:test",
163163
"@phpstan",

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
---
2+
title: Brief Guide on Grid Column
3+
draft: false
4+
date: 2025-03-11
5+
authors:
6+
- kiatng
7+
categories:
8+
- Guides
9+
tags:
10+
- Grid
11+
- Column
12+
---
13+
14+
# Overview
15+
16+
The Grid Column system in OpenMage provides a powerful way to create and customize admin grid interfaces. Grid columns are essential components of the admin panel that display data in a tabular format, allowing for sorting, filtering, copying, formatting, and other operations on the data. This guide explains how to work with grid columns using the `Mage_Adminhtml_Block_Widget_Grid_Column` class, see [source code](https://github.com/OpenMage/magento-lts/blob/main/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php).
17+
18+
<!-- more -->
19+
20+
## Understanding the `addColumn()` Method
21+
22+
The `addColumn()` method is the primary way to add columns to a grid in OpenMage. See https://github.com/OpenMage/magento-lts/blob/71f38e9f9e1ec98bdea12d00a8e29622df594455/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php#L328-L328
23+
24+
### Parameters:
25+
26+
1. **$columnId** (string): A unique identifier for the column. This ID is used to reference the column elsewhere in the code.
27+
28+
2. **$column** (array): An array of column attributes that define the column's behavior and appearance.
29+
30+
## Column Attributes
31+
32+
The `$column` parameter accepts various attributes that determine how the column behaves and appears in the grid. It is used to set the data in the class `Mage_Adminhtml_Block_Widget_Grid_Column`. Here are the most commonly used attributes:
33+
34+
### Basic Attributes:
35+
36+
- **header**: The text displayed in the column header
37+
- **index**: The field name from the collection that provides the data for this column, if missing, it is default to `$columnId`
38+
- **width**: The width of the column (in pixels or percentage), if missing, the width is auto adjusted
39+
- **type**: The column type (e.g., 'text', 'number', 'date', 'options', etc.), if missing, it is default to 'text'
40+
41+
#### Common Column Types
42+
43+
The 'type' attribute defines the column type. Some common types are:
44+
45+
- **text**: Simple text display
46+
- **number**: Numeric values with optional formatting
47+
- **price**: Price values with currency formatting
48+
- **date**: Date values
49+
- **datetime**: Date and time values
50+
- **options**: Dropdown selection with predefined options
51+
- **action**: Column with action buttons
52+
- **longtext**: Text that may be truncated with a "more" link
53+
54+
For a complete list, see this [folder](https://github.com/OpenMage/magento-lts/tree/main/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer).
55+
56+
### Functionality Attributes:
57+
58+
- **sortable**: (bool) Whether the column can be sorted
59+
- **filter**: (bool) Whether the column can be filtered
60+
- **copyable**: (bool) Whether the column's content can be copied to clipboard
61+
- **filter_index**: The database field to use for filtering (useful when 'index' is a calculated field)
62+
- **renderer**: A custom renderer class for the column
63+
- **filter_condition_callback**: A callback function for custom filtering logic
64+
- **no_link**: (bool) Prevents rendering links in the column
65+
66+
### Data Formatting Attributes:
67+
68+
- **align**: Text alignment within the column ('left', 'center', 'right')
69+
- **frame_callback**: A callback function to format the column's data
70+
- **column_css_class**: Add additional CSS classes
71+
72+
### Attributes Specific to Column Types
73+
There are attributes that are applied to specific column types:
74+
75+
- **actions**: Array of actions for an 'actions' column type
76+
- **options**: Array of options for an 'options' column type
77+
- **format**: Format for date/time column types
78+
- **nl2br**: (bool) Whether to convert newlines to `<br>` tags for a 'longtext' column type
79+
80+
## Example Usage
81+
82+
Here's a basic example of adding columns to a grid:
83+
84+
```php
85+
protected function _prepareColumns()
86+
{
87+
$this->addColumn('entity_id', [
88+
'header' => $this->__('ID'),
89+
'align' => 'right',
90+
'width' => '50px',
91+
'index' => 'entity_id',
92+
'type' => 'number',
93+
'sortable' => true,
94+
]);
95+
96+
$this->addColumn('name', [
97+
'header' => $this->__('Name'),
98+
'index' => 'name',
99+
'type' => 'text',
100+
'copyable' => true,
101+
]);
102+
103+
$this->addColumn('created_at', [
104+
'header' => $this->__('Created At'),
105+
'index' => 'created_at',
106+
'type' => 'datetime',
107+
'filter' => true,
108+
'sortable' => true,
109+
]);
110+
111+
$this->addColumn('status', [
112+
'header' => $this->__('Status'),
113+
'index' => 'status',
114+
'type' => 'options',
115+
'options' => [
116+
1 => 'Enabled',
117+
0 => 'Disabled',
118+
],
119+
]);
120+
121+
return parent::_prepareColumns();
122+
}
123+
```
124+
125+
## Advanced Usage: Custom Renderers and Filters
126+
127+
For more complex column requirements, you can create custom renderers and filters:
128+
129+
```php
130+
$this->addColumn('custom_field', [
131+
'header' => $this->__('Custom Field'),
132+
'renderer' => 'Namespace_Module_Block_Adminhtml_Grid_Renderer_Custom',
133+
'filter' => 'Namespace_Module_Block_Adminhtml_Grid_Filter_Custom',
134+
]);
135+
136+
```
137+
138+
The renderer and filter classes are reusable for other grids. If there is no such need, you can use the callback attributes:
139+
140+
```php
141+
// in addColumn()
142+
'frame_callback' => [$this, '_decorateUserUpdatedAt'],
143+
'filter_condition_callback' => [$this, '_findInSet'],
144+
// more code
145+
146+
/**
147+
* @param string $value
148+
* @param Varien_Object $row
149+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
150+
* @param bool $isExport
151+
* @return string
152+
*/
153+
protected function _decorateUserUpdatedAt($value, $row, $column, $isExport)
154+
{
155+
if (!$isExport) {
156+
return $value > $row->getAdminUpdatedAt())
157+
? '<strong><span class="not-available">' . $value . '</span></strong>'
158+
: '<span class="available">' . $value . '</span>';
159+
}
160+
161+
return $value;
162+
}
163+
164+
/**
165+
* @param Varien_Data_Collection_Db $collection
166+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
167+
* @return void
168+
*/
169+
protected function _findInSet($collection, $column)
170+
{
171+
if ($value = $column->getFilter()->getValue()) {
172+
$collection->addFieldToFilter('apply_to', ['finset' => $value]);
173+
}
174+
}
175+
```
176+
177+
## Conclusion
178+
179+
The Grid Column system in OpenMage provides a flexible and powerful way to display and manipulate data in the admin panel. By understanding the various attributes and options available, you can create highly customized and functional grid interfaces for your admin users.
180+

lib/3Dsecure/CentinelClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
class CentinelClient {
1919

20-
var $request ;
21-
var $response ;
22-
var $parser;
20+
public $request ;
21+
public $response ;
22+
public $parser;
2323

2424
/////////////////////////////////////////////////////////////////////////////////////////////
2525
// Function Add(name, value)

0 commit comments

Comments
 (0)