本文整理匯總了PHP中TYPO3\CMS\Core\Http\AjaxRequestHandler::setJavascriptCallbackWrap方法的典型用法代碼示例。如果您正苦於以下問題:PHP AjaxRequestHandler::setJavascriptCallbackWrap方法的具體用法?PHP AjaxRequestHandler::setJavascriptCallbackWrap怎麽用?PHP AjaxRequestHandler::setJavascriptCallbackWrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Core\Http\AjaxRequestHandler
的用法示例。
在下文中一共展示了AjaxRequestHandler::setJavascriptCallbackWrap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createTag
/**
* Create a tag
*
* @param array $params
* @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj
* @return void
* @throws \Exception
*/
public function createTag(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
{
$request = GeneralUtility::_POST();
try {
// Check if a tag is submitted
if (!isset($request['item']) || empty($request['item'])) {
throw new \Exception('error_no-tag');
}
$itemUid = $request['uid'];
if ((int) $itemUid === 0 && (strlen($itemUid) == 16 && !GeneralUtility::isFirstPartOfStr($itemUid, 'NEW'))) {
throw new \Exception('error_no-uid');
}
$table = $request['table'];
if (empty($table)) {
throw new \Exception('error_no-table');
}
// Get tag uid
$newTagId = $this->getTagUid($request);
$ajaxObj->setContentFormat('javascript');
$ajaxObj->setContent('');
$response = array($newTagId, $request['item'], self::TAG, $table, 'tags', 'data[' . htmlspecialchars($table) . '][' . $itemUid . '][tags]', $itemUid);
$ajaxObj->setJavascriptCallbackWrap(implode('-', $response));
} catch (\Exception $e) {
$errorMsg = $GLOBALS['LANG']->sL(self::LLPATH . $e->getMessage());
$ajaxObj->setError($errorMsg);
}
}
示例2: createTarget
/**
* Create a target
*
* @param array $params
* @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj
* @return void
* @throws Exception
*/
public function createTarget(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
{
$request = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST();
try {
// Check if a tag is submitted
if (!isset($request['item']) || empty($request['item'])) {
throw new Exception('error_no-target');
}
$newsUid = $request['newsid'];
if ((int) $newsUid === 0 && (strlen($newsUid) == 16 && !\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($newsUid, 'NEW'))) {
throw new Exception('error_no-newsid');
}
// Get tag uid
$newTargetId = $this->getTargetUid($request);
$ajaxObj->setContentFormat('javascript');
$ajaxObj->setContent('');
$response = array($newTargetId, $request['item'], self::TARGET, self::NEWS, 'tags', 'data[tx_mooxnews_domain_model_news][' . $newsUid . '][targets]', $newsUid);
$ajaxObj->setJavascriptCallbackWrap(implode('-', $response));
} catch (Exception $e) {
$errorMsg = $GLOBALS['LANG']->sL(self::LLPATHTARGET . $e->getMessage());
$ajaxObj->setError($errorMsg);
}
}