public function onBeforeRender() { parent::onBeforeRender(); $this->initJs(); $noVideo = OW::getLanguage()->text('equestions', 'attacments_yt_no_video'); $listHtml = '<div class="yt-empty-result ow_nocontent">' . $noVideo . '</div>'; $itemsCount = 0; if (!empty($this->response)) { $response = json_decode($this->response, true); if (!empty($response['feed']['entry'])) { $list = new EQUESTIONS_CMP_YoutubeList($response); $listHtml = $list->render(); $itemsCount = $list->getItemsCount(); } } $this->assign('window', array('height' => $this->window['height'] - 250)); $this->assign('list', $listHtml); $this->assign('uniqId', $this->uniqId); $this->assign('query', $this->query); $this->assign('viewMore', $itemsCount == self::ITEMS_COUNT); }
public function ytMore($query) { if (empty($query['data']['query'])) { return array('viewMore' => false); } $query['data']['start'] = $query['data']['start'] + $query['data']['offset']; $queryUrl = OW::getRequest()->buildUrlQueryString("http://gdata.youtube.com/feeds/api/videos", array('q' => $query['data']['query'], 'alt' => 'json', 'format' => 5, 'v' => 2, 'start-index' => $query['data']['start'], 'max-results' => $query['data']['offset'])); $response = file_get_contents($queryUrl); $response = json_decode($response, true); $cmp = new EQUESTIONS_CMP_YoutubeList($response); $markup = array('html' => $cmp->render(), 'js' => '', 'css' => ''); return array('more' => $markup, 'viewMore' => $cmp->getItemsCount() == $query['data']['offset'], 'data' => $query['data']); }