if ($contentTypeModelName) { $t->is($contentTypeName, $contentTypeModelName, sprintf('getContentTypeForPlugin() returns the content type "%s"', $contentTypeName)); $contentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName($contentTypeName); $t->is($contentType['name'], $contentTypeName, 'Test content type name set'); $t->is($contentType['label'], sfInflector::humanize(sfInflector::tableize(str_replace('sfSympal', null, $contentTypeName))), 'Test content type label set'); $contentList = Doctrine_Core::getTable('sfSympalContentList')->findOneByContentTypeId($contentType['id']); $t->is($contentList instanceof sfSympalContentList, true, 'Test sample content list was created.'); $menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneByContentId($contentList['content_id']); $t->is($menuItem instanceof sfSympalMenuItem, true, 'Test menu item to sample content list was created.'); } else { $t->is($contentTypeName, false, '->getContentTypeForPlugin() return false, there is not content type'); } } function uninstallPlugin($name, $t, $delete = true) { $manager = sfSympalPluginManager::getActionInstance($name, 'uninstall'); $manager->uninstall($delete); $t->is(file_exists(sfConfig::get('sf_plugins_dir') . '/' . $name), !$delete, 'Test plugin was was deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/model/doctrine/' . $name), !$delete, 'Test plugin models were deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/form/doctrine/' . $name), !$delete, 'Test plugin forms were deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/filter/doctrine/' . $name), !$delete, 'Test plugin form filters were deleted'); $t->is(file_exists(sfConfig::get('sf_web_dir') . '/' . $name), !$delete, 'Test plugin assets symlink was removed'); } $t->info('1 - Uninstalling sfSympalBlogPlugin...'); uninstallPlugin('sfSympalBlogPlugin', $t, false); $t->info('2 - Installing sfSympalBlogPlugin...'); installPlugin('sfSympalBlogPlugin', $t, 'sfSympalBlogPost'); $t->info('3 - Uninstalling sfSympalCommentsPlugin...'); uninstallPlugin('sfSympalCommentsPlugin', $t, false); $t->info('4 - Installing sfSympalCommentsPlugin'); installPlugin('sfSympalCommentsPlugin', $t, false);
{ // Install the plugin $manager = sfSympalPluginManager::getActionInstance($name, 'install'); $manager->install(); // Check that content type was created $contentTypeName = $manager->getContentTypeForPlugin($name); $contentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName($contentTypeName); $t->is($contentType['name'], $contentTypeName, 'Test content type name set'); $t->is($contentType['label'], sfInflector::humanize(sfInflector::tableize(str_replace('sfSympal', null, $contentTypeName))), 'Test content type label set'); $t->is($contentType['plugin_name'], $name, 'Test content type plugin name set'); $contentList = Doctrine_Core::getTable('sfSympalContentList')->findOneByContentTypeId($contentType['id']); $t->is($contentList instanceof sfSympalContentList, true, 'Test sample content list was created.'); $menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneByContentId($contentList['content_id']); $t->is($menuItem instanceof sfSympalMenuItem, true, 'Test menu item to sample content list was created.'); } function uninstallPlugin($name, $t, $delete = true) { $manager = sfSympalPluginManager::getActionInstance($name, 'uninstall'); $manager->uninstall($delete); $t->is(file_exists(sfConfig::get('sf_plugins_dir') . '/' . $name), !$delete, 'Test plugin was was deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/model/doctrine/' . $name), !$delete, 'Test plugin models were deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/form/doctrine/' . $name), !$delete, 'Test plugin forms were deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/filter/doctrine/' . $name), !$delete, 'Test plugin form filters were deleted'); $t->is(file_exists(sfConfig::get('sf_web_dir') . '/' . $name), !$delete, 'Test plugin assets symlink was removed'); } uninstallPlugin('sfSympalBlogPlugin', $t, false); installPlugin('sfSympalBlogPlugin', $t); installPlugin('sfSympalEventPlugin', $t); uninstallPlugin('sfSympalEventPlugin', $t); uninstallPlugin('sfSympalObjectReplacerPlugin', $t);
$modtype = getDBCell("modules", "MODULE_TYPE_ID", "MODULE_ID = {$oid}"); if ($modtype == 5) { $form->buttonbar->add("action", $lang->get("settings", "Settings")); } $form->buttonbar->addConfirm("action", $lang->get("uninstall", "Uninstall"), $lang->get("uninstconf", "Uninstalling a plugin can cause damage to the website! Do you want to proceed?"), $c["docroot"] . "modules/plugins/install.php?sid={$sid}&oid={$oid}&action=uninstall"); $form->add(new DisplayedValue($lang->get("name"), "modules", "MODULE_NAME", "MODULE_ID={$oid}")); $form->add(new DisplayedValue($lang->get("modtype", "Plugin Type"), "module_type", "NAME", "MODULE_TYPE_ID={$modtype}")); $form->add(new DisplayedValue($lang->get("description"), "modules", "DESCRIPTION", "MODULE_ID={$oid}")); $form->add(new DisplayedValue($lang->get("version", "Version"), "modules", "VERSION", "MODULE_ID={$oid}")); $form->add(new DisplayedValue($lang->get("sourcefile", "Source file"), "modules", "SOURCE", "MODULE_ID={$oid}")); $form->add(new Hidden("action", "")); $form->add(new Hidden("oid", $oid)); $form->forbidDelete(true); $form->forbidUpdate(true); if (value("action") == "uninstall" && is_numeric($oid)) { uninstallPlugin($oid); } } if (value("action") == $lang->get("settings")) { if ($page_action == "") { $page_action = 'UPDATE'; $page_state = "start"; } //if (!isset($go)) $go="update"; //$page_action="UPDATE"; $oid = value("oid", "NUMERIC"); $form = new StdEDForm($lang->get("settings")); $cond = $form->setPK("modules", "MODULE_ID"); $form->forbidDelete(true); $form->addHeaderLink(crHeaderLink($lang->get("Back"), 'modules/plugins/install.php?oid=' . $oid . '&sid=' . $sid . '&go=update')); $form->add(new DisplayedValue($lang->get("name"), "modules", "MODULE_NAME", "MODULE_ID={$oid}"));
} global $i; global $m; switch (SYSTEM_PAGE) { case 'admin:plugins': doAction('plugin_setting_1'); if (isset($_GET['dis'])) { inactivePlugin($_GET['dis']); } elseif (isset($_GET['act'])) { activePlugin($_GET['act']); } elseif (isset($_GET['upd'])) { if (updatePlugin($_GET['upd']) == false) { Redirect('index.php?mod=admin:plugins&error_msg=' . urlencode("插件更新失败")); } } elseif (isset($_GET['uninst'])) { uninstallPlugin($_GET['uninst']); } elseif (isset($_GET['install'])) { if (!empty($_REQUEST['ver'])) { msg('该插件仅适用于 V' . $_REQUEST['ver'] . ' 及以上的版本,您的云签到版本低于插件所需最低版本,是否强制安装(强制安装可能造成云签到损坏)<br/><br/><a href="setting.php?mod=admin:plugins&install=' . $_GET['install'] . '">强制安装</a> <a href="setting.php?mod=admin:plugins">取消安装</a><br/>', false, true); } installPlugin($_GET['install']); } elseif (isset($_GET['xorder'])) { global $m; foreach ($_POST as $id => $order) { $m->query('Update `' . DB_NAME . '`.`' . DB_PREFIX . "plugins` Set `order`={$order} Where `name`='{$id}'"); } } doAction('plugin_setting_2'); Redirect('index.php?mod=admin:plugins&ok'); break; case 'admin:cloud':
global $m; switch (SYSTEM_PAGE) { case 'admin:plugins': doAction('plugin_setting_1'); if (isset($_GET['dis'])) { inactivePlugin($_GET['dis']); } elseif (isset($_GET['act'])) { activePlugin($_GET['act']); } elseif (isset($_GET['upd'])) { if (updatePlugin($_GET['upd']) == false) { Redirect('index.php?mod=admin:plugins&error_msg=' . urlencode("插件更新失败")); } } elseif (isset($_GET['uninst'])) { uninstallPlugin($_GET['uninst']); } elseif (isset($_GET['clean'])) { uninstallPlugin($_GET['clean'], false); } elseif (isset($_GET['install'])) { if (!empty($_REQUEST['ver'])) { msg('该插件仅适用于 V' . $_REQUEST['ver'] . ' 及以上的版本,您的云签到版本低于插件所需最低版本,是否强制安装(强制安装可能造成云签到损坏)<br/><br/><a href="setting.php?mod=admin:plugins&install=' . $_GET['install'] . '">强制安装</a> <a href="setting.php?mod=admin:plugins">取消安装</a><br/>', false, true); } installPlugin($_GET['install']); } elseif (isset($_GET['xorder'])) { global $m; foreach ($_POST as $id => $order) { $m->query('Update `' . DB_NAME . '`.`' . DB_PREFIX . "plugins` Set `order`={$order} Where `name`='{$id}'"); } } doAction('plugin_setting_2'); Redirect('index.php?mod=admin:plugins&ok'); break; case 'admin:cloud':