當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JAXResponse::addScript方法代碼示例

本文整理匯總了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();
 }
開發者ID:joshjim27,項目名稱:jobsglobal,代碼行數:67,代碼來源:videos.php


注:本文中的JAXResponse::addScript方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。