/**
  * 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 '';
 }
Esempio n. 2
0
 /**
  * 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 <*****@*****.**>
  */
 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;
 }
Esempio n. 3
0
 /**
  * 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);
     }
 }
Esempio n. 4
0
 /**
  * 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.');
     }
 }
 /**
  * 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);
 }
 /**
  * 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);
     }
 }
Esempio n. 7
0
 /**
  * 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');
     }
 }
Esempio n. 8
0
 /**
  * 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.');
     }
 }
 /**
  * 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);
     }
 }
Esempio n. 10
0
 /**
  * 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);
     }
 }
Esempio n. 11
0
 /**
  * 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');
     }
 }
 /**
  * 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);
 }