本文整理汇总了PHP中ca_objects::getTypeCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getTypeCode方法的具体用法?PHP ca_objects::getTypeCode怎么用?PHP ca_objects::getTypeCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_objects
的用法示例。
在下文中一共展示了ca_objects::getTypeCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetObjectInfo
/**
* Return info via ajax on selected object
*/
public function GetObjectInfo()
{
$pn_checkout_id = $this->request->getParameter('checkout_id', pInteger);
$t_checkout = new ca_object_checkouts($pn_checkout_id);
$t_user = new ca_users($t_checkout->get('user_id'));
$t_object = new ca_objects($t_checkout->get('object_id'));
$va_status = $t_object->getCheckoutStatus();
$va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
$va_info = array('object_id' => $t_object->getPrimaryKey(), 'idno' => $t_object->get('idno'), 'name' => $t_object->get('ca_objects.preferred_labels.name'), 'media' => $t_object->getWithTemplate('^ca_object_representations.media.icon'), 'status' => $t_object->getCheckoutStatus(), 'status_display' => $t_object->getCheckoutStatus(array('returnAsText' => true)), 'checkout_date' => $t_checkout->get('ca_object_checkouts.checkout_date', array('timeOmit' => true)), 'user_name' => $t_user->get('ca_users.fname') . ' ' . $t_user->get('ca_users.lname'), 'config' => $va_checkout_config);
$va_info['title'] = $va_info['name'] . ' (' . $va_info['idno'] . ')';
$va_info['borrower'] = _t('Borrowed by %1 on %2', $va_info['user_name'], $va_info['checkout_date']);
$this->view->setVar('data', $va_info);
$this->render('checkin/ajax_data_json.php');
}
示例2: GetObjectInfo
/**
* Return info via ajax on selected object
*/
public function GetObjectInfo()
{
$pn_user_id = $this->request->getParameter('user_id', pInteger);
$pn_object_id = $this->request->getParameter('object_id', pInteger);
$t_object = new ca_objects($pn_object_id);
$vn_current_user_id = $vs_current_user = $vs_current_user_checkout_date = $vs_reservation_list = null;
// user_id of current holder of item
$vb_is_reserved_by_current_user = false;
switch ($vn_status = $t_object->getCheckoutStatus()) {
case __CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__:
$vs_status_display = _t('Available');
break;
case __CA_OBJECTS_CHECKOUT_STATUS_OUT__:
$t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
$vn_current_user_id = $t_checkout->get('user_id');
$vs_status_display = $vn_current_user_id == $pn_user_id ? _t('Out with this user') : _t('Out');
$vs_current_user_checkout_date = $t_checkout->get('checkout_date', array('timeOmit' => true));
break;
case __CA_OBJECTS_CHECKOUT_STATUS_OUT_WITH_RESERVATIONS__:
$t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
$vn_current_user_id = $t_checkout->get('user_id');
$va_reservations = $t_object->getCheckoutReservations();
$vn_num_reservations = sizeof($va_reservations);
$vs_current_user_checkout_date = $t_checkout->get('checkout_date', array('timeOmit' => true));
$vs_status_display = $vn_num_reservations == 1 ? _t('Out with %1 reservation', $vn_num_reservations) : _t('Out with %1 reservations', $vn_num_reservations);
break;
case __CA_OBJECTS_CHECKOUT_STATUS_RESERVED__:
// get reservations list
$va_reservations = $t_object->getCheckoutReservations();
$vn_num_reservations = sizeof($va_reservations);
$t_checkout = ca_object_checkouts::getCurrentCheckoutInstance($pn_object_id);
$vs_current_user_checkout_date = $t_checkout->get('created_on', array('timeOmit' => true));
$vs_status_display = $vn_num_reservations == 1 ? _t('Reserved') : _t('Available with %1 reservations', $vn_num_reservations);
break;
}
$vb_is_held_by_current_user = $pn_user_id == $vn_current_user_id;
if (is_array($va_reservations)) {
$va_tmp = array();
foreach ($va_reservations as $va_reservation) {
$vb_is_reserved_by_current_user = $va_reservation['user_id'] == $pn_user_id;
$t_user = new ca_users($va_reservation['user_id']);
$va_tmp[] = $t_user->get('fname') . ' ' . $t_user->get('lname') . (($vs_email = $t_user->get('email')) ? " ({$vs_email})" : "");
}
$vs_reservation_list = join(", ", $va_tmp);
}
if ($vn_current_user_id) {
$t_user = new ca_users($vn_current_user_id);
$vs_current_user = $t_user->get('fname') . ' ' . $t_user->get('lname');
}
$va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
$vs_holder_display_label = '';
if ($vb_is_held_by_current_user) {
$vs_status_display = _t('The user currently has this item');
} elseif ($vb_is_reserved_by_current_user) {
$vs_status_display = _t('The user has reserved this item');
} else {
$vs_reserve_display_label = $vn_status == 3 ? _t('Currently reserved by %1', $vs_reservation_list) : _t('Will reserve');
if (in_array($vn_status, array(1, 2))) {
$vs_holder_display_label = _t('held by %1 since %2', $vs_current_user, $vs_current_user_checkout_date);
}
}
$va_info = array('object_id' => $t_object->getPrimaryKey(), 'idno' => $t_object->get('idno'), 'name' => $t_object->get('ca_objects.preferred_labels.name'), 'media' => $t_object->getWithTemplate('^ca_object_representations.media.icon'), 'status' => $vn_status, 'status_display' => $vs_status_display, 'numReservations' => sizeof($va_reservations), 'reservations' => $va_reservations, 'config' => $va_checkout_config, 'current_user_id' => $vn_current_user_id, 'current_user' => $vs_current_user, 'current_user_checkout_date' => $vs_current_user_checkout_date, 'isOutWithCurrentUser' => $pn_user_id == $vn_current_user_id, 'isReservedByCurrentUser' => $vb_is_reserved_by_current_user, 'reserve_display_label' => $vs_reserve_display_label, 'due_on_display_label' => _t('Due on'), 'notes_display_label' => _t('Notes'), 'holder_display_label' => $vs_holder_display_label);
$va_info['title'] = $va_info['name'] . " (" . $va_info['idno'] . ")";
$va_info['storage_location'] = $t_object->getWithTemplate($va_checkout_config['show_storage_location_template']);
$this->view->setVar('data', $va_info);
$this->render('checkout/ajax_data_json.php');
}
示例3: reserve
/**
*
*/
public function reserve($pn_object_id, $pn_user_id, $ps_note, $pa_options = null)
{
global $g_ui_locale_id;
$vb_we_set_transaction = false;
if ($this->inTransaction()) {
$o_trans = $this->getTransaction();
} else {
$vb_we_set_transaction = true;
$this->setTransaction($o_trans = new Transaction());
}
$o_request = caGetOption('request', $pa_options, null);
$t_object = new ca_objects($pn_object_id);
$t_object->setTransaction($o_trans);
if (!$t_object->getPrimaryKey()) {
return null;
}
if ($o_request && !$t_object->isReadable($o_request)) {
return null;
}
// is object out?
if ($t_object->getCheckoutStatus() === __CA_OBJECTS_CHECKOUT_STATUS_AVAILABLE__) {
throw new Exception(_t('Item is not out'));
}
$va_reservations = $this->objectHasReservations($pn_object_id);
// is object already reserved by this user?
if (is_array($va_reservations)) {
foreach ($va_reservations as $va_reservation) {
if ($va_reservation['user_id'] == $pn_user_id) {
throw new Exception(_t('Item is already reserved by this user'));
}
}
}
$vs_uuid = $this->getTransactionUUID();
$va_checkout_config = ca_object_checkouts::getObjectCheckoutConfigForType($t_object->getTypeCode());
$this->setMode(ACCESS_WRITE);
$this->set(array('group_uuid' => $vs_uuid, 'object_id' => $pn_object_id, 'user_id' => $pn_user_id, 'checkout_notes' => $ps_notes));
// Do we need to set values?
if (is_array($va_checkout_config['set_values']) && sizeof($va_checkout_config['set_values'])) {
$t_object->setMode(ACCESS_WRITE);
foreach ($va_checkout_config['set_values'] as $vs_attr => $va_attr_values_by_event) {
if (!is_array($va_attr_values_by_event['reserve'])) {
if ($t_object->hasField($vs_attr)) {
// Intrinsic
$t_object->set($vs_attr, $va_attr_values_by_event['reserve']);
}
} else {
$va_attr_values['locale_id'] = $g_ui_locale_id;
$t_object->replaceAttribute($va_attr_values_by_event['reserve'], $vs_attr);
}
$t_object->update();
if ($t_object->numErrors()) {
$this->errors = $t_object->errors;
if ($vb_we_set_transaction) {
$o_trans->rollback();
}
return false;
}
}
}
$vn_rc = $this->insert();
if ($vb_we_set_transaction) {
$vn_rc ? $o_trans->commit() : $o_trans->rollback();
}
return $vn_rc;
}
示例4: isComponent
/**
* Check if currently loaded object is a component
*
* @return bool
*/
public function isComponent()
{
$va_container_types = $this->getAppConfig()->getList('ca_objects_container_types');
$va_component_types = $this->getAppConfig()->getList('ca_objects_component_types');
if (!is_array($va_container_types) || !sizeof($va_container_types)) {
return false;
}
if (!is_array($va_component_types) || !sizeof($va_component_types)) {
return false;
}
if (!($vn_parent_id = $this->get('parent_id'))) {
return false;
}
// component must be in a container
if (!in_array($this->getTypeCode(), $va_component_types) && !in_array('*', $va_component_types)) {
return false;
}
// check component type
$t_parent = new ca_objects($vn_parent_id);
if (!$t_parent->getPrimaryKey()) {
return false;
}
if (!in_array($t_parent->getTypeCode(), $va_container_types) && !in_array('*', $va_container_types)) {
return false;
}
// check container type
return true;
}
示例5: media
/**
*
*/
public function media()
{
if (!is_object($t_entity = $this->_checkEntity())) {
return $t_entity;
}
$vn_id = $t_entity->getPrimaryKey();
$t_list = new ca_lists();
$vn_exhibition_audio_type_id = $t_list->getItemIDFromList('object_types', 'MemEx_Audio');
$vs_filter = $this->opo_request->getParameter('filter', pString);
if (!in_array($vs_filter, array('video', 'audio', 'image', 'pdf'))) {
$vs_filter = null;
}
$t_object = new ca_objects();
$va_data = array('id' => $vn_id);
$from = $this->opo_request->getParameter('from', pString);
$until = $this->opo_request->getParameter('until', pString);
if (!$until) {
$until = date('c');
}
$vs_range = $from && $until ? self::utcToDb($from) . ' to ' . self::utcToDb($until) : null;
$o_tep = new TimeExpressionParser();
$vb_parsed_date = false;
if ($vs_range) {
if ($vb_parsed_date = $o_tep->parse($vs_range)) {
$va_range = $o_tep->getUnixTimestamps();
}
}
$t_rep = new ca_object_representations();
$t_list = new ca_lists();
$va_pub_target_values = $t_list->getItemsForList('object_publication_targets', array('extractValuesByUserLocale' => true));
$va_audio_target_values = $t_list->getItemsForList('audio_publication_targets', array('extractValuesByUserLocale' => true));
$vn_memorial_exhibition_audio_type_id = $t_list->getItemIDFromList('object_types', 'MemEx_Audio');
$vn_publish_annotation_id = $t_list->getItemIDFromList('annotation_publication_targets', 'interactive_tables');
$vn_publish_rep = $t_list->getItemIDFromList("memex_status", "publish");
$va_objects = $t_entity->getRelatedItems('ca_objects');
foreach ($va_objects as $vn_relation_id => $va_object_info) {
$va_timestamp = $t_object->getLastChangeTimestamp($va_object_info['object_id']);
if ($vb_parsed_date && ($va_timestamp['timestamp'] <= $va_range['start'] || $va_timestamp['timestamp'] >= $va_range['end'])) {
continue;
}
if ($t_object->load($va_object_info['object_id'])) {
$va_reps = $t_object->getRepresentations(array("preview", "preview170", "icon", "small", "medium", "large", "large_png", "original", "h264_hi", "mp3"));
if (!is_array($va_reps) || !sizeof($va_reps)) {
continue;
}
$va_filtered_reps = array();
foreach ($va_reps as $vn_i => $va_rep) {
$va_tmp = explode('/', $vs_mimetype = $va_rep['info']['original']['MIMETYPE']);
if ($vs_filter && ($va_tmp[0] != $vs_filter && $va_tmp[1] != $vs_filter)) {
continue;
}
$vb_is_audio = false;
if ($t_object->get('type_id') == $vn_memorial_exhibition_audio_type_id) {
$va_pub_targets = $t_object->get('ca_objects.audio_publication_targets', array('returnAsArray' => true, 'convertCodesToDisplayText' => false));
$vb_is_audio = true;
} else {
$va_pub_targets = $t_object->get('ca_objects.object_publication_targets', array('returnAsArray' => true, 'convertCodesToDisplayText' => false));
}
if (!sizeof($va_pub_targets)) {
continue;
}
if (!$t_rep->load($va_rep['representation_id'])) {
continue;
}
if ($t_rep->get("ca_object_representations.memex_status", array('convertCodesToDisplayText' => false)) != $vn_publish_rep) {
continue;
}
// reset filesize property to reflect size of version, not size of original
foreach ($va_reps[$vn_i]['paths'] as $vs_version => $vs_path) {
$va_reps[$vn_i]['info'][$vs_version]['PROPERTIES']['filesize'] = @filesize($va_reps[$vn_i]['paths'][$vs_version]);
}
unset($va_reps[$vn_i]['paths']);
unset($va_reps[$vn_i]['tags']);
unset($va_reps[$vn_i]['media']);
unset($va_reps[$vn_i]['media_metadata']);
unset($va_reps[$vn_i]['is_primary']);
unset($va_reps[$vn_i]['name']);
unset($va_reps[$vn_i]['status']);
unset($va_reps[$vn_i]['locale_id']);
unset($va_reps[$vn_i]['type_id']);
$va_reps[$vn_i]['lastupdate_timestamp'] = date('o-m-N', $va_timestamp['timestamp']) . "T" . date('H:i:s', $va_timestamp['timestamp']) . "Z";
//date('c', $va_timestamp['timestamp']);
$va_reps[$vn_i]['type_id'] = $vn_type_id = $t_object->get('ca_objects.type_id');
$va_reps[$vn_i]['typename'] = $t_object->getTypeName();
$va_reps[$vn_i]['typecode'] = $t_object->getTypeCode();
$va_targets = array();
foreach ($va_pub_targets as $vn_attr_id => $va_value) {
$va_targets[] = $va_pub_target_values[$va_value['object_publication_targets']]['idno'] ? $va_pub_target_values[$va_value['object_publication_targets']]['idno'] : $va_audio_target_values[$va_value['audio_publication_targets']]['idno'];
}
$va_reps[$vn_i]['publication_targets'] = $va_targets;
$va_reps[$vn_i]['title'] = $t_object->get('ca_objects.memex_title');
$va_reps[$vn_i]['credit'] = $t_object->get('ca_objects.memex_credit_line');
$va_reps[$vn_i]['caption'] = $t_object->get('ca_objects.memex_caption');
if ($t_object->get('type_id') == $vn_exhibition_audio_type_id) {
$va_reps[$vn_i]['transcript'] = $t_object->get('ca_objects.final_text_inner_chamber');
$va_reps[$vn_i]['attribution'] = $t_object->get('ca_objects.remembrance_attribution');
}
//.........这里部分代码省略.........