public static function add(GatheringDataSourceConfiguration $configuration, $tweet) { $gathering = $configuration->getGatheringObject(); try { // we wrap this in a try because it MIGHT fail if it's a duplicate $item = parent::create($gathering, $configuration->getGatheringDataSourceObject(), date('Y-m-d H:i:s', strtotime($tweet->created_at)), $tweet->text, $tweet->id); } catch (Exception $e) { } if (is_object($item)) { $item->assignFeatureAssignments($tweet); if (count($tweet->entities->media) > 0 && $tweet->entities->media[0]->type == 'photo') { $item->setAutomaticGatheringItemTemplate(); } else { $type = GatheringItemTemplateType::getByHandle('tile'); $template = GatheringItemTemplate::getByHandle('tweet'); $item->setGatheringItemTemplate($type, $template); } return $item; } }
$template = GatheringItemTemplate::getByID($_POST['gatID']); $item->setGatheringItemTemplate($type, $template); if ($reloadItemTile) { $item->render($type); } exit; } $assignments = GatheringItemFeatureAssignment::getList($item); $features = array(); foreach ($assignments as $as) { $f = $as->getFeatureObject(); if (is_object($f)) { $features[] = $f; } } $templates = GatheringItemTemplate::getListByType($type); ?> <script type="text/javascript"> $(function() { $('#ccm-dialog-gathering-item-templates .ccm-dialog-icon-item-grid-sets ul a').on('click', function() { $('#ccm-dialog-gathering-item-templates .ccm-overlay-icon-item-grid-list li').hide(); $('#ccm-dialog-gathering-item-templates .ccm-overlay-icon-item-grid-list li[data-gathering-item-template-features~=' + $(this).attr('data-tab') + ']').show(); $('#ccm-dialog-gathering-item-templates .ccm-dialog-icon-item-grid-sets ul a').removeClass('active'); $(this).addClass('active'); return false; }); $($('#ccm-dialog-gathering-item-templates .ccm-dialog-icon-item-grid-sets ul a').get(0)).trigger('click');
public function itemSupportsGatheringItemTemplate(GatheringItemTemplate $template) { // checks to see if all the features necessary to implement the template are present in this item. $templateFeatures = $template->getGatheringItemTemplateFeatureHandles(); $itemFeatures = $this->getGatheringItemFeatureHandles(); $features = array_intersect($templateFeatures, $itemFeatures); return count($features) == count($templateFeatures); }