Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • PimPlugin
  • PimPluginArchiveExtractor
  • PimPluginCollection
  • PimPluginRelations
  • PimPluginRelationsCollection
  • PimPluginSetup

Functions

  • installationRoutine
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains Plugin Manager Backend View.
  5:  *
  6:  * @package Plugin
  7:  * @subpackage PluginManager
  8:  * @version SVN Revision $Rev:$
  9:  *
 10:  * @author Frederic Schneider
 11:  * @copyright four for business AG <www.4fb.de>
 12:  * @license http://www.contenido.org/license/LIZENZ.txt
 13:  * @link http://www.4fb.de
 14:  * @link http://www.contenido.org
 15:  */
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: // initializing classes
 19: $page = new cGuiPage('pim_overview', 'pim');
 20: 
 21: $setup = new PimPluginSetup();
 22: 
 23: // access denied
 24: if (!$perm->isSysadmin($currentuser)) {
 25:     $page->displayCriticalError(i18n("Permission denied"));
 26:     $page->render();
 27:     exit();
 28: }
 29: 
 30: // check disable plugin var
 31: if ($cfg['debug']['disable_plugins'] === true) {
 32:     $page->displayWarning(i18n('Currently the plugin system is disabled via configuration', 'pim'));
 33: }
 34: 
 35: $viewAction = isset($_REQUEST['pim_view'])? $_REQUEST['pim_view'] : 'overview';
 36: 
 37: switch ($viewAction) {
 38:     case 'activestatus':
 39:         $setup->changeActiveStatus($_GET['pluginId'], $page);
 40:         break;
 41:     case 'update':
 42:         $setup->checkZip();
 43:         $setup->checkSamePlugin($_POST['pluginId']);
 44:         $setup->setIsUpdate(1);
 45:         $setup->uninstall($_POST['pluginId']);
 46:         installationRoutine($page, true, $_POST['foldername'], true);
 47:         break;
 48:     case 'uninstall':
 49:         $setup->uninstall($_GET['pluginId']);
 50:         break;
 51:     case 'uninstall-extracted':
 52:         $setup->uninstallDir($_GET['pluginFoldername'], $page);
 53:         break;
 54:     case 'install':
 55:         $setup->checkZip();
 56:         $setup->checkSamePlugin();
 57:         installationRoutine($page);
 58:         break;
 59:     case 'install-extracted':
 60:         installationRoutine($page, true, $_GET['pluginFoldername']);
 61:         break;
 62: }
 63: 
 64: // TODO: Move the following function into classes
 65: /**
 66:  * Installation steps to install a new plugin.
 67:  * Function differ between extracted
 68:  * and Zip archive plugins
 69:  *
 70:  * @param cGuiPage $page
 71:  * @param boolean $isExtracted
 72:  * @param string $extractedPath foldername from extracted plugin
 73:  * @param boolean $update
 74:  */
 75: function installationRoutine($page, $isExtracted = false, $extractedPath = '', $update = false) {
 76:     global $setup;
 77:     $cfg = cRegistry::getConfig();
 78:     $sess = cRegistry::getSession();
 79: 
 80:     if ($isExtracted === false) {
 81: 
 82:         // name of uploaded file
 83:         $tempFileName = cSecurity::escapeString($_FILES['package']['name']);
 84: 
 85:         // path to temporary dir
 86:         $tempFileNewPath = $cfg['path']['frontend'] . '/' . $cfg['path']['temp'];
 87: 
 88:         // move temporary files into CONTENIDO temp dir
 89:         move_uploaded_file($_FILES['package']['tmp_name'], $tempFileNewPath . $tempFileName);
 90: 
 91:         // initalizing plugin archive extractor
 92:         try {
 93:             $extractor = new PimPluginArchiveExtractor($tempFileNewPath, $tempFileName);
 94:             $setup->addArchiveObject($extractor);
 95:         } catch (cException $e) {
 96:             $extractor->destroyTempFiles();
 97:         }
 98: 
 99:         $tempPluginXmlContent = $extractor->extractArchiveFileToVariable('plugin.xml');
100:         $setup->setTempXml($tempPluginXmlContent);
101:     } else {
102:         $tempPluginXmlContent = file_get_contents($cfg['path']['contenido'] . $cfg['path']['plugins'] . $extractedPath . '/plugin.xml');
103:         $setup->setTempXml($tempPluginXmlContent);
104:         $setup->setIsExtracted($isExtracted);
105:         $setup->setExtractedPath($extractedPath);
106:     }
107: 
108:     // xml file validation
109:     $setup->checkValidXml();
110: 
111:     // load plugin.xml to an xml-string
112:     $tempXml = simplexml_load_string($setup->getTempXml());
113: 
114:     // check plugin specific requirements
115:     $setup->checkRequirements();
116: 
117:     // build the new plugin dir
118:     $tempPluginDir = $cfg['path']['contenido'] . $cfg['path']['plugins'] . $tempXml->general->plugin_foldername . DIRECTORY_SEPARATOR;
119: 
120:     // extract files into plugin dir
121:     if ($setup->getValid() === true && $isExtracted === false) {
122:         try {
123:             $extractor->setDestinationPath($tempPluginDir);
124:         } catch (cException $e) {
125:             $extractor->destroyTempFiles();
126:         }
127: 
128:         try {
129:             $extractor->extractArchive();
130:         } catch (cException $e) {
131:             $extractor->destroyTempFiles();
132:         }
133:     }
134: 
135:     if ($isExtracted === true) {
136: 
137:         // sql inserts
138:         $setup->install($tempXml);
139: 
140:         // success message
141:         if ($update == false) {
142:             $page->displayInfo(i18n('The plugin has been successfully installed. To apply the changes please login into backend again.', 'pim'));
143:         } else {
144:             $page->displayInfo(i18n('The plugin has been successfully updated. To apply the changes please login into backend again.', 'pim'));
145:         }
146:     } else {
147: 
148:         // success message
149:         $page->displayInfo(i18n('The plugin has been successfully uploaded. Now you can install it.', 'pim'));
150: 
151:         // close extracted archive
152:         $extractor->closeArchive();
153:     }
154: }
155: 
156: // path to pim template files
157: $tempTplPath = $cfg['path']['contenido'] . $cfg['path']['plugins'] . 'pim/templates';
158: 
159: // initializing array for installed plugins
160: $installedPluginFoldernames = array();
161: 
162: // get all installed plugins
163: $oItem = new PimPluginCollection();
164: $oItem->select(null, null, 'name');
165: 
166: while (($plugin = $oItem->next()) !== false) {
167: 
168:     // initialization new template class
169:     $pagePlugins = new cTemplate();
170: 
171:     // date
172:     $date = date_format(date_create($plugin->get('installed')), i18n('Y-m-d', 'pim'));
173: 
174:     $pagePlugins->set('s', 'IDPLUGIN', $plugin->get('idplugin'));
175:     $pagePlugins->set('s', 'FOLDERNAME', $plugin->get('folder'));
176:     $pagePlugins->set('s', 'NAME', $plugin->get('name'));
177:     $pagePlugins->set('s', 'VERSION', $plugin->get('version'));
178:     $pagePlugins->set('s', 'DESCRIPTION', $plugin->get('description'));
179:     $pagePlugins->set('s', 'AUTHOR', $plugin->get('author'));
180:     $pagePlugins->set('s', 'MAIL', $plugin->get('mail'));
181:     $pagePlugins->set('s', 'WEBSITE', $plugin->get('website'));
182:     $pagePlugins->set('s', 'COPYRIGHT', $plugin->get('copyright'));
183:     $pagePlugins->set('s', 'INSTALLED', $date);
184: 
185:     $pagePlugins->set('s', 'LANG_INSTALLED', i18n('Installed since', 'pim'));
186:     $pagePlugins->set('s', 'LANG_AUTHOR', i18n('Author', 'pim'));
187:     $pagePlugins->set('s', 'LANG_CONTACT', i18n('Contact', 'pim'));
188: 
189:     $pagePlugins->set('s', 'LANG_UPDATE', i18n('Update', 'pim'));
190:     $pagePlugins->set('s', 'LANG_UPDATE_CHOOSE', i18n('Please choose your new file', 'pim'));
191:     $pagePlugins->set('s', 'LANG_UPDATE_UPLOAD', i18n('Update', 'pim'));
192: 
193:     // enable / disable functionality
194:     $activeStatus = $plugin->get('active');
195:     $tempActiveStatusLink = $sess->url('main.php?area=pim&frame=4&pim_view=activestatus&pluginId=' . $plugin->get('idplugin'));
196:     if ($activeStatus == 1) {
197:         $pagePlugins->set('s', 'LANG_ACTIVESTATUS', '<img src="images/online.gif" class="vAlignMiddle" /> <a href="' . $tempActiveStatusLink . '">' . i18n('Disable plugin', 'pim') . '</a>');
198:     } else {
199:         $pagePlugins->set('s', 'LANG_ACTIVESTATUS', '<img src="images/offline.gif" class="vAlignMiddle" /> <a href="' . $tempActiveStatusLink . '">' . i18n('Enable plugin', 'pim') . '</a>');
200:     }
201: 
202:     // uninstall link
203:     $tempUninstallLink = $sess->url('main.php?area=pim&frame=4&pim_view=uninstall&pluginId=' . $plugin->get('idplugin'));
204:     $pagePlugins->set('s', 'UNINSTALL_LINK', '<a href="javascript:void(0)" onclick="javascript:showConfirmation(\'' . i18n('Are you sure to delete this plugin? Files are not deleted in filesystem.', 'pim') . '\', function() { window.location.href=\'' . $tempUninstallLink . '\';})">' . i18n('Uninstall', 'pim') . '</a>');
205: 
206:     // put foldername into array installedPluginFoldernames
207:     $installedPluginFoldernames[] = $plugin->get('folder');
208: 
209:     $pluginsInstalled .= $pagePlugins->generate($tempTplPath . '/template.pim_plugins_installed.html', true, false);
210: }
211: 
212: // get extracted plugins
213: if(is_dir($cfg['path']['plugins'])){
214: if ($handle = opendir($cfg['path']['plugins'])) {
215:     while ($pluginFoldername = readdir($handle)) {
216: 
217:         $tempPath = $cfg['path']['contenido'] . $cfg['path']['plugins'] . $pluginFoldername . '/plugin.xml';
218: 
219:         if (cFileHandler::exists($tempPath) && !in_array($pluginFoldername, $installedPluginFoldernames)) {
220: 
221:             // initalization new template class
222:             $pagePlugins = new cTemplate();
223: 
224:             $pagePlugins->set('s', 'LANG_FOLDERNAME', i18n('Foldername', 'pim'));
225:             $pagePlugins->set('s', 'LANG_TOOLTIP_INSTALL', i18n('Install extracted plugin', 'pim'));
226:             $pagePlugins->set('s', 'LANG_TOOLTIP_UNINSTALL', i18n('Uninstall extracted plugin (deleted plugin files from filesystem)', 'pim'));
227:             $pagePlugins->set('s', 'FOLDERNAME', $pluginFoldername);
228:             $pagePlugins->set('s', 'INSTALL_LINK', $sess->url('main.php?area=pim&frame=4&pim_view=install-extracted&pluginFoldername=' . $pluginFoldername));
229: 
230:             // uninstall link
231:             if (is_writable($cfg['path']['contenido'] . $cfg['path']['plugins'] . $pluginFoldername)) {
232:                 $pagePlugins->set('s', 'UNINSTALL_LINK', $sess->url('main.php?area=pim&frame=4&pim_view=uninstall-extracted&pluginFoldername=' . $pluginFoldername));
233:                 $pagePlugins->set('s', 'LANG_WRITABLE', '');
234:             } else {
235:                 $pagePlugins->set('s', 'UNINSTALL_LINK', 'javascript://');
236:                 $pagePlugins->set('s', 'LANG_WRITABLE', '(<span class="settingWrong">' . i18n('This plugin is not writeable, please set the rights manually', 'pim') . '</span>)');
237:             }
238: 
239:             $pluginsExtracted .= $pagePlugins->generate($tempTplPath . '/template.pim_plugins_extracted.html', true, false);
240:         }
241:     }
242:     closedir($handle);
243: }
244: }
245: 
246: // if pluginsExtracted var is empty
247: if (empty($pluginsExtracted)) {
248:     $pluginsExtracted = i18n('No entries', 'pim');
249: }
250: 
251: // added language vars
252: $page->set('s', 'LANG_UPLOAD', i18n('Upload a new plugin', 'pim'));
253: $page->set('s', 'LANG_UPLOAD_CHOOSE', i18n('Please choose a plugin package', 'pim'));
254: $page->set('s', 'LANG_UPLOAD_BUTTON', i18n('Upload plugin package', 'pim'));
255: $page->set('s', 'LANG_INSTALLED', i18n('Installed Plugins', 'pim'));
256: $page->set('s', 'LANG_EXTRACTED', i18n('Not installed Plugins', 'pim'));
257: 
258: // added installed plugins to pim_overview
259: $page->set('s', 'INSTALLED_PLUGINS', $oItem->count());
260: $page->set('s', 'PLUGINS_INSTALLED', $pluginsInstalled);
261: $page->set('s', 'PLUGINS_EXTRACTED', $pluginsExtracted);
262: 
263: $page->render();
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0