示例#1
0
 /**
  * Return list of modules and/or core to upgrade
  *
  * @return array
  */
 protected function getUpgradeEntries()
 {
     if (!isset($this->entries)) {
         $this->entries = \XLite\Upgrade\Cell::getInstance()->getEntries();
     }
     return $this->entries;
 }
示例#2
0
 /**
  * Execute certain hook handle
  *
  * @return void
  */
 public function executeHookHandler()
 {
     if (\XLite\Upgrade\Cell::getInstance()->isUpgraded()) {
         $entries = \XLite\Upgrade\Cell::getInstance()->getEntries();
         if ($entries) {
             \Includes\Utils\Operator::showMessage('', true, false);
             /** @var \XLite\Upgrade\Entry\AEntry $entry */
             foreach ($entries as $entry) {
                 if (!$entry->isPostUpgradeActionsCalled()) {
                     $message = '...Invoke actions for ' . $entry->getActualName();
                     \Includes\Decorator\Utils\CacheManager::logMessage(PHP_EOL);
                     \Includes\Decorator\Utils\CacheManager::logMessage($message);
                     $isInvoked = \XLite\Upgrade\Cell::getInstance()->runHelper($entry, 'post_rebuild');
                     if ($isInvoked && \XLite\Upgrade\Cell::getInstance()->getHookRedirect()) {
                         break;
                     }
                     if (!\XLite\Upgrade\Cell::getInstance()->hasUnfinishedUpgradeHooks('post_rebuild', $entry)) {
                         // All post-rebuild hooks completed, run the rest actions...
                         \XLite\Upgrade\Cell::getInstance()->runCommonHelper($entry, 'add_labels');
                         \XLite\Upgrade\Cell::getInstance()->callInstallEvent($entry);
                         $entry->setPostUpgradeActionsCalled();
                     }
                     if (\Includes\Decorator\Utils\CacheManager::isTimeExceeds(static::STEP_TTL)) {
                         break;
                     }
                 }
             }
         }
     }
     \Includes\Decorator\Utils\CacheManager::logMessage(PHP_EOL);
     \XLite\Core\Database::getEM()->flush();
     \XLite\Core\Database::getEM()->clear();
 }
示例#3
0
 /**
  * Return title
  *
  * @return string
  */
 protected function getHead()
 {
     if (\XLite\Upgrade\Cell::getInstance()->isUpgrade()) {
         $result = static::t('X modules will be upgraded', array('count' => $this->getUpgradeEntriesCount()));
     } else {
         $result = 'These components will be updated';
     }
     return $result;
 }
示例#4
0
 /**
  * Check for uncalled actions
  *
  * @return boolean
  */
 protected function hasUncalledActions()
 {
     $result = false;
     $entries = \XLite\Upgrade\Cell::getInstance()->getEntries();
     if ($entries) {
         /** @var \XLite\Upgrade\Entry\AEntry $entry */
         foreach ($entries as $entry) {
             if (!$entry->isPostUpgradeActionsCalled()) {
                 $result = true;
                 break;
             }
         }
     }
     return $result;
 }
示例#5
0
 /**
  * Get entries count
  *
  * @return integer
  */
 protected function getCounter()
 {
     $entries = \XLite\Upgrade\Cell::getInstance()->getEntries();
     return count($entries);
 }
 /**
  * Return list of files
  *
  * @return array
  */
 protected function getPreUpgradeWarningModules()
 {
     return \XLite\Upgrade\Cell::getInstance()->getPreUpgradeWarningModules();
 }
示例#7
0
 /**
  * Return true if entry is selectable in the entries list (in advanced mode)
  *
  * @return boolean
  */
 protected function isEntrySelectable(\XLite\Upgrade\Entry\AEntry $entry)
 {
     return $this->isAdvancedMode() && (!$this->isModule($entry) || !($entry->isSystem() && \XLite\Upgrade\Cell::getInstance()->hasCoreUpdate()));
 }
示例#8
0
文件: APrepare.php 项目: kingsj/core
 /**
  * Check if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     return parent::isVisible() && !\XLite\Upgrade\Cell::getInstance()->isUnpacked() && !\XLite\Upgrade\Cell::getInstance()->isUpgraded();
 }
示例#9
0
 /**
  * Unseen updates available hash
  *
  * @return string Hash of modules updates messages
  */
 public function unseenUpdatesHash()
 {
     $result = array();
     $messages = $this->getXC5Notifications();
     $coreVersion = \XLite\Upgrade\Cell::getInstance()->getCoreVersion();
     if ($messages) {
         foreach ($messages as $message) {
             if ($message['type'] == 'module') {
                 $result[] = $message;
             }
         }
     }
     return md5(serialize($result) . serialize($coreVersion));
 }
