public function execute($request) { $this->thumbnails = array(); // Set limit (null for no limit) if (!isset($request->showFullImageflow) || 'true' != $request->showFullImageflow) { $this->limit = sfConfig::get('app_hits_per_page', 10); } // Add thumbs $criteria = new Criteria(); $criteria->addJoin(QubitInformationObject::ID, QubitDigitalObject::INFORMATION_OBJECT_ID); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_THAN); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_THAN); if (isset($this->limit)) { $criteria->setLimit($this->limit); } foreach (QubitDigitalObject::get($criteria) as $item) { $thumbnail = $item->getRepresentationByUsage(QubitTerm::THUMBNAIL_ID); if (!$thumbnail) { $thumbnail = QubitDigitalObject::getGenericRepresentation($item->mimeType, QubitTerm::THUMBNAIL_ID); $thumbnail->setParent($item); } $this->thumbnails[] = $thumbnail; } // Get total number of descendant digital objects $this->total = 0; if (isset($this->resource)) { $criteria = new Criteria(); $criteria->addJoin(QubitInformationObject::ID, QubitDigitalObject::INFORMATION_OBJECT_ID); $criteria->add(QubitInformationObject::LFT, $this->resource->lft, Criteria::GREATER_THAN); $criteria->add(QubitInformationObject::RGT, $this->resource->rgt, Criteria::LESS_THAN); $this->total = BasePeer::doCount($criteria)->fetchColumn(0); } if (2 > count($this->thumbnails)) { return sfView::NONE; } }
/** * Decide whether to show child digital objects as a compound object based * on 'displayAsCompound' toggle and available digital objects. * * @return boolean */ public function showAsCompoundDigitalObject() { // Return false if this digital object is not linked directly to an // information object if (null === $this->informationObjectId) { return false; } // Return false if "show compound" toggle is not set to '1' (yes) $showCompoundProp = QubitProperty::getOneByObjectIdAndName($this->id, 'displayAsCompound'); if (null === $showCompoundProp || '1' != $showCompoundProp->getValue(array('sourceCulture' => true))) { return false; } // Return false if this object has no children with digital objects $criteria = new Criteria(); $criteria->addJoin(QubitInformationObject::ID, QubitDigitalObject::INFORMATION_OBJECT_ID); $criteria->add(QubitInformationObject::PARENT_ID, $this->informationObjectId); if (0 === count(QubitDigitalObject::get($criteria))) { return false; } return true; }
public static function getdigitalObjectsById($id, array $options = array()) { $criteria = new Criteria(); self::adddigitalObjectsCriteriaById($criteria, $id); return QubitDigitalObject::get($criteria, $options); }