Example #1
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));
 }
 /**
  * {@inheritDoc}
  */
 public function callModuleMethod($method, $result = NULL, array $args = array())
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'callModuleMethod', array($method, $result, $args));
     return parent::callModuleMethod($method, $result, $args);
 }
Example #3
0
 /**
  * Return pack metadata
  *
  * @return array
  */
 public function getMetadata()
 {
     return parent::getMetadata() + array(self::METADATA_FIELD_ACTUAL_NAME => $this->module->getActualName(), self::METADATA_FIELD_VERSION_MAJOR => $this->module->callModuleMethod('getMajorVersion'), self::METADATA_FIELD_VERSION_MINOR => $this->module->callModuleMethod('getMinorVersion'), self::METADATA_FIELD_NAME => $this->module->callModuleMethod('getModuleName'), self::METADATA_FIELD_AUTHOR => $this->module->callModuleMethod('getAuthorName'), self::METADATA_FIELD_ICON_LINK => $this->module->callModuleMethod('getIconURL'), self::METADATA_FIELD_DESCRIPTION => $this->module->callModuleMethod('getDescription'), self::METADATA_FIELD_DEPENDENCIES => $this->module->callModuleMethod('getDependencies'), self::METADATA_FIELD_IS_SYSTEM => $this->module->callModuleMethod('isSystem'));
 }
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;
 }
 /**
  * Check if module has settings form
  * 
  * @param \XLite\Model\Module $module Module
  * 
  * @return boolean
  */
 protected function hasSetting($module)
 {
     return $module->callModuleMethod('showSettingsForm');
 }