当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_objects::getPrimaryKey方法代码示例

本文整理汇总了PHP中ca_objects::getPrimaryKey方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getPrimaryKey方法的具体用法?PHP ca_objects::getPrimaryKey怎么用?PHP ca_objects::getPrimaryKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_objects的用法示例。


在下文中一共展示了ca_objects::getPrimaryKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAllItemInfo

 protected function getAllItemInfo()
 {
     $va_info = parent::getAllItemInfo();
     if ($this->getTableName() == 'ca_objects' && is_array($va_info) && sizeof($va_info) > 0) {
         $t_object = new ca_objects($va_info['object_id']['value']);
         if (!$t_object->getPrimaryKey()) {
             return $va_info;
         }
         // include number of 'likes' (comments)
         $va_info['likes'] = (int) $t_object->getNumComments(null);
         // include copyright holder
         $vs_copyright_holder = $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => 'copyright'));
         if ($vs_copyright_holder) {
             $va_info['copyright_holder'] = $vs_copyright_holder;
         }
         // include urls for reference img
         $va_objects = $t_object->getRelatedItems('ca_objects', array('restrictToRelationshipTypes' => 'reference'));
         if (!is_array($va_objects) || sizeof($va_objects) != 1) {
             return $va_info;
         }
         $va_object = array_shift($va_objects);
         $t_rel_object = new ca_objects($va_object['object_id']);
         $va_rep = $t_rel_object->getPrimaryRepresentation(array('preview170', 'medium', 'alhalqa1000', 'alhalqa2000'));
         if (!is_array($va_rep) || !is_array($va_rep['urls'])) {
             return $va_info;
         }
         $va_info['reference_image_urls'] = $va_rep['urls'];
     }
     return $va_info;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:30,代码来源:AlhalqaItemService.php

示例2: 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');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:17,代码来源:CheckInController.php

