/** * */ public function __construct(&$po_request, &$po_response, $pa_view_paths = null) { $this->ops_theme = __CA_THEME__; // get current theme if (!is_dir(__CA_APP_DIR__ . '/plugins/Contribute/themes/' . $this->ops_theme . '/views')) { // if theme is not defined for this plugin, try to use "default" theme $this->ops_theme = 'default'; } parent::__construct($po_request, $po_response, array(__CA_APP_DIR__ . '/plugins/Contribute/themes/' . $this->ops_theme . '/views')); #$this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins').'/Contribute/conf/contribute.conf'); if (file_exists($po_request->getAppConfig()->get('application_plugins') . '/Contribute/themes/' . $this->ops_theme . '/conf/contribute.conf')) { // check if there is a config file in the theme first $this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Contribute/themes/' . $this->ops_theme . '/conf/contribute.conf'); } else { $this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Contribute/conf/contribute.conf'); } if (!(bool) $this->opo_plugin_config->get('enabled')) { die(_t('Contribute plugin is not enabled')); } $vs_default_ui = $this->opo_plugin_config->get('default_ui'); $vs_requested_ui = $this->request->getParameter('ui', pString); $va_ui_list = $this->opo_plugin_config->getAssoc('uis'); $o_dm = Datamodel::load(); if (isset($va_ui_list[$vs_requested_ui]) && is_array($va_ui_list[$vs_requested_ui])) { $this->opa_ui_info = $va_ui_list[$vs_requested_ui]; $this->ops_ui_code = $vs_requested_ui; } else { if (isset($va_ui_list[$vs_default_ui]) && is_array($va_ui_list[$vs_default_ui])) { $this->opa_ui_info = $va_ui_list[$vs_default_ui]; } else { $vs_default_ui = array_shift(array_keys($va_ui_list)); $this->opa_ui_info = $va_ui_list[$vs_default_ui]; } $this->ops_ui_code = $vs_default_ui; } $this->ops_table_name = $this->opa_ui_info['table']; if (!($this->opo_instance = $o_dm->getInstanceByTableName($this->ops_table_name, true))) { die(_t('Invalid table "%1" specified in Contribute plugin for form "%2"', $this->ops_table_name, $vs_default_ui)); } $t_list = new ca_lists(); if (isset($this->opa_ui_info['type']) && $this->opa_ui_info['type']) { $this->opa_ui_info['type_id'] = $t_list->getItemIDFromList($this->opo_instance->getTypeListCode(), $this->opa_ui_info['type']); } if (isset($this->opa_ui_info['representation_type']) && $this->opa_ui_info['representation_type']) { $this->opa_ui_info['representation_type_id'] = $t_list->getItemIDFromList('object_representation_types', $this->opa_ui_info['representation_type']); } ContributePlugin::setUIInfo($this->ops_ui_code, $this->opa_ui_info); JavascriptLoadManager::register('panel'); MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/Contribute/themes/" . $this->ops_theme . "/css/contribute.css", 'text/css'); $this->request->setParameter('dont_set_pawtucket2_last_page', '1'); // Setting this parameter ensures that the "last page" we (may) redirect to after submission isn't the Contribute form itself if ($this->opa_ui_info['require_login'] && !$po_request->isLoggedIn()) { $this->notification->addNotification(_t("You must be logged in to use user contribution features."), __NOTIFICATION_TYPE_ERROR__); $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form')); return; } }