本文整理匯總了PHP中JAXResponse::addScript方法的典型用法代碼示例。如果您正苦於以下問題:PHP JAXResponse::addScript方法的具體用法?PHP JAXResponse::addScript怎麽用?PHP JAXResponse::addScript使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JAXResponse
的用法示例。
在下文中一共展示了JAXResponse::addScript方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ajaxLinkVideoPreview
public function ajaxLinkVideoPreview($videoUrl)
{
$filter = JFilterInput::getInstance();
$videoUrl = $filter->clean($videoUrl, 'string');
$objResponse = new JAXResponse();
if (!JRequest::checkToken()) {
$objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_INVALID_TOKEN'));
$objResponse->sendResponse();
}
$config = CFactory::getConfig();
if (!$config->get('enablevideos')) {
$objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_VIDEOS_DISABLED'));
$objResponse->sendResponse();
}
$my = CFactory::getUser();
// @rule: Do not allow users to add more videos than they are allowed to
if (CLimitsLibrary::exceedDaily('videos')) {
$objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_VIDEOS_LIMIT_REACHED'));
$objResponse->sendResponse();
}
// Without CURL library, there's no way get the video information
// remotely
if (!CRemoteHelper::curlExists()) {
$objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_CURL_NOT_EXISTS'));
$objResponse->sendResponse();
}
// Determine if the video belongs to group or user and
// assign specify value for checking accordingly
$creatorType = VIDEO_USER_TYPE;
$videoLimit = $config->get('videouploadlimit');
if (CLimitsHelper::exceededVideoUpload($my->id, $creatorType)) {
$objResponse->addScriptCall('__throwError', JText::sprintf('COM_COMMUNITY_VIDEOS_CREATION_LIMIT_ERROR', $videoLimit));
$objResponse->sendResponse();
}
// Create the video object and save
if (empty($videoUrl)) {
$objResponse->addScriptCall('__throwError', JText::_('COM_COMMUNITY_VIDEOS_INVALID_VIDEO_LINKS'));
$objResponse->sendResponse();
}
$videoLib = new CVideoLibrary();
$video = JTable::getInstance('Video', 'CTable');
$isValid = $video->init($videoUrl);
if (!$isValid) {
$objResponse->addScriptCall('__throwError', $video->getProvider()->getError());
$objResponse->sendResponse();
}
$video->set('creator', $my->id);
$video->set('creator_type', $creatorType);
$video->set('category_id', 1);
$video->set('status', 'temp');
if (!$video->store()) {
$objResponse->addScript('__throwError', JText::_('COM_COMMUNITY_VIDEOS_ADD_LINK_FAILED'));
$objResponse->sendResponse();
}
// Fetch the thumbnail and store it locally,
// else we'll use the thumbnail remotely
CError::assert($video->thumb, '', '!empty');
$this->_fetchThumbnail($video->id);
$model = CFactory::getModel('videos');
$category = $model->getAllCategories();
$category = CCategoryHelper::getCategories($category);
$attachment = new stdClass();
$attachment->video = $video;
$attachment->category = $category;
$objResponse->addScriptCall('__callback', $attachment);
$objResponse->sendResponse();
}