Example #1
0
 /**
  * If we can proceed with checkout with current cart
  *
  * @return boolean
  */
 public function getDescription()
 {
     $description = parent::getDescription();
     if ('CDev\\XPaymentsConnector' == $this->getActualName()) {
         $description = \XLite\Module\CDev\XPaymentsConnector\Main::getDescription();
     }
     return $description;
 }
Example #2
0
 /**
  * Return list of module directories which contain templates. Custom skins
  *
  * @return array
  */
 protected function getCustomSkinDirs()
 {
     $result = array();
     // Collect the custom skins registered via the module
     foreach ($this->module->callModuleMethod('getSkins', array()) as $tmp) {
         $result = array_merge($result, $tmp);
     }
     array_walk($result, array($this, 'addSkinPrefix'));
     return array_values(array_unique($result));
 }
Example #3
0
 /**
  * Return list of module directories which contain templates
  *
  * @return array
  */
 protected function getSkinDirs()
 {
     $result = array();
     foreach (\XLite\Core\Layout::getInstance()->getSkinsAll() as $interface => $tmp) {
         $result = array_merge($result, \XLite\Core\Layout::getInstance()->getSkinPaths($interface));
     }
     foreach ($result as $key => &$data) {
         $path = \Includes\Utils\ModulesManager::getRelativeDir($this->module->getAuthor(), $this->module->getName());
         $path = $data['fs'] . LC_DS . 'modules' . LC_DS . $path;
         if (\Includes\Utils\FileManager::isDirReadable($path)) {
             $data = $path;
         } else {
             unset($result[$key]);
         }
     }
     return array_values(array_unique($result));
 }
Example #4
0
 /**
  * Uninstall module
  *
  * @param \XLite\Model\Module $module    Module object
  * @param array               &$messages Messages list
  *
  * @return boolean
  */
 public function uninstallModule(\XLite\Model\Module $module, &$messages)
 {
     $result = false;
     // Get module pack
     $pack = new \XLite\Core\Pack\Module($module);
     $dirs = $pack->getDirs();
     $nonWritableDirs = array();
     // Check module directories permissions
     foreach ($dirs as $dir) {
         if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
             $nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
         }
     }
     $params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
     if (empty($nonWritableDirs)) {
         $yamlData = array();
         $yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
         foreach ($yamlFiles as $yamlFile) {
             $yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
         }
         if (!$module->checkModuleMainClass()) {
             $classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
             if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
                 require_once $classFile;
             }
         }
         // Call uninstall event method
         $r = $module->callModuleMethod('callUninstallEvent', 111);
         if (111 == $r) {
             \XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
         }
         // Remove from FS
         foreach ($dirs as $dir) {
             \Includes\Utils\FileManager::unlinkRecursive($dir);
         }
         \Includes\Utils\ModulesManager::disableModule($module->getActualName());
         \Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
         // Remove module from DB
         try {
             // Refresh module entity as it was changed by disableModule() method above
             $module = $this->find($module->getModuleID());
             $this->delete($module);
         } catch (\Exception $e) {
             $messages[] = $e->getMessage();
         }
         if ($module->getModuleID()) {
             $messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
         } else {
             if (!empty($yamlData)) {
                 foreach ($yamlData as $yaml) {
                     \XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
                 }
             }
             $messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
             $result = true;
         }
     } else {
         $messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
     }
     return $result;
 }
Example #5
0
 /**
  * Check module license and return true if it's non-empty
  *
  * @param \XLite\Model\Module $module Module
  *
  * @return boolean
  */
 protected function hasNonEmptyLicense(\XLite\Model\Module $module)
 {
     return $module->getHasLicense();
 }
