Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
空白の変更を非表示
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
テキストスタイル
外観を変更
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
private-content.phtml
作成日
3 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
1 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
149 行
すべてコピー
54 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
199 行
すべてコピー
コピー
コピー済み
コピー
コピー済み
<?php
/**
* Hyvä Themes - https://hyva.io
* Copyright © Hyvä Themes 2020-present. All rights reserved.
* This product is licensed per Magento install
* See https://hyva.io/license
*/
declare(strict_types=1);
/** @var Template $block */
/** @var Escaper $escaper */
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\Template;
?>
<script>
<script>
'use strict';
'use strict';
{
{
const private_content_key = 'mage-cache-storage';
const private_content_key = 'mage-cache-storage';
const private_content_expire_key = 'mage-cache-timeout';
const private_content_expire_key = 'mage-cache-timeout';
const private_content_version_key = 'private_content_version';
const private_content_version_key = 'private_content_version';
const section_data_ids_key = 'section_data_ids';
const section_data_ids_key = 'section_data_ids';
const mage_cache_session_id_key = 'mage-cache-sessid';
const mage_cache_session_id_key = 'mage-cache-sessid';
const last_visited_store_key = 'last_visited_store';
const last_visited_store_key = 'last_visited_store';
const ttl = 3600;
const ttl = 3600;
コピー
コピー済み
コピー
コピー済み
<?php
/**
* The `hyva` JS namespace is being set by Hyva_Theme/src/view/frontend/templates/page/js/hyva.phtml
* and should be included through Hyva_Theme/src/view/frontend/layout/default_hyva.xml
*/
?>
if (typeof hyva === 'undefined' || (!hyva.getBrowserStorage || !hyva.getCookie || !hyva.setCookie)) {
if (typeof hyva === 'undefined' || (!hyva.getBrowserStorage || !hyva.getCookie || !hyva.setCookie)) {
console.warn("Hyvä helpers are not loaded yet. Make sure they are included before this script");
console.warn("Hyvä helpers are not loaded yet. Make sure they are included before this script");
}
}
function loadSectionData () {
function loadSectionData () {
const browserStorage = hyva.getBrowserStorage();
const browserStorage = hyva.getBrowserStorage();
if (!browserStorage) {
if (!browserStorage) {
typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
typeof window.dispatchMessages !== "undefined" && window.dispatchMessages(
[{
[{
type: "warning",
type: "warning",
コピー
コピー済み
コピー
コピー済み
text: "
Please enable LocalStorage in your browser.
"
text: "
<?= $escaper->escapeHtml(__('
Please enable LocalStorage in your browser.
')) ?>
"
}]
}]
);
);
return;
return;
}
}
try {
try {
let isInvalid = false;
let isInvalid = false;
コピー
コピー済み
コピー
コピー済み
<?php
/**
* Usually store switch is made via POST requests, but if this happen on other ways (eg. the customer
* changing manually the base url, or landing from search engines on a different store) we need to
* request again private contents
*/
?>
if (hyva.getCookie(last_visited_store_key) !== CURRENT_STORE_CODE) {
if (hyva.getCookie(last_visited_store_key) !== CURRENT_STORE_CODE) {
isInvalid = true;
isInvalid = true;
}
}
hyva.setCookie(last_visited_store_key, CURRENT_STORE_CODE, false, false);
hyva.setCookie(last_visited_store_key, CURRENT_STORE_CODE, false, false);
コピー
コピー済み
コピー
コピー済み
<?php
/**
* The `mage-cache-sessid` cookie is being unset from backend to
* indicate that sectionData is invalidated and needs to be reloaded
* in the frontend. So we mark it as invalid, and then re-set the
* `mage-cache-sessid` cookie
*/
?>
if (!hyva.getCookie(mage_cache_session_id_key)) {
if (!hyva.getCookie(mage_cache_session_id_key)) {
isInvalid = true;
isInvalid = true;
const skipSetDomain = true;
const skipSetDomain = true;
const days = false;
const days = false;
hyva.setCookie(mage_cache_session_id_key, true, days, skipSetDomain)
hyva.setCookie(mage_cache_session_id_key, true, days, skipSetDomain)
}
}
const cookieVersion = hyva.getCookie(private_content_version_key);
const cookieVersion = hyva.getCookie(private_content_version_key);
const storageVersion = browserStorage.getItem(private_content_version_key);
const storageVersion = browserStorage.getItem(private_content_version_key);
if (cookieVersion && !storageVersion || cookieVersion !== storageVersion) {
if (cookieVersion && !storageVersion || cookieVersion !== storageVersion) {
isInvalid = true;
isInvalid = true;
}
}
const privateContentExpires = browserStorage.getItem(private_content_expire_key);
const privateContentExpires = browserStorage.getItem(private_content_expire_key);
if (privateContentExpires && new Date(privateContentExpires) < new Date()) {
if (privateContentExpires && new Date(privateContentExpires) < new Date()) {
browserStorage.removeItem(private_content_key);
browserStorage.removeItem(private_content_key);
}
}
if (isInvalid) {
if (isInvalid) {
fetchPrivateContent([]);
fetchPrivateContent([]);
} else if (cookieVersion && storageVersion && cookieVersion === storageVersion) {
} else if (cookieVersion && storageVersion && cookieVersion === storageVersion) {
const privateContent = JSON.parse(browserStorage.getItem(private_content_key));
const privateContent = JSON.parse(browserStorage.getItem(private_content_key));
if (
if (
privateContent &&
privateContent &&
privateContentExpires &&
privateContentExpires &&
privateContent.cart &&
privateContent.cart &&
privateContent.customer
privateContent.customer
) {
) {
dispatchPrivateContent(privateContent);
dispatchPrivateContent(privateContent);
} else {
} else {
fetchPrivateContent([]);
fetchPrivateContent([]);
}
}
} else {
} else {
dispatchPrivateContent({});
dispatchPrivateContent({});
}
}
} catch (error) {
} catch (error) {
console.warn('Error retrieving Private Content:', error);
console.warn('Error retrieving Private Content:', error);
}
}
}
}
コピー
コピー済み
コピー
コピー済み
window.addEventListener('
load
', loadSectionData);
window.addEventListener('
alpine:initialized
', loadSectionData);
window.addEventListener('reload-customer-section-data', loadSectionData);
window.addEventListener('reload-customer-section-data', loadSectionData);
function dispatchPrivateContent(data) {
function dispatchPrivateContent(data) {
const privateContentEvent = new CustomEvent("private-content-loaded", {
const privateContentEvent = new CustomEvent("private-content-loaded", {
detail: {
detail: {
data: data
data: data
}
}
});
});
window.dispatchEvent(privateContentEvent);
window.dispatchEvent(privateContentEvent);
}
}
コピー
コピー済み
コピー
コピー済み
<?php
/**
* We use 'X-Requested-With': 'XMLHttpRequest' to prevent Magento from clearing the customer session
* in \Magento\PageCache\Model\DepersonalizeChecker::checkIfDepersonalize
* Otherwise, \Magento\Tax\Plugin\Checkout\CustomerData\Cart::afterGetSectionData can't add tax to
* cart items.
*/
?>
function fetchPrivateContent(sections) {
function fetchPrivateContent(sections) {
fetch(`${BASE_URL}customer/section/load/?sections=${encodeURIComponent(sections.join(','))}`, {
fetch(`${BASE_URL}customer/section/load/?sections=${encodeURIComponent(sections.join(','))}`, {
method: 'GET',
method: 'GET',
headers: {
headers: {
'Content-Type': 'application/json',
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
'X-Requested-With': 'XMLHttpRequest'
}
}
})
})
.then(response => response.json())
.then(response => response.json())
.then(
.then(
data => {
data => {
if (data) {
if (data) {
try {
try {
const browserStorage = hyva.getBrowserStorage();
const browserStorage = hyva.getBrowserStorage();
// merge new data preserving non-invalidated sections
// merge new data preserving non-invalidated sections
コピー
コピー済み
コピー
コピー済み
const oldSectionData = JSON.parse(browserStorage.getItem(private_content_key) || '{}')
;
const oldSectionData = JSON.parse(browserStorage.getItem(private_content_key) || '{}')
|| {}
;
コピー
コピー済み
コピー
コピー済み
<?php
/** Ensure no checkout data remains after logout (from Luma checkout) */
?>
if ((! data.cart || ! data.cart.cartId) && oldSectionData['checkout-data']) {
if ((! data.cart || ! data.cart.cartId) && oldSectionData['checkout-data']) {
delete oldSectionData['checkout-data'];
delete oldSectionData['checkout-data'];
}
}
const newSectionData = Object.assign(oldSectionData, data);
const newSectionData = Object.assign(oldSectionData, data);
dispatchPrivateContent(newSectionData);
dispatchPrivateContent(newSectionData);
// don't persist messages, they've been dispatched already
// don't persist messages, they've been dispatched already
if (newSectionData.messages && newSectionData.messages.messages ) {
if (newSectionData.messages && newSectionData.messages.messages ) {
newSectionData.messages.messages = [];
newSectionData.messages.messages = [];
}
}
browserStorage.setItem(private_content_key, JSON.stringify(newSectionData));
browserStorage.setItem(private_content_key, JSON.stringify(newSectionData));
const expiresAt = new Date(Date.now() + (ttl * 1000)).toISOString();
const expiresAt = new Date(Date.now() + (ttl * 1000)).toISOString();
browserStorage.setItem(private_content_expire_key, expiresAt);
browserStorage.setItem(private_content_expire_key, expiresAt);
const newCookieVersion = hyva.getCookie(private_content_version_key);
const newCookieVersion = hyva.getCookie(private_content_version_key);
browserStorage.setItem(private_content_version_key, newCookieVersion);
browserStorage.setItem(private_content_version_key, newCookieVersion);
// We don't need the section_data_ids in Hyvä, but we store them for compatibility
// We don't need the section_data_ids in Hyvä, but we store them for compatibility
// with Luma Fallback. Otherwise, not all sections are loaded in Luma Checkout
// with Luma Fallback. Otherwise, not all sections are loaded in Luma Checkout
hyva.setCookie(
hyva.setCookie(
section_data_ids_key,
section_data_ids_key,
JSON.stringify(
JSON.stringify(
Object.keys(data).reduce((sectionDataIds, sectionKey) => {
Object.keys(data).reduce((sectionDataIds, sectionKey) => {
sectionDataIds[sectionKey] = data[sectionKey]['data_id'];
sectionDataIds[sectionKey] = data[sectionKey]['data_id'];
return sectionDataIds;
return sectionDataIds;
}, {})
}, {})
),
),
false,
false,
true
true
);
);
} catch (error) {
} catch (error) {
console.warn("Couldn't store privateContent", error);
console.warn("Couldn't store privateContent", error);
}
}
}
}
}
}
);
);
}
}
}
}
</script>
</script>
コピー
コピー済み
コピー
コピー済み
保存された差分
原文
ファイルを開く
<script> 'use strict'; { const private_content_key = 'mage-cache-storage'; const private_content_expire_key = 'mage-cache-timeout'; const private_content_version_key = 'private_content_version'; const section_data_ids_key = 'section_data_ids'; const mage_cache_session_id_key = 'mage-cache-sessid'; const last_visited_store_key = 'last_visited_store'; const ttl = 3600; if (typeof hyva === 'undefined' || (!hyva.getBrowserStorage || !hyva.getCookie || !hyva.setCookie)) { console.warn("Hyvä helpers are not loaded yet. Make sure they are included before this script"); } function loadSectionData () { const browserStorage = hyva.getBrowserStorage(); if (!browserStorage) { typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: "warning", text: "Please enable LocalStorage in your browser." }] ); return; } try { let isInvalid = false; if (hyva.getCookie(last_visited_store_key) !== CURRENT_STORE_CODE) { isInvalid = true; } hyva.setCookie(last_visited_store_key, CURRENT_STORE_CODE, false, false); if (!hyva.getCookie(mage_cache_session_id_key)) { isInvalid = true; const skipSetDomain = true; const days = false; hyva.setCookie(mage_cache_session_id_key, true, days, skipSetDomain) } const cookieVersion = hyva.getCookie(private_content_version_key); const storageVersion = browserStorage.getItem(private_content_version_key); if (cookieVersion && !storageVersion || cookieVersion !== storageVersion) { isInvalid = true; } const privateContentExpires = browserStorage.getItem(private_content_expire_key); if (privateContentExpires && new Date(privateContentExpires) < new Date()) { browserStorage.removeItem(private_content_key); } if (isInvalid) { fetchPrivateContent([]); } else if (cookieVersion && storageVersion && cookieVersion === storageVersion) { const privateContent = JSON.parse(browserStorage.getItem(private_content_key)); if ( privateContent && privateContentExpires && privateContent.cart && privateContent.customer ) { dispatchPrivateContent(privateContent); } else { fetchPrivateContent([]); } } else { dispatchPrivateContent({}); } } catch (error) { console.warn('Error retrieving Private Content:', error); } } window.addEventListener('load', loadSectionData); window.addEventListener('reload-customer-section-data', loadSectionData); function dispatchPrivateContent(data) { const privateContentEvent = new CustomEvent("private-content-loaded", { detail: { data: data } }); window.dispatchEvent(privateContentEvent); } function fetchPrivateContent(sections) { fetch(`${BASE_URL}customer/section/load/?sections=${encodeURIComponent(sections.join(','))}`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' } }) .then(response => response.json()) .then( data => { if (data) { try { const browserStorage = hyva.getBrowserStorage(); // merge new data preserving non-invalidated sections const oldSectionData = JSON.parse(browserStorage.getItem(private_content_key) || '{}'); if ((! data.cart || ! data.cart.cartId) && oldSectionData['checkout-data']) { delete oldSectionData['checkout-data']; } const newSectionData = Object.assign(oldSectionData, data); dispatchPrivateContent(newSectionData); // don't persist messages, they've been dispatched already if (newSectionData.messages && newSectionData.messages.messages ) { newSectionData.messages.messages = []; } browserStorage.setItem(private_content_key, JSON.stringify(newSectionData)); const expiresAt = new Date(Date.now() + (ttl * 1000)).toISOString(); browserStorage.setItem(private_content_expire_key, expiresAt); const newCookieVersion = hyva.getCookie(private_content_version_key); browserStorage.setItem(private_content_version_key, newCookieVersion); // We don't need the section_data_ids in Hyvä, but we store them for compatibility // with Luma Fallback. Otherwise, not all sections are loaded in Luma Checkout hyva.setCookie( section_data_ids_key, JSON.stringify( Object.keys(data).reduce((sectionDataIds, sectionKey) => { sectionDataIds[sectionKey] = data[sectionKey]['data_id']; return sectionDataIds; }, {}) ), false, true ); } catch (error) { console.warn("Couldn't store privateContent", error); } } } ); } } </script>
変更されたテキスト
ファイルを開く
<?php /** * Hyvä Themes - https://hyva.io * Copyright © Hyvä Themes 2020-present. All rights reserved. * This product is licensed per Magento install * See https://hyva.io/license */ declare(strict_types=1); /** @var Template $block */ /** @var Escaper $escaper */ use Magento\Framework\Escaper; use Magento\Framework\View\Element\Template; ?> <script> 'use strict'; { const private_content_key = 'mage-cache-storage'; const private_content_expire_key = 'mage-cache-timeout'; const private_content_version_key = 'private_content_version'; const section_data_ids_key = 'section_data_ids'; const mage_cache_session_id_key = 'mage-cache-sessid'; const last_visited_store_key = 'last_visited_store'; const ttl = 3600; <?php /** * The `hyva` JS namespace is being set by Hyva_Theme/src/view/frontend/templates/page/js/hyva.phtml * and should be included through Hyva_Theme/src/view/frontend/layout/default_hyva.xml */ ?> if (typeof hyva === 'undefined' || (!hyva.getBrowserStorage || !hyva.getCookie || !hyva.setCookie)) { console.warn("Hyvä helpers are not loaded yet. Make sure they are included before this script"); } function loadSectionData () { const browserStorage = hyva.getBrowserStorage(); if (!browserStorage) { typeof window.dispatchMessages !== "undefined" && window.dispatchMessages( [{ type: "warning", text: "<?= $escaper->escapeHtml(__('Please enable LocalStorage in your browser.')) ?>" }] ); return; } try { let isInvalid = false; <?php /** * Usually store switch is made via POST requests, but if this happen on other ways (eg. the customer * changing manually the base url, or landing from search engines on a different store) we need to * request again private contents */ ?> if (hyva.getCookie(last_visited_store_key) !== CURRENT_STORE_CODE) { isInvalid = true; } hyva.setCookie(last_visited_store_key, CURRENT_STORE_CODE, false, false); <?php /** * The `mage-cache-sessid` cookie is being unset from backend to * indicate that sectionData is invalidated and needs to be reloaded * in the frontend. So we mark it as invalid, and then re-set the * `mage-cache-sessid` cookie */ ?> if (!hyva.getCookie(mage_cache_session_id_key)) { isInvalid = true; const skipSetDomain = true; const days = false; hyva.setCookie(mage_cache_session_id_key, true, days, skipSetDomain) } const cookieVersion = hyva.getCookie(private_content_version_key); const storageVersion = browserStorage.getItem(private_content_version_key); if (cookieVersion && !storageVersion || cookieVersion !== storageVersion) { isInvalid = true; } const privateContentExpires = browserStorage.getItem(private_content_expire_key); if (privateContentExpires && new Date(privateContentExpires) < new Date()) { browserStorage.removeItem(private_content_key); } if (isInvalid) { fetchPrivateContent([]); } else if (cookieVersion && storageVersion && cookieVersion === storageVersion) { const privateContent = JSON.parse(browserStorage.getItem(private_content_key)); if ( privateContent && privateContentExpires && privateContent.cart && privateContent.customer ) { dispatchPrivateContent(privateContent); } else { fetchPrivateContent([]); } } else { dispatchPrivateContent({}); } } catch (error) { console.warn('Error retrieving Private Content:', error); } } window.addEventListener('alpine:initialized', loadSectionData); window.addEventListener('reload-customer-section-data', loadSectionData); function dispatchPrivateContent(data) { const privateContentEvent = new CustomEvent("private-content-loaded", { detail: { data: data } }); window.dispatchEvent(privateContentEvent); } <?php /** * We use 'X-Requested-With': 'XMLHttpRequest' to prevent Magento from clearing the customer session * in \Magento\PageCache\Model\DepersonalizeChecker::checkIfDepersonalize * Otherwise, \Magento\Tax\Plugin\Checkout\CustomerData\Cart::afterGetSectionData can't add tax to * cart items. */ ?> function fetchPrivateContent(sections) { fetch(`${BASE_URL}customer/section/load/?sections=${encodeURIComponent(sections.join(','))}`, { method: 'GET', headers: { 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest' } }) .then(response => response.json()) .then( data => { if (data) { try { const browserStorage = hyva.getBrowserStorage(); // merge new data preserving non-invalidated sections const oldSectionData = JSON.parse(browserStorage.getItem(private_content_key) || '{}') || {}; <?php /** Ensure no checkout data remains after logout (from Luma checkout) */ ?> if ((! data.cart || ! data.cart.cartId) && oldSectionData['checkout-data']) { delete oldSectionData['checkout-data']; } const newSectionData = Object.assign(oldSectionData, data); dispatchPrivateContent(newSectionData); // don't persist messages, they've been dispatched already if (newSectionData.messages && newSectionData.messages.messages ) { newSectionData.messages.messages = []; } browserStorage.setItem(private_content_key, JSON.stringify(newSectionData)); const expiresAt = new Date(Date.now() + (ttl * 1000)).toISOString(); browserStorage.setItem(private_content_expire_key, expiresAt); const newCookieVersion = hyva.getCookie(private_content_version_key); browserStorage.setItem(private_content_version_key, newCookieVersion); // We don't need the section_data_ids in Hyvä, but we store them for compatibility // with Luma Fallback. Otherwise, not all sections are loaded in Luma Checkout hyva.setCookie( section_data_ids_key, JSON.stringify( Object.keys(data).reduce((sectionDataIds, sectionKey) => { sectionDataIds[sectionKey] = data[sectionKey]['data_id']; return sectionDataIds; }, {}) ), false, true ); } catch (error) { console.warn("Couldn't store privateContent", error); } } } ); } } </script>
違いを見つける