本文整理汇总了PHP中ca_objects::getIDNoPlugInInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getIDNoPlugInInstance方法的具体用法?PHP ca_objects::getIDNoPlugInInstance怎么用?PHP ca_objects::getIDNoPlugInInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_objects
的用法示例。
在下文中一共展示了ca_objects::getIDNoPlugInInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObjectID
//.........这里部分代码省略.........
$o_event->beginItem($vs_event_source, 'ca_objects', 'I');
}
$t_object->setMode(ACCESS_WRITE);
$t_object->set('locale_id', $pn_locale_id);
$t_object->set('type_id', $pn_type_id);
$t_object->set('parent_id', $pn_parent_id);
$t_object->set('source_id', isset($pa_values['source_id']) ? $pa_values['source_id'] : null);
$t_object->set('access', isset($pa_values['access']) ? $pa_values['access'] : 0);
$t_object->set('status', isset($pa_values['status']) ? $pa_values['status'] : 0);
$t_object->set('idno', $vs_idno);
$t_object->set('hier_object_id', isset($pa_values['hier_object_id']) ? $pa_values['hier_object_id'] : null);
$t_object->insert();
if ($t_object->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not insert object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not insert object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())));
}
return null;
}
$vb_label_errors = false;
$t_object->addLabel(array('name' => $ps_object_name), $pn_locale_id, null, true);
if ($t_object->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not set preferred label for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not set preferred label for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())));
}
$vb_label_errors = true;
}
/** @var IIDNumbering $o_idno */
if ($o_idno = $t_object->getIDNoPlugInInstance()) {
$va_values = $o_idno->htmlFormValuesAsArray('idno', $vs_idno);
if (!is_array($va_values)) {
$va_values = array($va_values);
}
if (!($vs_sep = $o_idno->getSeparator())) {
$vs_sep = '';
}
if (($vs_proc_idno = join($vs_sep, $va_values)) && $vs_proc_idno != $vs_idno) {
$t_object->set('idno', $vs_proc_idno);
$t_object->update();
if ($t_object->numErrors()) {
if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
print "[Error] " . _t("Could not update idno for %1: %2", $ps_object_name, join('; ', $t_object->getErrors())) . "\n";
}
if ($o_log) {
$o_log->logError(_t("Could not object idno for %1: %2", $ps_object_name, join('; ', $t_object->getErrors())));
}
return null;
}
}
}
unset($pa_values['access']);
unset($pa_values['status']);
unset($pa_values['idno']);
unset($pa_values['source_id']);
unset($pa_values['hier_object_id']);
$vb_attr_errors = false;
if (is_array($pa_values)) {
foreach ($pa_values as $vs_element => $va_values) {
if (!caIsIndexedArray($va_values)) {
$va_values = array($va_values);
}
示例2: renumberObjects
/**
*
*
* @return boolean
*/
public function renumberObjects($po_application_plugin_manager = null)
{
if (!$this->getPrimaryKey()) {
return false;
}
if ($va_non_conforming_objects = $this->getObjectsWithNonConformingIdnos()) {
$va_objects = $this->getObjects();
$vs_lot_num = $this->get('idno_stub');
$t_object = new ca_objects();
$vb_web_set_transaction = false;
if (!$this->inTransaction()) {
$o_trans = new Transaction($this->getDb());
$vb_web_set_transaction = true;
} else {
$o_trans = $this->getTransaction();
}
$t_object->setTransaction($o_trans);
$t_idno = $t_object->getIDNoPlugInInstance();
$vs_separator = $t_idno->getSeparator();
$vn_i = 1;
foreach ($va_objects as $vn_object_id => $va_object_info) {
if ($t_object->load($vn_object_id)) {
if ($po_application_plugin_manager) {
$po_application_plugin_manager->hookBeforeSaveItem(array('id' => $vn_object_id, 'table_num' => $t_object->tableNum(), 'table_name' => $t_object->tableName(), 'instance' => $t_object));
}
$t_object->setMode(ACCESS_WRITE);
$t_object->set('idno', $vs_lot_num . $vs_separator . $vn_i);
$t_object->update();
if ($t_object->numErrors()) {
$t->rollback();
$this->errors = $t_object->errors;
return false;
}
if ($po_application_plugin_manager) {
$po_application_plugin_manager->hookSaveItem(array('id' => $vn_object_id, 'table_num' => $t_object->tableNum(), 'table_name' => $t_object->tableName(), 'instance' => $t_object));
}
$vn_i++;
}
}
if ($vb_web_set_transaction) {
$o_trans->commit();
}
}
return true;
}
示例3: importMediaFromDirectory
//.........这里部分代码省略.........
if ($t_object->getPrimaryKey()) {
// found existing object
$t_object->setMode(ACCESS_WRITE);
$t_new_rep = $t_object->addRepresentation($vs_directory . '/' . $f, $vn_rep_type_id, $vn_locale_id, $vn_object_representation_status, $vn_object_representation_access, false, array(), array('original_filename' => $f, 'returnRepresentation' => true));
if ($t_object->numErrors()) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Error importing {$f} from {$vs_directory}: " . join('; ', $t_object->getErrors())));
$va_errors[$vs_relative_directory . '/' . $f] = array('idno' => $t_object->get($t_object->getProperty('ID_NUMBERING_ID_FIELD')), 'label' => $t_object->getLabelForDisplay(), 'errors' => $t_object->errors(), 'message' => _t("Error importing %1 from %2: %3", $f, $vs_relative_directory, join('; ', $t_object->getErrors())), 'status' => 'ERROR');
$o_trans->rollback();
continue;
} else {
if ($vb_delete_media_on_import) {
@unlink($vs_directory . '/' . $f);
}
}
} else {
// should we create new object?
if (in_array($vs_import_mode, array('TRY_TO_MATCH', 'DONT_MATCH'))) {
$t_object->setMode(ACCESS_WRITE);
$t_object->set('type_id', $vn_object_type_id);
$t_object->set('locale_id', $vn_locale_id);
$t_object->set('status', $vn_object_status);
$t_object->set('access', $vn_object_access);
switch ($vs_idno_mode) {
case 'filename':
// use the filename as identifier
$t_object->set('idno', $f);
break;
case 'directory_and_filename':
// use the directory + filename as identifier
$t_object->set('idno', $d . '/' . $f);
break;
default:
// Calculate identifier using numbering plugin
$o_numbering_plugin = $t_object->getIDNoPlugInInstance();
if (!($vs_sep = $o_numbering_plugin->getSeparator())) {
$vs_sep = '';
}
if (!is_array($va_idno_values = $o_numbering_plugin->htmlFormValuesAsArray('idno', $vs_object_idno, false, false, true))) {
$va_idno_values = array();
}
$t_object->set('idno', join($vs_sep, $va_idno_values));
// true=always set serial values, even if they already have a value; this let's us use the original pattern while replacing the serial value every time through
break;
}
$t_object->insert();
if ($t_object->numErrors()) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Error creating new object while importing {$f} from {$vs_relative_directory}: " . join('; ', $t_object->getErrors())));
$va_errors[$vs_relative_directory . '/' . $f] = array('idno' => $t_object->get($t_object->getProperty('ID_NUMBERING_ID_FIELD')), 'label' => $t_object->getLabelForDisplay(), 'errors' => $t_object->errors(), 'message' => _t("Error creating new object while importing %1 from %2: %3", $f, $vs_relative_directory, join('; ', $t_object->getErrors())), 'status' => 'ERROR');
$o_trans->rollback();
continue;
}
$t_object->addLabel(array('name' => $f), $vn_locale_id, null, true);
if ($t_object->numErrors()) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Error creating object label while importing {$f} from {$vs_relative_directory}: " . join('; ', $t_object->getErrors())));
$va_errors[$vs_relative_directory . '/' . $f] = array('idno' => $t_object->get($t_object->getProperty('ID_NUMBERING_ID_FIELD')), 'label' => $t_object->getLabelForDisplay(), 'errors' => $t_object->errors(), 'message' => _t("Error creating object label while importing %1 from %2: %3", $f, $vs_relative_directory, join('; ', $t_object->getErrors())), 'status' => 'ERROR');
$o_trans->rollback();
continue;
}
$t_new_rep = $t_object->addRepresentation($vs_directory . '/' . $f, $vn_rep_type_id, $vn_locale_id, $vn_object_representation_status, $vn_object_representation_access, true, array(), array('original_filename' => $f, 'returnRepresentation' => true));
if ($t_object->numErrors()) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Error importing {$f} from {$vs_relative_directory}: " . join('; ', $t_object->getErrors())));
$va_errors[$vs_relative_directory . '/' . $f] = array('idno' => $t_object->get($t_object->getProperty('ID_NUMBERING_ID_FIELD')), 'label' => $t_object->getLabelForDisplay(), 'errors' => $t_object->errors(), 'message' => _t("Error importing %1 from %2: %3", $f, $vs_relative_directory, join('; ', $t_object->getErrors())), 'status' => 'ERROR');
$o_trans->rollback();
continue;
} else {
if ($vb_delete_media_on_import) {