示例#10
0
 /**
  * Return title
  *
  * @return string
  */
 protected function getHead()
 {
     return 'These components will be ' . (\XLite\Upgrade\Cell::getInstance()->isUpgrade() ? 'upgraded' : 'updated');
 }
示例#11
0
文件: Log.php 项目: kingsj/core
 /**
  * Called after the includeCompiledFile()
  *
  * @return void
  */
 protected function closeView()
 {
     parent::closeView();
     \XLite\Upgrade\Cell::getInstance()->clear(true, true, false);
     \XLite\Upgrade\Cell::getInstance()->setUpgraded(false);
 }
示例#12
0
 /**
  * Execute some helper methods
  * Return true if at least one method was executed
  *
  * @param string $type Helper type
  *
  * @return boolean
  */
 public function runHelpers($type)
 {
     $result = false;
     $path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath());
     // Helpers must examine itself if the module has been installed previously
     if ($path) {
         $helpers = 'post_rebuild' === $type ? $this->postRebuildHelpers : $this->getHelpers($type);
         $helpers = (array) $helpers;
         $invokedHooks = \XLite\Upgrade\Cell::getInstance()->getInvokedHooks();
         $pendingHooks = \XLite\Upgrade\Cell::getInstance()->getPendingHooks();
         foreach ($helpers as $file) {
             if (isset($invokedHooks[$file])) {
                 // Hook has been invoked earlier, skip...
                 continue;
             }
             /** @var \Closure $function */
             $function = (require_once $path . $file);
             // Prepare argument for hook function
             $suffix = '';
             $arg = null;
             if (!empty($pendingHooks[$file]) && 0 < $pendingHooks[$file]) {
                 $arg = $pendingHooks[$file];
                 $suffix = sprintf(' (%d)', $arg);
             }
             \Includes\Utils\Operator::showMessage(\XLite\Core\Translation::getInstance()->translate('...Invoke {{type}} hook for {{entry}}...', array('type' => $file, 'entry' => addslashes($this->getActualName()) . $suffix)));
             // Run hook function
             $hookResult = $function($arg);
             // Hook has been invoked - return true
             $result = true;
             // Save result of hook function
             \XLite\Upgrade\Cell::getInstance()->addPassedHook($file, intval($hookResult));
             $this->addInfoMessage('Update hook is run: {{type}}:{{file}}', true, array('type' => $this->getActualName(), 'file' => $file . $suffix));
             if (0 < intval($hookResult)) {
                 \XLite\Upgrade\Cell::getInstance()->setHookRedirect(true);
                 break;
             }
         }
         if ($helpers) {
             \XLite\Core\Database::getCacheDriver()->deleteAll();
         }
     }
     return $result;
 }
示例#13
0
 /**
  * Get error messages
  *
  * @return boolean
  */
 public function getErrorMessages()
 {
     return \XLite\Upgrade\Cell::getInstance()->getErrorMessages();
 }
示例#14
0
 /**
  * Check for request for upgrade availability
  *
  * @return boolean
  */
 protected function isRequestForUpgradeAvailable()
 {
     $result = false;
     if (\XLite\Upgrade\Cell::getInstance()->hasCoreUpdate() && \XLite::getXCNLicense()) {
         foreach ($this->getIncompatibleEntries() as $module) {
             if (!$module->isCustom()) {
                 $result = true;
                 break;
             }
         }
     }
     return $result;
 }
示例#15
0
文件: AAdmin.php 项目: kingsj/core
 /**
  * Log upgrade info and show top message
  *
  * @param string $method  Method to call
  * @param string $action  Current action
  * @param string $message Message to log and show
  * @param array  $args    Arguments to subsistute
  *
  * @return void
  */
 protected function showCommon($method, $action, $message, array $args)
 {
     if (!isset($message)) {
         $message = implode('; ', \XLite\Upgrade\Cell::getInstance()->getErrorMessages()) ?: 'unknown error';
     }
     if (isset($action) && LC_DEVELOPER_MODE) {
         $message = 'Action "' . get_class($this) . '::' . $action . '", ' . lcfirst($message);
     }
     \XLite\Upgrade\Logger::getInstance()->{'log' . $method}($message, $args, true);
 }
示例#16
0
 protected function isUpgrade()
 {
     return \XLite\Upgrade\Cell::getInstance()->isUpgrade();
 }
