Skip to content

Commit

Permalink
[#] Clean-up: PSR2 rules, comments...
Browse files Browse the repository at this point in the history
  • Loading branch information
bm-services committed Mar 17, 2017
1 parent 38ba141 commit 0b8095e
Show file tree
Hide file tree
Showing 133 changed files with 5,548 additions and 3,755 deletions.
55 changes: 34 additions & 21 deletions Block/Admin/Field/Checkboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,51 @@
/**
* Paybox Epayment module for Magento
*
* This source file is subject to the Open Software License (OSL 3.0)
* available at : http://opensource.org/licenses/osl-3.0.php
* Feel free to contact Paybox by Verifone at support@paybox.com for any
* question.
*
* @package Paybox_Epayment
* @copyright Copyright (c) 2013-2014 Paybox
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* LICENSE: This source file is subject to the version 3.0 of the Open
* Software License (OSL-3.0) that is available through the world-wide-web
* at the following URI: http://opensource.org/licenses/OSL-3.0. If
* you did not receive a copy of the OSL-3.0 license and are unable
* to obtain it through the web, please send a note to
* support@paybox.com so we can mail you a copy immediately.
*
*
* @version 1.0.0
* @author BM Services <contact@bm-services.com>
* @copyright 2012-2017 Paybox
* @license http://opensource.org/licenses/OSL-3.0
* @link http://www.paybox.com/
*/

namespace Paybox\Epayment\Block\Admin\Field;

class Checkboxes extends \Magento\Config\Block\System\Config\Form\Field
{
protected $_coreHelper;
protected $_coreHelper;

public function __construct()
{
$manager = \Magento\Framework\App\ObjectManager::getInstance();
$this->_coreHelper = $manager->get('\Magento\Framework\Api\DataObjectHelper');
}
public function __construct()
{
$manager = \Magento\Framework\App\ObjectManager::getInstance();
$this->_coreHelper = $manager->get('\Magento\Framework\Api\DataObjectHelper');
}

protected function _getOptionHtmlAttributes() {
protected function _getOptionHtmlAttributes()
{
return array('type', 'name', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled');
}

protected function _optionToHtml($option, \Magento\Framework\Data\Form\Element\AbstractElement $element) {
protected function _optionToHtml($option, \Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$id = $element->getHtmlId().'_'.$this->_coreHelper->escapeHtml($option['value']);

$html = '<li><input id="'.$id.'"';
foreach ($this->_getOptionHtmlAttributes() as $attribute) {
if ($value = $element->getDataUsingMethod($attribute, $option['value'])) {
if ($attribute == 'name') {
$value .= '[]';
}
if ($attribute == 'name') {
$value .= '[]';
}
$html .= ' '.$attribute.'="'.$value.'"';
}
}
Expand All @@ -44,9 +56,10 @@ protected function _optionToHtml($option, \Magento\Framework\Data\Form\Element\A
return $html;
}

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
$element->setValue(explode(',', $element->getValue()));
$values = $element->getValues();
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$element->setValue(explode(',', $element->getValue()));
$values = $element->getValues();

if (!$values) {
return '';
Expand All @@ -61,5 +74,5 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
$html .= '</ul>'. $this->getAfterElementHtml();

return $html;
}
}
}
}
71 changes: 41 additions & 30 deletions Block/Admin/Field/Info.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
<?php
/**
* Paybox Epayment module for Magento
*
* This source file is subject to the Open Software License (OSL 3.0)
* available at : http://opensource.org/licenses/osl-3.0.php
*
* @package Paybox_Epayment
* @copyright Copyright (c) 2013-2014 Paybox
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace Paybox\Epayment\Block\Admin\Field;

class Info extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Render element html
*
* @param Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
$html = '<tr id="row_'.$element->getHtmlId().
'"><td class="label" colspan="5" style="text-align: left;"><span id="'.$element->getHtmlId().'">';
$html .= $element->getLabel();
$html .= '</span></td></tr>';
return $html;
}
}
<?php
/**
* Paybox Epayment module for Magento
*
* Feel free to contact Paybox by Verifone at support@paybox.com for any
* question.
*
* LICENSE: This source file is subject to the version 3.0 of the Open
* Software License (OSL-3.0) that is available through the world-wide-web
* at the following URI: http://opensource.org/licenses/OSL-3.0. If
* you did not receive a copy of the OSL-3.0 license and are unable
* to obtain it through the web, please send a note to
* support@paybox.com so we can mail you a copy immediately.
*
*
* @version 1.0.0
* @author BM Services <contact@bm-services.com>
* @copyright 2012-2017 Paybox
* @license http://opensource.org/licenses/OSL-3.0
* @link http://www.paybox.com/
*/

namespace Paybox\Epayment\Block\Admin\Field;

class Info extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Render element html
*
* @param Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = '<tr id="row_'.$element->getHtmlId().
'"><td class="label" colspan="5" style="text-align: left;"><span id="'.$element->getHtmlId().'">';
$html .= $element->getLabel();
$html .= '</span></td></tr>';
return $html;
}
}
75 changes: 43 additions & 32 deletions Block/Admin/Field/Presentation.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
<?php
/**
* Paybox Epayment module for Magento
*
* This source file is subject to the Open Software License (OSL 3.0)
* available at : http://opensource.org/licenses/osl-3.0.php
*
* @package Paybox_Epayment
* @copyright Copyright (c) 2013-2014 Paybox
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace Paybox\Epayment\Block\Admin\Field;

class Presentation extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Render element html
*
* @param Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
$block = $this->getLayout()->createBlock('Paybox\Epayment\Block\Admin\Presentation');
$template_html = $block->toHtml();
$html = '<tr id="row_'.$element->getHtmlId().
'"><td class="label" colspan="5" style="text-align: left;"><span id="'.$element->getHtmlId().'">';
$html .= $template_html;
$html .= '</span></td></tr>';
return $html;
}
}
<?php
/**
* Paybox Epayment module for Magento
*
* Feel free to contact Paybox by Verifone at support@paybox.com for any
* question.
*
* LICENSE: This source file is subject to the version 3.0 of the Open
* Software License (OSL-3.0) that is available through the world-wide-web
* at the following URI: http://opensource.org/licenses/OSL-3.0. If
* you did not receive a copy of the OSL-3.0 license and are unable
* to obtain it through the web, please send a note to
* support@paybox.com so we can mail you a copy immediately.
*
*
* @version 1.0.0
* @author BM Services <contact@bm-services.com>
* @copyright 2012-2017 Paybox
* @license http://opensource.org/licenses/OSL-3.0
* @link http://www.paybox.com/
*/

namespace Paybox\Epayment\Block\Admin\Field;

class Presentation extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Render element html
*
* @param Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$block = $this->getLayout()->createBlock('Paybox\Epayment\Block\Admin\Presentation');
$template_html = $block->toHtml();
$html = '<tr id="row_'.$element->getHtmlId().
'"><td class="label" colspan="5" style="text-align: left;"><span id="'.$element->getHtmlId().'">';
$html .= $template_html;
$html .= '</span></td></tr>';
return $html;
}
}
43 changes: 26 additions & 17 deletions Block/Admin/Field/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,42 @@
/**
* Paybox Epayment module for Magento
*
* This source file is subject to the Open Software License (OSL 3.0)
* available at : http://opensource.org/licenses/osl-3.0.php
* Feel free to contact Paybox by Verifone at support@paybox.com for any
* question.
*
* @package Paybox_Epayment
* @copyright Copyright (c) 2013-2014 Paybox
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* LICENSE: This source file is subject to the version 3.0 of the Open
* Software License (OSL-3.0) that is available through the world-wide-web
* at the following URI: http://opensource.org/licenses/OSL-3.0. If
* you did not receive a copy of the OSL-3.0 license and are unable
* to obtain it through the web, please send a note to
* support@paybox.com so we can mail you a copy immediately.
*
*
* @version 1.0.0
* @author BM Services <contact@bm-services.com>
* @copyright 2012-2017 Paybox
* @license http://opensource.org/licenses/OSL-3.0
* @link http://www.paybox.com/
*/

