TYPO3 CMS  TYPO3_6-2
TsConfigParser.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
29  protected $rootLine = array();
30 
40  public function parseTSconfig($TStext, $type, $id = 0, array $rootLine = array()) {
41  $this->type = $type;
42  $this->id = $id;
43  $this->rootLine = $rootLine;
44  $hash = md5($type . ':' . $TStext);
45  $cachedContent = BackendUtility::getHash($hash);
46  if (is_array($cachedContent)) {
47  $storedData = $cachedContent[0];
48  $storedMD5 = $cachedContent[1];
49  $storedData['match'] = array();
50  $storedData = $this->matching($storedData);
51  $checkMD5 = md5(serialize($storedData));
52  if ($checkMD5 == $storedMD5) {
53  $res = array(
54  'TSconfig' => $storedData['TSconfig'],
55  'cached' => 1,
56  'hash' => $hash
57  );
58  } else {
59  $shash = md5($checkMD5 . $hash);
60  $cachedSpec = BackendUtility::getHash($shash);
61  if (is_array($cachedSpec)) {
62  $storedData = $cachedSpec;
63  $res = array(
64  'TSconfig' => $storedData['TSconfig'],
65  'cached' => 1,
66  'hash' => $shash
67  );
68  } else {
69  $storeData = $this->parseWithConditions($TStext);
70  BackendUtility::storeHash($shash, $storeData, $type . '_TSconfig');
71  $res = array(
72  'TSconfig' => $storeData['TSconfig'],
73  'cached' => 0,
74  'hash' => $shash
75  );
76  }
77  }
78  } else {
79  $storeData = $this->parseWithConditions($TStext);
80  $md5 = md5(serialize($storeData));
81  BackendUtility::storeHash($hash, array($storeData, $md5), $type . '_TSconfig');
82  $res = array(
83  'TSconfig' => $storeData['TSconfig'],
84  'cached' => 0,
85  'hash' => $hash
86  );
87  }
88  return $res;
89  }
90 
97  protected function parseWithConditions($TSconfig) {
99  $matchObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TypoScript\\ConditionMatching\\ConditionMatcher');
100  $matchObj->setRootline($this->rootLine);
101  $matchObj->setPageId($this->id);
102  $this->parse($TSconfig, $matchObj);
103  $storeData = array(
104  'TSconfig' => $this->setup,
105  'sections' => $this->sections,
106  'match' => $this->sectionsMatch
107  );
108  return $storeData;
109  }
110 
117  protected function matching(array $cc) {
118  if (is_array($cc['sections'])) {
120  $matchObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TypoScript\\ConditionMatching\\ConditionMatcher');
121  $matchObj->setRootline($this->rootLine);
122  $matchObj->setPageId($this->id);
123  foreach ($cc['sections'] as $key => $pre) {
124  if ($matchObj->match($pre)) {
125  $cc['match'][$key] = $pre;
126  }
127  }
128  }
129  return $cc;
130  }
131 
132 }
parseTSconfig($TStext, $type, $id=0, array $rootLine=array())
static storeHash($hash, $data, $ident)