Skip to content

Commit

Permalink
Merge branch 'main' into tinymce
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.lock
  • Loading branch information
sreichel committed Nov 20, 2024
2 parents 672d355 + a156f8f commit c8df745
Show file tree
Hide file tree
Showing 27 changed files with 272 additions and 86 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,11 @@ phpunit.xml
/site

# DDEV
.ddev/config.yaml
.ddev/.sampleData
.ddev/config.yaml
.ddev/config.*.yaml
.ddev/xhgui
.ddev/xhprof
.ddev/docker-compose.xhgui.yaml
.ddev/docker-compose.xhgui_norouter.yaml
app/etc/includes/ddev.xhgui.php
4 changes: 4 additions & 0 deletions .phpunit.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
>
<php>
<env name="NO_XHGUI" value="1"/>
</php>

<testsuites>
<testsuite name="Base">
<directory>tests/unit/Base</directory>
Expand Down
5 changes: 5 additions & 0 deletions LICENSE_TINYMCE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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 TINYMCE OR ITS LICENSORS 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.
4 changes: 4 additions & 0 deletions LICENSE_TINYMCE_OPENMAGE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
THE USE OF TINYMCE IN THIS PROJECT IS POSSIBLE ON THE BASIS OF THE AGREEMENT CONCLUDED BETWEEN
THE OWNER OF TINYMCE AND THE COMMUNITY OF THIS OPEN-SOURCE PROJECT. UNDER THE CONCLUDED
AGREEMENT, IT IS PROHIBITED TO USE TINYMCE OUTSIDE OF THIS PROJECT. IF THIS IS THE CASE, TINYMCE MUST
BE USED IN LINE WITH THE ORIGINAL OPEN-SOURCE LICENSE.
2 changes: 1 addition & 1 deletion app/code/core/Mage/AdminNotification/Model/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function getFeedXml()
$data = $this->getFeedData();
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?>');
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><feed />');
}

