public function renderRaw() { if ($this->_params['media']['media_type'] == 'video_embed') { $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this))); $html = new XenForo_BbCode_TextWrapper($this->_params['media']['media_tag'], $bbCodeParser); $this->_params['videoHtml'] = $html; } $this->_params['jQuerySource'] = XenForo_Dependencies_Public::getJquerySource(); $template = $this->createTemplateObject($this->_templateName, $this->_params); return $template; }
public function actionDialog() { $styleId = $this->_input->filterSingle('style', XenForo_Input::UINT); if ($styleId) { $this->setViewStateChange('styleId', $styleId); } $dialog = $this->_input->filterSingle('dialog', XenForo_Input::STRING); $viewParams = array(); if ($dialog == 'media') { $viewParams['sites'] = $this->_getBbCodeModel()->getAllBbCodeMediaSites(); } $viewParams['jQuerySource'] = XenForo_Dependencies_Public::getJquerySource(); $viewParams['jQuerySourceLocal'] = XenForo_Dependencies_Public::getJquerySource(true); $viewParams['javaScriptSource'] = XenForo_Application::$javaScriptUrl; return $this->responseView('XenForo_ViewPublic_Editor_Dialog', 'editor_dialog_' . $dialog, $viewParams); }
/** * @return XenForo_ControllerResponse_Abstract */ public function actionEditor() { $styleId = $this->_input->filterSingle('style', XenForo_Input::UINT); if ($styleId) { $this->setViewStateChange('styleId', $styleId); } $viewParams = array('jQuerySource' => XenForo_Dependencies_Public::getJquerySource(), 'jQuerySourceLocal' => XenForo_Dependencies_Public::getJquerySource(true), 'javaScriptSource' => XenForo_Application::$javaScriptUrl); $type = $this->_input->filterSingle('type', XenForo_Input::STRING); $url = $this->_input->filterSingle('url', XenForo_Input::STRING); if (!in_array($type, array('album', 'content'))) { $type = 'album'; } if (empty($url)) { return $this->responseView('sonnb_XenGallery_ViewPublic_Editor_Attach', 'sonnb_xengallery_editor_' . $type, $viewParams); } else { $id = $this->_input->filterSingle('url', XenForo_Input::UINT); $size = $this->_input->filterSingle('size', XenForo_Input::STRING); if (!in_array($size, $this->_allowedBBCodeSizes)) { $size = sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_MEDIUM; } $message = $bbcode = ''; if ($id) { switch ($type) { case 'content': $fetchOptions = array('join' => sonnb_XenGallery_Model_Content::FETCH_ALBUM); $content = $this->_getContentModel()->getContentById($id, $fetchOptions); $content = $this->_getContentModel()->prepareContent($content, $fetchOptions); if (empty($content)) { $message = new XenForo_Phrase('sonnb_xengallery_requested_photo_video_does_not_exist'); } elseif (!$this->_getContentModel()->canViewContentAndContainer($content, $content['album'], $errorKey)) { $message = new XenForo_Phrase($errorKey); } else { if (!empty($content['content_id'])) { switch ($content['content_type']) { case sonnb_XenGallery_Model_Photo::$contentType: $bbcode = "[photo=\"{$size}\"]{$content['content_id']}[/photo]"; break; case sonnb_XenGallery_Model_Video::$contentType: $bbcode = "[video]{$content['content_id']}[/video]"; break; } } } break; case 'album': default: $album = $this->_getAlbumModel()->getAlbumById($id); $album = $this->_getAlbumModel()->prepareAlbum($album); if (empty($album)) { $message = new XenForo_Phrase('sonnb_xengallery_requested_album_does_not_exist'); } elseif (!$this->_getAlbumModel()->canViewAlbum($album, $errorKey)) { $message = new XenForo_Phrase($errorKey); } else { if (!empty($album['album_id'])) { $bbcode = "[album=\"{$size}\"]{$album['album_id']}[/album]"; } } break; } } else { $url = $this->_getValidUrl($url); $routeUrlMatch = $this->parseRouteUrl($url); if ($routeUrlMatch) { switch ($type) { case 'content': if (!empty($routeUrlMatch['params']['content_id'])) { $contentId = intval($routeUrlMatch['params']['content_id']); $fetchOptions = array('join' => sonnb_XenGallery_Model_Content::FETCH_ALBUM); $content = $this->_getContentModel()->getContentById($contentId, $fetchOptions); $content = $this->_getContentModel()->prepareContent($content, $fetchOptions); if (empty($content)) { $message = new XenForo_Phrase('sonnb_xengallery_requested_photo_video_does_not_exist'); } elseif (!$this->_getContentModel()->canViewContentAndContainer($content, $content['album'], $errorKey)) { $message = new XenForo_Phrase($errorKey); } else { if (!empty($content['content_id'])) { switch ($content['content_type']) { case sonnb_XenGallery_Model_Photo::$contentType: $bbcode = "[photo=\"{$size}\"]{$content['content_id']}[/photo]"; break; case sonnb_XenGallery_Model_Video::$contentType: $bbcode = "[video]{$content['content_id']}[/video]"; break; } } } } else { $message = new XenForo_Phrase('sonnb_xengallery_your_url_is_not_valid_photo_video_url'); } break; case 'album': if (!empty($routeUrlMatch['params']['album_id'])) { $albumId = intval($routeUrlMatch['params']['album_id']); $album = $this->_getAlbumModel()->getAlbumById($albumId); $album = $this->_getAlbumModel()->prepareAlbum($album); if (empty($album)) { $message = new XenForo_Phrase('sonnb_xengallery_requested_album_does_not_exist'); } elseif (!$this->_getAlbumModel()->canViewAlbum($album, $errorKey)) { $message = new XenForo_Phrase($errorKey); } else { if (!empty($album['album_id'])) { $bbcode = "[album=\"{$size}\"]{$album['album_id']}[/album]"; } } } else { $message = new XenForo_Phrase('sonnb_xengallery_your_url_is_not_valid_album_url'); } break; default: $message = new XenForo_Phrase('sonnb_xengallery_your_url_is_invalid'); break; } } else { $message = new XenForo_Phrase('sonnb_xengallery_your_url_is_invalid'); } } return $this->responseView('sonnb_XenGallery_ViewPublic_Editor_Insert', '', array('message' => $message, 'bbcode' => $bbcode)); } }