当前位置: 首页>>代码示例>>PHP>>正文


PHP AjaxRequestHandler::setError方法代码示例

本文整理汇总了PHP中TYPO3\CMS\Core\Http\AjaxRequestHandler::setError方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxRequestHandler::setError方法的具体用法?PHP AjaxRequestHandler::setError怎么用?PHP AjaxRequestHandler::setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TYPO3\CMS\Core\Http\AjaxRequestHandler的用法示例。


在下文中一共展示了AjaxRequestHandler::setError方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDescription

 /**
  * Get description
  *
  * @param string $typeId
  * @param string $parameterName
  * @return string
  */
 protected function getDescription($typeId, $parameterName = '')
 {
     if (!$typeId) {
         $this->ajaxObj->setError($GLOBALS['LANG']->getLL('typeIDMissing'));
         return '';
     }
     // getElementById does only work with schema
     $type = $this->getType($typeId);
     // Retrieve propertyDescription
     if ($parameterName) {
         $properties = $type->getElementsByTagName('property');
         foreach ($properties as $propery) {
             $propName = $propery->getAttribute('name');
             if ($propName == $parameterName) {
                 $descriptions = $propery->getElementsByTagName('description');
                 if ($descriptions->length) {
                     $description = $descriptions->item(0)->textContent;
                     $description = htmlspecialchars($description);
                     $description = nl2br($description);
                     return $description;
                 }
             }
         }
     }
     return '';
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:33,代码来源:TypoScriptReferenceLoader.php

示例2: loadTemplates

 /**
  * Loads all templates up to a given page id (walking the rootline) and
  * cleans parts that are not required for the t3editor codecompletion.
  *
  * @param integer $pageId ID of the page
  * @param integer $templateId Currently unused (default: 0)
  * @return array Cleaned array of TypoScript information
  * @author Oliver Hader <oliver@typo3.org>
  */
 protected function loadTemplates($pageId, $templateId = 0)
 {
     $templates = array();
     // Check whether access is granted (only admin have access to sys_template records):
     if ($GLOBALS['BE_USER']->isAdmin()) {
         // Check whether there is a pageId given:
         if ($pageId) {
             $templates = $this->getMergedTemplates($pageId);
         } else {
             $this->ajaxObj->setError($GLOBALS['LANG']->getLL('pageIDInteger'));
         }
     } else {
         $this->ajaxObj->setError($GLOBALS['LANG']->getLL('noPermission'));
     }
     return $templates;
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:25,代码来源:CodeCompletion.php

示例3: 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);
     }
 }
开发者ID:beechit,项目名称:tag_items,代码行数:35,代码来源:SuggestReceiverCall.php

