1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: 19: 20: 21: 22: 23: 24: 25:
26: class PimPluginViewDependencies {
27:
28:
29: const PLUGIN_CONFIG_FILENAME = "plugin.xml";
30:
31:
32: private static $pluginFoldername;
33: private static $tempXml;
34:
35: 36: 37:
38: public function __construct() {
39: $this->_setPluginFoldername();
40: }
41:
42: 43: 44: 45: 46:
47: private function _setPluginFoldername() {
48: $cfg = cRegistry::getConfig();
49: return self::$pluginFoldername = $cfg['path']['contenido'] . $cfg['path']['plugins'];
50: }
51:
52: 53: 54: 55: 56:
57: private function _getPluginFoldername() {
58: return self::$pluginFoldername;
59: }
60:
61: 62: 63: 64: 65: 66:
67: private function _getPluginDependencies() {
68:
69: $tempXml = self::$tempXml;
70:
71:
72: $dependencies = '';
73:
74: $dependenciesCount = count($tempXml->dependencies);
75: for ($i = 0; $i < $dependenciesCount; $i++) {
76: $dependencies .= sprintf(i18n('This plugin has a dependency to plugin "%s"<br />', 'pim'), $tempXml->dependencies->depend[$i]);
77: }
78:
79: if ($dependencies == '') {
80: return i18n('This plugin has no dependencies to other plugins', 'pim');
81: } else {
82: return $dependencies;
83: }
84:
85: }
86:
87: 88: 89: 90: 91: 92:
93: public function getPluginDependenciesExtracted($tempXml) {
94:
95: self::$tempXml = $tempXml;
96:
97:
98: return $this->_getPluginDependencies();
99: }
100:
101: 102: 103: 104: 105: 106:
107: public function getPluginDependenciesInstalled($idplugin = '') {
108:
109:
110: if ($idplugin == '') {
111: return false;
112: }
113:
114:
115: $pimPluginColl = new PimPluginCollection();
116: $pimPluginColl->setWhere('idplugin', $idplugin);
117: $pimPluginColl->query();
118: $pimPluginSql = $pimPluginColl->next();
119: $folderBase = $pimPluginSql->get('folder');
120:
121:
122: $pimPluginColl->resetQuery();
123:
124:
125: if (!cFileHandler::exists($this->_getPluginFoldername() . $folderBase . DIRECTORY_SEPARATOR . self::PLUGIN_CONFIG_FILENAME)) {
126: return false;
127: }
128:
129:
130: $tempXmlContent = cFileHandler::read($this->_getPluginFoldername() . $folderBase . DIRECTORY_SEPARATOR . self::PLUGIN_CONFIG_FILENAME);
131:
132:
133: self::$tempXml = simplexml_load_string($tempXmlContent);
134:
135:
136: return $this->_getPluginDependencies();
137: }
138:
139:
140: }
141: ?>