From d77091bc2eb53dd9ce5a9dcad5b89c03c7626e97 Mon Sep 17 00:00:00 2001 From: Alex Trofimov Date: Wed, 27 Apr 2022 20:34:45 +1000 Subject: [PATCH] Upgrade script from 13.0.0-A2 to 13.0.0-A3 --- .../files/inc/utils.inc.php | 33 +++++++++----- .../classes/BxBaseModGeneralModule.php | 8 ++-- .../files/plugins/autoload.php | 2 +- .../files/plugins/composer/autoload_real.php | 14 +++--- .../plugins/composer/autoload_static.php | 10 ++--- .../files/plugins/composer/installed.php | 4 +- .../files/studio/store.php | 44 +++++++++++++++++++ .../files/template/scripts/BxBaseCategory.php | 6 +-- .../scripts/BxBaseServiceMetatags.php | 13 +++--- 9 files changed, 93 insertions(+), 41 deletions(-) create mode 100644 upgrade/files/13.0.0.A2-13.0.0.A3/files/studio/store.php diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/inc/utils.inc.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/inc/utils.inc.php index fac0a5a7ed..128e32f4c9 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/inc/utils.inc.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/inc/utils.inc.php @@ -1324,20 +1324,29 @@ function bx_get_base_url($sPageLink) function bx_get_page_info() { - $a = bx_get_base_url_inline(); - $oPage = BxDolPage::getObjectInstanceByURI($a[1]['i']); - $oServ = bx_instance('BxTemplServices'); - if ($oServ->serviceIsModuleContext($oPage->getModule())){ - $oProfile = BxDolProfile::getInstanceByContentAndType($a[1]['id'], $oPage->getModule()); - return ['context_module' => $oPage->getModule(), 'context_id' => isset($a[1]['id']) ? $a[1]['id'] : '', 'profile_context_id' => $oProfile->id()]; + list($sPageLink, $aPageParams) = bx_get_base_url_inline(); + + if(isset($aPageParams['i'], $aPageParams['id']) && ($oPage = BxDolPage::getObjectInstanceByURI($aPageParams['i'])) !== false) { + $sPageModule = $oPage->getModule(); + if(bx_srv('system', 'is_module_context', [$sPageModule]) && ($oProfile = BxDolProfile::getInstanceByContentAndType($aPageParams['id'], $sPageModule)) !== false) + return [ + 'context_module' => $sPageModule, + 'context_id' => $aPageParams['id'], + 'context_profile_id' => $oProfile->id() + ]; } - - if (isset($a[1]['profile_id'])){ - $oProfile = BxDolProfile::getInstance($a[1]['profile_id']); - if($oProfile && $oServ->serviceIsModuleContext($oProfile->getModule())){ - return ['context_module' => $oProfile->getModule(), 'context_id' => $oProfile->getContentId(), 'profile_context_id' => $a[1]['profile_id']]; - } + + if(isset($aPageParams['profile_id']) && ($oProfile = BxDolProfile::getInstance($aPageParams['profile_id'])) !== false) { + $sProfileModule = $oProfile->getModule(); + if(bx_srv('system', 'is_module_context', [$sProfileModule])) + return [ + 'context_module' => $sProfileModule, + 'context_id' => $oProfile->getContentId(), + 'context_profile_id' => $aPageParams['profile_id'] + ]; } + + return false; } function bx_get_location_bounds_latlng($fLatitude, $fLongitude, $iRadiusInKm) diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/modules/base/general/classes/BxBaseModGeneralModule.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/modules/base/general/classes/BxBaseModGeneralModule.php index 1104de6118..cd46038154 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/modules/base/general/classes/BxBaseModGeneralModule.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/modules/base/general/classes/BxBaseModGeneralModule.php @@ -2391,12 +2391,12 @@ public function serviceGetBadges($iContentId, $bIsSingle = false, $bIsCompact public function serviceCategoriesMultiList($bDisplayEmptyCats = true) { $aContextInfo = bx_get_page_info(); + $mProfileContextId = false; - if (isset($aContextInfo['context_module']) && isset($aContextInfo['profile_context_id'])){ - $mProfileContextId = $aContextInfo['profile_context_id']; - } + if ($aContextInfo !== false) + $mProfileContextId = $aContextInfo['context_profile_id']; - $oCategories = BxDolCategories::getInstance(); + $oCategories = BxDolCategories::getInstance(); if ($mProfileContextId) $aCats = $oCategories->getData([ 'type' => 'by_module&context_with_num', diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/autoload.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/autoload.php index cc3ed86473..08f7acb8d6 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/autoload.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInita6c4a21debe3a86d296d6890d526cc19::getLoader(); +return ComposerAutoloaderInit60e3f6a64733205d9daf98e574d1e99b::getLoader(); diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_real.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_real.php index 100297fa43..d1dcca78ee 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_real.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita6c4a21debe3a86d296d6890d526cc19 +class ComposerAutoloaderInit60e3f6a64733205d9daf98e574d1e99b { private static $loader; @@ -24,15 +24,15 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInita6c4a21debe3a86d296d6890d526cc19', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit60e3f6a64733205d9daf98e574d1e99b', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); - spl_autoload_unregister(array('ComposerAutoloaderInita6c4a21debe3a86d296d6890d526cc19', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit60e3f6a64733205d9daf98e574d1e99b', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInita6c4a21debe3a86d296d6890d526cc19::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -53,19 +53,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInita6c4a21debe3a86d296d6890d526cc19::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequirea6c4a21debe3a86d296d6890d526cc19($fileIdentifier, $file); + composerRequire60e3f6a64733205d9daf98e574d1e99b($fileIdentifier, $file); } return $loader; } } -function composerRequirea6c4a21debe3a86d296d6890d526cc19($fileIdentifier, $file) +function composerRequire60e3f6a64733205d9daf98e574d1e99b($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_static.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_static.php index b270d48d37..57e32cc987 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_static.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInita6c4a21debe3a86d296d6890d526cc19 +class ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b { public static $files = array ( '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', @@ -282,10 +282,10 @@ class ComposerStaticInita6c4a21debe3a86d296d6890d526cc19 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita6c4a21debe3a86d296d6890d526cc19::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita6c4a21debe3a86d296d6890d526cc19::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInita6c4a21debe3a86d296d6890d526cc19::$prefixesPsr0; - $loader->classMap = ComposerStaticInita6c4a21debe3a86d296d6890d526cc19::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b::$prefixesPsr0; + $loader->classMap = ComposerStaticInit60e3f6a64733205d9daf98e574d1e99b::$classMap; }, null, ClassLoader::class); } diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/installed.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/installed.php index dac1302853..84411fd369 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/installed.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/plugins/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'a285896dbfb744f65cc03a63f4de3349f5097223', + 'reference' => '2b3adf499fc17dc235ed8f20171a5c02810e37eb', 'name' => 'unaio/una', 'dev' => true, ), @@ -330,7 +330,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'a285896dbfb744f65cc03a63f4de3349f5097223', + 'reference' => '2b3adf499fc17dc235ed8f20171a5c02810e37eb', 'dev_requirement' => false, ), 'wikimedia/less.php' => array( diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/studio/store.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/studio/store.php new file mode 100644 index 0000000000..39902a2816 --- /dev/null +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/studio/store.php @@ -0,0 +1,44 @@ +checkAction()) !== false) { + echoJson($mixedResult); + exit; +} + +$oTemplate = BxDolStudioTemplate::getInstance(); + +$sPageCode = $oPage->getPageCode(); +if($sPageCode === false) + $oTemplate->displayMsg(($sError = $oPage->getError(false)) !== false ? $sError : '_sys_txt_error_occured', true); + +$oTemplate->setPageNameIndex($oPage->getPageIndex()); +$oTemplate->setPageHeader($oPage->getPageHeader()); +$oTemplate->setPageContent('page_caption_code', $oPage->getPageCaption()); +$oTemplate->setPageContent('page_attributes', $oPage->getPageAttributes()); +$oTemplate->setPageContent('page_menu_code', $oPage->getPageMenu()); +$oTemplate->setPageContent('page_main_code', $sPageCode); +$oTemplate->addCss($oPage->getPageCss()); +$oTemplate->addJs($oPage->getPageJs()); +$oTemplate->getPageCode(); +/** @} */ diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseCategory.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseCategory.php index bc98006d78..9883c9bfd3 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseCategory.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseCategory.php @@ -70,10 +70,10 @@ public function getCategoryLink($sName, $sValue) public function getCategoriesList($bDisplayEmptyCats = true, $bAsArray = false) { $aContextInfo = bx_get_page_info(); + $mProfileContextId = false; - if (isset($aContextInfo['context_module']) && isset($aContextInfo['profile_context_id'])){ - $mProfileContextId = $aContextInfo['profile_context_id']; - } + if ($aContextInfo !== false) + $mProfileContextId = $aContextInfo['context_profile_id']; $a = BxDolForm::getDataItems($this->_aObject['list_name']); if (!$a) diff --git a/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseServiceMetatags.php b/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseServiceMetatags.php index 35c6e02bd3..caeccfe74d 100644 --- a/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseServiceMetatags.php +++ b/upgrade/files/13.0.0.A2-13.0.0.A3/files/template/scripts/BxBaseServiceMetatags.php @@ -52,16 +52,15 @@ public function serviceKeywordsCloud($sObject, $mixedSection, $aParams = array() $bShowEmpty = isset($aParams['show_empty']) ? (bool)$aParams['show_empty'] : false; $aContextInfo = bx_get_page_info(); - if (isset($aContextInfo['context_module']) && isset($aContextInfo['profile_context_id'])){ - $sResult = BxDolMetatags::getObjectInstance($sObject)->getKeywordsCloud($mixedSection, $iMaxCount, false, ['context_id' => $aContextInfo['profile_context_id']]); - } - else{ + if ($aContextInfo !== false) + $sResult = BxDolMetatags::getObjectInstance($sObject)->getKeywordsCloud($mixedSection, $iMaxCount, false, ['context_id' => $aContextInfo['context_profile_id']]); + else $sResult = BxDolMetatags::getObjectInstance($sObject)->getKeywordsCloud($mixedSection, $iMaxCount); - } + if(empty($sResult)) - return $bShowEmpty ? MsgBox(_t('_Empty')) : ''; + return $bShowEmpty ? MsgBox(_t('_Empty')) : ''; - return $sResult; + return $sResult; } public function serviceBrowseLabels($aParams = array())