示例4: getRsaPublicKey

 /**
  * Gets RSA Public Key.
  *
  * @param array $parameters Parameters (not used)
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $parent The calling parent AJAX object
  * @return void
  */
 public function getRsaPublicKey(array $parameters, \TYPO3\CMS\Core\Http\AjaxRequestHandler $parent)
 {
     $backend = BackendFactory::getBackend();
     if ($backend !== NULL) {
         $keyPair = $backend->createNewKeyPair();
         $storage = \TYPO3\CMS\Rsaauth\Storage\StorageFactory::getStorage();
         $storage->put($keyPair->getPrivateKey());
         session_commit();
         $parent->addContent('publicKeyModulus', $keyPair->getPublicKeyModulus());
         $parent->addContent('exponent', sprintf('%x', $keyPair->getExponent()));
         $parent->setContentFormat('json');
     } else {
         $parent->setError('No OpenSSL backend could be obtained for rsaauth.');
     }
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:22,代码来源:AjaxLoginHandler.php

示例5: dispatch

 /**
  * The main dispatcher function. Collect data and prepare HTML output.
  *
  * @param array $params array of parameters from the AJAX interface, currently unused
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj object of type AjaxRequestHandler
  * @return void
  */
 public function dispatch($params = array(), \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj = NULL)
 {
     $content = '';
     // Basic test for required value
     if ($this->conf['page'] > 0) {
         // Init TCE for execution of update
         /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
         $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
         $tce->stripslashes_values = 1;
         // Determine the scripts to execute
         switch ($this->conf['action']) {
             case 'show_change_owner_selector':
                 $content = $this->renderUserSelector($this->conf['page'], $this->conf['ownerUid'], $this->conf['username']);
                 break;
             case 'change_owner':
                 if (is_int($this->conf['new_owner_uid'])) {
                     // Prepare data to change
                     $data = array();
                     $data['pages'][$this->conf['page']]['perms_userid'] = $this->conf['new_owner_uid'];
                     // Execute TCE Update
                     $tce->start($data, array());
                     $tce->process_datamap();
                     $content = self::renderOwnername($this->conf['page'], $this->conf['new_owner_uid'], $this->conf['new_owner_username']);
                 } else {
                     $ajaxObj->setError('An error occurred: No page owner uid specified.');
                 }
                 break;
             case 'show_change_group_selector':
                 $content = $this->renderGroupSelector($this->conf['page'], $this->conf['groupUid'], $this->conf['groupname']);
                 break;
             case 'change_group':
                 if (is_int($this->conf['new_group_uid'])) {
                     // Prepare data to change
                     $data = array();
                     $data['pages'][$this->conf['page']]['perms_groupid'] = $this->conf['new_group_uid'];
                     // Execute TCE Update
                     $tce->start($data, array());
                     $tce->process_datamap();
                     $content = self::renderGroupname($this->conf['page'], $this->conf['new_group_uid'], $this->conf['new_group_username']);
                 } else {
                     $ajaxObj->setError('An error occurred: No page group uid specified.');
                 }
                 break;
             case 'toggle_edit_lock':
                 // Prepare data to change
                 $data = array();
                 $data['pages'][$this->conf['page']]['editlock'] = $this->conf['editLockState'] === 1 ? 0 : 1;
                 // Execute TCE Update
                 $tce->start($data, array());
                 $tce->process_datamap();
                 $content = $this->renderToggleEditLock($this->conf['page'], $data['pages'][$this->conf['page']]['editlock']);
                 break;
             default:
                 if ($this->conf['mode'] == 'delete') {
                     $this->conf['permissions'] = (int) ($this->conf['permissions'] - $this->conf['bits']);
                 } else {
                     $this->conf['permissions'] = (int) ($this->conf['permissions'] + $this->conf['bits']);
                 }
                 // Prepare data to change
                 $data = array();
                 $data['pages'][$this->conf['page']]['perms_' . $this->conf['who']] = $this->conf['permissions'];
                 // Execute TCE Update
                 $tce->start($data, array());
                 $tce->process_datamap();
                 $content = self::renderPermissions($this->conf['permissions'], $this->conf['page'], $this->conf['who']);
         }
     } else {
         $ajaxObj->setError('This script cannot be called directly.');
     }
     $ajaxObj->addContent($this->conf['page'] . '_' . $this->conf['who'], $content);
 }
开发者ID:khanhdeux,项目名称:typo3test,代码行数:78,代码来源:PermissionAjaxController.php

示例6: ajaxExpandCollapse

 /**
  * Makes the AJAX call to expand or collapse the pagetree.
  * Called by typo3/ajax.php
  *
  * @param array $params Additional parameters (not used here)
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The TYPO3AJAX object of this request
  * @return void
  */
 public function ajaxExpandCollapse($params, $ajaxObj)
 {
     $this->init();
     $tree = $this->pagetree->getBrowsableTree();
     if (!$this->pagetree->ajaxStatus) {
         $ajaxObj->setError($tree);
     } else {
         $ajaxObj->addContent('tree', $tree);
     }
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:18,代码来源:PageTreeNavigationController.php

示例7: processAjaxRequest

 /**
  * Handles the actual process from within the ajaxExec function
  * therefore, it does exactly the same as the real typo3/tce_file.php
  * but without calling the "finish" method, thus makes it simpler to deal with the
  * actual return value
  *
  * @param array $params Always empty.
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The Ajax object used to return content and set content types
  * @return void
  */
 public function processAjaxRequest(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
 {
     $this->init();
     $this->main();
     $errors = $this->fileProcessor->getErrorMessages();
     if (count($errors)) {
         $ajaxObj->setError(implode(',', $errors));
     } else {
         $ajaxObj->addContent('result', $this->fileData);
         if ($this->redirect) {
             $ajaxObj->addContent('redirect', $this->redirect);
         }
         $ajaxObj->setContentFormat('json');
     }
 }
开发者ID:noxludo,项目名称:TYPO3v4-Core,代码行数:25,代码来源:FileController.php

示例8: ajaxBroker

 /**
  * Used to broker incoming requests to other calls.
  * Called by typo3/ajax.php
  *
  * @param array $unused additional parameters (not used)
  * @param AjaxRequestHandler $ajax the AJAX object for this request
  *
  * @return void
  */
 public function ajaxBroker(array $unused, AjaxRequestHandler $ajax)
 {
     $state = (bool) GeneralUtility::_POST('state');
     $checkbox = GeneralUtility::_POST('checkbox');
     if (in_array($checkbox, $this->validCheckboxKeys, true)) {
         $ajax->setContentFormat('json');
         $this->userSettingsService->set($checkbox, $state);
         $ajax->addContent('success', true);
     } else {
         $ajax->setContentFormat('plain');
         $ajax->setError('Illegal input parameters.');
     }
 }
开发者ID:TrueType,项目名称:phpunit,代码行数:22,代码来源:Ajax.php

示例9: ajaxExpandCollapse

 /**
  * Makes the AJAX call to expand or collapse the foldertree.
  * Called by typo3/ajax.php
  *
  * @param array $params Additional parameters (not used here)
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
  * @return void
  */
 public function ajaxExpandCollapse($params, $ajaxObj)
 {
     $this->init();
     $tree = $this->foldertree->getBrowsableTree();
     if ($this->foldertree->getAjaxStatus() === FALSE) {
         $ajaxObj->setError($tree);
     } else {
         $ajaxObj->addContent('tree', $tree);
     }
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:18,代码来源:FileSystemNavigationFrameController.php

示例10: 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);
     }
 }
开发者ID:preinboth,项目名称:moox_news,代码行数:31,代码来源:SuggestReceiverCall.php

示例11: processAjaxRequest

 /**
  * Handles the actual process from within the ajaxExec function
  * therefore, it does exactly the same as the real typo3/tce_file.php
  * but without calling the "finish" method, thus makes it simpler to deal with the
  * actual return value
  *
  * @param array $params Always empty.
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object used to return content and set content types
  * @return void
  */
 public function processAjaxRequest(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
 {
     $this->init();
     $this->main();
     $errors = $this->fileProcessor->getErrorMessages();
     if (!empty($errors)) {
         $ajaxObj->setError(implode(',', $errors));
     } else {
         $flatResult = array();
         foreach ($this->fileData as $action => $results) {
             foreach ($results as $result) {
                 if (is_array($result)) {
                     foreach ($result as $subResult) {
                         $flatResult[$action][] = $this->flattenResultDataValue($subResult);
                     }
                 } else {
                     $flatResult[$action][] = $this->flattenResultDataValue($result);
                 }
             }
         }
         $ajaxObj->addContent('result', $flatResult);
         if ($this->redirect) {
             $ajaxObj->addContent('redirect', $this->redirect);
         }
         $ajaxObj->setContentFormat('json');
     }
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:37,代码来源:FileController.php

示例12: dispatch

 /**
  * The main dispatcher function. Collect data and prepare HTML output.
  *
  * @param array $params array of parameters from the AJAX interface, currently unused
  * @param AjaxRequestHandler $ajaxObj object of type AjaxRequestHandler
  * @return void
  */
 public function dispatch($params = array(), AjaxRequestHandler $ajaxObj = NULL)
 {
     $extPath = ExtensionManagementUtility::extPath('beuser');
     $view = GeneralUtility::makeInstance(StandaloneView::class);
     $view->setPartialRootPaths(array('default' => ExtensionManagementUtility::extPath('beuser') . 'Resources/Private/Partials'));
     $view->assign('pageId', $this->conf['page']);
     $content = '';
     // Basic test for required value
     if ($this->conf['page'] > 0) {
         // Init TCE for execution of update
         /** @var $tce DataHandler */
         $tce = GeneralUtility::makeInstance(DataHandler::class);
         $tce->stripslashes_values = FALSE;
         // Determine the scripts to execute
         switch ($this->conf['action']) {
             case 'show_change_owner_selector':
                 $content = $this->renderUserSelector($this->conf['page'], $this->conf['ownerUid'], $this->conf['username']);
                 break;
             case 'change_owner':
                 $userId = $this->conf['new_owner_uid'];
                 if (is_int($userId)) {
                     // Prepare data to change
                     $data = array();
                     $data['pages'][$this->conf['page']]['perms_userid'] = $userId;
                     // Execute TCE Update
                     $tce->start($data, array());
                     $tce->process_datamap();
                     $view->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/PermissionAjax/ChangeOwner.html');
                     $view->assign('userId', $userId);
                     $usernameArray = BackendUtility::getUserNames('username', ' AND uid = ' . $userId);
                     $view->assign('username', $usernameArray[$userId]['username']);
                     $content = $view->render();
                 } else {
                     $ajaxObj->setError('An error occurred: No page owner uid specified.');
                 }
                 break;
             case 'show_change_group_selector':
                 $content = $this->renderGroupSelector($this->conf['page'], $this->conf['groupUid'], $this->conf['groupname']);
                 break;
             case 'change_group':
                 $groupId = $this->conf['new_group_uid'];
                 if (is_int($groupId)) {
                     // Prepare data to change
                     $data = array();
                     $data['pages'][$this->conf['page']]['perms_groupid'] = $groupId;
                     // Execute TCE Update
                     $tce->start($data, array());
                     $tce->process_datamap();
                     $view->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/PermissionAjax/ChangeGroup.html');
                     $view->assign('groupId', $groupId);
                     $groupnameArray = BackendUtility::getGroupNames('title', ' AND uid = ' . $groupId);
                     $view->assign('groupname', $groupnameArray[$groupId]['title']);
                     $content = $view->render();
                 } else {
                     $ajaxObj->setError('An error occurred: No page group uid specified.');
                 }
                 break;
             case 'toggle_edit_lock':
                 // Prepare data to change
                 $data = array();
                 $data['pages'][$this->conf['page']]['editlock'] = $this->conf['editLockState'] === 1 ? 0 : 1;
                 // Execute TCE Update
                 $tce->start($data, array());
                 $tce->process_datamap();
                 $content = $this->renderToggleEditLock($this->conf['page'], $data['pages'][$this->conf['page']]['editlock']);
                 break;
             default:
                 if ($this->conf['mode'] === 'delete') {
                     $this->conf['permissions'] = (int) ($this->conf['permissions'] - $this->conf['bits']);
                 } else {
                     $this->conf['permissions'] = (int) ($this->conf['permissions'] + $this->conf['bits']);
                 }
                 // Prepare data to change
                 $data = array();
                 $data['pages'][$this->conf['page']]['perms_' . $this->conf['who']] = $this->conf['permissions'];
                 // Execute TCE Update
                 $tce->start($data, array());
                 $tce->process_datamap();
                 $view->setTemplatePathAndFilename($extPath . 'Resources/Private/Templates/PermissionAjax/ChangePermission.html');
                 $view->assign('permission', $this->conf['permissions']);
                 $view->assign('scope', $this->conf['who']);
                 $content = $view->render();
         }
     } else {
         $ajaxObj->setError('This script cannot be called directly.');
     }
     $ajaxObj->addContent($this->conf['page'] . '_' . $this->conf['who'], $content);
 }
开发者ID:plan2net,项目名称:TYPO3.CMS,代码行数:95,代码来源:PermissionAjaxController.php


注:本文中的TYPO3\CMS\Core\Http\AjaxRequestHandler::setError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。