本文整理汇总了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);
}
}