Example #6
0
 /**
  * Defines specific downloads CSS class if necessary
  *
  * @param \XLite\Model\Module $module
  *
  * @return string
  */
 protected function getDownloadsCSSClass(\XLite\Model\Module $module)
 {
     return $module->getDownloads() / $this->getMaximumPopularity() >= static::MAX_POPULAR_LEVEL ? ' high-popular' : '';
 }
 /**
  * Get shipping module property value
  * 
  * @param \XLite\Model\Module $module Module
  * @param string $property Property key
  * 
  * @return string
  */
 protected function getShippingModulePropertyValue($module, $type, $property)
 {
     $dict = $this->getShippingModulePropertyDictionary();
     $moduleTypeDict = $dict[$module->getName()][$type];
     return $moduleTypeDict[$property];
 }
 /**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }
Example #9
0
 /**
  * Prepare and return module identity data
  *
  * @param \XLite\Model\Module $module          Module to get info
  * @param boolean             $fromMarketplace Flag
  *
  * @return array
  */
 protected function getPreparedModuleInfo(\XLite\Model\Module $module, $fromMarketplace)
 {
     // :WARNING: do not change the summands order:
     // it's important for the "updateDBRecords()" method
     return array('fromMarketplace' => $fromMarketplace) + $module->getIdentityData();
 }
Example #10
0
 /**
  * Checks if this widget's module is a CloudSearch module
  *
  * @param \XLite\Model\Module $module
  *
  * @return bool
  */
 public function isCloudSearch(\XLite\Model\Module $module)
 {
     return $module->getActualName() == 'QSL\\CloudSearch';
 }
Example #11
0
 /**
  * Returns skin preview image URL
  *
  * @param \XLite\Model\Module $module Skin module
  * @param string              $color  Color
  * @param string              $type   Layout type
  *
  * @return string
  */
 public function getLayoutPreview($module, $color, $type)
 {
     $skinModule = $module && '' === $color && 'XC' === $module->getAuthor() && 'ColorSchemes' === $module->getName() ? null : $module;
     return parent::getLayoutPreview($skinModule, $color, $type);
 }
Example #12
0
 /**
  * Check if the module is installed
  *
  * @param \XLite\Model\Module $module Module
  *
  * @return boolean
  */
 protected function isInstalled(\XLite\Model\Module $module)
 {
     return $module->isInstalled();
 }
Example #13
0
 /**
  * Returns installed module url
  *
  * @param \XLite\Model\Module $module Module
  *
  * @return string
  */
 protected function getInstalledModuleURL($module)
 {
     return $module->getInstalledURL();
 }
Example #14
0
 /**
  * Returns installed module url
  *
  * @param \XLite\Model\Module $module Module
  *
  * @return string
  */
 protected function getInstalledModuleURL($module)
 {
     $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getInstalledPageId($module->getAuthor(), $module->getName(), \XLite\View\Pager\Admin\Module\Manage::getInstance()->getItemsPerPage());
     $params = array('clearCnd' => 1, \XLite\View\Pager\APager::PARAM_PAGE_ID => $pageId);
     return \XLite::getInstance()->getShopURL(sprintf('%s#%s', $this->buildURL('addons_list_installed', '', $params), $module->getName()));
 }
Example #15
0
 /**
  * Check if core requires new (but the same as core major) version of module
  *
  * @param \XLite\Model\Module $module Module to check
  *
  * @return boolean
  */
 protected function isModuleUpdateAvailable(\XLite\Model\Module $module)
 {
     return $module->isInstalled() && $this->isModuleCompatible($module) && $this->getModuleForUpdate($module);
 }
Example #16
0
 /**
  * Define query for switchModuleLink() method
  *
  * @param boolean             $enabled Module enabled status
  * @param \XLite\Model\Module $module  Model module
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function defineQuerySwitchModuleLink($enabled, \XLite\Model\Module $module)
 {
     return $this->getQueryBuilder()->update($this->_entityName, 'e')->set('e.moduleEnabled', ':enabled')->where('LOCATE(:class, e.class) > 0')->setParameter('enabled', (bool) $enabled ? 1 : 0)->setParameter('class', $module->getActualName());
 }
Example #17
0
 /**
  * Returns skin preview image URL
  *
  * @param \XLite\Model\Module $module Skin module
  * @param string              $color  Color
  * @param string              $type   Layout type
  *
  * @return string
  */
 public function getLayoutPreview($module, $color, $type)
 {
     $result = null;
     $path = $module && $module instanceof \XLite\Model\Module ? 'modules/' . $module->getAuthor() . '/' . $module->getName() . '/' : 'images/layout/';
     $image = 'preview' . ($color ? '_' . $color : '') . ($type ? '_' . $type : '') . '.jpg';
     $result = $this->getResourceWebPath($path . $image);
     if (null === $result) {
         $image = 'preview' . ($color ? '_' . $color : '') . '.jpg';
         $result = $this->getResourceWebPath($path . $image);
     }
     if (null === $result) {
         $image = 'preview' . ($type ? '_' . $type : '') . '.jpg';
         $result = $this->getResourceWebPath($path . $image);
     }
     if (null === $result) {
         $image = 'preview.jpg';
         $result = $this->getResourceWebPath($path . $image);
     }
     return $result ?: $this->getResourceWebPath('images/layout/preview_placeholder.jpg');
 }