namespace Paybox\Epayment\Block\Admin\Field;

class Select extends \Magento\Config\Block\System\Config\Form\Field
{
protected function _getOptionHtmlAttributes() {
protected function _getOptionHtmlAttributes()
{
return array('type', 'name', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled');
}

protected function _optionToHtml($option, $selected) {
protected function _optionToHtml($option, $selected)
{
if (is_array($option['value'])) {
$html ='<optgroup label="'.$option['label'].'">'."\n";
foreach ($option['value'] as $groupItem) {
$html .= $this->_optionToHtml($groupItem, $selected);
}
$html .='</optgroup>'."\n";
}
else {
} else {
$html = '<option value="'.$this->escapeHtml($option['value']).'"';
$html.= isset($option['title']) ? 'title="'.$this->escapeHtml($option['title']).'"' : '';
$html.= isset($option['style']) ? 'style="'.$option['style'].'"' : '';
Expand All @@ -39,7 +50,8 @@ protected function _optionToHtml($option, $selected) {
return $html;
}

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) {
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$element->addClass('select');
$html = '<select id="'.$element->getHtmlId().'" name="'.
$element->getName().'" '.
Expand All @@ -58,15 +70,13 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
'label' => $option),
$value
);
}
elseif (is_array($option['value'])) {
} elseif (is_array($option['value'])) {
$html.='<optgroup label="'.$option['label'].'">'."\n";
foreach ($option['value'] as $groupItem) {
$html.= $this->_optionToHtml($groupItem, $value);
}
$html.='</optgroup>'."\n";
}
else {
} else {
$html.= $this->_optionToHtml($option, $value);
}
}
Expand All @@ -75,6 +85,5 @@ protected function _getElementHtml(\Magento\Framework\Data\Form\Element\Abstract
$html.= '</select>'."\n";
$html.= $this->getAfterElementHtml();
return $html;
}

}
}
}
Loading

0 comments on commit 0b8095e

Please sign in to comment.