/** * Enter description here... * * @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); if ($parameterName) { //retrieve propertyDescription $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; } } } } else { // retrieve typedescription /* $descriptions = $type->getElementsByTagName('description'); if($descriptions->length){ $description = $descriptions->item(0)->textContent; return htmlspecialchars($description); }*/ } return ''; }
/** * 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); // Otherwise, set an error: } else { $this->ajaxObj->setError($GLOBALS['LANG']->getLL('pageIDInteger')); } // Set an error if user has no access to sys_template records: } else { $this->ajaxObj->setError($GLOBALS['LANG']->getLL('noPermission')); } return $templates; }
/** * Create a tag * * @param array $params * @param TYPO3AJAX $ajaxObj * @return void * @throws Exception */ public function createTag(array $params, TYPO3AJAX $ajaxObj) { $request = t3lib_div::_POST(); try { // Check if a tag is submitted if (!isset($request['item']) || empty($request['item'])) { throw new Exception('error_no-tag'); } $newsUid = $request['newsid']; if ((int) $newsUid === 0 && (strlen($newsUid) == 16 && !t3lib_div::isFirstPartOfStr($newsUid, 'NEW'))) { throw new Exception('error_no-newsid'); } // Get tag uid $newTagId = $this->getTagUid($request); $ajaxObj->setContentFormat('javascript'); $ajaxObj->setContent(''); $response = array($newTagId, $request['item'], self::TAG, self::NEWS, 'tags', 'data[tx_news_domain_model_news][' . $newsUid . '][tags]', $newsUid); $ajaxObj->setJavascriptCallbackWrap(implode('-', $response)); } catch (Exception $e) { $errorMsg = $GLOBALS['LANG']->sL(self::LLPATH . $e->getMessage()); $ajaxObj->setError($errorMsg); } }
/** * Used to broker incoming requests to other calls. * Called by typo3/ajax.php * * @param array $unused additional parameters (not used) * @param TYPO3AJAX $ajax the AJAX object for this request * * @return void */ public function ajaxBroker(array $unused, TYPO3AJAX $ajax) { $state = (bool) t3lib_div::_POST('state'); $checkbox = t3lib_div::_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.'); } }
/** * 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 string $params always empty. * @param string $ajaxObj The Ajax object used to return content and set content types * @return void */ public function processAjaxRequest(array $params, TYPO3AJAX $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'); } }
/** * The main dispatcher function. Collect data and prepare HTML output. * * @param array $params: array of parameters from the AJAX interface, currently unused * @param TYPO3AJAX $ajaxObj: object of type TYPO3AJAX * @return Void */ public function dispatch($params = array(), TYPO3AJAX &$ajaxObj = null) { $content = ''; // Basic test for required value if ($this->conf['page'] > 0) { // Init TCE for execution of update $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values = 1; // Determine the scripts to execute switch ($this->conf['action']) { // Return the select to change the owner (BE user) of the page case 'show_change_owner_selector': $content = $this->renderUserSelector($this->conf['page'], $this->conf['ownerUid'], $this->conf['username']); break; // Change the owner and return the new owner HTML snippet // Change the owner and return the new owner HTML snippet 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 = $this->renderOwnername($this->conf['page'], $this->conf['new_owner_uid'], $this->conf['new_owner_username']); } else { $ajaxObj->setError('An error occured: No page owner uid specified.'); } break; // Return the select to change the group (BE group) of the page // Return the select to change the group (BE group) of the page case 'show_change_group_selector': $content = $this->renderGroupSelector($this->conf['page'], $this->conf['groupUid'], $this->conf['groupname']); break; // Change the group and return the new group HTML snippet // Change the group and return the new group HTML snippet 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 = $this->renderGroupname($this->conf['page'], $this->conf['new_group_uid'], $this->conf['new_group_username']); } else { $ajaxObj->setError('An error occured: No page group uid specified.'); } break; // Change the group and return the new group HTML snippet // Change the group and return the new group HTML snippet 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; // The script defaults to change permissions // The script defaults to change permissions default: if ($this->conf['mode'] == 'delete') { $this->conf['permissions'] = intval($this->conf['permissions'] - $this->conf['bits']); } else { $this->conf['permissions'] = intval($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 = $this->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); }