示例#17
0
 /**
  * Log upgrade info and show top message
  *
  * @param string $method  Method to call
  * @param string $action  Current action
  * @param string $message Message to log and show
  * @param array  $args    Arguments to substitute
  *
  * @return void
  */
 protected function showCommon($method, $action, $message, array $args)
 {
     if (null === $message) {
         $message = static::t(implode('; ', \XLite\Upgrade\Cell::getInstance()->getErrorMessages())) ?: static::t('unknown error');
     }
     if (null !== $action && LC_DEVELOPER_MODE) {
         $message = static::t('Action X::Y, M', array('class' => get_class($this), 'action' => $action, 'message' => $message));
     }
     \XLite\Upgrade\Logger::getInstance()->{'log' . $method}($message, $args, true);
 }
示例#18
0
 /**
  * Check if module will be disabled after upgrade
  *
  * :TRICKY: check if the "getMajorVersion" is not declared in the main module class
  *
  * @param \XLite\Model\Module $module Module to check
  *
  * @return boolean
  */
 protected function isModuleToDisable(\XLite\Model\Module $module)
 {
     $versionCore = \XLite\Upgrade\Cell::getInstance()->getCoreMajorVersion();
     $versionModule = $module->getMajorVersion();
     $classModule = \Includes\Utils\ModulesManager::getClassNameByModuleName($module->getActualName());
     $reflection = new \ReflectionMethod($classModule, 'getMajorVersion');
     $classModule = \Includes\Utils\Converter::prepareClassName($classModule);
     $classActual = \Includes\Utils\Converter::prepareClassName($reflection->getDeclaringClass()->getName());
     return version_compare($versionModule, $versionCore, '<') || $classModule !== $classActual;
 }
示例#19
0
文件: AUpgrade.php 项目: kingsj/core
 /**
  * Return list of modules and/or core to upgrade
  *
  * @return array
  */
 protected function getUpgradeEntries()
 {
     return \XLite\Upgrade\Cell::getInstance()->getEntries();
 }
示例#20
0
 /**
  * Do specific directory preparations after unpacking
  * Actually we add the disabled module with the active upgrade helpers (post_rebuild, pre_upgrade, post_upgrade)
  * into a special module list which will be either enabled or uninstall before the upgrade process
  *
  * @param string $dir Directory
  *
  * @return void
  */
 protected function prepareUnpackDir($dir)
 {
     if (!$this->isEnabled()) {
         $this->hasUpgradeHelpers() && \XLite\Upgrade\Cell::getInstance()->addDisabledModulesHook($this->getModuleInstalled()->getMarketplaceID());
         $this->hasPreUpgradeHelpers() && \XLite::getInstance()->checkVersion($this->getMajorVersionOld(), '>') && \XLite\Upgrade\Cell::getInstance()->addPreUpgradeWarningModules($this->getModuleForUpgrade()->getMarketplaceID());
     }
 }
示例#21
0
 /**
  * Return list of files
  *
  * @return array
  */
 protected function getDisabledModulesHooks()
 {
     return \XLite\Upgrade\Cell::getInstance()->getDisabledModulesHooks();
 }
示例#22
0
 /**
  * Check if only skins in in upgrade cell
  *
  * @return boolean
  */
 protected function isOnlySkins()
 {
     $result = false;
     $entries = \XLite\Upgrade\Cell::getInstance()->getEntries();
     if ($entries) {
         /** @var \XLite\Upgrade\Entry\Module\AModule $entry */
         foreach ($entries as $entry) {
             if ($entry->isSkinModule()) {
                 $result = true;
             } else {
                 $result = false;
                 break;
             }
         }
     }
     return $result;
 }
示例#23
0
 /**
  * Completed steps for upgrade is visible:
  * if there is at least one upgrade entry (core or module) (\XLite\View\Upgrade\EmptyCells widget is displayed instead)
  * and if the upgrade process is finished
  *
  * @return boolean
  */
 protected function isVisible()
 {
     return parent::isVisible() && \XLite\Upgrade\Cell::getInstance()->getEntries() && \XLite\Upgrade\Cell::getInstance()->isUpgraded();
 }
示例#24
0
 /**
  * Return list of files
  *
  * @return array
  */
 protected function getCustomFiles()
 {
     return \XLite\Upgrade\Cell::getInstance()->getCustomFiles();
 }
示例#25
0
 /**
  * Return list of premium license modules
  *
  * @return array
  */
 protected function getModules()
 {
     return \XLite\Upgrade\Cell::getInstance()->getPremiumLicenseModules();
 }