public function showAction() { parent::showAction(); $db = $this->_helper->db; $itemTable = $db->getTable('Item'); $itemAlias = $itemTable->getTableAlias(); $select = $itemTable->getSelectForFindBy(array(), is_admin_theme() ? 10 : 5); $rrTable = $db->getTable('RecordRelationsRelation'); $rrAlias = $rrTable->getTableAlias(); $select->joinInner(array($rrAlias => $rrTable->getTableName()), "{$rrAlias}.subject_id = {$itemAlias}.id", array()); $select->where("{$rrAlias}.object_id = ?", $this->view->collection->id); $select->where("{$rrAlias}.object_record_type = 'Collection'"); $select->where("{$rrAlias}.property_id = ?", get_record_relations_property_id(DCTERMS, 'isPartOf')); $select->where("{$rrAlias}.subject_record_type = 'Item'"); $this->view->items = $itemTable->fetchObjects($select); }
/** * Corresponds to function get_records('Item', array('collection' => $collection->id)). * * @uses get_records() * @param $num * @return array An array of Items. */ function multicollections_get_items_in_collection($num = 10, $item_type = null) { $collection = get_current_record('collection'); $db = get_db(); $itemTable = $db->getTable('Item'); $select = $itemTable->getSelect(); $select->limit($num); if ($item_type) { $type = $db->getTable('ItemType')->findByName($item_type); $select->where('item_type_id = ?', $type->id); } $select->joinInner(array('rr' => $db->RecordRelationsRelation), 'rr.subject_id = i.id', array()); $select->where('rr.object_id = ?', $collection->id); $select->where('rr.object_record_type = "Collection"'); $select->where('rr.property_id = ?', get_record_relations_property_id(DCTERMS, 'isPartOf')); $select->where('rr.subject_record_type = "Item"'); $items = $itemTable->fetchObjects($select); return $items; }
public static function defaultParams() { return array('subject_record_type' => 'Item', 'object_record_type' => 'Collection', 'property_id' => get_record_relations_property_id(DCTERMS, 'isPartOf'), 'public' => true); }
/** * returns an array of the most common parameters for queries */ static function defaultParams() { $params = array(); $params['subject_record_type'] = $this->subject_record_type; $params['object_record_type'] = $this->object_record_type; $params['property_id'] = get_record_relations_property_id($this->namespace, $this->local_part); if ($this->_isSubject) { $params['subject_id'] = $this->id; } else { $params['object_id'] = $this->id; } $params['public'] = true; return $params; }