本文整理汇总了PHP中ca_objects::getRelatedItems方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getRelatedItems方法的具体用法?PHP ca_objects::getRelatedItems怎么用?PHP ca_objects::getRelatedItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_objects
的用法示例。
在下文中一共展示了ca_objects::getRelatedItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: get
//.........这里部分代码省略.........
}
break;
case 'hierarchy':
$vs_direction = isset($pa_options['direction']) ? strtoupper($pa_options['direction']) : null;
if (!in_array($vs_direction, array('ASC', 'DESC'))) {
$vs_direction = 'ASC';
}
$vn_top = (int) isset($pa_options['top']) ? strtoupper($pa_options['top']) : 0;
if ($vn_top < 0) {
$vn_top = 0;
}
$vn_bottom = (int) isset($pa_options['bottom']) ? strtoupper($pa_options['bottom']) : 0;
if ($vn_bottom < 0) {
$vn_bottom = 0;
}
$vs_pk = $this->primaryKey();
$vs_label_table_name = $this->getLabelTableName();
$t_label_instance = $this->getLabelTableInstance();
if (!$vs_template && ($vs_display_field = $t_label_instance->hasField($va_tmp[2]) ? $t_label_instance->tableName() . "." . $va_tmp[2] : ($this->hasField($va_tmp[2]) ? $this->tableName() . "." . $va_tmp[2] : null))) {
$vs_template = "^{$vs_display_field}";
}
$vn_top_id = null;
if (!($va_ancestor_list = $this->getHierarchyAncestors(null, array('idsOnly' => true, 'includeSelf' => true)))) {
$va_ancestor_list = array();
}
// TODO: this should really be in a model subclass
if ($this->tableName() == 'ca_objects' && $this->getAppConfig()->get('ca_objects_x_collections_hierarchy_enabled') && ($vs_coll_rel_type = $this->getAppConfig()->get('ca_objects_x_collections_hierarchy_relationship_type'))) {
require_once __CA_MODELS_DIR__ . '/ca_objects.php';
if ($this->getPrimaryKey() == $vn_top_id) {
$t_object = $this;
} else {
$t_object = new ca_objects($vn_top_id);
}
if (is_array($va_collections = $t_object->getRelatedItems('ca_collections', array('restrictToRelationshipTypes' => $vs_coll_rel_type)))) {
require_once __CA_MODELS_DIR__ . '/ca_collections.php';
$t_collection = new ca_collections();
foreach ($va_collections as $vn_i => $va_collection) {
if ($va_collections_ancestor_list = $t_collection->getHierarchyAncestors($va_collection['collection_id'], array('idsOnly' => true, 'includeSelf' => true))) {
$va_ancestor_list = array_merge($va_ancestor_list, $va_collections_ancestor_list);
}
break;
// for now only process first collection (no polyhierarchies)
}
}
}
// remove root and children if so desired
if (isset($pa_options['removeFirstItems']) && (int) $pa_options['removeFirstItems'] > 0) {
for ($vn_i = 0; $vn_i < (int) $pa_options['removeFirstItems']; $vn_i++) {
array_pop($va_ancestor_list);
}
}
if ($vs_display_field != $va_tmp[2]) {
if ($this->hasField($va_tmp[2])) {
$vs_display_field = $va_tmp[2];
}
}
$vb_check_access = is_array($pa_options['checkAccess']) && $this->hasField('access');
if ($vb_check_access) {
$va_access_values = $this->getFieldValuesForIDs($va_ancestor_list, array('access'));
$va_ancestor_list = array();
foreach ($va_access_values as $vn_ancestor_id => $vn_access_value) {
if (in_array($vn_access_value, $pa_options['checkAccess'])) {
$va_ancestor_list[] = $vn_ancestor_id;
}
}
}
示例4: getLocationContentsHTMLFormBundle
/**
* Returns HTML form bundle for location contents
*
* @param HTTPRequest $po_request The current request
* @param string $ps_form_name
* @param string $ps_placement_code
* @param array $pa_bundle_settings
* @param array $pa_options Array of options. Options include:
* None yet.
*
* @return string Rendered HTML bundle
*/
public function getLocationContentsHTMLFormBundle($po_request, $ps_form_name, $ps_placement_code, $pa_bundle_settings = null, $pa_options = null)
{
require_once __CA_MODELS_DIR__ . "/ca_movements.php";
require_once __CA_MODELS_DIR__ . "/ca_movements_x_objects.php";
require_once __CA_MODELS_DIR__ . "/ca_objects_x_storage_locations.php";
global $g_ui_locale;
$o_view = new View($po_request, $po_request->getViewsDirectoryPath() . '/bundles/');
if (!is_array($pa_options)) {
$pa_options = array();
}
$vs_display_template = caGetOption('displayTemplate', $pa_bundle_settings, _t('No template defined'));
$o_view->setVar('id_prefix', $ps_form_name);
$o_view->setVar('placement_code', $ps_placement_code);
// pass placement code
$o_view->setVar('settings', $pa_bundle_settings);
$o_view->setVar('add_label', isset($pa_bundle_settings['add_label'][$g_ui_locale]) ? $pa_bundle_settings['add_label'][$g_ui_locale] : null);
$o_view->setVar('t_subject', $this);
$o_view->setVar('mode', $vs_mode = caGetOption('locationTrackingMode', $pa_bundle_settings, 'ca_movements'));
switch ($vs_mode) {
case 'ca_storage_locations':
// Get current storage locations
$o_view->setVar('t_subject_rel', new ca_objects_x_storage_locations());
// Get current objects for location
$va_object_ids = $this->getRelatedItems('ca_objects', array('idsOnly' => true));
if (is_array($va_object_ids) && sizeof($va_object_ids)) {
// check each object for current location
// ... then get the list of objects for which the *current* movement is one of ours
$t_object = new ca_objects();
$va_current_locations_ids = $t_object->getRelatedItems('ca_storage_locations', array('idsOnly' => false, 'showCurrentOnly' => true, 'row_ids' => $va_object_ids));
$va_object_rels = array();
foreach ($va_current_locations_ids as $vn_relation_id => $va_location_info) {
if ($va_location_info['location_id'] == $this->getPrimaryKey()) {
$va_object_rels[] = $vn_relation_id;
}
}
$o_view->setVar('qr_result', sizeof($va_object_rels) ? caMakeSearchResult('ca_objects_x_storage_locations', $va_object_rels) : null);
}
break;
case 'ca_movements':
default:
// Get current movements for location
$va_movement_ids = $this->getRelatedItems('ca_movements', array('idsOnly' => true));
if (is_array($va_movement_ids) && sizeof($va_movement_ids)) {
// get list of objects on these movements...
$t_movement = new ca_movements();
$va_object_ids = $t_movement->getRelatedItems('ca_objects', array('idsOnly' => true, 'showCurrentOnly' => true, 'row_ids' => $va_movement_ids));
// ... then get the list of objects for which the *current* movement is one of ours
$t_object = new ca_objects();
$va_current_movement_ids = $t_object->getRelatedItems('ca_movements', array('idsOnly' => false, 'showCurrentOnly' => true, 'row_ids' => $va_object_ids));
$va_movement_rels = array();
foreach ($va_current_movement_ids as $vn_relation_id => $va_movement_info) {
if (in_array($va_movement_info['movement_id'], $va_movement_ids)) {
$va_movement_rels[] = $vn_relation_id;
}
}
$o_view->setVar('qr_result', sizeof($va_movement_rels) ? caMakeSearchResult('ca_movements_x_objects', $va_movement_rels) : null);
}
$o_view->setVar('t_subject_rel', new ca_movements_x_objects());
break;
}
return $o_view->render('ca_storage_locations_contents.php');
}