/** * */ public function loadIDNoPlugInInstance($pa_options = null) { if ($this->opo_idno_plugin_instance) { return $this->opo_idno_plugin_instance; } return $this->opo_idno_plugin_instance = IDNumbering::newIDNumberer($this->tableName(), $this->getTypeCode(), null, $this->getDb(), caGetOption('IDNumberingConfig', $pa_options, null)); }
/** * */ protected function initLabelDefinitions($pa_options = null) { $pb_dont_cache = caGetOption('dontCache', $pa_options, false); $this->BUNDLES = is_subclass_of($this, "BaseRelationshipModel") ? array() : array('preferred_labels' => array('type' => 'preferred_label', 'repeating' => true, 'label' => _t("Preferred labels")), 'nonpreferred_labels' => array('type' => 'nonpreferred_label', 'repeating' => true, 'label' => _t("Non-preferred labels"))); // add form fields to bundle list foreach ($this->getFormFields() as $vs_f => $va_info) { $vs_type_id_fld = isset($this->ATTRIBUTE_TYPE_ID_FLD) ? $this->ATTRIBUTE_TYPE_ID_FLD : null; if ($vs_f === $vs_type_id_fld) { continue; } // don't allow type_id field to be a bundle (isn't settable in a form) if (isset($va_info['DONT_USE_AS_BUNDLE']) && $va_info['DONT_USE_AS_BUNDLE']) { continue; } $this->BUNDLES[$vs_f] = array('type' => 'intrinsic', 'repeating' => false, 'label' => $this->getFieldInfo($vs_f, 'LABEL')); } $vn_type_id = $this->getTypeID(); // Create instance of idno numbering plugin (if table supports it) if ($vs_field = $this->getProperty('ID_NUMBERING_ID_FIELD')) { if (!$vn_type_id) { $vn_type_id = null; } if (!isset(BundlableLabelableBaseModelWithAttributes::$s_idno_instance_cache[$this->tableNum() . "/" . $vn_type_id])) { $va_types = array(); $o_db = $this->getDb(); // have to do direct query here... if we use ca_list_items model we'll just endlessly recurse if ($vn_type_id) { $qr_res = $o_db->query("\n\t\t\t\t\t\tSELECT idno, list_id, hier_left, hier_right \n\t\t\t\t\t\tFROM ca_list_items \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\titem_id = ?", (int) $vn_type_id); if ($qr_res->nextRow()) { if ($vn_list_id = $qr_res->get('list_id')) { $vn_hier_left = $qr_res->get('hier_left'); $vn_hier_right = $qr_res->get('hier_right'); $vs_idno = $qr_res->get('idno'); $qr_res = $o_db->query("\n\t\t\t\t\t\t\t\tSELECT idno, parent_id\n\t\t\t\t\t\t\t\tFROM ca_list_items \n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t(list_id = ? AND hier_left < ? AND hier_right > ?)", (int) $vn_list_id, (int) $vn_hier_left, (int) $vn_hier_right); while ($qr_res->nextRow()) { if (!$qr_res->get('parent_id')) { continue; } $va_types[] = $qr_res->get('idno'); } $va_types[] = $vs_idno; $va_types = array_reverse($va_types); } } } BundlableLabelableBaseModelWithAttributes::$s_idno_instance_cache[$this->tableNum() . "/" . $vn_type_id] = $this->opo_idno_plugin_instance = IDNumbering::newIDNumberer($this->tableName(), $va_types, null, $o_db); } else { $this->opo_idno_plugin_instance = BundlableLabelableBaseModelWithAttributes::$s_idno_instance_cache[$this->tableNum() . "/" . $vn_type_id]; } } else { $this->opo_idno_plugin_instance = null; } // add metadata elements foreach ($this->getApplicableElementCodes($vn_type_id, false, $pb_dont_cache) as $vs_code) { $this->BUNDLES['ca_attribute_' . $vs_code] = array('type' => 'attribute', 'repeating' => false, 'label' => $vs_code); } }