return $xml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function getFormHtml(Varien_Object $entity, $entityType = 'quote')
*/
public function getItems()
{
if (!$this->isOutputEnabled('Mage_GiftMessage')) {
return false;
}

/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');

Expand All @@ -51,7 +55,7 @@ public function getItems()

foreach ($allItems as $item) {
if ($this->_getGiftmessageSaveModel()->getIsAllowedQuoteItem($item)
&& $helper->getIsMessagesAvailable('item', $item, $this->getStore())
&& $helper->getIsMessagesAvailable($helper::TYPE_ITEM, $item, $this->getStore())
) {
// if item allowed
$items[] = $item;
Expand Down Expand Up @@ -82,6 +86,6 @@ public function canDisplayGiftmessage(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getEntity(), $this->getEntity()->getStoreId());
return $helper->getIsMessagesAvailable($helper::TYPE_CONFIG, $this->getQuote(), $this->getStoreId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ public function isGiftMessagesAvailable($item = null)
$helper = $this->helper('giftmessage/message');

if (is_null($item)) {
return $helper->getIsMessagesAvailable('items', $this->getQuote(), $this->getStore());
return $helper->getIsMessagesAvailable($helper::TYPE_ITEMS, $this->getQuote(), $this->getStore());
}

return $helper->getIsMessagesAvailable('item', $item, $this->getStore());
return $helper->getIsMessagesAvailable($helper::TYPE_ITEM, $item, $this->getStore());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function render(Varien_Object $row)
{
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
if (!$helper->getIsMessagesAvailable('order_item', $row, $this->getColumn()->getGrid()->getStore())) {
if (!$helper->getIsMessagesAvailable($helper::TYPE_ORDER_ITEM, $row, $this->getColumn()->getGrid()->getStore())) {
return '&nbsp;';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ public function canDisplayGiftmessage()
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getEntity(), $this->getEntity()->getStoreId());
return $helper->getIsMessagesAvailable($helper::TYPE_ORDER, $this->getEntity(), $this->getEntity()->getStoreId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function canDisplayGiftmessage()
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable(
'order_item',
$helper::TYPE_ORDER_ITEM,
$this->getItem(),
$this->getItem()->getOrder()->getStoreId()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function render(Varien_Data_Form_Element_Abstract $element)
$isMultiple = $element->getExtType() === 'multiple';

// replace [value] with [inherit]
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', $element->getName());
$namePrefix = preg_replace('#\[value\](\[\])?$#', '', (string) $element->getName());

$options = $element->getValues();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class Mage_GiftMessage_Block_Adminhtml_Product_Helper_Form_Config extends Mage_A
/**
* Get config value data
*
* @return mixed
* @return bool
*/
protected function _getValueFromConfig()
{
return Mage::getStoreConfig(Mage_GiftMessage_Helper_Message::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS);
return Mage::getStoreConfigFlag(Mage_GiftMessage_Helper_Message::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function canDisplayGiftmessageForm()
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
return $helper->getIsMessagesAvailable('items', $quote, $quote->getStore());
return $helper->getIsMessagesAvailable($helper::TYPE_ITEMS, $quote, $quote->getStore());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function canDisplayGiftMessage()
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable(
'item',
$helper::TYPE_ITEM,
$item,
$item->getStoreId()
);
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/GiftMessage/Block/Message/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ public function getEscaped($value, $defaultValue = '')
*/
public function isMessagesAvailable()
{
return Mage::helper('giftmessage/message')->isMessagesAvailable('quote', $this->getEntity());
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->isMessagesAvailable($helper::TYPE_CONFIG, $this->getEntity());
}

/**
Expand Down
118 changes: 63 additions & 55 deletions app/code/core/Mage/GiftMessage/Helper/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class Mage_GiftMessage_Helper_Message extends Mage_Core_Helper_Data
public const XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS = 'sales/gift_options/allow_items';
public const XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER = 'sales/gift_options/allow_order';

public const TYPE_ADDRESS_ITEM = 'address_item';
public const TYPE_CONFIG = 'config';
public const TYPE_ITEM = 'item';
public const TYPE_ITEMS = 'items';
public const TYPE_ORDER = 'order';
public const TYPE_ORDER_ITEM = 'order_item';

protected $_moduleName = 'Mage_GiftMessage';

/**
Expand Down Expand Up @@ -88,74 +95,75 @@ public function getInline($type, Varien_Object $entity, $dontDisplayContainer =
/**
* Check availability of giftmessages for specified entity.
*
* @param string $type
* @param Mage_Core_Model_Store|integer $store
* @return bool|int
* @param self::TYPE_* $type $type
* @param bool|int|Mage_Core_Model_Store|null|string $store
* @return bool
*/
public function isMessagesAvailable($type, Varien_Object $entity, $store = null)
{
if ($type == 'items') {
$items = $entity->getAllItems();
if (!is_array($items) || empty($items)) {
return Mage::getStoreConfig(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, $store);
}
if ($entity instanceof Mage_Sales_Model_Quote) {
$_type = $entity->getIsMultiShipping() ? 'address_item' : 'item';
} else {
$_type = 'order_item';
}

foreach ($items as $item) {
if ($item->getParentItem()) {
continue;
switch ($type) {
case self::TYPE_ITEMS:
$items = $entity->getAllItems();
if (!is_array($items) || empty($items)) {
return Mage::getStoreConfigFlag(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, $store);
}
if ($this->isMessagesAvailable($_type, $item, $store)) {
return true;
if ($entity instanceof Mage_Sales_Model_Quote) {
$_type = $entity->getIsMultiShipping() ? self::TYPE_ADDRESS_ITEM : self::TYPE_ITEM;
} else {
$_type = self::TYPE_ORDER_ITEM;
}
}
} elseif ($type == 'item') {
return $this->_getDependenceFromStoreConfig(
$entity->getProduct()->getGiftMessageAvailable(),
$store
);
} elseif ($type == 'order_item') {
return $this->_getDependenceFromStoreConfig(
$entity->getGiftMessageAvailable(),
$store
);
} elseif ($type == 'address_item') {
$storeId = is_numeric($store) ? $store : Mage::app()->getStore($store)->getId();

if (!$this->isCached('address_item_' . $entity->getProductId())) {
$this->setCached(
'address_item_' . $entity->getProductId(),
Mage::getModel('catalog/product')
->setStoreId($storeId)
->load($entity->getProductId())
->getGiftMessageAvailable()
foreach ($items as $item) {
if ($item->getParentItem()) {
continue;
}
if ($this->isMessagesAvailable($_type, $item, $store)) {
return true;
}
}
// no break
case self::TYPE_ITEM:
return $this->_getDependenceFromStoreConfig(
$entity->getProduct()->getGiftMessageAvailable(),
$store
);
}
return $this->_getDependenceFromStoreConfig(
$this->getCached('address_item_' . $entity->getProductId()),
$store
);
} else {
return Mage::getStoreConfig(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, $store);
}
case self::TYPE_ORDER_ITEM:
return $this->_getDependenceFromStoreConfig(
$entity->getGiftMessageAvailable(),
$store
);
case self::TYPE_ADDRESS_ITEM:
$storeId = is_numeric($store) ? $store : Mage::app()->getStore($store)->getId();
$cacheId = self::TYPE_ADDRESS_ITEM . '_' . $entity->getProductId();

return false;
if (!$this->isCached($cacheId)) {
$this->setCached(
$cacheId,
Mage::getModel('catalog/product')
->setStoreId($storeId)
->load($entity->getProductId())
->getGiftMessageAvailable()
);
}
return $this->_getDependenceFromStoreConfig(
$this->getCached($cacheId),
$store
);
default:
return Mage::getStoreConfigFlag(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER, $store);
}
}

/**
* Check availability of gift messages from store config if flag eq 2.
*
* @param int $productGiftMessageAllow
* @param Mage_Core_Model_Store|integer $store
* @return bool|int
* @param bool $productGiftMessageAllow
* @param bool|int|Mage_Core_Model_Store|null|string $store
* @return bool
*/
protected function _getDependenceFromStoreConfig($productGiftMessageAllow, $store = null)
{
$result = Mage::getStoreConfig(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, $store);
$result = Mage::getStoreConfigFlag(self::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, $store);
if ($productGiftMessageAllow === '' || is_null($productGiftMessageAllow)) {
return $result;
} else {
Expand All @@ -166,9 +174,9 @@ protected function _getDependenceFromStoreConfig($productGiftMessageAllow, $stor
/**
* Alias for isMessagesAvailable(...)
*
* @param string $type
* @param Mage_Core_Model_Store|integer $store
* @return bool|int
* @param self::TYPE_* $type
* @param bool|int|Mage_Core_Model_Store|null|string $store
* @return bool
*/
public function getIsMessagesAvailable($type, Varien_Object $entity, $store = null)
{
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Install/etc/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<mcrypt/>
</mcrypt>
<pdo/>
<pdo_mysql/>
<simplexml/>
<soap/>
<spl/>
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Sales/Block/Order/Creditmemo.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ public function canDisplayGiftmessage(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getOrder());
return $helper->getIsMessagesAvailable($helper::TYPE_ORDER, $this->getOrder());
}
}
2 changes: 1 addition & 1 deletion app/code/core/Mage/Sales/Block/Order/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ public function canDisplayGiftmessage(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getOrder());
return $helper->getIsMessagesAvailable($helper::TYPE_ORDER, $this->getOrder());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ public function canDisplayGiftmessage(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order_item', $this->getOrderItem()) && $this->getItem()->getGiftMessageId();
return $helper->getIsMessagesAvailable(
$helper::TYPE_ORDER_ITEM,
$this->getOrderItem()
) && $this->getItem()->getGiftMessageId();
}

public function getGiftMessage(): ?Mage_GiftMessage_Model_Message
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Sales/Block/Order/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public function canDisplayGiftmessage(Mage_Sales_Model_Order_Item $item): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order_item', $item) && $item->getGiftMessageId();
return $helper->getIsMessagesAvailable($helper::TYPE_ORDER_ITEM, $item) && $item->getGiftMessageId();
}
}
2 changes: 1 addition & 1 deletion app/code/core/Mage/Sales/Block/Order/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,6 @@ public function canDisplayGiftmessage(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getOrder());
return $helper->getIsMessagesAvailable($helper::TYPE_ORDER, $this->getOrder());
}
}
7 changes: 5 additions & 2 deletions app/code/core/Mage/Sales/Block/Order/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function canDisplayGiftmessageItems(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('items', $this->getOrder());
return $helper->getIsMessagesAvailable($helper::TYPE_ITEMS, $this->getOrder());
}

public function canDisplayGiftmessageOrder(): bool
Expand All @@ -136,6 +136,9 @@ public function canDisplayGiftmessageOrder(): bool
}
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getOrder()) && $this->getOrder()->getGiftMessageId();
return $helper->getIsMessagesAvailable(
$helper::TYPE_ORDER,
$this->getOrder()
) && $this->getOrder()->getGiftMessageId();
}
}
Loading

0 comments on commit c8df745

Please sign in to comment.