本文整理汇总了PHP中PluginRegistry::getPlugins方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginRegistry::getPlugins方法的具体用法?PHP PluginRegistry::getPlugins怎么用?PHP PluginRegistry::getPlugins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PluginRegistry
的用法示例。
在下文中一共展示了PluginRegistry::getPlugins方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPluginVersions
/**
* For 2.3 upgrade: Add initial plugin data to versions table
* @return boolean
*/
function addPluginVersions()
{
$versionDao =& DAORegistry::getDAO('VersionDAO');
import('site.VersionCheck');
$categories = PluginRegistry::getCategories();
foreach ($categories as $category) {
PluginRegistry::loadCategory($category, true);
$plugins = PluginRegistry::getPlugins($category);
foreach ($plugins as $plugin) {
$versionFile = $plugin->getPluginPath() . '/version.xml';
if (FileManager::fileExists($versionFile)) {
$versionInfo =& VersionCheck::parseVersionXML($versionFile);
$pluginVersion = $versionInfo['version'];
$pluginVersion->setCurrent(1);
$versionDao->insertVersion($pluginVersion);
} else {
$pluginVersion = new Version();
$pluginVersion->setMajor(1);
$pluginVersion->setMinor(0);
$pluginVersion->setRevision(0);
$pluginVersion->setBuild(0);
$pluginVersion->setDateInstalled(Core::getCurrentDate());
$pluginVersion->setCurrent(1);
$pluginVersion->setProductType('plugins.' . $category);
$pluginVersion->setProduct(basename($plugin->getPluginPath()));
$versionDao->insertVersion($pluginVersion);
}
}
}
}
示例2: fetch
/**
* @copydoc ContextSettingsForm::fetch()
*/
function fetch($request)
{
// Get all upload form image link actions.
$uploadImageLinkActions = array();
foreach ($this->getImagesSettingsName() as $settingName => $altText) {
$uploadImageLinkActions[$settingName] = $this->_getFileUploadLinkAction($settingName, 'image', $request);
}
// Get the css upload link action.
$uploadCssLinkAction = $this->_getFileUploadLinkAction('styleSheet', 'css', $request);
$imagesViews = $this->_renderAllFormImagesViews($request);
$cssView = $this->renderFileView('styleSheet', $request);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('uploadImageLinkActions', $uploadImageLinkActions);
$templateMgr->assign('uploadCssLinkAction', $uploadCssLinkAction);
$themePlugins = PluginRegistry::getPlugins('themes');
if (is_null($themePlugins)) {
$themePlugins = PluginRegistry::loadCategory('themes', true);
}
$enabledThemes = array();
$activeThemeOptions = array();
foreach ($themePlugins as $themePlugin) {
$enabledThemes[basename($themePlugin->getPluginPath())] = $themePlugin->getDisplayName();
if ($themePlugin->isActive()) {
$activeThemeOptions = $themePlugin->getOptionsConfig();
$activeThemeOptionsValues = $themePlugin->getOptionValues();
foreach ($activeThemeOptions as $name => $option) {
$activeThemeOptions[$name]['value'] = isset($activeThemeOptionsValues[$name]) ? $activeThemeOptionsValues[$name] : '';
}
}
}
$templateMgr->assign(array('enabledThemes' => $enabledThemes, 'activeThemeOptions' => $activeThemeOptions));
$params = array('imagesViews' => $imagesViews, 'styleSheetView' => $cssView, 'locale' => AppLocale::getLocale());
return parent::fetch($request, $params);
}
示例3: executeMetadataPluginTest
/**
* Executes the metadata plug-in test.
* @param $pluginDir string
* @param $pluginName string
* @param $filterGroups array
* @param $controlledVocabs array
*/
protected function executeMetadataPluginTest($pluginDir, $pluginName, $filterGroups, $controlledVocabs)
{
// Make sure that the vocab xml configuration is valid.
$controlledVocabFile = 'plugins/metadata/' . $pluginDir . '/schema/' . METADATA_PLUGIN_VOCAB_DATAFILE;
$this->validateXmlConfig(array('./' . $controlledVocabFile, './lib/pkp/' . $controlledVocabFile));
// Delete vocab data so that we can re-install it.
$controlledVocabDao = DAORegistry::getDAO('ControlledVocabDAO');
/* @var $controlledVocabDao ControlledVocabDAO */
foreach ($controlledVocabs as $controlledVocabSymbolic) {
$controlledVocab = $controlledVocabDao->getBySymbolic($controlledVocabSymbolic, 0, 0);
if ($controlledVocab) {
$controlledVocabDao->deleteObject($controlledVocab);
}
}
// Reset the plug-in setting indicating that vocabs have already been installed.
$pluginSettingsDao = DAORegistry::getDAO('PluginSettingsDAO');
/* @var $pluginSettingsDao PluginSettingsDAO */
$pluginSettingsDao->updateSetting(0, $pluginName, METADATA_PLUGIN_VOCAB_INSTALLED_SETTING, false);
// Unregister the plug-in so that we're sure it will be registered again.
$plugins =& PluginRegistry::getPlugins();
unset($plugins['metadata'][$pluginName]);
$this->executePluginTest('metadata', $pluginDir, $pluginName, $filterGroups);
// Test whether the controlled vocabs have been installed.
foreach ($controlledVocabs as $controlledVocab) {
self::assertInstanceOf('ControlledVocab', $controlledVocabDao->getBySymbolic($controlledVocab, 0, 0));
}
}
示例4: fetch
/**
* @see Form::fetch()
* @param $request PKPRequest
* @param $params array
*/
function fetch($request, $params = null)
{
$site = $request->getSite();
$publicFileManager = new PublicFileManager();
$contextDao = Application::getContextDAO();
$contexts = $contextDao->getNames();
$siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
$cssSettingName = 'siteStyleSheet';
$imageSettingName = 'pageHeaderTitleImage';
// Get link actions.
$uploadCssLinkAction = $this->_getFileUploadLinkAction($cssSettingName, 'css', $request);
$uploadImageLinkAction = $this->_getFileUploadLinkAction($imageSettingName, 'image', $request);
// Get the files view.
$cssView = $this->renderFileView($cssSettingName, $request);
$imageView = $this->renderFileView($imageSettingName, $request);
$application = Application::getApplication();
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign(array('locale' => AppLocale::getLocale(), 'siteStyleFileExists' => file_exists($siteStyleFilename), 'uploadCssLinkAction' => $uploadCssLinkAction, 'uploadImageLinkAction' => $uploadImageLinkAction, 'cssView' => $cssView, 'imageView' => $imageView, 'redirectOptions' => $contexts, 'pageHeaderTitleImage' => $site->getSetting($imageSettingName), 'availableMetricTypes' => $application->getMetricTypes(true)));
$themePlugins = PluginRegistry::getPlugins('themes');
$enabledThemes = array();
$activeThemeOptions = array();
foreach ($themePlugins as $themePlugin) {
$enabledThemes[basename($themePlugin->getPluginPath())] = $themePlugin->getDisplayName();
if ($themePlugin->isActive()) {
$activeThemeOptions = $themePlugin->getOptionsConfig();
$activeThemeOptionsValues = $themePlugin->getOptionValues();
foreach ($activeThemeOptions as $name => $option) {
$activeThemeOptions[$name]['value'] = isset($activeThemeOptionsValues[$name]) ? $activeThemeOptionsValues[$name] : '';
}
}
}
$templateMgr->assign(array('enabledThemes' => $enabledThemes, 'activeThemeOptions' => $activeThemeOptions));
return parent::fetch($request);
}
示例5: display
/**
* Display the form.
*/
function display()
{
$press =& Request::getPress();
// Ensure upload file settings are reloaded when the form is displayed.
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign(array('homeHeaderTitleImage' => $press->getSetting('homeHeaderTitleImage'), 'homeHeaderLogoImage' => $press->getSetting('homeHeaderLogoImage'), 'pageHeaderTitleImage' => $press->getSetting('pageHeaderTitleImage'), 'pageHeaderLogoImage' => $press->getSetting('pageHeaderLogoImage'), 'homepageImage' => $press->getSetting('homepageImage'), 'pressStyleSheet' => $press->getSetting('pressStyleSheet'), 'readerInformation' => $press->getSetting('readerInformation'), 'authorInformation' => $press->getSetting('authorInformation'), 'librarianInformation' => $press->getSetting('librarianInformation')));
// Make lists of the sidebar blocks available.
$templateMgr->initialize();
$leftBlockPlugins = $disabledBlockPlugins = $rightBlockPlugins = array();
$plugins =& PluginRegistry::getPlugins('blocks');
foreach ($plugins as $key => $junk) {
if (!$plugins[$key]->getEnabled() || $plugins[$key]->getBlockContext() == '') {
if (count(array_intersect($plugins[$key]->getSupportedContexts(), array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR))) > 0) {
$disabledBlockPlugins[] =& $plugins[$key];
}
} else {
switch ($plugins[$key]->getBlockContext()) {
case BLOCK_CONTEXT_LEFT_SIDEBAR:
$leftBlockPlugins[] =& $plugins[$key];
break;
case BLOCK_CONTEXT_RIGHT_SIDEBAR:
$rightBlockPlugins[] =& $plugins[$key];
break;
}
}
}
$templateMgr->assign(array('disabledBlockPlugins' => &$disabledBlockPlugins, 'leftBlockPlugins' => &$leftBlockPlugins, 'rightBlockPlugins' => &$rightBlockPlugins));
$templateMgr->setCacheability(CACHEABILITY_MUST_REVALIDATE);
parent::display();
}
示例6: importexport
/**
* Import or export data.
* @param $args array
* @param $request PKPRequest
*/
function importexport($args, $request)
{
$this->setupTemplate($request, true);
PluginRegistry::loadCategory(IMPORTEXPORT_PLUGIN_CATEGORY);
$templateMgr = TemplateManager::getManager($request);
if (array_shift($args) === 'plugin') {
$pluginName = array_shift($args);
$plugin = PluginRegistry::getPlugin(IMPORTEXPORT_PLUGIN_CATEGORY, $pluginName);
if ($plugin) {
return $plugin->display($args, $request);
}
}
$templateMgr->assign('plugins', PluginRegistry::getPlugins(IMPORTEXPORT_PLUGIN_CATEGORY));
$templateMgr->display('manager/importexport/plugins.tpl');
}
示例7: display
/**
* Display the form.
*/
function display()
{
$journal =& Request::getJournal();
//Opatan Inc. : get files_dir value
$files_dir = Config::getVar('files', 'files_dir');
if (Core::isWindows()) {
// Replace backslashes with slashes for the default files directory.
$cwd = str_replace('\\', '/', $files_dir);
}
$files_dir = explode('/', $files_dir);
$files_dir = $files_dir[count($files_dir) - 1];
$files_dir = ucfirst($files_dir);
$allThemes =& PluginRegistry::loadCategory('themes', true);
$journalThemes = array();
foreach ($allThemes as $key => $junk) {
$plugin =& $allThemes[$key];
// by ref
$journalThemes[basename($plugin->getPluginPath())] =& $plugin;
unset($plugin);
}
// Ensure upload file settings are reloaded when the form is displayed.
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign(array('homeHeaderTitleImage' => $journal->getSetting('homeHeaderTitleImage'), 'homeHeaderLogoImage' => $journal->getSetting('homeHeaderLogoImage'), 'pageHeaderTitleImage' => $journal->getSetting('pageHeaderTitleImage'), 'pageHeaderLogoImage' => $journal->getSetting('pageHeaderLogoImage'), 'homepageImage' => $journal->getSetting('homepageImage'), 'journalStyleSheet' => $journal->getSetting('journalStyleSheet'), 'readerInformation' => $journal->getSetting('readerInformation'), 'authorInformation' => $journal->getSetting('authorInformation'), 'librarianInformation' => $journal->getSetting('librarianInformation'), 'journalThemes' => $journalThemes));
$templateMgr->assign('files_dir', $files_dir);
$templateMgr->assign_by_ref('journal', $journal);
// Make lists of the sidebar blocks available.
$templateMgr->initialize();
$leftBlockPlugins = $disabledBlockPlugins = $rightBlockPlugins = array();
$plugins =& PluginRegistry::getPlugins('blocks');
foreach ($plugins as $key => $junk) {
if (!$plugins[$key]->getEnabled() || $plugins[$key]->getBlockContext() == '') {
if (count(array_intersect($plugins[$key]->getSupportedContexts(), array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR))) > 0) {
$disabledBlockPlugins[] =& $plugins[$key];
}
} else {
switch ($plugins[$key]->getBlockContext()) {
case BLOCK_CONTEXT_LEFT_SIDEBAR:
$leftBlockPlugins[] =& $plugins[$key];
break;
case BLOCK_CONTEXT_RIGHT_SIDEBAR:
$rightBlockPlugins[] =& $plugins[$key];
break;
}
}
}
$templateMgr->assign(array('disabledBlockPlugins' => &$disabledBlockPlugins, 'leftBlockPlugins' => &$leftBlockPlugins, 'rightBlockPlugins' => &$rightBlockPlugins));
parent::display();
}
示例8: importexport
function importexport($args)
{
$this->setupTemplate(true);
PluginRegistry::loadCategory(IMPORTEXPORT_PLUGIN_CATEGORY);
$templateMgr =& TemplateManager::getManager();
if (array_shift($args) === 'plugin') {
$pluginName = array_shift($args);
$plugin =& PluginRegistry::getPlugin(IMPORTEXPORT_PLUGIN_CATEGORY, $pluginName);
if ($plugin) {
return $plugin->display($args);
}
}
$templateMgr->assign_by_ref('plugins', PluginRegistry::getPlugins(IMPORTEXPORT_PLUGIN_CATEGORY));
$templateMgr->assign('helpTopicId', 'press.managementPages.importExport');
$templateMgr->display('manager/importexport/plugins.tpl');
}
示例9: display
/**
* Display the form.
*/
function display()
{
$site =& Request::getSite();
$allThemes =& PluginRegistry::loadCategory('themes');
$siteThemes = array();
foreach ($allThemes as $key => $junk) {
$plugin =& $allThemes[$key];
// by ref
$siteThemes[basename($plugin->getPluginPath())] =& $plugin;
unset($plugin);
}
// Ensure upload file settings are reloaded when the form is displayed.
$templateMgr =& TemplateManager::getManager();
$templateMgr->setCacheability(CACHEABILITY_MUST_REVALIDATE);
$templateMgr->assign(array('siteThemes' => $siteThemes));
// Make lists of the sidebar blocks available.
$templateMgr->initialize();
$leftBlockPlugins = $disabledBlockPlugins = $rightBlockPlugins = array();
$plugins =& PluginRegistry::getPlugins('blocks');
foreach ($plugins as $key => $junk) {
if (!$plugins[$key]->getEnabled() || $plugins[$key]->getBlockContext() == '') {
if (count(array_intersect($plugins[$key]->getSupportedContexts(), array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR))) > 0) {
$disabledBlockPlugins[] =& $plugins[$key];
}
} else {
switch ($plugins[$key]->getBlockContext()) {
case BLOCK_CONTEXT_LEFT_SIDEBAR:
$leftBlockPlugins[] =& $plugins[$key];
break;
case BLOCK_CONTEXT_RIGHT_SIDEBAR:
$rightBlockPlugins[] =& $plugins[$key];
break;
}
}
}
$templateMgr->assign(array('disabledBlockPlugins' => &$disabledBlockPlugins, 'leftBlockPlugins' => &$leftBlockPlugins, 'rightBlockPlugins' => &$rightBlockPlugins));
parent::display();
}
示例10: display
/**
* Display the form.
*/
function display()
{
$journal =& Request::getJournal();
$allThemes =& PluginRegistry::loadCategory('themes', true);
$journalThemes = array();
foreach ($allThemes as $key => $junk) {
$plugin =& $allThemes[$key];
// by ref
$journalThemes[basename($plugin->getPluginPath())] =& $plugin;
unset($plugin);
}
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign(array('homeHeaderTitleImage' => $journal->getSetting('homeHeaderTitleImage'), 'homeHeaderLogoImage' => $journal->getSetting('homeHeaderLogoImage'), 'pageHeaderTitleImage' => $journal->getSetting('pageHeaderTitleImage'), 'pageHeaderLogoImage' => $journal->getSetting('pageHeaderLogoImage'), 'homepageImage' => $journal->getSetting('homepageImage'), 'journalStyleSheet' => $journal->getSetting('journalStyleSheet'), 'readerInformation' => $journal->getSetting('readerInformation'), 'authorInformation' => $journal->getSetting('authorInformation'), 'librarianInformation' => $journal->getSetting('librarianInformation'), 'journalThemes' => $journalThemes, 'journalFavicon' => $journal->getSetting('journalFavicon')));
// Make lists of the sidebar blocks available.
$templateMgr->initialize();
$leftBlockPlugins = $disabledBlockPlugins = $rightBlockPlugins = array();
$plugins =& PluginRegistry::getPlugins('blocks');
foreach ($plugins as $key => $junk) {
if (!$plugins[$key]->getEnabled() || $plugins[$key]->getBlockContext() == '') {
if (count(array_intersect($plugins[$key]->getSupportedContexts(), array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR))) > 0) {
$disabledBlockPlugins[] =& $plugins[$key];
}
} else {
switch ($plugins[$key]->getBlockContext()) {
case BLOCK_CONTEXT_LEFT_SIDEBAR:
$leftBlockPlugins[] =& $plugins[$key];
break;
case BLOCK_CONTEXT_RIGHT_SIDEBAR:
$rightBlockPlugins[] =& $plugins[$key];
break;
}
}
}
$templateMgr->assign(array('disabledBlockPlugins' => &$disabledBlockPlugins, 'leftBlockPlugins' => &$leftBlockPlugins, 'rightBlockPlugins' => &$rightBlockPlugins));
$templateMgr->setCacheability(CACHEABILITY_MUST_REVALIDATE);
parent::display();
}
示例11: array
/**
* Load all plugins for a given category.
* @param $category string The name of the category to load
* @param $enabledOnly boolean if true load only enabled
* plug-ins (db-installation required), otherwise look on
* disk and load all available plug-ins (no db required).
* @param $mainContextId integer To identify enabled plug-ins
* we need a context. This context is usually taken from the
* request but sometimes there is no context in the request
* (e.g. when executing CLI commands). Then the main context
* can be given as an explicit ID.
*/
function &loadCategory($category, $enabledOnly = false, $mainContextId = null)
{
$plugins = array();
$categoryDir = PLUGINS_PREFIX . $category;
if (!is_dir($categoryDir)) {
return $plugins;
}
if ($enabledOnly && Config::getVar('general', 'installed')) {
// Get enabled plug-ins from the database.
$application =& PKPApplication::getApplication();
$products =& $application->getEnabledProducts('plugins.' . $category, $mainContextId);
foreach ($products as $product) {
$file = $product->getProduct();
$plugin =& PluginRegistry::_instantiatePlugin($category, $categoryDir, $file, $product->getProductClassname());
if ($plugin && is_object($plugin)) {
$plugins[$plugin->getSeq()]["{$categoryDir}/{$file}"] =& $plugin;
unset($plugin);
}
}
} else {
// Get all plug-ins from disk. This does not require
// any database access and can therefore be used during
// first-time installation.
$handle = opendir($categoryDir);
while (($file = readdir($handle)) !== false) {
if ($file == '.' || $file == '..') {
continue;
}
$plugin =& PluginRegistry::_instantiatePlugin($category, $categoryDir, $file);
if ($plugin && is_object($plugin)) {
$plugins[$plugin->getSeq()]["{$categoryDir}/{$file}"] =& $plugin;
unset($plugin);
}
}
closedir($handle);
}
// If anyone else wants to jump category, here is the chance.
HookRegistry::call('PluginRegistry::loadCategory', array(&$category, &$plugins));
// Register the plugins in sequence.
ksort($plugins);
foreach ($plugins as $seq => $junk1) {
foreach ($plugins[$seq] as $pluginPath => $junk2) {
PluginRegistry::register($category, $plugins[$seq][$pluginPath], $pluginPath);
}
}
unset($plugins);
// Return the list of successfully-registered plugins.
$plugins =& PluginRegistry::getPlugins($category);
return $plugins;
}
示例12: addPluginVersions
/**
* Insert or update plugin data in versions
* and plugin_settings tables.
* @return boolean
*/
function addPluginVersions()
{
$versionDao =& DAORegistry::getDAO('VersionDAO');
import('lib.pkp.classes.site.VersionCheck');
$fileManager = new FileManager();
$categories = PluginRegistry::getCategories();
foreach ($categories as $category) {
PluginRegistry::loadCategory($category);
$plugins = PluginRegistry::getPlugins($category);
if (is_array($plugins)) {
foreach ($plugins as $plugin) {
$versionFile = $plugin->getPluginPath() . '/version.xml';
if ($fileManager->fileExists($versionFile)) {
$versionInfo =& VersionCheck::parseVersionXML($versionFile);
$pluginVersion = $versionInfo['version'];
} else {
$pluginVersion = new Version(1, 0, 0, 0, Core::getCurrentDate(), 1, 'plugins.' . $category, basename($plugin->getPluginPath()), '', 0, $plugin->isSitePlugin());
}
$versionDao->insertVersion($pluginVersion, true);
}
}
}
return true;
}
示例13: trigger_error
/**
* Return an instance of the template manager.
* @param $request PKPRequest
* @return TemplateManager the template manager object
*/
static function &getManager($request = null)
{
if (!isset($request)) {
$request = Registry::get('request');
if (Config::getVar('debug', 'deprecation_warnings')) {
trigger_error('Deprecated call without request object.');
}
}
assert(is_a($request, 'PKPRequest'));
$instance =& Registry::get('templateManager', true, null);
// Reference required
if ($instance === null) {
$instance = new TemplateManager($request);
$themes = PluginRegistry::getPlugins('themes');
if (is_null($themes)) {
$themes = PluginRegistry::loadCategory('themes', true);
}
$instance->initialize();
}
return $instance;
}
示例14: display
/**
* Display the form.
*/
function display()
{
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('archiveId', $this->archiveId);
if ($this->captchaEnabled && !Validation::isSiteAdmin()) {
import('lib.pkp.lib.recaptcha.recaptchalib');
$publicKey = Config::getVar('captcha', 'recaptcha_public_key');
$useSSL = Config::getVar('security', 'force_ssl') ? true : false;
$reCaptchaHtml = recaptcha_get_html($publicKey, null, $useSSL);
$templateMgr->assign('reCaptchaHtml', $reCaptchaHtml);
$templateMgr->assign('captchaEnabled', true);
}
if ($this->archive) {
$templateMgr->assign('archiveImage', $this->archive->getSetting('archiveImage'));
}
$templateMgr->assign_by_ref('harvesters', PluginRegistry::getPlugins('harvesters'));
$templateMgr->assign('allowManagement', $this->allowManagement);
HookRegistry::call('ArchiveForm::display', array(&$this, &$templateMgr, $this->harvesterPluginName));
parent::display();
}
示例15: createData
/**
* Create initial required data.
* @return boolean
*/
function createData()
{
if ($this->getParam('manualInstall')) {
// Add insert statements for default data
// FIXME use ADODB data dictionary?
$this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
$this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
$this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
$this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
$this->executeSQL(sprintf('INSERT INTO users (username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
$this->executeSQL(sprintf('INSERT INTO roles (conference_id, user_id, role_id) VALUES (%d, (SELECT user_id FROM users WHERE username = \'%s\'), %d)', 0, $this->getParam('adminUsername'), ROLE_ID_SITE_ADMIN));
// Install email template list and data for each locale
$emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
$this->executeSQL($sql);
}
foreach ($this->installedLocales as $locale) {
foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
$this->executeSQL($sql);
}
}
} else {
// Add initial site data
$locale = $this->getParam('locale');
$siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
$site = new Site();
$site->setRedirect(0);
$site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
$site->setPrimaryLocale($locale);
$site->setInstalledLocales($this->installedLocales);
$site->setSupportedLocales($this->installedLocales);
if (!$siteDao->insertSite($site)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
$siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
$siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
$siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
$siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
// Add initial site administrator user
$userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
$user = new User();
$user->setUsername($this->getParam('adminUsername'));
$user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
$user->setFirstName($user->getUsername());
$user->setLastName('');
$user->setEmail($this->getParam('adminEmail'));
if (!$userDao->insertUser($user)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
$roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
$role = new Role();
$role->setConferenceId(0);
$role->setUserId($user->getId());
$role->setRoleId(ROLE_ID_SITE_ADMIN);
if (!$roleDao->insertRole($role)) {
$this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
return false;
}
// Install email template list and data for each locale
$emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
$emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
foreach ($this->installedLocales as $locale) {
$emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
}
// Add initial plugin data to versions table
$versionDao =& DAORegistry::getDAO('VersionDAO');
import('site.VersionCheck');
$categories = PluginRegistry::getCategories();
foreach ($categories as $category) {
PluginRegistry::loadCategory($category, true);
$plugins = PluginRegistry::getPlugins($category);
foreach ($plugins as $plugin) {
$versionFile = $plugin->getPluginPath() . '/version.xml';
if (FileManager::fileExists($versionFile)) {
$versionInfo =& VersionCheck::parseVersionXML($versionFile);
$pluginVersion = $versionInfo['version'];
$pluginVersion->setCurrent(1);
$versionDao->insertVersion($pluginVersion);
} else {
$pluginVersion = new Version();
$pluginVersion->setMajor(1);
$pluginVersion->setMinor(0);
$pluginVersion->setRevision(0);
$pluginVersion->setBuild(0);
$pluginVersion->setDateInstalled(Core::getCurrentDate());
$pluginVersion->setCurrent(1);
$pluginVersion->setProductType('plugins.' . $category);
$pluginVersion->setProduct(basename($plugin->getPluginPath()));
$versionDao->insertVersion($pluginVersion);
}
}
}
}
return true;
//.........这里部分代码省略.........