TYPO3 CMS  TYPO3_6-2
CodeCompletion.php
Go to the documentation of this file.
1 <?php
3 
24 
28  protected $ajaxObj;
29 
33  public function __construct() {
34  $GLOBALS['LANG']->includeLLFile('EXT:t3editor/locallang.xlf');
35  }
36 
46  public function processAjaxRequest($params, \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj) {
47  $this->ajaxObj = $ajaxObj;
48  $ajaxIdParts = explode('::', $ajaxObj->getAjaxID(), 2);
49  $ajaxMethod = $ajaxIdParts[1];
50  $response = array();
51  // Process the AJAX requests:
52  if ($ajaxMethod == 'loadTemplates') {
53  $ajaxObj->setContent($this->loadTemplates((int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pageId')));
54  $ajaxObj->setContentFormat('jsonbody');
55  }
56  }
57 
67  protected function loadTemplates($pageId, $templateId = 0) {
68  $templates = array();
69  // Check whether access is granted (only admin have access to sys_template records):
70  if ($GLOBALS['BE_USER']->isAdmin()) {
71  // Check whether there is a pageId given:
72  if ($pageId) {
73  $templates = $this->getMergedTemplates($pageId);
74  } else {
75  $this->ajaxObj->setError($GLOBALS['LANG']->getLL('pageIDInteger'));
76  }
77  } else {
78  $this->ajaxObj->setError($GLOBALS['LANG']->getLL('noPermission'));
79  }
80  return $templates;
81  }
82 
91  protected function getMergedTemplates($pageId, $templateId = 0) {
92  $result = array();
94  $tsParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
95  $tsParser->tt_track = 0;
96  $tsParser->init();
97  // Gets the rootLine
98  $page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
99  $rootLine = $page->getRootLine($pageId);
100  // This generates the constants/config + hierarchy info for the template.
101  $tsParser->runThroughTemplates($rootLine);
102  // ts-setup & ts-constants of the currently edited template should not be included
103  // therefor we have to delete the last template from the stack
104  array_pop($tsParser->config);
105  array_pop($tsParser->constants);
106  $tsParser->linkObjects = TRUE;
107  $tsParser->ext_regLinenumbers = FALSE;
108  $tsParser->bType = $bType;
109  $tsParser->resourceCheck = 1;
110  $tsParser->removeFromGetFilePath = PATH_site;
111  $tsParser->generateConfig();
112  $result = $this->treeWalkCleanup($tsParser->setup);
113  return $result;
114  }
115 
123  private function treeWalkCleanup(array $treeBranch) {
124  $cleanedTreeBranch = array();
125  foreach ($treeBranch as $key => $value) {
126  $dotCount = substr_count($key, '.');
127  //type definition or value-assignment
128  if ($dotCount == 0) {
129  if ($value != '') {
130  if (strlen($value) > 20) {
131  $value = substr($value, 0, 20);
132  }
133  if (!isset($cleanedTreeBranch[$key])) {
134  $cleanedTreeBranch[$key] = array();
135  }
136  $cleanedTreeBranch[$key]['v'] = $value;
137  }
138  } elseif ($dotCount == 1) {
139  // subtree (definition of properties)
140  $subBranch = $this->treeWalkCleanup($value);
141  if ($subBranch) {
142  $key = str_replace('.', '', $key);
143  if (!isset($cleanedTreeBranch[$key])) {
144  $cleanedTreeBranch[$key] = array();
145  }
146  $cleanedTreeBranch[$key]['c'] = $subBranch;
147  }
148  }
149  }
150  return $cleanedTreeBranch;
151  }
152 
153 }
processAjaxRequest($params, \TYPO3\CMS\Core\Http\AjaxRequestHandler &$ajaxObj)
loadTemplates($pageId, $templateId=0)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]