Example #18
0
 /**
  * Get all data to dependency item in list
  *
  * @param \XLite\Model\Module $module Current module
  *
  * @return array
  */
 protected function getDependencyData(\XLite\Model\Module $module)
 {
     if ($module->isPersistent()) {
         if ($module->getInstalled()) {
             if ($module->getEnabled()) {
                 $result = array('status' => 'enabled', 'class' => 'good');
             } else {
                 $result = array('status' => 'disabled', 'class' => 'none');
             }
             $result['href'] = $this->buildURL('addons_list_installed') . '#' . $module->getName();
         } else {
             $url = $this->buildURL('addons_list_marketplace', '', array('substring' => $module->getModuleName()));
             $url .= '#' . $module->getName();
             $result = array('href' => $url, 'status' => 'not installed', 'class' => 'none');
         }
     } else {
         $result = array('status' => 'unknown', 'class' => 'poor');
     }
     return $result;
 }
Example #19
0
 /**
  * Return true if module upgrade is allowed (selected by user)
  *
  * @param \XLite\Model\Module $module Module object
  *
  * @return boolean
  */
 protected function isModuleUpgradeSelected($module)
 {
     $result = true;
     if (\XLite\Core\Session::getInstance()->selectedEntries && is_array(\XLite\Core\Session::getInstance()->selectedEntries)) {
         $moduleID = $module->getMarketplaceID();
         $result = !empty(\XLite\Core\Session::getInstance()->selectedEntries[$moduleID]);
     }
     if (!$result && $module->getIsSystem() && $this->isCoreUpgradeSelected()) {
         $result = true;
     }
     return $result;
 }
 /**
  * Check if module license is available and allowed
  *
  * @param \XLite\Model\Module $module Module
  *
  * @return boolean
  */
 protected function isLicenseAllowed(\XLite\Model\Module $module)
 {
     return \XLite\Model\Module::NOT_XCN_MODULE == $module->getXcnPlan() || \XLite\Model\Module::NOT_XCN_MODULE < $module->getXcnPlan() && 1 == $module->getEditionState();
 }
Example #21
0
 /**
  * Check for custom module
  *
  * @param \XLite\Model\Module $module Module to check
  *
  * @return boolean
  */
 protected function isModuleCustom(\XLite\Model\Module $module)
 {
     return $module->isCustom();
 }
Example #22
0
 /**
  * Get formatted module name
  *
  * @return string
  */
 protected function getFormattedModuleName(\XLite\Model\Module $module)
 {
     return sprintf('%s (%s %s)', $module->getModuleName(), static::t('by'), $module->getAuthorName());
 }
Example #23
0
 /**
  * Helper to search module with the same name and author
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param \XLite\Model\Module        $module       Module to get info from
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function prepareCndSingleModuleSearch(\Doctrine\ORM\QueryBuilder $queryBuilder, \XLite\Model\Module $module)
 {
     $queryBuilder->andWhere('m.name = :name')->andWhere('m.author = :author')->setParameter('name', $module->getName())->setParameter('author', $module->getAuthor())->setMaxResults(1);
 }
Example #24
0
 /**
  * Module page URL getter
  *
  * @param \XLite\Model\Module $module Module model
  *
  * @return string
  */
 protected function getModulePageURL(\XLite\Model\Module $module)
 {
     return $module->getInstalledURL();
 }