示例3: search

 protected function search($pa_bundles = null)
 {
     $va_return = parent::search($pa_bundles);
     if ($this->getTableName() == 'ca_objects' && is_array($va_return['results']) && sizeof($va_return['results']) > 0) {
         $pb_only_with_likes = (bool) $this->opo_request->getParameter('likesOnly', pInteger);
         foreach ($va_return['results'] as $vn_k => &$va_result) {
             $t_object = new ca_objects($va_result['object_id']);
             if (!$t_object->getPrimaryKey()) {
                 continue;
             }
             // include number of 'likes' (comments)
             $va_result['likes'] = (int) $t_object->getNumComments(null);
             if ($pb_only_with_likes && !$va_result['likes']) {
                 unset($va_return['results'][$vn_k]);
                 continue;
             }
             // include copyright holder
             $vs_copyright_holder = $t_object->get('ca_entities.preferred_labels', array('restrictToRelationshipTypes' => 'copyright'));
             if ($vs_copyright_holder) {
                 $va_result['copyright_holder'] = $vs_copyright_holder;
             }
             // include urls for reference img
             $va_objects = $t_object->getRelatedItems('ca_objects', array('restrictToRelationshipTypes' => 'reference'));
             if (!is_array($va_objects) || sizeof($va_objects) != 1) {
                 continue;
             }
             $va_object = array_shift($va_objects);
             $t_rel_object = new ca_objects($va_object['object_id']);
             $va_rep = $t_rel_object->getPrimaryRepresentation(array('preview170', 'medium', 'alhalqa1000', 'alhalqa2000'));
             if (!is_array($va_rep) || !is_array($va_rep['urls'])) {
                 continue;
             }
             $va_result['reference_image_urls'] = $va_rep['urls'];
         }
         if ($this->opo_request->getParameter('sort', pString) == 'likes') {
             if (strtolower($this->opo_request->getParameter('sortDirection', pString)) == 'asc') {
                 usort($va_return['results'], function ($a, $b) {
                     return $a['likes'] - $b['likes'];
                 });
             } else {
                 // default is desc
                 usort($va_return['results'], function ($a, $b) {
                     return $b['likes'] - $a['likes'];
                 });
             }
         }
     }
     return $va_return;
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:49,代码来源:AlhalqaSearchService.php

示例4: setUp

 public function setUp()
 {
     $t_list = new ca_lists();
     // add a minimal object for testing
     $va_object_types = $t_list->getItemsForList('object_types', array('idsOnly' => true, 'enabledOnly' => true));
     $t_object = new ca_objects();
     $t_object->setMode(ACCESS_WRITE);
     $t_object->set('type_id', array_shift($va_object_types));
     $t_object->insert();
     $this->opn_object_id = $t_object->getPrimaryKey();
     $this->assertGreaterThan(0, $this->opn_object_id, 'Object should have a primary key after insert');
     // add minimal set
     $va_set_types = $t_list->getItemsForList('set_types', array('idsOnly' => true, 'enabledOnly' => true));
     $t_set = new ca_sets();
     $t_set->setMode(ACCESS_WRITE);
     $t_set->set('type_id', array_shift($va_set_types));
     $t_set->set('table_num', $t_object->tableNum());
     $t_set->insert();
     $this->opn_set_id = $t_set->getPrimaryKey();
     $this->assertGreaterThan(0, $this->opn_set_id, 'Set should have a primary key after insert');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:21,代码来源:ca_setsTest.php

示例5: _renderMediaView

 /**
  * Returns content for overlay containing details for object representation
  */
 private function _renderMediaView($ps_view_name, $ps_media_context)
 {
     $pn_object_id = $this->request->getParameter('object_id', pInteger);
     $pn_representation_id = $this->request->getParameter('representation_id', pInteger);
     $pn_year = $this->request->getParameter('year', pInteger);
     $this->view->setVar("year", $pn_year);
     $va_periods = $this->ops_periods;
     $this->view->setVar('object_id', $pn_object_id);
     $t_object = new ca_objects($pn_object_id);
     # --- get caption and photocredit
     $this->view->setVar("caption", $t_object->get("description"));
     $this->view->setVar("photographer", $t_object->get("provenance"));
     $t_rep = new ca_object_representations($pn_representation_id);
     $this->view->setVar('representation_id', $pn_representation_id);
     $this->view->setVar('t_object_representation', $t_rep);
     if ($this->request->config->get("dont_enforce_access_settings")) {
         $va_access_values = array();
     } else {
         $va_access_values = caGetUserAccessValues($this->request);
     }
     if (!$t_object->getPrimaryKey()) {
         die("Invalid object_id");
     }
     if (!$t_rep->getPrimaryKey()) {
         die("Invalid representation_id");
     }
     if (sizeof($va_access_values) && !in_array($t_object->get('access'), $va_access_values)) {
         die("Invalid object_id");
     }
     if (sizeof($va_access_values) && !in_array($t_rep->get('access'), $va_access_values)) {
         die("Invalid rep_id");
     }
     $this->view->setVar('t_display_rep', $t_rep);
     // Get media for display using configured rules
     $va_rep_display_info = caGetMediaDisplayInfo($ps_media_context, $t_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
     // set version
     $this->view->setVar('display_version', $va_rep_display_info['display_version']);
     // set other options
     $this->view->setVar('display_options', $va_rep_display_info);
     // Get all representation as icons for navigation
     # --- do a search for all chronology image objects
     # --- determine the period from the year
     foreach ($va_periods as $i => $va_per_info) {
         if ($pn_year >= $va_per_info["start"] && $pn_year <= $va_per_info["end"]) {
             $vn_period = $i;
             break;
         }
     }
     # --- what is year to search by?
     $vn_y = "";
     if ($va_periods[$vn_period]["displayAllYears"] == 1) {
         $vn_y = $va_periods[$vn_period]["start"] . "-" . $va_periods[$vn_period]["end"];
     } else {
         $vn_y = $pn_year;
     }
     # --- get type is for chron images
     $t_list = new ca_lists();
     $vn_chron_images_type_id = $t_list->getItemIDFromList('object_types', 'chronology_image');
     $o_obj_search = new ObjectSearch();
     $qr_chron_images = $o_obj_search->search("ca_objects.access:1 AND ca_objects.date.parsed_date:\"" . $vn_y . "\" AND ca_objects.type_id:{$vn_chron_images_type_id}", array("sort" => "ca_objects.date.parsed_date", "no_cache" => !$this->opb_cache_searches));
     $va_thumbnails = array();
     if ($qr_chron_images->numHits() > 0) {
         $t_image_objects = new ca_objects();
         $i = 1;
         while ($qr_chron_images->nextHit()) {
             $t_image_objects->load($qr_chron_images->get("ca_objects.object_id"));
             if ($t_primary_rep = $t_image_objects->getPrimaryRepresentationInstance()) {
                 $va_temp = array();
                 if (!sizeof($va_access_values) || in_array($t_primary_rep->get('access'), $va_access_values)) {
                     $va_temp["representation_id"] = $t_primary_rep->get("representation_id");
                     $va_temp["rep_icon"] = $t_primary_rep->getMediaTag('media', 'icon');
                     $va_temp["rep_tiny"] = $t_primary_rep->getMediaTag('media', 'tinyicon');
                     $va_temp["object_id"] = $qr_chron_images->get("ca_objects.object_id");
                     $va_thumbnails[$qr_chron_images->get("ca_objects.object_id")] = $va_temp;
                     if ($vn_getNext == 1) {
                         $this->view->setVar("next_object_id", $qr_chron_images->get("object_id"));
                         $this->view->setVar("next_representation_id", $t_primary_rep->get("representation_id"));
                         $vn_getNext = 0;
                     }
                     if ($qr_chron_images->get("object_id") == $pn_object_id) {
                         $this->view->setVar("representation_index", $i);
                         $this->view->setVar("previous_object_id", $vn_prev_obj_id);
                         $this->view->setVar("previous_representation_id", $vn_prev_rep_id);
                         $vn_getNext = 1;
                     }
                     $vn_prev_obj_id = $qr_chron_images->get("object_id");
                     $vn_prev_rep_id = $t_primary_rep->get("representation_id");
                     $i++;
                 }
             }
         }
     }
     $this->view->setVar('reps', $va_thumbnails);
     return $this->render("Chronology/{$ps_view_name}.php");
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:98,代码来源:ChronologyController.php

示例6: DownloadMedia

 /**
  * Download all media attached to specified object (not necessarily open for editing)
  * Includes all representation media attached to the specified object + any media attached to oter
  * objects in the same object hierarchy as the specified object. Used by the book viewer interfacce to 
  * initiate a download.
  */
 public function DownloadMedia()
 {
     if (!caObjectsDisplayDownloadLink($this->request)) {
         $this->postError(1100, _t('Cannot download media'), 'DetailController->DownloadMedia');
         return;
     }
     $pn_object_id = $this->request->getParameter('object_id', pInteger);
     $t_object = new ca_objects($pn_object_id);
     if (!($vn_object_id = $t_object->getPrimaryKey())) {
         return;
     }
     $ps_version = $this->request->getParameter('version', pString);
     if (!$ps_version) {
         $ps_version = 'original';
     }
     $this->view->setVar('version', $ps_version);
     $va_ancestor_ids = $t_object->getHierarchyAncestors(null, array('idsOnly' => true, 'includeSelf' => true));
     if ($vn_parent_id = array_pop($va_ancestor_ids)) {
         $t_object->load($vn_parent_id);
         array_unshift($va_ancestor_ids, $vn_parent_id);
     }
     $va_child_ids = $t_object->getHierarchyChildren(null, array('idsOnly' => true));
     foreach ($va_ancestor_ids as $vn_id) {
         array_unshift($va_child_ids, $vn_id);
     }
     $vn_c = 1;
     $va_file_names = array();
     $va_file_paths = array();
     foreach ($va_child_ids as $vn_object_id) {
         $t_object = new ca_objects($vn_object_id);
         if (!$t_object->getPrimaryKey()) {
             continue;
         }
         $va_reps = $t_object->getRepresentations(array($ps_version));
         $vs_idno = $t_object->get('idno');
         foreach ($va_reps as $vn_representation_id => $va_rep) {
             $va_rep_info = $va_rep['info'][$ps_version];
             $vs_idno_proc = preg_replace('![^A-Za-z0-9_\\-]+!', '_', $vs_idno);
             switch ($this->request->user->getPreference('downloaded_file_naming')) {
                 case 'idno':
                     $vs_file_name = $vs_idno_proc . '_' . $vn_c . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'idno_and_version':
                     $vs_file_name = $vs_idno_proc . '_' . $ps_version . '_' . $vn_c . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'idno_and_rep_id_and_version':
                     $vs_file_name = $vs_idno_proc . '_representation_' . $vn_representation_id . '_' . $ps_version . '.' . $va_rep_info['EXTENSION'];
                     break;
                 case 'original_name':
                 default:
                     if ($va_rep['info']['original_filename']) {
                         $va_tmp = explode('.', $va_rep['info']['original_filename']);
                         if (sizeof($va_tmp) > 1) {
                             if (strlen($vs_ext = array_pop($va_tmp)) < 3) {
                                 $va_tmp[] = $vs_ext;
                             }
                         }
                         $vs_file_name = join('_', $va_tmp);
                     } else {
                         $vs_file_name = $vs_idno_proc . '_representation_' . $vn_representation_id . '_' . $ps_version;
                     }
                     if (isset($va_file_names[$vs_file_name . '.' . $va_rep_info['EXTENSION']])) {
                         $vs_file_name .= "_{$vn_c}";
                     }
                     $vs_file_name .= '.' . $va_rep_info['EXTENSION'];
                     break;
             }
             $va_file_names[$vs_file_name] = true;
             $this->view->setVar('version_download_name', $vs_file_name);
             //
             // Perform metadata embedding
             $t_rep = new ca_object_representations($va_rep['representation_id']);
             if (!($vs_path = caEmbedMetadataIntoRepresentation($t_object, $t_rep, $ps_version))) {
                 $vs_path = $t_rep->getMediaPath('media', $ps_version);
             }
             $va_file_paths[$vs_path] = $vs_file_name;
             $vn_c++;
         }
     }
     if (sizeof($va_file_paths) > 1) {
         if (!($vn_limit = ini_get('max_execution_time'))) {
             $vn_limit = 30;
         }
         set_time_limit($vn_limit * 2);
         $o_zip = new ZipFile();
         foreach ($va_file_paths as $vs_path => $vs_name) {
             $o_zip->addFile($vs_path, $vs_name, null, array('compression' => 0));
             // don't try to compress
         }
         $this->view->setVar('archive_path', $vs_path = $o_zip->output(ZIPFILE_FILEPATH));
         $this->view->setVar('archive_name', preg_replace('![^A-Za-z0-9\\.\\-]+!', '_', $t_object->get('idno')) . '.zip');
         $this->response->sendHeaders();
         $vn_rc = $this->render('Details/object_download_media_binary.php');
         $this->response->sendContent();
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:DetailController.php

示例7: getObjectID


//.........这里部分代码省略.........
             $vn_id = ca_objects::find($va_find_arr, array('returnAs' => 'firstId', 'transaction' => $pa_options['transaction']));
         }
     }
     if (!$vn_id) {
         if (isset($pa_options['dontCreate']) && $pa_options['dontCreate']) {
             return false;
         }
         if ($o_event) {
             $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;
         }
         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_value) {
                 if (is_array($va_value)) {
                     // array of values (complex multi-valued attribute)
                     $t_object->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
                 } else {
                     // scalar value (simple single value attribute)
                     if ($va_value) {
                         $t_object->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                     }
                 }
             }
         }
         $t_object->update();
         if ($t_object->numErrors()) {
             if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                 print "[Error] " . _t("Could not set values for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())) . "\n";
             }
             if ($o_log) {
                 $o_log->logError(_t("Could not set values for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())));
             }
             $vb_attr_errors = true;
         }
         $vn_object_id = $t_object->getPrimaryKey();
         if ($o_event) {
             if ($vb_attr_errors || $vb_label_errors) {
                 $o_event->endItem($vn_object_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_object->getErrors())));
             } else {
                 $o_event->endItem($vn_object_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
             }
         }
         if ($o_log) {
             $o_log->logInfo(_t("Created new object %1", $ps_object_name));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return $t_object;
         }
     } else {
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_objects', 'U');
         }
         $vn_object_id = $vn_id;
         if ($o_event) {
             $o_event->endItem($vn_object_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
         }
         if ($o_log) {
             $o_log->logDebug(_t("Found existing object %1 in DataMigrationUtils::getObjectID(); total of %2 objects were found", $ps_collection_name, sizeof($va_object_ids) + 1));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return new ca_objects($vn_object_id);
         }
     }
     return $vn_object_id;
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:DataMigrationUtils.php

示例8: getObjectID


//.........这里部分代码省略.........
                 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);
                 }
                 foreach ($va_values as $va_value) {
                     if (is_array($va_value)) {
                         // array of values (complex multi-valued attribute)
                         $t_object->addAttribute(array_merge($va_value, array('locale_id' => $pn_locale_id)), $vs_element);
                     } else {
                         // scalar value (simple single value attribute)
                         if ($va_value) {
                             $t_object->addAttribute(array('locale_id' => $pn_locale_id, $vs_element => $va_value), $vs_element);
                         }
                     }
                 }
             }
             $t_object->update();
             if ($t_object->numErrors()) {
                 if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                     print "[Error] " . _t("Could not set values for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())) . "\n";
                 }
                 if ($o_log) {
                     $o_log->logError(_t("Could not set values for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())));
                 }
                 $vb_attr_errors = true;
             }
         }
         if (is_array($va_nonpreferred_labels = caGetOption("nonPreferredLabels", $pa_options, null))) {
             if (caIsAssociativeArray($va_nonpreferred_labels)) {
                 // single non-preferred label
                 $va_labels = array($va_nonpreferred_labels);
             } else {
                 // list of non-preferred labels
                 $va_labels = $va_nonpreferred_labels;
             }
             foreach ($va_labels as $va_label) {
                 $t_object->addLabel($va_label, $pn_locale_id, null, false);
                 if ($t_object->numErrors()) {
                     if (isset($pa_options['outputErrors']) && $pa_options['outputErrors']) {
                         print "[Error] " . _t("Could not set non-preferred label for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())) . "\n";
                     }
                     if ($o_log) {
                         $o_log->logError(_t("Could not set non-preferred label for object %1: %2", $ps_object_name, join('; ', $t_object->getErrors())));
                     }
                 }
             }
         }
         $vn_object_id = $t_object->getPrimaryKey();
         if ($o_event) {
             if ($vb_attr_errors || $vb_label_errors) {
                 $o_event->endItem($vn_object_id, __CA_DATA_IMPORT_ITEM_PARTIAL_SUCCESS__, _t("Errors setting field values: %1", join('; ', $t_object->getErrors())));
             } else {
                 $o_event->endItem($vn_object_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
             }
         }
         if ($o_log) {
             $o_log->logInfo(_t("Created new object %1", $ps_object_name));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             return $t_object;
         }
     } else {
         if ($o_event) {
             $o_event->beginItem($vs_event_source, 'ca_objects', 'U');
         }
         $vn_object_id = $vn_id;
         if ($o_event) {
             $o_event->endItem($vn_object_id, __CA_DATA_IMPORT_ITEM_SUCCESS__, '');
         }
         if ($o_log) {
             $o_log->logDebug(_t("Found existing object %1 in DataMigrationUtils::getObjectID()", $ps_object_name));
         }
         if (isset($pa_options['returnInstance']) && $pa_options['returnInstance']) {
             $t_object = new ca_objects($vn_object_id);
             if (isset($pa_options['transaction']) && $pa_options['transaction'] instanceof Transaction) {
                 $t_object->setTransaction($pa_options['transaction']);
             }
             return $t_object;
         }
     }
     return $vn_object_id;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:101,代码来源:DataMigrationUtils.php

示例9: testGetAttributeCount

 public function testGetAttributeCount()
 {
     $t_element = ca_attributes::getElementInstance('internal_notes');
     $this->opt_object->getDb()->dieOnError(true);
     $this->assertEquals(2, ca_attributes::getAttributeCount($this->opt_object->getDb(), $this->opt_object->tableNum(), $this->opt_object->getPrimaryKey(), $t_element->getPrimaryKey()));
 }
开发者ID:samrahman,项目名称:providence,代码行数:6,代码来源:CaAttributesTest.php

示例10: testPrepopulateFieldsOverwriteContainer

 public function testPrepopulateFieldsOverwriteContainer()
 {
     // load config
     $va_prepopulate_options = array('prepopulateConfig' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . 'prepopulate_container_overwrite.conf');
     $t_object = new ca_objects();
     $t_object->setMode(ACCESS_WRITE);
     $t_object->set('type_id', 'image');
     $t_object->set('idno', 'test123');
     $t_object->addAttribute(array('url_entry' => "http://en.wikipedia.org", 'url_source' => 'Wikipedia'), 'external_link');
     $t_object->insert();
     $this->assertGreaterThan(0, $t_object->getPrimaryKey(), 'Primary key for new object must be greater than 0');
     $this->opa_test_record_ids['ca_objects'][] = $t_object->getPrimaryKey();
     $o_plugin = new prepopulatePlugin(__CA_APP_DIR__ . '/plugins/prepopulate');
     $this->assertTrue($o_plugin->prepopulateFields($t_object, $va_prepopulate_options), 'Prepopulate should return true');
     $this->assertEquals('test123', $t_object->get('ca_objects.external_link.url_source'), 'url source must prepopulate');
     $this->assertEquals("http://en.wikipedia.org", $t_object->get('ca_objects.external_link.url_entry'), 'url entry must not change');
 }
开发者ID:samrahman,项目名称:providence,代码行数:17,代码来源:BundlableLabelableBaseModelWithAttributesTest.php

示例11: 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');
 }
开发者ID:samrahman,项目名称:providence,代码行数:70,代码来源:CheckOutController.php

示例12: importMediaFromDirectory

 /**
  * @param array $pa_options
  *		progressCallback =
  *		reportCallback = 
  *		sendMail = 
  */
 public static function importMediaFromDirectory($po_request, $pa_options = null)
 {
     global $g_ui_locale_id;
     $t_object = new ca_objects();
     $o_eventlog = new Eventlog();
     $t_set = new ca_sets();
     $va_notices = $va_errors = array();
     $vb_we_set_transaction = false;
     $o_trans = isset($pa_options['transaction']) && $pa_options['transaction'] ? $pa_options['transaction'] : null;
     if (!$o_trans) {
         $vb_we_set_transaction = true;
         $o_trans = new Transaction();
     }
     $o_log = new Batchlog(array('user_id' => $po_request->getUserID(), 'batch_type' => 'MI', 'table_num' => (int) $t_object->tableNum(), 'notes' => '', 'transaction' => $o_trans));
     if (!is_dir($pa_options['importFromDirectory'])) {
         $o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
         return null;
     }
     $vs_batch_media_import_root_directory = $po_request->config->get('batch_media_import_root_directory');
     if (!preg_match("!^{$vs_batch_media_import_root_directory}!", $pa_options['importFromDirectory'])) {
         $o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
         return null;
     }
     if (preg_match("!/\\.\\.!", $vs_directory) || preg_match("!\\.\\./!", $pa_options['importFromDirectory'])) {
         $o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
         return null;
     }
     $vb_include_subdirectories = (bool) $pa_options['includeSubDirectories'];
     $vb_delete_media_on_import = (bool) $pa_options['deleteMediaOnImport'];
     $vs_import_mode = $pa_options['importMode'];
     $vs_match_mode = $pa_options['matchMode'];
     $vn_object_type_id = $pa_options['ca_objects_type_id'];
     $vn_rep_type_id = $pa_options['ca_object_representations_type_id'];
     $vn_object_access = $pa_options['ca_objects_access'];
     $vn_object_representation_access = $pa_options['ca_object_representations_access'];
     $vn_object_status = $pa_options['ca_objects_status'];
     $vn_object_representation_status = $pa_options['ca_object_representations_status'];
     $vs_idno_mode = $pa_options['idnoMode'];
     $vs_idno = $pa_options['idno'];
     $vs_set_mode = $pa_options['setMode'];
     $vs_set_create_name = $pa_options['setCreateName'];
     $vn_set_id = $pa_options['set_id'];
     $vn_locale_id = $pa_options['locale_id'];
     $vs_skip_file_list = $pa_options['skipFileList'];
     $va_relationship_type_id_for = array();
     if (is_array($va_create_relationship_for = $pa_options['create_relationship_for'])) {
         foreach ($va_create_relationship_for as $vs_rel_table) {
             $va_relationship_type_id_for[$vs_rel_table] = $pa_options['relationship_type_id_for_' . $vs_rel_table];
         }
     }
     if (!$vn_locale_id) {
         $vn_locale_id = $g_ui_locale_id;
     }
     $va_files_to_process = caGetDirectoryContentsAsList($pa_options['importFromDirectory'], $vb_include_subdirectories);
     if ($vs_set_mode == 'add') {
         $t_set->load($vn_set_id);
     } else {
         if ($vs_set_mode == 'create' && $vs_set_create_name) {
             $va_set_ids = $t_set->getSets(array('user_id' => $po_request->getUserID(), 'table' => 'ca_objects', 'access' => __CA_SET_EDIT_ACCESS__, 'setIDsOnly' => true, 'name' => $vs_set_create_name));
             $vn_set_id = null;
             if (is_array($va_set_ids) && sizeof($va_set_ids) > 0) {
                 $vn_possible_set_id = array_shift($va_set_ids);
                 if ($t_set->load($vn_possible_set_id)) {
                     $vn_set_id = $t_set->getPrimaryKey();
                 }
             } else {
                 $vs_set_code = mb_substr(preg_replace("![^A-Za-z0-9_\\-]+!", "_", $vs_set_create_name), 0, 100);
                 if ($t_set->load(array('set_code' => $vs_set_code))) {
                     $vn_set_id = $t_set->getPrimaryKey();
                 }
             }
             if (!$t_set->getPrimaryKey()) {
                 $t_set->setMode(ACCESS_WRITE);
                 $t_set->set('user_id', $po_request->getUserID());
                 $t_set->set('type_id', $po_request->config->get('ca_sets_default_type'));
                 $t_set->set('table_num', $t_object->tableNum());
                 $t_set->set('set_code', $vs_set_code);
                 $t_set->insert();
                 if ($t_set->numErrors()) {
                     $va_notices['create_set'] = array('idno' => '', 'label' => _t('Create set %1', $vs_set_create_name), 'message' => _t('Failed to create set %1: %2', $vs_set_create_name, join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
                 } else {
                     $t_set->addLabel(array('name' => $vs_set_create_name), $vn_locale_id, null, true);
                     if ($t_set->numErrors()) {
                         $va_notices['add_set_label'] = array('idno' => '', 'label' => _t('Add label to set %1', $vs_set_create_name), 'message' => _t('Failed to add label to set: %1', join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
                     }
                     $vn_set_id = $t_set->getPrimaryKey();
                 }
             }
         } else {
             $vn_set_id = null;
             // no set
         }
     }
     if ($t_set->getPrimaryKey() && !$t_set->haveAccessToSet($po_request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:BatchProcessor.php

示例13: 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;
 }
开发者ID:samrahman,项目名称:providence,代码行数:33,代码来源:ca_objects.php

示例14: caRepresentationViewerHTMLBundleForSearchResult

/**
 * 
 *
 * @param RequestHTTP $po_request
 * @param array $pa_options
 * @param array $pa_additional_display_options
 * @return string HTML output
 */
function caRepresentationViewerHTMLBundleForSearchResult($po_data, $po_request, $pa_options = null, $pa_additional_display_options = null)
{
    $ps_version = $po_request->getParameter('version', pString);
    $va_access_values = isset($pa_options['access']) && is_array($pa_options['access']) ? $pa_options['access'] : array();
    $vs_display_type = isset($pa_options['display']) && $pa_options['display'] ? $pa_options['display'] : 'media_overlay';
    $vs_container_dom_id = isset($pa_options['containerID']) && $pa_options['containerID'] ? $pa_options['containerID'] : null;
    $vn_object_id = isset($pa_options['object_id']) && $pa_options['object_id'] ? $pa_options['object_id'] : null;
    $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null;
    $vn_order_item_id = isset($pa_options['order_item_id']) && $pa_options['order_item_id'] ? $pa_options['order_item_id'] : null;
    $vb_media_editor = isset($pa_options['mediaEditor']) && $pa_options['mediaEditor'] ? true : false;
    $vb_no_controls = isset($pa_options['noControls']) && $pa_options['noControls'] ? true : false;
    $vn_item_id = isset($pa_options['item_id']) && $pa_options['item_id'] ? $pa_options['item_id'] : null;
    $t_object = new ca_objects($vn_object_id);
    //if (!$t_object->getPrimaryKey()) { return false; }
    if (!$po_data->getPrimaryKey() && $t_object->getPrimaryKey() && method_exists($po_data, 'load')) {
        $po_data->load($t_object->getPrimaryRepresentationID(array('checkAccess' => $va_access_values)));
    }
    $t_set_item = new ca_set_items();
    if ($vn_item_id) {
        $t_set_item->load($vn_item_id);
    }
    $t_order_item = new ca_commerce_order_items();
    if ($vn_order_item_id) {
        $t_order_item->load($vn_order_item_id);
    }
    $o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
    $o_view->setVar('t_object', $t_object);
    $o_view->setVar('t_set_item', $t_set_item);
    $o_view->setVar('t_order_item', $t_order_item);
    $o_view->setVar('use_media_editor', $vb_media_editor);
    $o_view->setVar('noControls', $vb_no_controls);
    $va_rep_display_info = array();
    if (isset($pa_options['use_book_viewer'])) {
        $va_rep_display_info['use_book_viewer'] = (bool) $pa_options['use_book_viewer'];
    }
    if ($t_object->getPrimaryKey()) {
        $o_view->setVar('reps', $va_reps = $t_object->getRepresentations(array('icon'), null, array("return_with_access" => $va_access_values)));
    }
    $t_media = new Media();
    $va_buf = array();
    while ($po_data->nextHit()) {
        if (method_exists($po_data, 'numFiles')) {
            $o_view->setVar('num_multifiles', $po_data->numFiles());
        }
        $o_view->setVar('t_object_representation', $po_data);
        if (($vn_representation_id = $po_data->getPrimaryKey()) && (!sizeof($va_access_values) || in_array($po_data->get('access'), $va_access_values))) {
            // check rep access
            $va_rep_display_info = caGetMediaDisplayInfo($vs_display_type, $vs_mimetype = $po_data->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
            $va_rep_display_info['poster_frame_url'] = $po_data->getMediaUrl('media', $va_rep_display_info['poster_frame_version']);
            $va_additional_display_options = array();
            if (is_array($pa_additional_display_options) && isset($pa_additional_display_options[$vs_mimetype]) && is_array($pa_additional_display_options[$vs_mimetype])) {
                $va_additional_display_options = $pa_additional_display_options[$vs_mimetype];
            }
            $o_view->setVar('display_options', caGetMediaDisplayInfo('detail', $vs_mimetype));
            $o_view->setVar('display_type', $vs_display_type);
            $o_view->setVar('representation_id', $vn_representation_id);
            $o_view->setVar('t_object_representation', $po_data);
            $o_view->setVar('versions', $va_versions = $po_data->getMediaVersions('media'));
            $o_view->setVar('containerID', $vs_container_dom_id . $vn_representation_id);
            $o_view->setVar('version_type', $t_media->getMimetypeTypename($po_data->getMediaInfo('media', 'original', 'MIMETYPE')));
            if ($t_object->getPrimaryKey()) {
                $vn_next_rep = $vn_prev_rep = null;
                $va_rep_list = array_values($va_reps);
                foreach ($va_rep_list as $vn_i => $va_rep) {
                    if ($va_rep['representation_id'] == $vn_representation_id) {
                        if (isset($va_rep_list[$vn_i - 1])) {
                            $vn_prev_rep = $va_rep_list[$vn_i - 1]['representation_id'];
                        }
                        if (isset($va_rep_list[$vn_i + 1])) {
                            $vn_next_rep = $va_rep_list[$vn_i + 1]['representation_id'];
                        }
                        $o_view->setVar('representation_index', $vn_i + 1);
                    }
                }
                $o_view->setVar('previous_representation_id', $vn_prev_rep);
                $o_view->setVar('next_representation_id', $vn_next_rep);
            }
            if (!in_array($ps_version, $va_versions)) {
                if (!($ps_version = $va_rep_display_info['display_version'])) {
                    $ps_version = null;
                }
            }
            $o_view->setVar('version_info', $po_data->getMediaInfo('media', $ps_version));
            $o_view->setVar('version', $ps_version);
        }
        $va_buf[$vn_representation_id] = $o_view->render('representation_viewer_html.php');
    }
    return $va_buf;
}
开发者ID:ffarago,项目名称:pawtucket2,代码行数:97,代码来源:displayHelpers.php

示例15: unlike

 /**
  * Remove all likes from object (for one user)
  * @param array $pa_data
  * @return bool
  */
 protected function unlike($pa_data)
 {
     if (!is_array($pa_data) || !isset($pa_data['object_id']) || !isset($pa_data['entity_id'])) {
         $this->addError("Malformed request body");
         return false;
     }
     $vn_object_id = (int) $pa_data['object_id'];
     $t_object = new ca_objects($vn_object_id);
     if (!$t_object->getPrimaryKey()) {
         $this->addError("Invalid object id");
         return false;
     }
     $vn_entity_id = (int) $pa_data['entity_id'];
     $t_entity = new ca_entities($vn_entity_id);
     if (!$t_entity->getPrimaryKey()) {
         $this->addError("Invalid entity id");
         return false;
     }
     $o_db = new Db();
     $qr_likes = $o_db->query("\n\t\t\tDELETE FROM ca_item_comments WHERE name = ? AND table_num = ? AND row_id = ?\n\t\t", $vn_entity_id, $t_object->tableNum(), $t_object->getPrimaryKey());
     if (!$qr_likes) {
         $this->addError('something may have went wrong');
         return false;
     }
     return array('msg' => 'like(s) successfully removed');
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:31,代码来源:AlhalqaCommunityService.php


注:本文中的ca_objects::getPrimaryKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。