Example #1
0
 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;
     }
 }
Example #2
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$nh = Loader::helper('validation/numbers');
$form = Loader::helper('form');
$gaiID = intval($_REQUEST['gaiID']);
$gatTypeID = intval($_REQUEST['gatTypeID']);
$type = GatheringItemTemplateType::getByID($gatTypeID);
$nh = Loader::helper('validation/numbers');
$item = GatheringItem::getByID($gaiID);
if (is_object($item) && is_object($type)) {
    $gathering = $item->getGatheringObject();
    $agp = new Permissions($gathering);
    if ($agp->canEditGatheringItems() && Loader::helper('validation/token')->validate('edit_gathering_item_template', $_REQUEST['token'])) {
        $reloadItemTile = false;
        if ($type->getGatheringItemTemplateTypeHandle() == 'tile') {
            $reloadItemTile = true;
        }
        if ($_POST['task'] == 'update_item_template') {
            $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)) {
Example #3
0
<?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">
Example #4
0
 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));
             }
         }
     }
 }
Example #5
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$nh = Loader::helper('validation/numbers');
$form = Loader::helper('form');
$gaiID = intval($_REQUEST['gaiID']);
$nh = Loader::helper('validation/numbers');
$item = GatheringItem::getByID($gaiID);
$type = GatheringItemTemplateType::getByHandle('detail');
if (is_object($item) && Loader::helper('validation/token')->validate('get_gathering_items', $_REQUEST['token'])) {
    $item->render($type);
}