48 define(
'PLUGIN_FILTER_DATAFILE',
'filterConfig.xml');
49 define(
'PLUGIN_TEMPLATE_RESOURCE_PREFIX',
'plugins');
90 function register($category, $path, $mainContextId =
null) {
91 $this->pluginPath = $path;
92 $this->pluginCategory = $category;
184 throw new Exception(
'Unhandled management action!');
297 $filterConfigFile = $this->
getPluginPath().
'/filter/'.PLUGIN_FILTER_DATAFILE;
298 $filterConfigFiles = array(
299 './lib/pkp/'.$filterConfigFile,
300 './'.$filterConfigFile
302 return $filterConfigFiles;
330 return basename($this->pluginPath);
348 $resourceName = strtr(join(
'/', array(PLUGIN_TEMPLATE_RESOURCE_PREFIX,
$pluginPath, $category, $plugin)),
'/',
'-');
349 return $resourceName . ($template!==
null?
":$template":
'');
358 $templatePath = ($inCore?PKP_LIB_PATH . DIRECTORY_SEPARATOR:
'') . $this->
getPluginPath() . DIRECTORY_SEPARATOR .
'templates';
359 if (is_dir($templatePath))
return $templatePath;
371 $templateMgr->registerResource($this->
getTemplateResource(
null, $inCore), $pluginTemplateResource);
390 $filePath =& $args[0];
391 $template = $args[1];
392 $checkFilePath = $filePath;
395 if (strpos($filePath,
'plugins/') === 0) $checkFilePath =
'templates/' . $checkFilePath;
398 $libPkpPrefix =
'lib' . DIRECTORY_SEPARATOR .
'pkp' . DIRECTORY_SEPARATOR;
399 if (strpos($checkFilePath, $libPkpPrefix) === 0) $checkFilePath = substr($filePath, strlen($libPkpPrefix));
402 if ($overriddenFilePath = $this->_findOverriddenTemplate($checkFilePath)) {
403 $filePath = $overriddenFilePath;
414 private function _findOverriddenTemplate($path) {
417 if (file_exists($fullPath)) {
422 if (($fullPath = preg_replace(
"/templates\/(?!.*templates\/)/",
"", $fullPath)) && file_exists($fullPath)) {
424 trigger_error(
'Deprecated: The template at ' . $fullPath .
' has moved and will not be found in the future.');
430 if (is_a($this,
'ThemePlugin')
432 && $fullPath = $this->parent->_findOverriddenTemplate($path)) {
448 if ($localeFilenames) {
449 if (is_scalar($localeFilenames)) $localeFilenames = array($localeFilenames);
450 foreach($localeFilenames as $localeFilename) {
465 if (!defined(
'RUNNING_UPGRADE') && !
Config::getVar(
'general',
'installed'))
return null;
475 return call_user_func_array(array(&$pluginSettingsDao,
'getSetting'), $arguments);
486 function updateSetting($contextId, $name, $value, $type =
null) {
498 call_user_func_array(array(&$pluginSettingsDao,
'updateSetting'), $arguments);
506 function import($class) {
507 require_once($this->
getPluginPath() .
'/' . str_replace(
'.',
'/', $class) .
'.inc.php');
523 $masterLocale = MASTER_LOCALE;
524 $baseLocaleFilename = $this->
getPluginPath() .
"/locale/$locale/locale.po";
525 $baseMasterLocaleFilename = $this->
getPluginPath() .
"/locale/$masterLocale/locale.po";
526 $libPkpFilename =
"lib/pkp/$baseLocaleFilename";
527 $masterLibPkpFilename =
"lib/pkp/$baseMasterLocaleFilename";
528 $filenames = array();
529 if (file_exists($baseMasterLocaleFilename)) $filenames[] = $baseLocaleFilename;
530 if (file_exists($masterLibPkpFilename)) $filenames[] = $libPkpFilename;
534 $baseMasterXmlLocaleFilename = preg_replace(
'/\.po$/',
'.xml', $baseMasterLocaleFilename);
535 if (file_exists($baseMasterXmlLocaleFilename)) $filenames[] = preg_replace(
'/\.po$/',
'.xml', $baseLocaleFilename);
536 $masterXmlLibPkpLocaleFilename = preg_replace(
'/\.po$/',
'.xml', $baseMasterLocaleFilename);
537 if (file_exists($masterXmlLibPkpLocaleFilename)) $filenames[] = preg_replace(
'/\.po$/',
'.xml', $libPkpFilename);
550 $installer =& $args[0];
555 if (is_scalar($dataFiles)) $dataFiles = array($dataFiles);
558 foreach($dataFiles as $dataFile) {
559 $sql = $installer->dataXMLParser->parseData($dataFile);
561 $result = $installer->executeSQL($sql);
564 $installer->setError(INSTALLER_ERROR_DB, str_replace(
'{$file}', $this->
getInstallDataFile(), __(
'installer.installParseDBFileError')));
567 if (!$result)
return false;
583 if ($contextDepth >0) {
584 $arguments = array_fill(0, $contextDepth, 0);
586 $arguments = array();
591 call_user_func_array(array(&$pluginSettingsDao,
'installSettings'), $arguments);
606 $controlledVocabDao->installXML($file);
621 $pluginSettingsDao->installSettings($context->getId(), $this->getName(), $this->getContextSpecificPluginSettingsFile());
633 $installer =& $args[0];
638 $emailTemplateLocales = [];
639 foreach ($installer->installedLocales as $locale) {
640 $emailFile = $this->
getPluginPath() .
"/locale/$locale/emails.po";
641 if (!file_exists($emailFile))
continue;
643 $emailTemplateLocales[] = $locale;
647 if ($sql ===
false) {
649 $installer->setError(INSTALLER_ERROR_DB, str_replace(
'{$file}', $this->
getInstallEmailTemplatesFile(), __(
'installer.installParseEmailTemplatesFileError')));
653 assert(is_array($sql));
656 $result = $installer->executeSQL($sql);
671 $installer =& $args[0];
675 foreach ($installer->installedLocales as $locale) {
677 if (!file_exists($filename))
continue;
678 $sql = $emailTemplateDao->installEmailTemplateData($filename, $locale,
true);
680 $result = $installer->executeSQL($sql);
682 $installer->setError(INSTALLER_ERROR_DB, str_replace(
'{$file}', $this->
getInstallDataFile(), __(
'installer.installParseEmailTemplatesFileError')));
706 if (file_exists($emailFile = $this->
getPluginPath() .
"/locale/$locale/emails.po")) {
719 $installer =& $args[0];
724 if (is_scalar($filterConfigFiles)) $filterConfigFiles = array($filterConfigFiles);
728 foreach($filterConfigFiles as $filterConfigFile) {
730 if (!file_exists($filterConfigFile))
continue;
733 $result = $installer->installFilterConfig($filterConfigFile);
736 $installer->setError(INSTALLER_ERROR_DB, str_replace(
'{$file}', $filterConfigFile, __(
'installer.installParseFilterConfigFileError')));
753 $installer =& $args[0];
758 $schemaXMLParser =
new adoSchema($installer->dbconn);
759 $sql = $schemaXMLParser->parseSchema($schemaFile);
761 $result = $installer->executeSQL($sql);
763 $installer->setError(INSTALLER_ERROR_DB, str_replace(
'{$file}', $this->
getInstallSchemaFile(), __(
'installer.installParseDBFileError')));
770 }
catch (Exception $e) {
771 $installer->setError(INSTALLER_ERROR_DB, __(
'installer.installMigrationError', [
'class' => get_class($migration)]));
786 if (is_array($params[
'path'])) {
787 $params[
'path'] = array_merge($path, $params[
'path']);
788 } elseif (!empty($params[
'path'])) {
789 $params[
'path'] = array_merge($path, array($params[
'path']));
791 $params[
'path'] = $path;
793 return $smarty->smartyUrl($params, $smarty);
806 $installedPlugin = $versionDao->getCurrentVersion(
'plugins.'.$category, $product,
true);
808 if ($installedPlugin) {
809 return $installedPlugin;
820 if (!$this->request) {