public function setAutomaticGatheringItemTemplate() { $arr = Core::make('helper/arrays'); $db = Database::connection(); $myFeatureHandles = $this->getGatheringItemFeatureHandles(); // we loop through and do it for all installed gathering item template types $types = GatheringItemTemplateType::getList(); foreach ($types as $type) { $matched = array(); $r = $db->Execute('select gatID from GatheringItemTemplates where gatTypeID = ?', array($type->getGatheringItemTemplateTypeID())); while ($row = $r->FetchRow()) { $templateFeatureHandles = $db->GetCol('select feHandle from Features f inner join GatheringItemTemplateFeatures af on f.feID = af.feID where gatID = ?', array($row['gatID'])); if ($arr->subset($templateFeatureHandles, $myFeatureHandles)) { $matched[] = GatheringItemTemplate::getByID($row['gatID']); } } usort($matched, array($this, 'sortByFeatureScore')); if (is_object($matched[0]) && $matched[0]->gatheringItemTemplateIsAlwaysDefault()) { $template = $matched[0]; } else { // we do some fun randomization math. usort($matched, array($this, 'weightByFeatureScore')); $template = $matched[0]; } if (is_object($template)) { $this->setGatheringItemTemplate($type, $template); if ($template->gatheringItemTemplateControlsSlotDimensions()) { $this->setGatheringItemSlotWidth($template->getGatheringItemTemplateSlotWidth($this)); $this->setGatheringItemSlotHeight($template->getGatheringItemTemplateSlotHeight($this)); } } } }
<?php defined('C5_EXECUTE') or die("Access Denied."); $ap = new Permissions($item->getGatheringObject()); $type = GatheringItemTemplateType::getByHandle('tile'); $types = GatheringItemTemplateType::getList(); if ($item->canViewGatheringItem()) { ?> <div data-block-type-handle="<?php echo BLOCK_HANDLE_GATHERING_ITEM_PROXY; ?> " data-gathering-item-batch-timestamp="<?php echo $item->getGatheringItemBatchTimestamp(); ?> " data-gathering-item-id="<?php echo $item->getGatheringItemID(); ?> " class="ccm-gathering-item h<?php echo $item->getGatheringItemSlotHeight(); ?> w<?php echo $item->getGatheringItemSlotWidth(); ?> "> <div class="ccm-gathering-item-inner"> <?php if ($showTileControls && $ap->canEditGatheringItems()) { ?> <div class="ccm-ui"> <ul class="ccm-gathering-item-inline-commands ccm-ui">