Index: branches/RC/core/units/modules/modules_tag_processor.php =================================================================== diff -u -r8929 -r10832 --- branches/RC/core/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 8929) +++ branches/RC/core/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 10832) @@ -1,12 +1,87 @@ Application->isModuleEnabled($params['name']); - } - -} + function ModuleInstalled($params) + { + return $this->Application->isModuleEnabled($params['name']); + } -?> \ No newline at end of file + function AlreadyInstalled($params) + { + $object =& $this->getObject($params); + /* @var $object kDBList */ + + $modules_helper =& $this->Application->recallObject('ModulesHelper'); + /* @var $modules_helper kModulesHelper */ + + return $modules_helper->moduleInstalled( $object->GetDBField('Name') ); + } + + function ModuleLicensed($params) + { + $object =& $this->getObject($params); + /* @var $object kDBList */ + + $modules_helper =& $this->Application->recallObject('ModulesHelper'); + /* @var $modules_helper kModulesHelper */ + + $licensed_modules = array_map('strtolower', $modules_helper->_GetModules()); + + return in_array(strtolower($object->GetDBField('Name')), $licensed_modules); + } + + function PrerequisitesMet($params) + { + return !$this->_getPrerequisitesErrors($params); + } + + function _getPrerequisitesErrors($params) + { + static $errors = Array (); + + $object =& $this->getObject($params); + /* @var $object kDBList */ + + $module_path = strtolower( $object->GetDBField('Name') ); + + if (!array_key_exists($module_path, $errors)) { + require_once FULL_PATH . '/core/install/install_toolkit.php'; + + $toolkit = new kInstallToolkit(); + + $module_version = $toolkit->GetMaxModuleVersion($module_path); + + $errors[$module_path] = $toolkit->CheckPrerequisites($module_path . '/', Array ($module_version), 'standalone'); + } + + return $errors[$module_path]; + } + + function ListPrerequisites($params) + { + $errors = $this->_getPrerequisitesErrors($params); + + $ret = ''; + $block_params = $this->prepareTagParams($params); + $block_params['name'] = $params['render_as']; + + foreach ($errors as $error) { + $block_params['error'] = $error; + $ret .= $this->Application->ParseBlock($block_params); + } + + return $ret; + } + + function InstallLink($params) + { + $object =& $this->getObject($params); + /* @var $object kDBList */ + + $module_path = strtolower( $object->GetDBField('Name') ); + $url_params = Array ('redirect' => 1, 'admin' => 1); + + return $this->Application->HREF('dummy', '_FRONT_END_', $url_params, $module_path . '/install.php'); + } + }