Exemplo n.º 1
0
 /**
  *
  */
 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/Cataloging/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/Cataloging/themes/' . $this->ops_theme . '/views'));
     $this->opo_plugin_config = Configuration::load($po_request->getAppConfig()->get('application_plugins') . '/Cataloging/conf/cataloging.conf');
     if (!(bool) $this->opo_plugin_config->get('enabled')) {
         die(_t('Cataloging 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 Cataloging plugin for form "%2"', $this->ops_table_name, $vs_default_ui));
     }
     # --- load the current record
     if (!($pn_id = $this->request->getParameter($this->opo_instance->primaryKey(), pInteger))) {
         die(_t("Primary key of record must be passed to form"));
     }
     if (!$this->opo_instance->load($pn_id)) {
         die(_t("Invalid id"));
     }
     $t_list = new ca_lists();
     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']);
     }
     CatalogingPlugin::setUIInfo($this->ops_ui_code, $this->opa_ui_info);
     JavascriptLoadManager::register('panel');
     MetaTagManager::addLink('stylesheet', $po_request->getBaseUrlPath() . "/app/plugins/Cataloging/themes/" . $this->ops_theme . "/css/cataloging.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 Cataloging form itself
     if ($this->opa_ui_info['require_login'] && !$po_request->isLoggedIn()) {
         $this->notification->addNotification(_t("You must be logged in to use user cataloging features."), __NOTIFICATION_TYPE_ERROR__);
         $this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
         return;
     }
 }