Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced join() with implode() #986

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public function getStartupPageUrl()
$startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE);
$aclResource = 'admin/' . $startupPage;
if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) {
$nodePath = 'menu/' . join('/children/', explode('/', $startupPage)) . '/action';
$nodePath = 'menu/' . implode('/children/', explode('/', $startupPage)) . '/action';
$url = (string)Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode($nodePath);
if ($url) {
return $url;
Expand Down
18 changes: 10 additions & 8 deletions app/code/core/Mage/Adminhtml/Block/Api/Tab/Rolesedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Mage_Adminhtml_Block_Api_Tab_Rolesedit extends Mage_Adminhtml_Block_Widget_Form {
class Mage_Adminhtml_Block_Api_Tab_Rolesedit extends Mage_Adminhtml_Block_Widget_Form
{

public function __construct() {
public function __construct()
{
parent::__construct();

$rid = Mage::app()->getRequest()->getParam('rid', false);
Expand All @@ -39,8 +41,7 @@ public function __construct() {

foreach ($rules_set->getItems() as $item) {
if (array_key_exists(strtolower($item->getResource_id()), $resources)
&& $item->getApiPermission() == 'allow')
{
&& $item->getApiPermission() == 'allow') {
$resources[$item->getResource_id()]['checked'] = true;
array_push($selrids, $item->getResource_id());
}
Expand All @@ -50,7 +51,7 @@ public function __construct() {

$this->setTemplate('api/rolesedit.phtml');
//->assign('resources', $resources);
//->assign('checkedResources', join(',', $selrids));
//->assign('checkedResources', implode(',', $selrids));
}

public function getEverythingAllowed()
Expand All @@ -63,7 +64,7 @@ public function getResTreeJson()
$rid = Mage::app()->getRequest()->getParam('rid', false);
$resources = Mage::getModel('api/roles')->getResourcesTree();

$rootArray = $this->_getNodeJson($resources,1);
$rootArray = $this->_getNodeJson($resources, 1);

$json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());

Expand All @@ -76,7 +77,7 @@ protected function _sortTree($a, $b)
}


protected function _getNodeJson($node, $level=0)
protected function _getNodeJson($node, $level = 0)
{
$item = array();
$selres = $this->getSelectedResources();
Expand All @@ -86,8 +87,9 @@ protected function _getNodeJson($node, $level=0)
$item['sort_order']= isset($node->sort_order) ? (string)$node->sort_order : 0;
$item['id'] = (string)$node->attributes()->aclpath;

if (in_array($item['id'], $selres))
if (in_array($item['id'], $selres)) {
$item['checked'] = true;
}
}
if (isset($node->children)) {
$children = $node->children->children();
Expand Down
14 changes: 7 additions & 7 deletions app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Rolesedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
class Mage_Adminhtml_Block_Permissions_Tab_Rolesedit extends Mage_Adminhtml_Block_Widget_Form
implements Mage_Adminhtml_Block_Widget_Tab_Interface
class Mage_Adminhtml_Block_Permissions_Tab_Rolesedit extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
/**
* Retrieve an instance of the fallback helper
Expand Down Expand Up @@ -115,9 +114,9 @@ public function __construct()

foreach ($undefinedResources as $undefinedResourceId) {
if ($this->_getFallbackHelper()->fallbackResourcePermissions(
$resourcesPermissionsMap,
$undefinedResourceId
) == Mage_Admin_Model_Rules::RULE_PERMISSION_ALLOWED
$resourcesPermissionsMap,
$undefinedResourceId
) == Mage_Admin_Model_Rules::RULE_PERMISSION_ALLOWED
) {
array_push($selrids, $undefinedResourceId);
}
Expand All @@ -128,7 +127,7 @@ public function __construct()

$this->setTemplate('permissions/rolesedit.phtml');
//->assign('resources', $resources);
//->assign('checkedResources', join(',', $selrids));
//->assign('checkedResources', implode(',', $selrids));
}

/**
Expand Down Expand Up @@ -187,8 +186,9 @@ protected function _getNodeJson($node, $level = 0)
$item['sort_order'] = isset($node->sort_order) ? (string)$node->sort_order : 0;
$item['id'] = (string)$node->attributes()->aclpath;

if (in_array($item['id'], $selres))
if (in_array($item['id'], $selres)) {
$item['checked'] = true;
}
}
if (isset($node->children)) {
$children = $node->children->children();
Expand Down
12 changes: 4 additions & 8 deletions app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
class Mage_Adminhtml_Block_System_Config_Form_Field
extends Mage_Adminhtml_Block_Abstract
implements Varien_Data_Form_Element_Renderer_Interface
class Mage_Adminhtml_Block_System_Config_Form_Field extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
{

/**
Expand Down Expand Up @@ -72,8 +70,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
if ($element->getCanUseWebsiteValue()) {
$addInheritCheckbox = true;
$checkboxLabel = $this->__('Use Website');
}
elseif ($element->getCanUseDefaultValue()) {
} elseif ($element->getCanUseDefaultValue()) {
$addInheritCheckbox = true;
$checkboxLabel = $this->__('Use Default');
}
Expand All @@ -99,11 +96,10 @@ public function render(Varien_Data_Form_Element_Abstract $element)
$html.= '</td>';

if ($addInheritCheckbox) {

$defText = $element->getDefaultValue();
if ($options) {
$defTextArr = array();
foreach ($options as $k=>$v) {
foreach ($options as $k => $v) {
if ($isMultiple) {
if (is_array($v['value']) && in_array($k, $v['value'])) {
$defTextArr[] = $v['label'];
Expand All @@ -120,7 +116,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
}
}
}
$defText = join(', ', $defTextArr);
$defText = implode(', ', $defTextArr);
}

// default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ protected function _prepareLayout()
$defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
$oldCurrencies = $this->_prepareRates($currencyModel->getCurrencyRates($defaultCurrencies, $currencies));

foreach( $currencies as $currency ) {
foreach( $oldCurrencies as $key => $value ) {
if( !array_key_exists($currency, $oldCurrencies[$key]) ) {
foreach ($currencies as $currency) {
foreach ($oldCurrencies as $key => $value) {
if (!array_key_exists($currency, $oldCurrencies[$key])) {
$oldCurrencies[$key][$currency] = '';
}
}
}

foreach( $oldCurrencies as $key => $value ) {
foreach ($oldCurrencies as $key => $value) {
ksort($oldCurrencies[$key]);
}

Expand All @@ -77,17 +77,17 @@ protected function getRatesFormAction()

protected function _prepareRates($array)
{
if( !is_array($array) ) {
if (!is_array($array)) {
return $array;
}

foreach ($array as $key => $rate) {
foreach ($rate as $code => $value) {
$parts = explode('.', $value);
if( sizeof($parts) == 2 ) {
if (sizeof($parts) == 2) {
$parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
$array[$key][$code] = join('.', $parts);
} elseif( $value > 0 ) {
$array[$key][$code] = implode('.', $parts);
} elseif ($value > 0) {
$array[$key][$code] = number_format($value, 4);
} else {
$array[$key][$code] = null;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/System/Store/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getGridHtml()
*/
public function getAddNewButtonHtml()
{
return join(' ', array(
return implode(' ', array(
$this->getChildHtml('add_new_website'),
$this->getChildHtml('add_new_group'),
$this->getChildHtml('add_new_store')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
* @author Magento Core Team <[email protected]>
*/

class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Concat
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Concat extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{

/**
Expand All @@ -50,9 +49,8 @@ public function render(Varien_Object $row)
$dataArr[] = $data;
}
}
$data = join($this->getColumn()->getSeparator(), $dataArr);
$data = implode($this->getColumn()->getSeparator(), $dataArr);
// TODO run column type renderer
return $data;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function addItem($itemId, array $item)
->setMassaction($this)
->setId($itemId);

if($this->_items[$itemId]->getAdditional()) {
if ($this->_items[$itemId]->getAdditional()) {
$this->_items[$itemId]->setAdditionalActionBlock($this->_items[$itemId]->getAdditional());
$this->_items[$itemId]->unsAdditional();
}
Expand All @@ -90,7 +90,7 @@ public function addItem($itemId, array $item)
*/
public function getItem($itemId)
{
if(isset($this->_items[$itemId])) {
if (isset($this->_items[$itemId])) {
return $this->_items[$itemId];
}

Expand All @@ -115,7 +115,7 @@ public function getItems()
public function getItemsJson()
{
$result = array();
foreach ($this->getItems() as $itemId=>$item) {
foreach ($this->getItems() as $itemId => $item) {
$result[$itemId] = $item->toArray();
}

Expand Down Expand Up @@ -189,9 +189,9 @@ public function getGridJsObjectName()
*/
public function getSelectedJson()
{
if($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $this->quoteEscape($selected));
return join(',', $selected);
return implode(',', $selected);
} else {
return '';
}
Expand All @@ -204,7 +204,7 @@ public function getSelectedJson()
*/
public function getSelected()
{
if($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
if ($selected = $this->getRequest()->getParam($this->getFormFieldNameInternal())) {
$selected = explode(',', $this->quoteEscape($selected));
return $selected;
} else {
Expand Down Expand Up @@ -242,7 +242,7 @@ public function getGridIdsJson()

$gridIds = $this->getParentBlock()->getCollection()->getAllIds();

if(!empty($gridIds)) {
if (!empty($gridIds)) {
return join(",", $gridIds);
}
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function _afterSave()
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);

try {
Mage::getModel('core/config_data')
Expand All @@ -64,5 +64,4 @@ protected function _afterSave()
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ protected function _afterSave()
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);
$cronExprString = join(' ', $cronExprArray);
}
else {
$cronExprString = implode(' ', $cronExprArray);
} else {
$cronExprString = '';
}

Expand All @@ -77,8 +76,7 @@ protected function _afterSave()
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
->setPath(self::CRON_MODEL_PATH)
->save();
}
catch (Exception $e) {
} catch (Exception $e) {
Mage::throwException(Mage::helper('adminhtml')->__('Unable to save the cron expression.'));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function _afterSave()
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);

try {
Mage::getModel('core/config_data')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function _afterSave()
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);

$cronExprString = join(' ', $cronExprArray);
$cronExprString = implode(' ', $cronExprArray);

try {
Mage::getModel('core/config_data')
Expand All @@ -70,5 +70,4 @@ protected function _afterSave()
throw new Exception(Mage::helper('cron')->__('Unable to save the cron expression.'));
}
}

}
8 changes: 3 additions & 5 deletions app/code/core/Mage/Backup/Model/Config/Backend/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ protected function _afterSave()
'*', # Month of the Year
($frequency == $frequencyWeekly) ? '1' : '*', # Day of the Week
);
$cronExprString = join(' ', $cronExprArray);
}
else {
$cronExprString = implode(' ', $cronExprArray);
} else {
$cronExprString = '';
}

Expand All @@ -81,8 +80,7 @@ protected function _afterSave()
->setValue((string) Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
->setPath(self::CRON_MODEL_PATH)
->save();
}
catch (Exception $e) {
} catch (Exception $e) {
Mage::throwException(Mage::helper('backup')->__('Unable to save the cron expression.'));
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Bundle/Model/Resource/Price/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function getProducts($product = null, $lastEntityId = 0, $limit = 100)

$select->joinLeft(
array($priceTypeAlias => $priceType->getBackend()->getTable()),
join(' AND ', $joinConds),
implode(' AND ', $joinConds),
array('price_type' => $priceTypeAlias . '.value')
);

Expand Down Expand Up @@ -770,7 +770,7 @@ public function _calculateBundleSelections(

// calculate selection price
if ($priceType == Mage_Bundle_Model_Product_Price::PRICE_TYPE_DYNAMIC) {
$priceIndexKey = join('-', array(
$priceIndexKey = implode('-', array(
$selection['product_id'],
$website->getId(),
$group->getId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
$applyTo = explode(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
if (!in_array('bundle', $applyTo)) {
$applyTo[] = 'bundle';
$installer->updateAttribute('catalog_product', $field, 'apply_to', join(',', $applyTo));
$installer->updateAttribute('catalog_product', $field, 'apply_to', implode(',', $applyTo));
}
}

Expand Down
Loading