public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function getAllVideoCategories($page, $limit) { $first = ($page - 1) * $limit; $categoryDao = IVIDEO_BOL_CategoryDao::getInstance(); $videoDao = IVIDEO_BOL_VideoDao::getInstance(); $query = "\n SELECT a.categoryId, b.name, b.description, count( * ) count\n FROM " . $this->getTableName() . " AS a," . $categoryDao->getTableName() . " AS b," . $videoDao->getTableName() . " AS c " . "WHERE a.categoryId = b.id\n AND c.id = a.videoId\n AND c.status = 'approved'\n GROUP BY a.categoryId\n ORDER BY count DESC\n LIMIT ?, ?\n "; return $this->dbo->queryForList($query, array($first, $limit)); }
private function __construct() { $this->videoDao = IVIDEO_BOL_VideoDao::getInstance(); }
public function viewvideo($params) { if (!isset($params['id']) || !($id = (int) $params['id'])) { throw new Redirect404Exception(); return; } $id = empty($params['id']) ? 0 : (int) $params['id']; $modPermissions = OW::getUser()->isAuthorized('ivideo'); $contentOwner = (int) IVIDEO_BOL_Service::getInstance()->findVideoOwner($id); $userId = OW::getUser()->getId(); $ownerMode = $contentOwner == $userId; if (!$ownerMode && !OW::getUser()->isAuthorized('ivideo', 'view') && !$modPermissions) { $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html'); return; } $item = IVIDEO_BOL_VideoDao::getInstance()->findById((int) $id); if (!$ownerMode && !$modPermissions) { $privacyParams = array('action' => 'ivideo_view_video', 'ownerId' => $contentOwner, 'viewerId' => $userId); $event = new OW_Event('privacy_check_permission', $privacyParams); OW::getEventManager()->trigger($event); } $eventParams = array('pluginKey' => 'ivideo', 'action' => 'view_video'); $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams); if ($credits === false) { $this->assign('authMsg', OW::getEventManager()->call('usercredits.error_message', $eventParams)); return; } else { $this->assign('authMsg', null); } $language = OW::getLanguage(); if (is_null($item)) { OW::getFeedback()->error($language->text('ivideo', 'view_invalid_video_error')); $this->redirect(OW::getRouter()->urlForRoute('ivideo_view_list', array('type' => 'latest'))); } $this->setPageTitle($item->name); $this->setPageHeading($item->name); $this->assign('isAdmin', OW::getUser()->isAdmin()); $this->assign('item', $item); $allow_comments = true; if ($item->owner != OW::getUser()->getId() && !OW::getUser()->isAuthorized('ivideo')) { $eventParams = array('action' => 'add_comment', 'ownerId' => $item->id, 'viewerId' => OW::getUser()->getId()); try { OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams); } catch (RedirectException $ex) { $allow_comments = false; } } OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('ivideo')->getStaticJsUrl() . 'ivideo.js'); $objParams = array('ajaxResponder' => $this->ajaxResponder, 'id' => $item->id, 'txtDelConfirm' => OW::getLanguage()->text('ivideo', 'confirm_delete'), 'txtMarkFeatured' => OW::getLanguage()->text('ivideo', 'mark_featured'), 'txtRemoveFromFeatured' => OW::getLanguage()->text('ivideo', 'remove_from_featured'), 'txtApprove' => OW::getLanguage()->text('base', 'approve'), 'txtDisapprove' => OW::getLanguage()->text('base', 'disapprove')); $script = "\$(document).ready(function(){\n var clip = new ivideoClip( " . json_encode($objParams) . ");\n }); "; OW::getDocument()->addOnloadScript($script); $cmpParams = new BASE_CommentsParams('ivideo', 'ivideo-comments'); $cmpParams->setEntityId($item->id)->setOwnerId($item->owner)->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_BOTTOM_FORM_WITH_FULL_LIST)->setAddComment($allow_comments); $this->addComponent('comments', new BASE_CMP_Comments($cmpParams)); $rateInfo = new BASE_CMP_Rate('ivideo', 'ivideo-rates', $item->id, $item->owner); $this->addComponent('rate', $rateInfo); $postTagsArray = BOL_TagService::getInstance()->findEntityTags($item->getId(), 'ivideo-video'); $postTags = ""; foreach ($postTagsArray as $tag) { $postTags .= $tag->label . ", "; } $postTags = substr($postTags, 0, -2); $tagCloud = new BASE_CMP_EntityTagCloud('ivideo-video'); $tagCloud->setEntityId($item->id); $tagCloud->setRouteName('ivideo_view_tagged_list'); $this->addComponent('tagCloud', $tagCloud); $username = BOL_UserService::getInstance()->getUserName($item->owner); $this->assign('username', $username); $displayName = BOL_UserService::getInstance()->getDisplayName($item->owner); $this->assign('displayName', $displayName); $ownerMode = $item->owner == OW::getUser()->getId(); $modPermissions = OW::getUser()->isAuthorized('ivideo'); $is_featured = IVIDEO_BOL_VideoFeaturedService::getInstance()->isFeatured($item->id); $this->assign('featured', $is_featured); $categoryList = IVIDEO_BOL_VideoCategoryService::getInstance()->getVideoCategories($item->id); $this->assign('categoryList', $categoryList); $toolbar = array(); if (OW::getUser()->isAuthenticated()) { array_push($toolbar, array('href' => 'javascript://', 'id' => 'btn-ivideo-flag', 'label' => $language->text('base', 'flag'))); } if ($ownerMode || $modPermissions) { array_push($toolbar, array('href' => OW::getRouter()->urlForRoute('ivideo_edit_video', array('id' => $item->getId())), 'label' => $language->text('base', 'edit'))); array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-delete', 'label' => $language->text('base', 'delete'))); } if ($modPermissions) { if ($is_featured) { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'remove_from_featured', 'label' => $language->text('ivideo', 'remove_from_featured'))); } else { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-mark-featured', 'rel' => 'mark_featured', 'label' => $language->text('ivideo', 'mark_featured'))); } if ($item->status == 'approved') { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-set-approval-staus', 'rel' => 'disapprove', 'label' => $language->text('base', 'disapprove'))); } else { array_push($toolbar, array('href' => 'javascript://', 'id' => 'clip-set-approval-staus', 'rel' => 'approve', 'label' => $language->text('base', 'approve'))); } } $this->assign('toolbar', $toolbar); $js = UTIL_JsGenerator::newInstance()->jQueryEvent('#btn-ivideo-flag', 'click', 'OW.flagContent(e.data.entity, e.data.id, e.data.title, e.data.href, "ivideo+flags");', array('e'), array('entity' => 'ivideo_video', 'id' => $item->getId(), 'title' => $item->name, 'href' => OW::getRouter()->urlForRoute('ivideo_view_video', array('id' => $item->getId())))); OW::getDocument()->addOnloadScript($js, 1001); $this->assign('getUserFilesUrl', OW::getPluginManager()->getPlugin('ivideo')->getUserFilesUrl()); $this->assign('videoWidth', OW::getConfig()->getValue('ivideo', 'videoWidth')); $this->assign('videoHeight', OW::getConfig()->getValue('ivideo', 'videoHeight')); $this->assign('videoType', UTIL_File::getExtension($item->filename)); $jsURL = OW::getPluginManager()->getPlugin('ivideo')->getStaticJsUrl(); $this->assign('jsURL', $jsURL); OW::getDocument()->addScript($jsURL . 'jquery.media.js'); OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('ivideo')->getStaticCssUrl() . 'video-js.css'); OW::getDocument()->addCustomHeadInfo('<script src="' . $jsURL . 'video.js" type="text/javascript"></script>'); OW::getDocument()->addCustomHeadInfo('<script type="text/javascript"> _V_.options.flash.swf ="' . $jsURL . 'video-js.swf"</script>'); OW::getDocument()->addCustomHeadInfo('<script type="text/javascript"> _V_.options.techOrder = ["flash", "html5"]</script>'); }