break;
 case 'reg':
     // currently rewrites delivery hooks to conf
     require_once LIB_PATH . '/Extension/ExtensionDelivery.php';
     $oExtensionManager = new OX_Extension_Delivery();
     $oExtensionManager->runTasksOnDemand();
     break;
 case 'exp':
     $oTpl = new OA_Admin_Template('plugin-export.html');
     require_once LIB_PATH . '/Plugin/PluginExport.php';
     $oExporter = new OX_PluginExport();
     $aErrors = array();
     foreach ($GLOBALS['_MAX']['CONF']['plugins'] as $name => $enabled) {
         $aPlugins[$name]['file'] = '';
         $aPlugins[$name]['error'] = false;
         if ($file = $oExporter->exportPlugin($name)) {
             $aPlugins[$name]['file'] = $file;
         } else {
             $aPlugins[$name]['error'] = true;
             $aErrors[] = $oExporter->aErrors;
         }
     }
     $oTpl->assign('aPlugins', $aPlugins);
     $oTpl->assign('aErrors', $aErrors);
     break;
     /*case 'dep':
       require_once LIB_PATH . '/Plugin/PluginManager.php';
       $oPluginManager = & new OX_PluginManager();
       $oPluginManager->_cacheDependencies();
       if (empty($oPluginManager->aErrors))
       {
Exemple #2
0
     $oTpl->assign('aPackage', $aPackageInfo);
     $oTpl->assign('aPlugins', $aComponents);
     $oTpl->assign('readme', $readme);
     $oTpl->assign('backURL', MAX::constructURL(MAX_URL_ADMIN, "plugin-index.php?selection=packages"));
     $oTpl->assign('aWarnings', $oPluginManager->aWarnings);
     $oPluginManager->getPackageDiagnostics($plugin);
     if (!count($oPluginManager->aErrors)) {
         $oPluginManager->aMessages[] = 'No problems detected';
     }
     $oTpl->assign('aErrors', $oPluginManager->aErrors);
     $oTpl->assign('aMessages', $oPluginManager->aMessages);
 } else {
     if (array_key_exists('export', $_POST)) {
         require_once LIB_PATH . '/Plugin/PluginExport.php';
         $oExporter = new OX_PluginExport();
         if ($file = $oExporter->exportPlugin($plugin)) {
             $aMessages = 'Plugin exported to ' . $file;
         }
         $oTpl = new OA_Admin_Template('plugin-view.html');
         $aPackageInfo = $oPluginManager->getPackageInfo($plugin);
         $aComponents = $aPackageInfo['contents'];
         unset($aPackageInfo['contents']);
         if ($aPackageInfo['readme']) {
             $readme = file_get_contents($aPackageInfo['readme']);
         }
         $aPackageInfo['package'] = true;
         $oTpl->assign('aPackage', $aPackageInfo);
         $oTpl->assign('aPlugins', $aComponents);
         $oTpl->assign('readme', $readme);
         $oTpl->assign('backURL', MAX::constructURL(MAX_URL_ADMIN, "plugin-index.php?selection=packages"));
         $oTpl->assign('aMessages', $aMessages);
 function test_exportPlugin()
 {
     TestEnv::installPluginPackage('openXTests', false);
     $pathPackages = $GLOBALS['_MAX']['CONF']['pluginPaths']['packages'];
     $pathPlugins = $GLOBALS['_MAX']['CONF']['pluginPaths']['plugins'];
     $pathAdmin = $GLOBALS['_MAX']['CONF']['pluginPaths']['admin'];
     $oExport = new OX_PluginExport();
     $oExport->init('openXTests');
     $pathExport = $oExport->outputDir;
     @unlink($pathExport . 'openXTests.zip');
     $this->assertTrue($oExport->exportPlugin('openXTests'));
     $baseDir = MAX_PATH . '/var/tmp/openXTests';
     $this->assertTrue(file_exists($pathExport . 'openXTests.zip'));
     $oZip = new PclZip($pathExport . 'openXTests.zip');
     $aContents = $oZip->listContent();
     $this->assertIsA($aContents, 'array');
     $this->assertEqual(count($aContents), 4);
     $this->assertEqual($aContents[0]['status'], 'ok');
     $this->assertEqual($aContents[0]['filename'], ltrim($pathPackages, '/') . 'Dummy/Dummy.xml');
     $this->assertEqual($aContents[0]['stored_filename'], ltrim($pathPackages, '/') . 'Dummy/Dummy.xml');
     $this->assertEqual($aContents[1]['status'], 'ok');
     $this->assertEqual($aContents[1]['filename'], ltrim($pathPlugins, '/') . 'deliveryLimitations/Dummy/Dummy.class.php');
     $this->assertEqual($aContents[1]['stored_filename'], ltrim($pathPlugins, '/') . 'deliveryLimitations/Dummy/Dummy.class.php');
     $this->assertEqual($aContents[2]['status'], 'ok');
     $this->assertEqual($aContents[2]['filename'], ltrim($pathPlugins, '/') . 'deliveryLimitations/Dummy/Dummy.delivery.php');
     $this->assertEqual($aContents[2]['stored_filename'], ltrim($pathPlugins, '/') . 'deliveryLimitations/Dummy/Dummy.delivery.php');
     $this->assertEqual($aContents[3]['status'], 'ok');
     $this->assertEqual($aContents[3]['filename'], ltrim($pathPackages, '/') . 'openXTests.xml');
     $this->assertEqual($aContents[3]['stored_filename'], ltrim($pathPackages, '/') . 'openXTests.xml');
     @unlink($pathExport . 'openXTests.zip');
     $aContentsNew = $aContents;
     $oZip = new PclZip(MAX_PATH . '/plugins_repo/release/openXTests.zip');
     $aContentsOld = $oZip->listContent();
     foreach ($aContentsOld as $i => $aItemOld) {
         if (!$aItemOld['folder']) {
             foreach ($aContentsNew as $n => $aItemNew) {
                 if ($aItemOld['filename'] == $aItemNew['filename'] && $aItemOld['stored_filename'] == $aItemNew['stored_filename'] && $aItemOld['size'] == $aItemNew['size'] && $aItemOld['crc'] == $aItemNew['crc']) {
                     unset($aContentsOld[$i]);
                     unset($aContentsNew[$n]);
                     break;
                 }
             }
         } else {
             // For somewhat reason "new" doesn't seem to contain folders. Bug?
             unset($aContentsOld[$i]);
         }
     }
     $this->assertFalse(count($aContentsNew));
     $this->assertFalse(count($aContentsOld));
     TestEnv::uninstallPluginPackage('openXTests', false);
     TestEnv::restoreConfig();
 }