/**
  * This method will be called by the plugin and must return the html-code
  * Use the method "$this->getPObj()->renderContent($data);" to interact with fluid
  *
  * @return string
  */
 public function render()
 {
     $this->pObj->pi_initPIflexForm();
     // Data-array from the content element
     $data = $this->getPObj()->cObj->data;
     $this->table = DatabaseFactory::getTable('tx_wmdbbaseewh_courses', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     $this->sysCategory = DatabaseFactory::getTable('sys_category', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     $this->speaker = DatabaseFactory::getTable('tx_wmdbbaseewh_speaker', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     $this->speakerMileStones = DatabaseFactory::getTable('tx_wmdbbaseewh_speaker_milestones', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     switch ($this->pObj->pi_getFFvalue($data['pi_flexform'], 'what_to_display')) {
         case 0:
             // Teaser
             $data['teaser'] = $this->getDataForTeaser();
             break;
         case 1:
             // List
             $data['list'] = $this->getDataForList();
             break;
         case 2:
             // Meta Information
             $data['meta'] = $this->getDataForMetaInformation();
             break;
         default:
             return $this->getPObj()->renderFlashMessage('Invalid dislay mode detected!', 'The selected display mode "' . htmlspecialchars($this->pObj->pi_getFFvalue($data['pi_flexform'], 'what_to_display')) . '" is not supported!', FlashMessage::ERROR);
     }
     return $this->getPObj()->renderContent($data);
 }
 /**
  * @param $uidList
  *
  * @return array|NULL
  */
 protected function loadSlides($uidList)
 {
     /** @var \WMDB\WmdbBaseEwh\DatabaseLayer\Tables\tx_wmdbbaseewh_slide $table */
     $table = DatabaseFactory::getTable('tx_wmdbbaseewh_slide', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     $items = $table->findByUidList($uidList);
     foreach ($items as &$item) {
         $item['image'] = $this->pObj->loadFalData($item, 'image', 'tx_wmdbbaseewh_slide');
         if ($item['style'] == 2) {
             $descriptionParts = GeneralUtility::trimExplode(LF, $item['description'], 1);
             $tmp = array();
             $leftCnt = $rightCnt = 190;
             $itemOffset = 800;
             foreach ($descriptionParts as $key => $part) {
                 $tmp[$key % 2 == 0 ? 'left' : 'right'][] = array('text' => $part, 'offset' => $key % 2 == 0 ? $leftCnt : $rightCnt, 'timeOffset' => $itemOffset);
                 if ($key % 2 == 0) {
                     $leftCnt += 55;
                 } else {
                     $rightCnt += 55;
                 }
                 $itemOffset += 150;
             }
             $item['split'] = $tmp;
         }
     }
     return $items;
 }
 /**
  * @param $elementUid
  * @param $table
  * @param $field
  *
  * @return array|NULL
  */
 public function findCategoriesForElement($elementUid, $table, $field)
 {
     $fields = $this->getTable() . '.*';
     $mm = 'sys_category_record_mm';
     $tablePart = $this->getTable() . ' INNER JOIN ' . $mm . ' ON ' . $mm . '.fieldname=' . $this->getDb()->fullQuoteStr($field, '') . ' AND ' . $mm . '.tablenames=' . $this->getDb()->fullQuoteStr($table, '') . ' AND ' . $mm . '.uid_local=' . $this->getTable() . '.uid AND ' . $mm . '.uid_foreign=' . intval($elementUid);
     $where = '1=1' . DatabaseFactory::enableFields($this->getTable());
     return $this->getDb()->exec_SELECTgetRows($fields, $tablePart, $where);
 }
 /**
  * @param $uidList
  *
  * @return array|NULL
  */
 public function findByUidList($uidList)
 {
     $list = implode(',', GeneralUtility::intExplode(',', $uidList, 1));
     if ($list != '') {
         return $this->getDb()->exec_SELECTgetRows('*', $this->getTable(), 'uid IN (' . $list . ')' . DatabaseFactory::enableFields($this->getTable()), '', 'FIELD(uid, ' . $list . ')');
     } else {
         throw new \Exception('Given uid list does not contain uids! Table: ' . $this->getTable());
     }
 }
 /**
  * @param $uidList
  *
  * @return array|NULL
  * @throws \Exception
  */
 public function findByUidList($uidList)
 {
     $list = implode(',', GeneralUtility::intExplode(',', $uidList, 1));
     if ($list != '') {
         return $this->getDb()->exec_SELECTgetRows('*', $this->getTable(), 'uid IN (' . $list . ')' . DatabaseFactory::enableFields($this->getTable()), '', 'FIELD(uid, ' . $list . ')');
     } else {
         return array();
     }
 }
 /**
  * @return array|NULL
  */
 protected function getSpeaker()
 {
     /** @var \WMDB\WmdbBaseEwh\DatabaseLayer\Tables\tx_wmdbbaseewh_speaker $table */
     $table = DatabaseFactory::getTable('tx_wmdbbaseewh_speaker', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     $speakerArray = $table->findAll();
     foreach ($speakerArray as &$speaker) {
         $speaker['image'] = $this->pObj->loadFalData($speaker, 'image', 'tx_wmdbbaseewh_speaker');
     }
     return $speakerArray;
 }
 /**
  * This method will be called by the plugin and must return the html-code
  * Use the method "$this->getPObj()->renderContent($data);" to interact with fluid
  *
  * @return string
  */
 public function render()
 {
     $this->getPObj()->pi_initPIflexForm();
     // Data-array from the content element
     $data = $this->getPObj()->cObj->data;
     $this->ttContent = DatabaseFactory::getTable('tt_content', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     foreach (explode(',', $data['records']) as $recordID) {
         $data['items'][] = $this->getOutput(str_replace('tt_content_', '', $recordID));
     }
     $data['mode'] = $this->getPObj()->pi_getFFvalue($data['pi_flexform'], 'what_to_display');
     return $this->getPObj()->renderContent($data);
 }
 /**
  * @param $fieldName
  * @param $value
  *
  * @return array
  */
 public function findByIdentifier($fieldName, $value)
 {
     if ($this->checkFieldName($fieldName)) {
         $rows = $this->getDb()->exec_SELECTgetRows('*', $this->table, $fieldName . '=' . $this->getDb()->fullQuoteStr($value, $this->table) . DatabaseFactory::enableFields($this->table));
         if ($rows == NULL) {
             $rows = array();
         }
     } else {
         throw new Exception('Invalid fieldname "' . htmlspecialchars($fieldName) . '" detected!');
     }
     return $rows;
 }
 /**
  * @param $speakerUid
  *
  * @return array
  */
 public function findCoursesOfSpeaker($speakerUid)
 {
     $result = array();
     if ($speakerUid > 0) {
         $fields = '*';
         $table = $this->getTable();
         $where = 'FIND_IN_SET(' . (int) $speakerUid . ', speaker)' . DatabaseFactory::enableFields($this->getTable());
         $rows = $this->getDb()->exec_SELECTgetRows($fields, $table, $where);
         if (is_array($rows)) {
             $result = $rows;
         }
     }
     return $result;
 }
 /**
  * Return all active items
  *
  * @return array|NULL
  */
 public function findAll()
 {
     return $this->getDb()->exec_SELECTgetRows('*', $this->getTable(), '1=1' . DatabaseFactory::enableFields($this->getTable()));
 }
 /**
  * @param $uidList
  *
  * @return array|NULL
  * @throws \Exception
  */
 protected function getLinks($uidList)
 {
     /** @var \WMDB\WmdbBaseEwh\DatabaseLayer\Tables\tx_wmdbbaseewh_links $table */
     $table = DatabaseFactory::getTable('tx_wmdbbaseewh_links', 'WMDB\\WmdbBaseEwh\\DatabaseLayer\\Tables\\');
     return $table->findByUidList($uidList);
 }